This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

POSIX compliance of unlink(2)


1.5.12 and the latest snapshots allow unlinking a file contrary to POSIX 
rules.  The addition of CYGWIN=traverse was not enough to fix this issue.  
Unlink is required to fail with EACCES if the file is contained in a directory 
without write permission.

$ mkdir a
$ touch a/b
$ chmod a-w a
$ touch a/c    # Correctly fails
touch: cannot touch `a/c': Permission denied
$ rm a/b       # Oops, should have failed
$ 

Furthermore, unlink should touch the ctime of the containing directory, and the 
ctime of the unlink'd file (if hard links remain after the unlink succeeds).  
In general, open(O_CREAT), link, rename, mkdir, and rmdir should touch the 
ctime of the containing directory when the directory's contents change.

$ stat .
  File: `.'
  Size: 12288           Blocks: 12         IO Block: 1024   directory
Device: 10292fb1h/271134641d    Inode: 3390366094479868980  Links: 13
Access: (0777/drwxrwxrwx)  Uid: (  544/Administrators)   Gid: (10513/Domain 
Users)
Access: 2005-02-28 15:25:36.990625000 -0700
Modify: 2005-02-28 15:25:32.350000000 -0700
Change: 2005-02-28 15:24:58.756250000 -0700
$ mkdir a   # Oops, ctime of . not affected
$ touch b   # Oops, ctime of . not affected
$ ln b c    # Oops, ctime of . not affected (but correctly touches b and c)
$ stat c
  File: `c'
  Size: 0               Blocks: 0          IO Block: 1024   regular empty file
Device: 10292fb1h/271134641d    Inode: 2251799813814789  Links: 1
Access: (0666/-rw-rw-rw-)  Uid: (22382/  eblake)   Gid: (10513/Domain Users)
Access: 2005-02-28 15:28:25.584375000 -0700
Modify: 2005-02-28 15:28:25.584375000 -0700
Change: 2005-02-28 15:28:28.225000000 -0700
$ rmdir a   # Oops, ctime of . not affected
$ rm b      # Oops, ctime of . and c not affected
$ mv c a    # Oops, ctime of . not affected
$ stat . a
  File: `.'
  Size: 12288           Blocks: 12         IO Block: 1024   directory
Device: 10292fb1h/271134641d    Inode: 3390366094479868980  Links: 13
Access: (0777/drwxrwxrwx)  Uid: (  544/Administrators)   Gid: (10513/Domain 
Users)
Access: 2005-02-28 15:28:40.850000000 -0700
Modify: 2005-02-28 15:28:40.850000000 -0700
Change: 2005-02-28 15:24:58.756250000 -0700
  File: `a'
  Size: 0               Blocks: 0          IO Block: 1024   regular empty file
Device: 10292fb1h/271134641d    Inode: 2251799813814789  Links: 1
Access: (0666/-rw-rw-rw-)  Uid: (22382/  eblake)   Gid: (10513/Domain Users)
Access: 2005-02-28 15:28:25.584375000 -0700
Modify: 2005-02-28 15:28:25.584375000 -0700
Change: 2005-02-28 15:28:28.225000000 -0700

--
Eric Blake



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]