root/kernel/file.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 struct file {
   2   enum { FD_NONE, FD_PIPE, FD_INODE, FD_DEVICE } type;
   3   int ref; // reference count
   4   char readable;
   5   char writable;
   6   struct pipe *pipe; // FD_PIPE
   7   struct inode *ip;  // FD_INODE and FD_DEVICE
   8   uint off;          // FD_INODE
   9   short major;       // FD_DEVICE
  10 };
  11 
  12 #define major(dev)  ((dev) >> 16 & 0xFFFF)
  13 #define minor(dev)  ((dev) & 0xFFFF)
  14 #define mkdev(m,n)  ((uint)((m)<<16| (n)))
  15 
  16 // in-memory copy of an inode
  17 struct inode {
  18   uint dev;           // Device number
  19   uint inum;          // Inode number
  20   int ref;            // Reference count
  21   struct sleeplock lock; // protects everything below here
  22   int valid;          // inode has been read from disk?
  23 
  24   short type;         // copy of disk inode
  25   short major;
  26   short minor;
  27   short nlink;
  28   uint size;
  29   uint addrs[NDIRECT+1];
  30 };
  31 
  32 // map major device number to device functions.
  33 struct devsw {
  34   int (*read)(int, uint64, int);
  35   int (*write)(int, uint64, int);
  36 };
  37 
  38 extern struct devsw devsw[];
  39 
  40 #define CONSOLE 1

/* [<][>][^][v][top][bottom][index][help] */