What does open() do anyways?

I know its kind of silly to think about it, but what does this function do anyways? I know it is used to open a given file with a variety of options but what is the best place to find out what is happening internally? I think it updates the file descriptor table and provides a lock file but does it do anything else besides that?

Yes.

No.

man open

will really help you, it opens existing, truncates, etc. To find out what it's doing internally look up some of the texts such as Lions on the UNIX internals, also there are books on the Linux internals.

Imagine the start state before open is called

and the end state of when open has returned a file descriptor

think of all the activities that would have to occur for that to happen, then that is what it does.

Thank you... So open is one of those critical functions right? I mean, I cannot do away if open were not present... The reason I was wondering is because there are so many file operations defined that open seemed to be that "i cannot live without it" like functions to me... Please correct me if I'm wrong...

You could narrow it down and say what are the things that open operates on and how are they implemented.

  1. files - by the file system

  2. devices, by each driver

  3. remote files - by the NFS file system

So you can actually see that 3 falls under 1. Say count the different file system types, files, directories, fifos, sockets, symbolic links, etc, what does open do in each case?

Then you could determine there is a common core of functionality but the majority would be implemented by a driver, module or subsystem.