fflush has no use?

Thomas Doerfler (nt) Thomas.Doerfler at imd-systems.de
Thu Nov 7 16:30:58 UTC 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hi,

without inverstigating too deep, your description sounds to me that
fflush might flush the pending output to the file system, but the file
system is not synced to the real storage medium.

If you are using the DOS FS, some sort of "sync" functionality is available.

wkr,

Thomas.

Am 07.11.2013 04:56, schrieb Rui Zhengxin:
> Hi all,
> In my application, I need a log file stored on hard disk to record
some log messages.
> The file pointer of the log file is opened by fopen, and we keep it
opening.
> When a new log messages coming, I use the fprintf to write it.
> In order to update the connent of hard disk,
> the "fflush" function is used to flush buffered file output.
>
> But unfortunately, **"fflush" seems have no use.**
>
> The test code is like this.
> -------------------------------------------------------
>  FILE *fp;
> 
>  int i;
> 
>  fp = fopen("/mnt/log.txt", "a+");
> 
>  for (i=0; i<10; i++)
>  {
>   fprintf(fp, "test fflush %d\n", i);
>   if (fflush(fp)!= EOF)
>    printf("%d ok!\n", i);
>   else
>    printf("%d bad!\n", i);
>   
>   rtems_task_wake_after(100);
>  }
> -------------------------------------------------------
> When the above code is executed,
> the console output is always print ok, fflush returns good.
>
> But when restart the board,
> then use "cat" command to display the log file, it has nothins.
> The length of the log file is zero too.
>
> [/mnt] # ls -l
> total 7973
> -rw-r--r--  1 root  root  1767821 Jan  1 00:03 hello.exe
> -rw-r--r--  1 root  root        0 Jan  1 00:08 log.txt
>
> We also find that if we use "cat" command after fflush, the file
content can be stored.
>
> If the fflush function in RTEMS is fully implemented or not?
>
> Thanks & Best regards,
> Rui Zhengxin
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users


- -- 
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available on request
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
 
iEYEARECAAYFAlJ7v/8ACgkQwHyg4bDtfjTvRACdFnxysMZCbVwzW6ZFGnGVApoo
tQIAmQGatDSXiT3Nt3F7VJWFhKkVghrx
=sRa/
-----END PGP SIGNATURE-----




More information about the users mailing list