delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2014/04/22/15:44:39

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Date: Tue, 22 Apr 2014 22:44:24 +0300
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: [PATCH] break xstat.c into pieces
In-reply-to: <CAA2C=vDAWcPpCex4koZXSdorEid7w1=QTAWip7t0n-exMH+vrQ@mail.gmail.com>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-id: <83r44p9mjr.fsf@gnu.org>
References: <CAA2C=vBuWHmVNrRAcGDSXYLc8Eg_xsyMVszPzrxqHGrpVq2vmw AT mail DOT gmail DOT com> <83wqeh9pwq DOT fsf AT gnu DOT org> <CAA2C=vD_97x3-A0Y52JDfbmmFiuVzF_Ufub6imhmuhTsdsNr4w AT mail DOT gmail DOT com> <83vbu19o4f DOT fsf AT gnu DOT org> <CAA2C=vDAWcPpCex4koZXSdorEid7w1=QTAWip7t0n-exMH+vrQ AT mail DOT gmail DOT com>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Tue, 22 Apr 2014 22:27:56 +0300
> From: Ozkan Sezer <sezeroz AT gmail DOT com>
> 
> >> I suggest that we chop xstat.c into pieces _and_ change mkdir() too.
> >
> > I see no need to chop, just get _djstat_flags out of there.
> >
> 
> OK, then I suggest moving those two flags into a new statbits.c

Maybe just into crt1.c.  It's just one int, so doesn't deserve a
separate file, and no one will complain about the code bloat of 4
bytes.

> >> --- mkdir.c	2 Oct 2011 02:40:11 -0000	1.7
> >> +++ mkdir.c	22 Apr 2014 18:50:40 -0000
> >> @@ -73,7 +73,8 @@ do_mkdir:
> >>      {
> >>        /* see if the directory existed, in which case
> >>           we should return EEXIST - DJ */
> >> -      if (access(mydirname, D_OK) == 0)
> >> +      if ((attr = _chmod(dir_name, 0)) != -1 &&
> >> +           attr & 0x10)
> >
> > Not enough: _chmod doesn't resolve symlinks (assuming we want to
> > return EEXIST for symlinks to directories, that is -- what does Posix
> > say?).
> >
> 
> On linux, 'man 2 mkdir' says:
> "EEXIST  pathname already exists (not necessarily as a directory).
>   This includes the case where pathname is a symbolic link, dangling
>   or not."

So we need to resolve symlinks.

> Note that what we presently have already resolves the symlinks even
> though we are passing mydirname to access() and not dir_name,
> because access() does resolve symlinks.

Right you are, sorry for the noise.

- Raw text -


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