Re: [PATCH] fsync.2: no writability requirements, must operate on directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 03, 2023 at 03:22:50PM +0200, Alejandro Colomar wrote:
> > diff --git a/man2/fsync.2 b/man2/fsync.2
> > index 1043e6a1b..9ced40b28 100644
> > --- a/man2/fsync.2
> > +++ b/man2/fsync.2
> > @@ -155,12 +155,6 @@ .SH VERSIONS
> >  .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
> >  .\" -1: unavailable, 0: ask using sysconf().
> >  .\" glibc defines them to 1.
> > -.PP
> > -On some UNIX systems (but not Linux),
> > -.I fd
> > -must be a
> > -.I writable
> > -file descriptor.
> But that's still true.  HP-UX and AIX had that issue.  I'd move
> that paragraph to HISTORY, and say "some old UNIX systems".
Apparently still true on AIX, fsync(2) "Last Updated: 2023-03-24"
(https://www.ibm.com/docs/en/aix/7.3?topic=f-fsync-fsync-range-subroutine)
says
  Note: The file identified by the FileDescriptor parameter must be open
  for writing when the fsync subroutine is issued or the call is
  unsuccessful. This restriction was not enforced in BSD systems. The
  fsync_range subroutine does not require write access.
and
  EBADF  The FileDescriptor parameter is not a valid file descriptor
         open for writing.

So this purely-nominal restriction is likely to go away because
Issue 8 requires directories to be fsync()able. It appears that classic
UNIXes https://www.austingroupbugs.net/view.php?id=672 (comment 0001499)
simply had no need for fsync() on directories and thus we 


No clue about recent HP-UX, no offline documentation seems to be extant.


History-wise, this is invented in 4.1c.1BSD in its present-day form,
then SysVr4 copies it but plain invents the writability restriction,
so this interface is just plain broken on SysV, good job AT&T.

Try this on for size:
-- >8 --
Subject: [PATCH v2] fsync.2: no writability requirements, must operate on
 directories

POSIX has for a long time implied that directories are fsyncable,
and since Issue 8 explicitly specifies directory syncing semantics:
  https://www.austingroupbugs.net/view.php?id=672

Simultaneously, directories being unopenable for writing is a
Longest-Standing UNIX Semantic, present in the UNIX Programmer's Manual
under directory (V), and has always been enshrined in the standards.

Replace the FUD that says that some UNIXes require the fd to be writable:
they /must not/ and this confuses users:
  https://101010.pl/@eater@cijber.social/110824211348995583
with mentioning explicitly that HP-UX and AIX (by name) are just broken.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
---
 man2/fsync.2 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/man2/fsync.2 b/man2/fsync.2
index 1043e6a1b..6a7739056 100644
--- a/man2/fsync.2
+++ b/man2/fsync.2
@@ -155,12 +155,6 @@ .SH VERSIONS
 .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
 .\" -1: unavailable, 0: ask using sysconf().
 .\" glibc defines them to 1.
-.PP
-On some UNIX systems (but not Linux),
-.I fd
-must be a
-.I writable
-file descriptor.
 .SH STANDARDS
 POSIX.1-2008.
 .SH HISTORY
@@ -181,6 +175,13 @@ .SH HISTORY
 or
 .BR sdparm (8)
 to guarantee safe operation.
+.PP
+Under AT&T UNIX System V Release 4
+.I fd
+needs to be opened for writing.
+This is by itself incompatible with the original BSD interface,
+and is now forbidden by POSIX,
+but nevertheless survives in HP-UX and AIX.
 .SH SEE ALSO
 .BR sync (1),
 .BR bdflush (2),
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux