delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/21/23:31:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 21 Sep 2005 20:31:12 -0700
From: Yitzchak Scott-Thoennes <sthoenna AT efn DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: fstat gives wrong mode after chmod and fchmod
Message-ID: <20050922033112.GA920@efn.org>
References: <20050918222256 DOT GA3420 AT efn DOT org>
Mime-Version: 1.0
In-Reply-To: <20050918222256.GA3420@efn.org>
User-Agent: Mutt/1.4.2.1i
X-IsSubscribed: yes

On Sun, Sep 18, 2005 at 03:22:56PM -0700, Yitzchak Scott-Thoennes wrote:
> I'm seeing this on the 20050916 but as far as I know it's not a
> regression.  A new perl test (actually using an existing file opened
> for read access) turned this up.
> 
> The following gives:
> after fchmod to 0 and chmod to 0666, stat: 666  fstat: 444

Does anyone else see this?
 
> #include <fcntl.h>
> #include <sys/stat.h>
> #include <stdio.h>
> 
> int main(int argc, char **argv)
> {
>    int fd;
>    struct stat statbuf, fstatbuf;
> 
>    if ( ( fd = open("foo", O_CREAT|O_EXCL|O_WRONLY, 0666) ) < 0 ) {
>       perror("open failed");
>       return 1;
>    }
> 
>    if ( fchmod(fd, 0) ) {
>       perror("fchmod failed");
>       return 1;
>    }
> 
>    if ( chmod("foo", 0666) ) {
>       perror("chmod failed");
>       return 1;
>    }
> 
>    if ( stat("foo", &statbuf) ) {
>       perror("stat failed");
>       return 1;
>    }
> 
>    if ( fstat(fd, &fstatbuf) ) {
>       perror("fstat failed");
>       return 1;
>    }
> 
>    printf("after fchmod to 0 and chmod to 0666, stat: %o  fstat: %o\n",
>           statbuf.st_mode & 0777,  fstatbuf.st_mode & 0777);
>           
>    return 0;
> }
> 
> --
> 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/
> 

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019