3 ms·
The discussion about /proc is a red herring. A /proc-like filesystem could use binary formats that would have better security (no formatted printing and scanni
by kazinator 3y ago
The discussion about /proc is a red herring.
A /proc-like filesystem could use binary formats that would have better security (no formatted printing and scanning bugs) as well as performance. (While not to mention having disadvantages also.)
The article somewhat conflates "everything is a file" with "everything is a text file".
Also, "everything is a file descriptor" is usefully different from "everything is a file". Not every resource bound to a file descriptor is a file (in the sense that it was obtained from a name resolution in the filesystem).
Things that are not files, but part of "everything is a file descriptor": socket(), socketpair(), pipe().
- deathanatos 3y agoBoth pipes and sockets are files, in the sense that they can appear on the filesystem. Some people refer to pipe(2) pipes as anonymous pipes — they're anonymous because they're not in the filesystem. (One in there is a "named" pipe.) (I do sort of wish most object creation in the FS was a pair of, int fd = create_a_file_descriptor_of_some_type(); link_fd(fd, "/the/name/for/it"); I think that'd be a cleaner abstraction, and then introduce syscalls on top of that for doing them together in case you think that's too much user/kernel traffic.)
- kevincox 3y agoLinux does have the O_TMPFILE flag to open. This creates a file with no name. But importantly it still needs a directory path because it needs to know which filesystem the data should be stored on. With your example if you wrote a few gigs of data to that fd before linking it the kernel would need to either buffer it (maybe swapping it out) or guess and then copy the data when it guesses wrong.