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

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type;
bh=wbMNPkkIwV1UUsnL8PMnS4l/KrGuggssK6mTfRzXihc=;
b=OFMZGm+Jeoab+YWnLrbk5tOupoeuEs8wJDJREQxoNGUq2MseIB73OzURVYcqE8zKEc
Ft3Xrvi3bp0qQQSwTVQekQygsIIg3tQNPxWd9r6UMtRH//CNPVachMJsHsCwrBx64Q+s
rrrDsVnosFcGGNiaiUesI0/z+TtMX3LY9pa1p2qhQJt51OmZtdXU3CJU2FYDF2/a5Fme
EgRw8fIJ5BjoJYMIJDGBmymjq+ixNjCWT0CMaPITradg/yTfk+2W3LjGuy61epMLNQdv
G/ybpJ/5GI4gp63jT7msJBXIifVFFSL5UvIAOHlGsK5bqnp/njjaCkCCUwG70lcUhwIT
XJkg==
MIME-Version: 1.0
X-Received: by 10.50.22.210 with SMTP id g18mr32222352igf.19.1398194876341;
Tue, 22 Apr 2014 12:27:56 -0700 (PDT)
In-Reply-To: <83vbu19o4f.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>
Date: Tue, 22 Apr 2014 22:27:56 +0300
Message-ID: <CAA2C=vDAWcPpCex4koZXSdorEid7w1=QTAWip7t0n-exMH+vrQ@mail.gmail.com>
Subject: Re: [PATCH] break xstat.c into pieces
From: Ozkan Sezer <sezeroz AT gmail DOT com>
To: djgpp-workers AT delorie 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

On 4/22/14, Eli Zaretskii <eliz AT gnu DOT org> wrote:
>> Date: Tue, 22 Apr 2014 21:54:16 +0300
>> From: Ozkan Sezer <sezeroz AT gmail DOT com>
>>
>> On 4/22/14, Eli Zaretskii <eliz AT gnu DOT org> wrote:
>> >> Date: Tue, 22 Apr 2014 14:11:36 +0300
>> >> From: Ozkan Sezer <sezeroz AT gmail DOT com>
>> >>
>> >> The following patch breaks xstat.c into smaller pieces, so that, e.g.
>> >> mkdir() doesn't pull in unnecessary dependencies such as ctime.o.
>> >
>> > I'd rather change 'mkdir' so that it doesn't call 'access', but only
>> > its small subset that is needed for testing the D_OK flag.  That
>> > sounds like a smaller and more localized change to me.  WDYT?
>> >
>>
>> Changing mkdir() is the first thing that conmes to mind, but there
>> is also _is_executable(), which is a public func through sys/stat.h,
>> an it relies on _djstat_flags which is in xstat.c at present.
>
> _is_executable is itself quite a monster, so I'm not sure adding ctime
> to it matters.  But if it does (I'd like to hear arguments to that
> effect), just pull _djstat_flags out of it and into, say, is_exec.c,
> and that should do the trick, I believe.
>
>> 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

>> A simple patch for mkdir() itself is inlined below. Note, however,
>> this eliminates the _fixpath() operation present in access(): I do
>> not know how necessary that is.
>
> It seems to be necessary for root directories, so I'd keep it.
>
>> diff -u -p -r1.7 mkdir.c
>> --- 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."

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.

- Raw text -


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