all 67 comments

sorted by: hot top controversial new old
[–] 119 points 1 month ago* (last edited 1 month ago) (30 children)

Stages of POSIX enlightenment:

  1. It couldn't possibly all be files
  2. It's all files
  3. What is a file, anyway?
  4. There's no such thing as a file
  5. It couldn't possibly all be files
  6. Everything is a file

Most people stop at stage 2, stage 3 hits when you decide to write a filesystem, stage 4 when you've finished your first filesystem. Stage 5 is when you start working on kernel internals. No one can tell you how to reach stage 6, you must discover it for yourself.

  • source
  • hideshow 30 child comments
  • [–] 54 points 1 month ago* (last edited 1 month ago) (7 children)

    /dev/null sez nothing is also a file

  • source
  • parent
  • hideshow 7 child comments
  • [–] 9 points 1 month ago (5 children)

    Asking for a friend.

    If you can recognize "nothing" then "nothing" must be something right? So if nothing is a file, because /dev/null says so, then nothing MUST be something to be a file. And therefore /dev/null can't be nothing.

    Or do I just need more tea? Or maybe whisk(e)y?

  • source
  • parent
  • hideshow 5 child comments
  • [–] 11 points 1 month ago (4 children)

    The word "nothing" isn't itself nothing. It is something used to describe nothing.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 11 points 1 month ago (3 children)

    The word "nothing" is the English word describing the concept of nothing. And I have to use the word to describe the concept. So yes, you are correct the word is itself "something". So that is probably one point for "nothing" to not exist.

    I have now consumed 3 cups of tea. And my head now hurts from thinking about nothing. I should never have stepped into this post.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 3 points 1 month ago (2 children)

    it's just a sentinel value. You ve reached the end. gimme back the length

  • source
  • parent
  • hideshow 2 child comments
  • [–] 24 points 1 month ago (3 children)

    Unfortunately, no one can be told what a file is. You have to see it for yourself.

    This is your last chance. After this, there is no turning back. You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill - you stay in Wonderland and I show you how deep the file system goes.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 10 points 1 month ago (3 children)
  • [–] 6 points 1 month ago (2 children)

    Okay, but what are blocks then? A file is really just a bunch of blocked stacked together with the inode metadata also sitting on another block, so is everything just blocks or because you can emulate a block device on a filesystem, are blocks themselves files? If that last part is true then files are infinitely recursive and my head is starting to spin.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 month ago

    The devnode that is used to reference the block is a file, so you come back to blocks just 'being offsets into some file'.

    Though system calls, ioctls and networking credibly get away from file semantics

  • source
  • parent
  • [–] 3 points 1 month ago (2 children)

    Missing stage 7: Not everything is a file.

    Linux is closer than other *nixes (sysctl equivalents in some platforms are not files, but they are files in Linux).

    However get very far into network and the file-like behaviors become more limited. From an application, at least you have a decent chance of having unseekable, but otherwise 'file-like' interaction with stream protocols. Then you need recvmsg/sendmsg. Then you want to deal with low level interaction with the network stack and dealing with NETLINK and such..

  • source
  • parent
  • hideshow 2 child comments
  • [–] 52 points 1 month ago (9 children)

    It makes more sense when you realize that it's not that everything is files it's that everything can be treated as a file. There are other APIs to interact with things, but everything can be interacted with as if it was a file. It doesn't seem as bonkers like this.

  • source
  • hideshow 9 child comments
  • [–] 16 points 1 month ago* (last edited 1 month ago) (2 children)

    Exactly. A file is really just a way to understand a collection of bits. So saying everything is files is like saying everything in computers can be described as sets of bits, which is not a terrible heuristic.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 7 points 1 month ago (4 children)

    Files don't actually exist once you dig down

  • source
  • parent
  • hideshow 4 child comments
  • [–] 8 points 1 month ago (2 children)

    Yeah, it sort of depends on the definition of the word file. "File" in the sense that it can be interacted with like a file versus "file" in the sense that it's data on a disk. But then, if you're really thinking about it, data on a disk isn't a file, it's data, and we can just interact with it like a file.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 44 points 1 month ago

    Yep, takes a moment to wrap your head around but the longer you read linux/unix documentation, the more it makes sense why it is the case.

  • source
  • [–] 20 points 1 month ago (2 children)
  • [–] 12 points 1 month ago

    Want take it to 11 plan 9 did it.

  • source
  • [–] 6 points 1 month ago (2 children)

    But some things are directories (like cgroups). And Networknamespaces were also controled in a weird way.
    And then there are kernel features which are not exposed through a file or syscall but through a special type of socket.

  • source
  • hideshow 2 child comments
  • [–] 7 points 1 month ago* (1 child)

    Aren't directories just files that say "hey i am directory ABCD and file X, Y and Z are my childs"?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 4 points 1 month ago

    Directories are just files if you squint at then right, and sockets are basically files too. As another commenter said, it's not that everything is literally a file, but that it presents as a file, and can be interacted with as one.

  • source
  • parent
  • [–] 6 points 1 month ago (6 children)

    Well, if you go back far enough you might encounter punch cards or even switches, but then again you're not taking about modern computers anymore.

  • source
  • hideshow 6 child comments
  • [–] 8 points 1 month ago (5 children)

    What's this "back far enough" shit, I've used punch cards and punch tape.

    Fuck me I'm old.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 1 month ago (2 children)
  • [–] 2 points 1 month ago

    Class of '99 here.

    There's at least a decade between the beginning of that list and people regularly using punch cards and tape. Maybe two.

    Magnetic tapes and actually floppy floppy disks were the medium of choice in the interim.

  • source
  • parent
  • [–] 6 points 1 month ago (1 child)

    In Windows land, it's HANDLEs...which is typedef void* HANDLE IIRC

  • source
  • hideshow 1 child comment
  • [–] 2 points 1 month ago

    Generally speaking, a handle is an opaque reference to an os object; the typedef here makes that clear. Linux uses the same general concept as well, though file objects are typically referenced through file descriptors rather than windows style handles.

  • source
  • parent
  • [–] 5 points 1 month ago

    Ok you got me with this one.

    Btw the mitochondria are the powerhouse of the cell.

  • source
  • [–] 1 point 1 month ago (1 child)

    ok then how do i access [2b00:13c0:47:1422::5]:7236 through a file?

    i don't think that's possible

    only on plan9

  • source
  • hideshow 1 child comment
  • [–] 5 points 1 month ago (1 child)
  • [–] 1 point 1 month ago (3 children)

    But what about the fotoes?

  • source
  • hideshow 3 child comments
  • [–] [S] 2 points 1 month ago (2 children)

    I suspect sarcasm but in case it is not, photos are just binary files, just like videos and many other file formats.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 1 month ago (1 child)

    Haha no my friend uses Linux and I haven't made the switch because I was under the impression that you have to be a command line wiz. Then he went on a rant about graphical interface.

  • source
  • parent
  • hideshow 1 child comment
  • Eh, there are distros where you will never need to touch a command line if you don't want to. In fact, most modern mainstream ones are that way: Mint, Fedora, Ubuntu, etc.

    Though I don't understand the fear of the command line. My grandmother owned two computers in her life and both of them were command line only. She was not a researcher at a university, a professional programmer or anything like that, just a normal person with a high school education.

    She just wasn't afraid to read the manual and try things. I still remember the spiral-bound manual with post-its covered in her nurses shorthand.

    She used them to run the books for the family business, first an Apple ][, then a PC running DOS. She also used them to write letters and the church newsletter, practice Bridge, organize her family genealogy work, and things like that.

  • source
  • parent