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 Subject: Re: [PATCH] break xstat.c into pieces In-reply-to: X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp-workers AT delorie DOT com Message-id: <83r44p9mjr.fsf@gnu.org> References: <83wqeh9pwq DOT fsf AT gnu DOT org> <83vbu19o4f DOT fsf AT gnu DOT org> 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 Precedence: bulk > Date: Tue, 22 Apr 2014 22:27:56 +0300 > From: Ozkan Sezer > > >> 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.