jehanne/sys/src/lib/c/9sys
Giacomo Tesio 99855d60d6 kernel: move chdir to libc using devself/devproc
Added wdir to devself and devproc:

- read '#0/wdir' to get the working directory of the calling process
  NOTE that a read(fd, nil, -1) will return the negated length
  of the working directory, just in case you want to
  allocate the memory required

- read '/proc/n/wdir' to know the working directory of process n
  (read(fd, nil, -1) still returns the negated length)

- write '#0/wdir' to change the working directory of the calling process
  NOTE: no offset is allowed and the provided string must
  be null terminated

- write '/proc/n/wdir' to change the working directory of process n
  NOTE: no offset is allowed and the provided string must
  be null terminated; moreover if another process change the working
  directory change during the write, the current process will
  receive an error.

In libc updated getwd() and chdir().
Also modified pwd to get advantage of the new file.

To test, run /arch/amd64/qa/kern/wdir.rc or simply try

	% pwd
	/usr/glenda
	% echo -n /tmp > /proc/$pid/wdir
        % pwd
        /tmp
        % cat '#0/wdir' && echo
        /tmp

The expected use cases for wdir in devproc are rio and acme.

Also, note that we could theoretically remove the cd builtin
from rc and simply implement it as a rc function.
We don't do that to preserve rc portability to other OS.
2016-12-15 22:42:01 +01:00
..
access.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
announce.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
awakened.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
chdir.c kernel: move chdir to libc using devself/devproc 2016-12-15 22:42:01 +01:00
convD2M.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
convM2D.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
cputime.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
ctime.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
dial.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
dirfstat.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
dirfwstat.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
dirmodefmt.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
dirread.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
dirstat.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
dirwstat.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
fork.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
getenv.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
getmainpid.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
getnetconninfo.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
getpid.c kernel: introduce devself 2016-12-11 01:26:08 +01:00
getppid.c kernel: introduce devself 2016-12-11 01:26:08 +01:00
getwd.c kernel: move chdir to libc using devself/devproc 2016-12-15 22:42:01 +01:00
iounit.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
nulldir.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
pipe.c kernel: introduce devself 2016-12-11 01:26:08 +01:00
postnote.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
privalloc.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
pushssl.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
putenv.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
qlock.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
read.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
rerrstr.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
sbrk.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
segattach.c kernel: introduce devself 2016-12-11 01:26:08 +01:00
setnetmtpt.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
sleep.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
stat.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
sysfatal.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
syslog.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
sysname.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
time.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
times.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
tm2sec.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
truerand.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
wait.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
waitpid.c decouple Jehanne from 9P2000 (as much as needed) 2016-12-06 23:01:45 +01:00
werrstr.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00
write.c first usable version of kernel and commands 2016-11-26 03:49:29 +01:00