mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Ismael Luceno <ismael@iodev.co.uk>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>
Subject: Re: [musl] [PATCH v3 2/2] nftw: implement FTW_ACTIONRETVAL (GNU extension)
Date: Mon, 24 Jan 2022 20:53:14 +0100	[thread overview]
Message-ID: <Ye8Dqm6lBUfCgAWf@pirotess> (raw)
In-Reply-To: <Ye33JWzA/+qZRQUF@atmark-techno.com>

On 24/Jan/2022 09:47, Dominique MARTINET wrote:
> This didn't get much traction when I submitted one last year:
> https://www.openwall.com/lists/musl/2021/03/26/1
> (and there were at least a couple other occurences I could find at the
> time)

Thanks for reviewing. I was unaware of your submission.

> But given it keeps getting resubmitted I assume we can say that confirms
> there's demand for it?
<...> 
> > @@ -72,12 +72,19 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
> >  		if (!fd_limit) close(dfd);
> >  	}
> >  
> > -	if (!(flags & FTW_DEPTH) && (r=fn(path, &st, type, &lev)))
> > -		return r;
> > +	r = 0;
> > +	if (!(flags & FTW_DEPTH) && (r=fn(path, &st, type, &lev))) {
> > +		if ((flags & FTW_ACTIONRETVAL)) {
> > +			if (r == FTW_STOP) return FTW_STOP;
> > +			if (r == FTW_SKIP_SUBTREE) return 0;
> > +			/* other values are saved for when returning */
> 
> Hm, I'd naively think you would want to return immediately the other
> values as well, so the else below is wrong?
> But I didn't take long enough to check what e.g. a SKIP_SIBLINGS would
> mean here, the construction just looks a bit odd to me.

SKIP_SIBLINGS doesn't imply SKIP_SUBTREE, so must be saved and returned
when finishing.

> > @@ -120,10 +130,13 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
> >  	}
> >  
> >  	path[l] = 0;
> > -	if ((flags & FTW_DEPTH) && (r=fn(path, &st, type, &lev)))
> > -		return r;
> > -
> > -	return 0;
> > +	if (flags & FTW_DEPTH) {
> > +		r = fn(path, &st, type, &lev);
> > +		/* ignore FTW_SKIP_SUBTREE (too late), the caller is broken */
> > +		if ((flags & FTW_ACTIONRETVAL) && r == FTW_SKIP_SUBTREE)
> > +			return 0;
> 
> IIRC the glibc implementation also ignores FTW_SKIP_SIBLINGS in that
> case (nftw returns 0), I'm not sure how much of a 1-to-1 implementation
> we want -- I had implemented my version through a black-box approach
> with a client exercising all kind of different code paths as for a gnu
> extension I'd assume glibc to be the reference.

FTW_SKIP_SUBTREE makes no sense with FTW_DEPTH, but FTW_SKIP_SIBLINGS
works with both.

  reply	other threads:[~2022-01-24 19:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23 15:59 [musl] [PATCH v3 0/2] nftw: Implement FTW_CHDIR and FTW_ACTIONRETVAL Ismael Luceno
2022-01-23 15:59 ` [musl] [PATCH v3 1/2] nftw: implement FTW_CHDIR Ismael Luceno
2022-05-12 13:00   ` Rich Felker
2022-01-23 15:59 ` [musl] [PATCH v3 2/2] nftw: implement FTW_ACTIONRETVAL (GNU extension) Ismael Luceno
2022-01-24  0:47   ` Dominique MARTINET
2022-01-24 19:53     ` Ismael Luceno [this message]
2022-03-09  4:37       ` Dominique MARTINET
2022-03-09 11:41         ` Rich Felker
2022-04-28  2:02           ` Dominique MARTINET
2022-01-24 22:13 ` [musl] [PATCH v3 0/2] nftw: Implement FTW_CHDIR and FTW_ACTIONRETVAL Rich Felker

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=Ye8Dqm6lBUfCgAWf@pirotess \
    --to=ismael@iodev.co.uk \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --subject='Re: [musl] [PATCH v3 2/2] nftw: implement FTW_ACTIONRETVAL (GNU extension)' \
    /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

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).