Re: Operations on file descriptors in addition to pathnames Duy Nguyen 12 Dec 2019 07:46 UTC

On Wed, Dec 11, 2019 at 7:44 PM Lassi Kortela <xxxxxx@lassi.io> wrote:
>
> Should we include these?

Are there good reasons to? I think these are mostly to prevent races
or maybe when path resolution becomes too expensive. I don't see a
typical scheme program needing any of those. In both cases, falling
back to C via FFI may be a safer bet even if it's not portable.

>
> fd = open("/some/dir", O_RDONLY);
> openat(fd, path_under_that_dir, ...);
> fstatat(fd, path_under_that_dir, ...);
> fchmodat(fd, path_under_that_dir, mode, ...);
> fchownat(fd, path_under_that_dir, uid, gid, ...);
> unlinkat(fd, path_under_that_dir, ...);
> renameat(from_fd, from_path, to_fd, to_path);
>
> fchdir(fd);
> fdopendir(fd);
> fchmod(fd, mode);
> fchown(fd, uid, gid);
> futimes(fd, timespecs...);
>
> maybe more

--
Duy