After sending the "clone" request to /proc/$pid/ns, the current process
will be moved to the working directory of $pid.
Otherwise the current process could still access the file and folders
on the service providing its dot, even if such service was not visible to $pid.
Also, keeping the original working directory means that the 'cd' line of the
current process's ns file would be different from that of $pid: the two ns
files must match since the command asked for a "clone".
See also https://marc.info/?l=9fans&m=150893734909969&w=2
Calling resrcwait in awake_gc_proc (that is called from pexit and thus
from sys_exits) means that we have to ignore errors that could cause
the syscall to return.
The funny part here was that one single test for newlib showed the
issue by faulting in a note handler AFTER completing with success:
/arch/amd64/qa/lib/newlib/sigchld/213-sigqueue
The fact was that in the executable, the function notifier() was
located just after the exits() function, whose last line was a call
to _exits().
Thus, when the _exits returned, the notifier() code was executed.
In _procfdprint print additional informations in the second column:
E is printed if the file was open with OCEXEC flag
D is printed if the file was open with ORCLOSE flag
Example output:
3 rE 9 46 (0000000000000001 0 00) 8192 13 /dev/cons
Any process X can get a new copy of the namespace of a target
process Y by writing the string "clone" to the ns file of Y.
The same user must own both processes.
The process writing the ns file must be allowed to mount.
The Pgrp of the calling process is then replaced with a new copy of
the Pgrp of the target process.
After the operation, any change done by X to its own namespace does
not affect Y. Also, if mount was forbidden for Y, it will also be
forbidden for X after the clone.
The new header envvars.h contains the names of commonly used
environment variables, such as $user, $ifs, $path and so on.
These defines are useful for Jehanne core applications that
use them to comunicate some values.
They are not strictly required, but having such defines we
can easily change the naming convention (from lowercase to uppercase).
I do not expect chown, fchownat and lchown to be much used in
UNIX softwares that we care to port.
We stub the functions in libposix so that we can refer them from
standard C libaries (such as newlib).
We will implement them (parsing /cfg/users to determinate uid and gid)
when it will be actually needed from a software ported to Jehanne.
There are a few issues with Plan 9's `access`:
- it has side effects: to test the actual access (that the file
servers can allow or deny according to complex custom rules)
it opens and then closes the file, allocating (and disposing) the fd
- it does not work on directories, since
- they cannot be opened for writing, despite the fact that to
create a file in a directory you must be granted write access on
that directory
- they cannot be opened for execution, despite the fact that to
access a file in a directory you must be granted execution access
on that directory
Despite the fact that `access` (even on UNIX) is a violation of the
"tell, don't ask" principle (the access could be forbidden just after
its successful return, making subsequent `open` fail anyway), this
fact smells of a little design error in the file interface.
So, right now we choose to let the libposix's `access` lie on directories:
it will always return 0 on AWRITE and AEXEC for them, accepting that
a successive create/mkdir may fail.
However, a cleaner file API and protocol should allow a simpler `access`
to be implemented for directories too.