[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: file_operations struct vs file struct
Dan Erickson wrote:
>
> In chapter 3 of Linux Device Drivers 2nd Edition it says
> An open device is identified internally by a file structure,
> and the kernel uses the file_operations structure to access the driver's functions.
>
> My first question would be, when it says " identified internally
> by a file structure", is is refering to *the* file structure, as in
> "struct file", or is it refering to the file_operations structure?
Each open device (and file) is represented by a struct file.
The file_operations structure contains pointers to functions
that actually implement the behavior associated with
the device (or filesystem).
> So basicly if it was refering to the file_operations structure the
> statement would expand to "An open device is identified internally by
> the file_operations structure, and the kernel uses the file_operations structure
> to access the driver's functions."
No, struct file and struct file_operations have different
purposes. I believe struct file contains a pointer to
the appropriate file_operations struct for the file
in question; in normal filesystem files that will
point to the VFS-supplied filesystem-specific file
operations, and for devices it will point to the
file_ops provided by the device driver (but don't
take my word for this, as I don't have the source
in front of me at this moment).
Cheers,
-- Joe
Any OS distinguishable from Windows is not sufficiently broken.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/