File Descriptor Layer
Concept
Everything is a file
Each process tracks its open file
Global table
Concurrent Access
File Data Structure
struct file {
enum { FD_NONE, FD_PIPE, FD_INODE, FD_DEVICE, FD_SOCK } type;
int ref; // reference count
char readable;
char writable;
struct net *net; // FD_NET
struct pipe *pipe; // FD_PIPE
struct inode *ip; // FD_INODE and FD_DEVICE
struct sock *sock; // FD_SOCK
uint off; // FD_INODE and FD_DEVICE
short major; // FD_DEVICE
short minor; // FD_DEVICE
};Read and Write
Last updated