tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: openat/fstatat functions implementation

> why no versions of unlink or rename or lstat?

fstatat() subsumes both stat() and lstat() - it takes a flag argument
specifying whether to follow final symlinks.

> It seems to me that you really want to solve the problem for all
> fs-related calls, not just open and fstat.

Yes.  Personally, I think I would do this with a mutant version of
syscall(2).  My first thought is something like

syscall_with_fchdir(int dirfd, int syscallnum, ...)

which effectively performs an fchdir(dirfd) for the purposes of the
syscall (I almost wrote "for the duration of the syscall", but for a
blocking syscall in a multithreaded program that's not right).

But, actually, I wouldn't do that.  I'd do something more general,
perhaps something like

        enum syscall_with_key key1, ...arg(s) for key1...,
        enum syscall_with_key key2, ...arg(s) for key2...,
        WITH_KEY_CALL, int syscallnum, ...args to syscall... )

where WITH_KEY_FCHDIR is, initially, the only key value defined aside
from WITH_KEY_CALL.  (Other possible keys might be WITH_KEY_SETREUID,
WITH_KEY_UMASK, doubtless others.)

Now, if only....

(defun openat (dir path how mode)
  (let (((locf (process-cwd (process-self))) dir))
    (open path how mode)))

> I agree the naming sucks.

Wow, something everyone agrees on.  Note the date on the calendar!

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index