Talk a little bit more about what happens when you open a file,
and how does access control factor into it.
So, process here is making these calls we're talking about.
It first opens this file F, without specifying the mode here,
but maybe this is read.
This line is going from user to the operating system,
system call, this is the boundary between the two.
This is untrusted, this is trusted, as we talked about.
So, this is all in the operating system.
So basically, the file got stored on the disk, and
files that are actively being accessed, the operating system keeps track of
those information about a particular file is in a file control block.
So if you've done the operating system's class,
you have some idea of how file systems are implemented.
But for each file that we want to access, we you know meta-data
that we're talking about for a file you know what's the file pointer,
where should we read next, where on disk the file blocks are.
Other kind of information.
We keep track of that in the file control log.
In Unix, well that's called an i-node, and there's a table of these.
That's where this i-node table stores the meta-data about the active or
currently open files.
So this is, here, I'm saying it file meta-data table.
A file that you're going to open has to be active,
it it's not active, it's going to get activated.
So, there's something interesting happen, when you open a file you tell
the filename, the operating system's actually is going to go and
say, is this file currently active.
If it is active then there is going to be a file control block for it, okay.
That's where the meta-data for this file is going to be.
So a process also has another data structure that's called an open
file table.
Okay this is kept by the operating system.
It's per process data structure we're talking about.
So in this open file table that we have for
this process that is making this open call, basically what
we want to do in the open call is that we want to see if the file is active.
If it is then there is a meta-data block or file control block for it.
In the open file table, there is some set of entries that we have.
This is a fixed sized table.
We're going to use one of those entries to actually store a pointer to this.
And the file descriptor we return is actually nothing but
an index into this table.
So i is the index in this table that we're returning.
I think it was about access check when do we perform.
Actually in Unix-based systems, access control is done when you open the file.
At the time the file is opened remember we're going to go in,
we're going to find out if the file is currently active or
not, we're going to locate its file into a block where the meta-data is.
In particular the ACL is here too.
With the ACL is here, then it was nine bits that I was talking about.
Depending on the user or group the user is part of.
I'm actually going to look at those ACL bits that we're discussing.
And if the mode here is read, and you have read information, I do all this.
Okay? I'm going to grant you access
Mode is right and the right permission is here.
I'm going to do all of this and give you write permission and
to place data in this file.
So access check is going to happen during the open calls execution in
the operating system because we locate this information where the ACL
information is and we're going to look that up.
And if everything checks out we set this up and return this file descriptor.
So the reason we do it at the time it's open is,
that when you come to read, you specify a file descriptor.
So, it's going to say read I here, for exam, that's what you're saying.
Well, once I come to the operating system, it's the that remember is
an index into a table, that tells me, it's this particular entry in the table.
Follow the pointer that it points to, that's where the file meta-data is, and
that tells you where the file data is.
I don't do any access check at the time I do a read or write.
I just sort of quickly follow these pointers and get to the file.
If I'm doing reads then I find the file data to return
to copy that into the buffer.
If I'm doing a write then I copy the data from the buffer into file cache or
something like that.
It gets copied.
So there's no check done during either read call or a write call.
The check was done when we did the open, okay.
So the fact that the script was returned to you
at that time we did the checking and now you're able to do that.
If we opened it for read and you tried to do write, of course.
Of course we're going to stop that.
Okay.
That goes without saying.
We don't have to go look for
the particular to do the transversal that we are talking about.