3 ms·
One thing to keep in mind is that the "everything is a file" paradigm breaks down with newer hardware. For example, you can't use the file metaphor to eject a C
by amyjess 10y ago
One thing to keep in mind is that the "everything is a file" paradigm breaks down with newer hardware. For example, you can't use the file metaphor to eject a CD.
To get around this, we have the ioctl subsystem, which adds a whole lot of complexity. Modern I/O programming involves heavy use of ioctl and thus isn't nearly as simple as those drawings suggest. Per Wikipedia, "A kernel that provides several hundred system calls may provide several thousand ioctl calls."
https://en.wikipedia.org/wiki/Ioctl https://en.wikipedia.org/wiki/Ioctl
- wahern 10y agoFILE *fh = fopen("/dev/cd/do", "w"); fputs("eject\n", fh); AFAIU, people use ioctl because it's a more strongly typed interface compared to juggling strings (usually the implementation defines the interface via /usr/include headers, useful from C), and because historically implementing an ioctl interface for a new device was easier in kernel implementations, including early Linux (and arguably still).