]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Files open O_WRONLY not supported in fallocate emulation.
authorCarlos O'Donell <carlos@systemhalted.org>
Tue, 29 Sep 2015 15:32:36 +0000 (11:32 -0400)
committerCarlos O'Donell <carlos@systemhalted.org>
Tue, 29 Sep 2015 15:32:36 +0000 (11:32 -0400)
In the posix_fallocate description in the manual we list various
drawbacks with the emulation, including the fact that a file opened
with O_APPEND fails with EBADF. Similarly a file opened with O_WRONLY
fails with EBADF. We must be able to emulate a compare-and-swap via
pread/compare/pwrite in order to make the emulation as safe as possible.
It is not acceptable to ignore the read failure because it could result
in significant data loss across all of the blocks. There is no other way
to make this work without a true atomic CAS and SIGBUS handler (which
is looking more attractive as a way to remove the race condition).

This patch adds O_WRONLY to the manual as another bullet to clarify the
limits of the emulation.

Manual looks good in PDF.

ChangeLog
manual/filesys.texi

index 8b5050be4d3551ca287b70f6e739fce2c1d96465..8851c6be853d7f81003ae78e40694a844e9ecbe7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-29  Carlos O'Donell  <carlos@redhat.com>
+
+       * manual/filesys.texi (Storage Allocation): Document that
+       posix_fallocate emulation fails when fd is open with O_WRONLY.
+
 2015-09-28  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #19016]
index ed4f5fdd85d52de4b6b7be3292ed74bd19435841..40648853bd3266aa6b1ee61e7d6e441d20acd680 100644 (file)
@@ -3299,6 +3299,10 @@ There is a race condition if another thread or process modifies the
 underlying file in the to-be-allocated area.  Non-null bytes could be
 overwritten with null bytes.
 
+@item
+If @var{fd} has been opened with the @code{O_WRONLY} flag, the function
+will fail with an @code{errno} value of @code{EBADF}.
+
 @item
 If @var{fd} has been opened with the @code{O_APPEND} flag, the function
 will fail with an @code{errno} value of @code{EBADF}.