NetBSD/sys/miscfs/procfs
christos 80ecd573c0 PR/1796: John Kohl: statfs misbehaves under chrooted environments.
- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
  and factored out some of the vfsop statfs() code to copy_statfs_info(). This
  fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.
2003-04-16 21:44:18 +00:00
..
Makefile
README
files.procfs Implement /proc/<pid>/fd/<n>. This is work in progress. Questionable things: 2003-01-03 13:21:17 +00:00
procfs.h This addresses PR kerm/19989. Thanks to hamajima@nagoya.ydc.co.jp for submitting this patch which enables /proc/uptime for linux emul. Patch reviewed by atatat@netbsd.org and tron@netbsd.org, approved by tron@netbsd.org. 2003-02-25 21:00:31 +00:00
procfs_cmdline.c Fix signed/unsigned comparison warnings. 2002-11-07 08:13:10 +00:00
procfs_ctl.c Merge the nathanw_sa branch. 2003-01-18 08:51:40 +00:00
procfs_fd.c Implement /proc/<pid>/fd/<n>. This is work in progress. Questionable things: 2003-01-03 13:21:17 +00:00
procfs_fpregs.c Merge the nathanw_sa branch. 2003-01-18 08:51:40 +00:00
procfs_linux.c Change "%llu" to "PRIu64" to make it compile on sparc64. 2003-02-27 12:20:28 +00:00
procfs_map.c Fix signed/unsigned comparison warnings. 2002-11-07 08:13:10 +00:00
procfs_mem.c
procfs_note.c
procfs_regs.c Merge the nathanw_sa branch. 2003-01-18 08:51:40 +00:00
procfs_status.c Merge the nathanw_sa branch. 2003-01-18 08:51:40 +00:00
procfs_subr.c Release the hash lock on failure. 2003-03-15 00:22:47 +00:00
procfs_vfsops.c PR/1796: John Kohl: statfs misbehaves under chrooted environments. 2003-04-16 21:44:18 +00:00
procfs_vnops.c use former genfs_eopnotsupp_rele() as genfs_eopnotsupp(), so that vnodes 2003-04-10 21:53:32 +00:00

README

/*	$NetBSD: README,v 1.5 1999/03/12 18:45:40 christos Exp $	*/

saute procfs lyonnais

procfs supports two levels of directory.  the filesystem root
directory contains a representation of the system process table.
this consists of an entry for each active and zombie process, and
an additional entry "curproc" which always represents the process
making the lookup request.

each of the sub-directories contains several files.  these files
are used to control and interrogate processes.  the files implemented
are:

	file	- xxx.  the exec'ed file.

	status  - r/o.  returns process status.

	ctl	- w/o.  sends a control message to the process.
			for example:
				echo hup > /proc/curproc/note
			will send a SIGHUP to the shell.
			whereas
				echo attach > /proc/1293/ctl
			would set up process 1293 for debugging.
			see below for more details.

	mem	- r/w.  virtual memory image of the process.
			parts of the address space are readable
			only if they exist in the target process.
			a more reasonable alternative might be
			to return zero pages instead of an error.
			comments?

	note	- w/o.  writing a string here sends the
			equivalent note to the process.
			[ not implemented. ]

	notepg	- w/o.  the same as note, but sends to all
			members of the process group.
			[ not implemented. ]

	regs	- r/w.	process register set.  this can be read
			or written any time even if the process
			is not stopped.  since the bsd kernel
			is single-processor, this implementation
			will get the "right" register values.
			a multi-proc kernel would need to do some
			synchronisation.
	cmdline - r/o.	process command line parameters, separated
			by NULLs

this then looks like:

% ls -li /proc
total 0
   9 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 0
  17 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 1
  89 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 10
  25 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 2
2065 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 257
2481 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 309
 265 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 32
3129 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 390
3209 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 400
3217 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 401
3273 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 408
 393 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 48
 409 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 50
 465 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 57
 481 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 59
 537 dr-xr-xr-x  2 root  kmem   0 Sep 21 15:06 66
 545 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 67
 657 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 81
 665 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 82
 673 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 83
 681 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 84
3273 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 curproc
% ls -li /proc/curproc
total 408
total 460
7692 -r--r--r--  1 dolecek  staff       0 Mar 12 12:02 cmdline
7687 --w-------  1 dolecek  staff       0 Mar 12 12:02 ctl
2003 -r-xr-xr-x  1 root     wheel  180224 Jan 31 23:32 file*
7686 -rw-------  1 dolecek  staff     108 Mar 12 12:02 fpregs
7691 -r--r--r--  1 dolecek  staff       0 Mar 12 12:02 map
7684 -rw-------  1 dolecek  staff  282624 Mar 12 12:02 mem
7689 --w-------  1 dolecek  staff       0 Mar 12 12:02 note
7690 --w-------  1 dolecek  staff       0 Mar 12 12:02 notepg
7685 -rw-------  1 dolecek  staff      64 Mar 12 12:02 regs
7688 -r--r--r--  1 dolecek  staff       0 Mar 12 12:02 status
% df /proc/curproc /proc/curproc/file
Filesystem  512-blocks    Used   Avail Capacity  Mounted on
proc                 2       2       0   100%    /proc
/dev/wd0a        16186   13548    1018    93%    /
% cat /proc/curproc/status
cat 446 439 400 81 12,0 ctty 748620684 270000 0 0 0 20000 nochan 11 20 20 20 0 21 117



the basic sequence of commands written to "ctl" would be

	attach		- this stops the target process and
			  arranges for the sending process
			  to become the debug control process
	wait		- wait for the target process to come to
			  a steady state ready for debugging.
	step		- single step, with no signal delivery.
	run		- continue running, with no signal delivery,
			  until next trap or breakpoint.
	<signame>	- deliver signal <signame> and continue running.
	detach		- continue execution of the target process
			  and remove it from control by the debug process

in a normal debugging environment, where the target is fork/exec'd by
the debugger, the debugger should fork and the child should stop itself
(with a self-inflicted SIGSTOP).  the parent should do a "wait" then an
"attach".  as before, the child will hit a breakpoint on the first
instruction in any newly exec'd image.