9 ms·
Everything is a file... except processes (you can't just delete a process), network interfaces (try setting an IP address with a write() or ioctl()), and plenty
by dozzie 8y ago
Everything is a file... except processes (you can't just delete a process), network interfaces (try setting an IP address with a write() or ioctl()), and plenty of other things. Unix never had "everything is a file" as its mantra, and Torvalds never introduced it.
- yjftsjthsd-h 8y ago> you can't just delete a process Kill? Possibly kill -9?
- agumonkey 8y agowell if they were files you'd use 'rm /proc/$pid'
- DonHopkins 8y agoThe power management system should be integrated with the file system so you can turn the power off by going "rm /dev/power". And also with the desktop so you can drag the power into the garbage can.
- smcl 8y agoSurely /dev/power would return “1” when you read it (“0” when it is powered down, of course), and “echo 0 > /dev/power” would turn the machine off. :-)
- laumars 8y agoPower is a physical state rather than a logical one. It would make more sense defining runlevels that way.
- yjftsjthsd-h 8y agoOh, we actually do something like that already; CPUs are listed in /sys and you can enable or disable them by echoing 0/1 to their power file.
- DonHopkins 8y agoAnd for all your two-phase alternating current and trigonometric needs, /dev/sin and /dev/cos could return sine and cosine waves!
- agumonkey 8y ago/bin/cosh
- agumonkey 8y agorm seems violent, what about unlink /dev/plug :p ps: jokes aside, I do believe that if the filesystem as machine representation was enforced and design with good sense and average joe in mind, you'd probably not even need man (pardon the hyperbole)
- detaro 8y ago> (try setting an IP address with a write() or ioctl()) ioctl(sock_fd, SIOCSIFADDR, &ifreq_pointer); is a thing, although it targets a socket on the interface, not the interface itself. Generally I think there's some cases where they try to push too much through limited interfaces, e.g. ptrace feels like "ok, we have an API already, lets push this unrelated functionality through it too so we don't have to design and add a new one"
- dozzie 8y ago> [SIOCSIFADDR] is a thing, although it targets a socket on the interface, not the interface itself. If we're cheating by using file descriptors instead of files, then you could go all the way and used AF_NETLINK sockets, they allow you even to set routing or firewall. That's kind of not the point.
- gpderetta 8y agoThe whole point of Linus's rant is that the actual Unix mantra is that everything is a file descriptor.
- dozzie 8y agoAnd then we go back to processes, System V-like IPC (shmget()/semget()/msgget()), and network configuration subsystem (routing, firewall, bringing interfaces up or down, and the like; netlink is only a recent development, after 2000). What was it about the mantra again?
- gpderetta 8y agoWell, the mantra is of course an aspiration. In practice things are not always done that way, especially in the past. SysV ipc is hopefully a thing of the past though. (I did upvote you btw)
- DonHopkins 8y agoIn Unix, you can't just delete a file either! You can remove a reference to an inode from a directory, but even if no other directories have references to that inode, a process might be holding it opened, and it won't get deleted until that process dies.
- bo1024 8y agoMy understanding of the mini-slogan "everything is a file" is that it was never meant to refer to the entire API of the object, but just reading/writing data.
- dozzie 8y agoAnd then you hit ioctls, which are necessary even by the very file-like way of working with terminals. The slogan in the unix world never matched anything well, or at least never since '90s.
- eadmund 8y ago> The slogan in the unix world never matched anything well It matched Plan 9 (which is really Unix V9) really well …
- zokier 8y ago> network interfaces (try setting an IP address with a write() or ioctl()), Aren't netlink sockets files, and used for setting IP addresses?