fsync()/fdatasync() issue

  • Follow


Hi,
I have a test app that writes to a device in raw initiated mode
(RedHat 2.4)

I use open() with O_SYNC flag 
I call write() in a loop.
I call fdatasync(fd) in each loop (check for success status)
I call close()

in above test app if i unplug my device during the while loop and
reconnect it, all my data is lost i don't see anything written to the
disk. leads me to believe fdatasync() does not work as expected.

ps(in windows commit() function works fine. and data is actually
written to the disk)

please let me know if there is a way to get the expected result. 

Thanks 
Adnan Abbas
0
Reply adnanx (4) 10/5/2004 5:04:16 PM

Adnan Abbas wrote:
> Hi,
> I have a test app that writes to a device in raw initiated mode
> (RedHat 2.4)
> 
> I use open() with O_SYNC flag 
> I call write() in a loop.
> I call fdatasync(fd) in each loop (check for success status)
> I call close()
> 
> in above test app if i unplug my device during the while loop and
> reconnect it, all my data is lost i don't see anything written to the
> disk. leads me to believe fdatasync() does not work as expected.
> 
> ps(in windows commit() function works fine. and data is actually
> written to the disk)
> 
> please let me know if there is a way to get the expected result. 

     It may surprise you to learn that none of this has
anything at all to do with C.  There's no open() function
in C.  There's no O_SYNC flag in C.  There's no write(),
no fdatasync(), no close(), and no commit() in C.  There's
not even a disk in C, much less any notion of what happens
if you unplug one or hit it with a hammer.

     All these things are platform-provided extensions to
the C language, and you need help from the experts on your
platform.  I suggest you consult a Linux or RedHat forum --
because your problem is not a C problem.  Good luck!

-- 
Eric.Sosman@sun.com

0
Reply Eric.Sosman (4228) 10/5/2004 5:30:17 PM


1 Replies
20 Views

(page loaded in 0.036 seconds)


Reply: