fsync()/fdatasync() issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adnan Abbas

    #1

    fsync()/fdatasync() issue

    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
  • Eric Sosman

    #2
    Re: fsync()/fdatasync() issue

    Adnan Abbas wrote:[color=blue]
    > 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.[/color]

    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

    Comment

    Working...