public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Paul Eggert <eggert@cs.ucla.edu>, libc-alpha@sourceware.org
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Subject: Re: [PATCH 3/3] linux: Optimize realpath stack usage
Date: Tue, 11 Aug 2020 12:18:27 -0300	[thread overview]
Message-ID: <637a27b3-96c6-5312-8df6-c476249bf084@linaro.org> (raw)
In-Reply-To: <0bc2bde9-c0e3-7465-fd18-c47862cc5150@linaro.org>



On 11/08/2020 11:14, Adhemerval Zanella wrote:
> 
> 
> On 10/08/2020 18:25, Paul Eggert wrote:
>> On 8/10/20 1:48 PM, Adhemerval Zanella wrote:
>>
>>> Regarding syscalls usage, for a sucessful path without symlinks it
>>> trades 2 syscalls (getcwd/lstat) for 5 (openat, readlink, fstat, stat,
>>>   and close). 
>>
>> Thanks for looking into this.
>>
>> There's no need for the new __resolve_path function to call __lstat64. It does that only to determine whether the file is a symlink or a directory, and it can do the former with __readlink (which it's gonna do already) and the latter by going into the next iteration and seeing whether it gets NOTDIR. Avoiding __lstat64 means we don't have to worry about irrelevant EOVERFLOW hassles.
> 
> I am not sure we can skip the __lstat64 because we can't check if a subpath
> passed on __readlink is a directory or not (so we can move to next iteration
> in some cases).
> 
> For instance the test 30 from stdlib/test-canon.c which issues:
> 
>   realpath ("./doesExist/someFile/", ...)

And I just checked your patch on BZ#24970 and it shows the issues:

$ grep ^FAIL stdlib/subdir-tests.sum 
FAIL: stdlib/test-canon
$ cat stdlib/test-canon.out 
/home/azanella/Projects/glibc/build/x86_64-linux-gnu/stdlib/test-canon: flunked test 30 (expected `NULL', got `/home/azanella/Projects/glibc/build/x86_64-linux-gnu/stdlib/doesExist/someFile')
/home/azanella/Projects/glibc/build/x86_64-linux-gnu/stdlib/test-canon: flunked test 31 (expected `NULL', got `/home/azanella/Projects/glibc/build/x86_64-linux-gnu/stdlib/doesExist')
2 errors.

I couldn't figure out a way to have the expected realpath semantic by
just using readlink.




  reply	other threads:[~2020-08-11 15:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 20:48 [PATCH 1/3] stdlib: Use fixed buffer size for realpath (BZ #26241) Adhemerval Zanella
2020-08-10 20:48 ` [PATCH 2/3] stdlib: Enforce PATH_MAX on allocated realpath buffer Adhemerval Zanella
2020-08-11  8:26   ` Florian Weimer
2020-08-11  9:54     ` Andreas Schwab
2020-08-11 10:24       ` Florian Weimer
2020-08-11 15:05         ` Adhemerval Zanella
2020-08-11 15:37           ` Paul Eggert
2020-08-11 18:29           ` Florian Weimer
2020-08-11  9:48   ` Andreas Schwab
2020-08-10 20:48 ` [PATCH 3/3] linux: Optimize realpath stack usage Adhemerval Zanella
2020-08-10 21:25   ` Paul Eggert
2020-08-11 14:14     ` Adhemerval Zanella
2020-08-11 15:18       ` Adhemerval Zanella [this message]
2020-08-11 15:52       ` Paul Eggert
2020-08-11 19:01         ` Adhemerval Zanella
2020-08-11 16:46     ` Andreas Schwab
2020-08-17 14:00       ` Dmitry V. Levin
2020-08-17 15:13         ` Andreas Schwab
2020-08-17 16:17           ` Dmitry V. Levin
2020-08-11  9:46   ` Andreas Schwab
2020-08-11  0:32 ` [PATCH 1/3] stdlib: Use fixed buffer size for realpath (BZ #26241) Matt Turner
2020-08-11  3:00 ` Xiaoming Ni
2020-08-11 14:57   ` Adhemerval Zanella
2020-08-12  1:38     ` Xiaoming Ni
2020-08-12 23:04       ` Adhemerval Zanella
2020-08-13 20:29         ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=637a27b3-96c6-5312-8df6-c476249bf084@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=nixiaoming@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).