FWIW, /proc was added in Linux v0.97.3, September 1992, which is early enough I couldn't find ps source for linux earlier then that date.
Edit: My mistake, it was /dev/mem - https://github.com/lsahn-gh/unix-v6/blob/master/source/s2/ps...
Yep, found it: https://www.ibiblio.org/pub/historic-linux/ftp-archives/suns...
And the Linux kernel CREDITS file has an entry mentioning it too:
N: Rick Sladkey
D: utility hacker: Emacs, NFS server, mount, kmem-ps, UPS debugger, strace, GDB
[...]On FreeBSD there seems to be some trick where opening "/dev/null" instead of "/dev/kmem" causes the process "to not access kernel memory directly". Looking at the code it seeems to me that it means that libkvm will really open /dev/null and treat it as if it was /dev/kmem, which raises a question of exactly how that works.
[Edit: apparently this works because in case of querying processes of running kernel, the code in kvm_proc.c does not read from the file and instead calls sysctl().]
Not sure if relevant to this discussion, but here's the problems I've experienced working with files for system devices:
[1] here's just a discovery of a logitech mouse receiver, notice that it touches:
* /sys/class/*
* /sys/module/*
* /sys/class/hidraw/*/device/driver
I must take care that each dir might not be present, symlinks may be dangling, and access to multiple files is not atomic.It would be much easier and stable using just one SQLite query, for example.
[1] https://github.com/Lekensteyn/ltunify/blob/master/ltunify.c#...
I will admit that it's likely that the same thing could be done with loadable kernel modules, that said.