by DonHopkins · 7y ago · 0 comments
Everything as a file is an abstraction, an enormously useful abstraction. The point isn't that it has to behave like a file in every way. At the C level, the fact that open(), read(), write(), or e/poll() behave the similarly is extremely helpful.
I can have a whole suite of functions that do not care what type of file descriptor they hold, but just that those functions behave in a predictable way. Maybe only 10% of my code has to care about the differences between them, instead of 70%.
ioctl, mmap, sockets could be represented as files, why not?
`echo 1 > /root/some-file/%lock` instead of fcntl(F_SETLK) -- I just made up this syntax
`echo SIGTERM > /proc/15683/signal` instead of kill
Not sure about mmap, since its very purpose it to map a file to memory.
The fact that they're not may be a clue to answering that question.