Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
To: cygwin@cygwin.com
From: Eric Blake <ebb9@byu.net>
Subject: POSIX compliance of unlink(2)
Date: Mon, 28 Feb 2005 22:45:59 +0000 (UTC)
Lines: 61
Message-ID: <loom.20050228T224243-848@post.gmane.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: usenet@sea.gmane.org
X-Gmane-NNTP-Posting-Host: main.gmane.org
User-Agent: Loom/3.14 (http://gmane.org/)
X-Loom-IP: 128.170.36.44 (Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322))
X-Gmane-MailScanner: Found to be clean
X-Gmane-MailScanner: Found to be clean
X-MailScanner-From: goc-cygwin@m.gmane.org
X-MailScanner-To: cygwin@cygwin.com
X-IsSubscribed: yes

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/

