mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Ismael Luceno <ismael@iodev.co.uk>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH v2 1/2] nftw: implement FTW_CHDIR
Date: Sun, 23 Jan 2022 16:47:37 +0100	[thread overview]
Message-ID: <Ye14mRvLsnrqUF3a@pirotess> (raw)
In-Reply-To: <20220122155057.GA11883@voyager>

On 22/Jan/2022 16:50, Markus Wichmann wrote:
> On Sat, Jan 22, 2022 at 03:51:58PM +0100, Ismael Luceno wrote:
> > @@ -133,9 +136,16 @@ int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, str
> >  	}
> >  	memcpy(pathbuf, path, l+1);
> >
> > +	if (flags & FTW_CHDIR)
> > +		orig_dfd = open(".", O_CLOEXEC | O_PATH);
> > +
> >  	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
> >  	r = do_nftw(pathbuf, fn, fd_limit, flags, NULL);
> >  	pthread_setcancelstate(cs, 0);
> > +	if (flags & FTW_CHDIR) {
> > +		fchdir(orig_dfd);
> > +		close(orig_dfd);
> > +	}
> >  	return r;
> >  }
> >
> > --
> > 2.33.0
> >
> 
> Erm... maybe a dumb question, but what if either the open() or the
> fchdir() fails? Is anything specified for that case? Is effectively
> ignoring FTW_CHDIR OK in that case or would you have to signal failure?
> I mean, I see that there is not much you can do in either case, but to
> just fail silently seems wrong to me.

Ah, indeed. I'll try to address that.

  reply	other threads:[~2022-01-23 15:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-22 14:51 [musl] [PATCH v2 0/2] nftw: Implement FTW_CHDIR and FTW_ACTIONRETVAL Ismael Luceno
2022-01-22 14:51 ` [musl] [PATCH v2 1/2] nftw: implement FTW_CHDIR Ismael Luceno
2022-01-22 15:50   ` Markus Wichmann
2022-01-23 15:47     ` Ismael Luceno [this message]
2022-01-22 14:51 ` [musl] [PATCH v2 2/2] nftw: implement FTW_ACTIONRETVAL (GNU extension) Ismael Luceno

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=Ye14mRvLsnrqUF3a@pirotess \
    --to=ismael@iodev.co.uk \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public 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).