Bug 29972 - Possibly bad EBADF error description in fsync(2)
Possibly bad EBADF error description in fsync(2)
Product: Documentation
Classification: Unclassified
Component: man-pages
All Linux
: P1 normal
Assigned To: documentation_man-pages@kernel-bugs.osdl.org
Depends on:
  Show dependency treegraph
Reported: 2011-02-26 23:49 UTC by Ricardo
Modified: 2013-12-11 12:32 UTC (History)
2 users (show)

See Also:
Kernel Version: N/A
Tree: Mainline
Regression: No


Description Ricardo 2011-02-26 23:49:26 UTC
The man-page of fsync(2) has the next error description:
    EBADF  fd is not a valid file descriptor open for writing.

This man-page says nothing about if fsync(2) works correctly on a file descriptor open with O_RDONLY, but it seems to work without any problem. So that description induce to think that O_WRONLY or O_RDWR must be used.

The Open Group Base Specifications says nothing about in what mode the file must be open. And the EBADF error description also says nothing about not being open in writing mode (http://pubs.opengroup.org/onlinepubs/009695399/functions/fsync.html).

In conclusion, as far as I know, the next code snippet is correct and seems to work correctly in my machine with regular files and directories:
    fd = open(path, O_RDONLY);

So the EBADF error description in man pages from fsync(2) is confusing, maybe it should be something like:
    EBADF  fd is not a valid file descriptor.

I'm using Ubuntu 10.10 with Linux man-pages 3.24.
Comment 1 Jorge Nerín 2013-09-10 16:55:12 UTC
man-pages 3.51 fsync(2):

       EBADF  fd is not a valid open file descriptor.

I think this bug should be closed.

Note You need to log in before you can comment on or make changes to this bug.