Re: [systemd-devel] Preferred way to recurse over a directory?
On Wed, 2021-09-15 at 10:43 +0200, Lennart Poettering wrote: > On Di, 14.09.21 23:26, Albert Brox (alb...@exypno.tech) wrote: > > > I'm working on PR #20239 loadcred-dir and wondering what the preferred way > > to recurse over a directory is. > > > > I was told recursively calling the `load_credential` function is too racy so > > I'm led to ftw/nftw. However I see in the TODO file, "Get rid of nftw(). We > > should refuse to use such useless APIs on principle." Can anyone point me in > > the right direction? > > Do your own recursion, use xopendirat() to get a subdir fd from a dir > fd, and then call your funciton on that, always iterating with > readdir() as needed. > > (Probably best to keep these discussions on the PR though). > > Lennart I have had this implementation in my downstream tree for a while (no use for it upstream yet), feel free to cherry-pick and use it for your PR: https://github.com/bluca/systemd/commit/58a36591a4b4353232d024f26d253995bd88f99d -- Kind regards, Luca Boccassi signature.asc Description: This is a digitally signed message part
Re: [systemd-devel] Preferred way to recurse over a directory?
On Di, 14.09.21 23:26, Albert Brox (alb...@exypno.tech) wrote: > I'm working on PR #20239 loadcred-dir and wondering what the preferred way > to recurse over a directory is. > > I was told recursively calling the `load_credential` function is too racy so > I'm led to ftw/nftw. However I see in the TODO file, "Get rid of nftw(). We > should refuse to use such useless APIs on principle." Can anyone point me in > the right direction? Do your own recursion, use xopendirat() to get a subdir fd from a dir fd, and then call your funciton on that, always iterating with readdir() as needed. (Probably best to keep these discussions on the PR though). Lennart -- Lennart Poettering, Berlin
[systemd-devel] Preferred way to recurse over a directory?
I'm working on PR #20239 loadcred-dir and wondering what the preferred way to recurse over a directory is. I was told recursively calling the `load_credential` function is too racy so I'm led to ftw/nftw. However I see in the TODO file, "Get rid of nftw(). We should refuse to use such useless APIs on principle." Can anyone point me in the right direction? Best Albert