fsync()/fdatasync() issue

A

Adnan Abbas

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
 
E

Eric Sosman

Adnan said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,377
Latest member
MableYocum

Latest Threads

Top