Everything is a File

UNIX

But!

What's a FILE?

Data?

Bytes?

Lots of Bytes...

Stream Bytes

Technically,

How does UNIX handle these so called "files"...?

File Descriptors

Basically each file is only identified by its file descriptor aka an int which has the id of the file.

So is it really true?

Not really...

"Everything is a stream of bytes, and everything that's not a stream of bytes is a process."

- Lots of smart people :P

But what's so special about it?

Well for starters the world becomes very simple.

What's everything?

  • Files [-]
  • Directories [d]
  • Symlinks [l]
  • Special Files (Devices) [c]
  • Sockets [s]
  • Named Pipes [p]

So now all our abstractions for one of these work for all of them...

  1. `read()` works with all of them too
  2. `write()` does too
  3.  links can point to other files means they can point to anything else even other links..... lol
  4.  you can do everything you can with one file that you can with another without any concern for its type which makes life of a user much simpler.

GOALS?

Consistency

consistent APIs make for happy programmers

 
 

Efficient IPC

efficiency is the gold standard of life

Robust I/O

you have device files which allow for pseudo, character,  block devices

Thank You...

Swarnim Arun

@swarnimarun

swarnimarun11@gmail.com

Everything is a File?

By Swarnim Arun

Everything is a File?

  • 529