slkern/file.h

29 lines
813 B
C

#include "fsinstance.h"
// TODO: CHECK/REPLACE/UPDATE OLD CODE (this file is based on xv6)
struct file {
enum { FD_NONE, FD_PIPE, FD_INODE, FD_DEVICE, FD_KQUEUE } type;
int ref; // reference count
char readable;
char writable; // NOTE: This is now set to 2 for append
struct pipe *pipe; // FD_PIPE
fsinstance_inode_t *ip; // FD_INODE and FD_DEVICE
uint off; // FD_INODE
short major; // FD_DEVICE
};
// These cause warnings as conflicts with non-macro uses of the words
//#define major(dev) ((dev) >> 16 & 0xFFFF)
//#define minor(dev) ((dev) & 0xFFFF)
#define mkdev(m,n) ((uint)((m)<<16| (n)))
// map major device number to device functions.
struct devsw {
int (*read)(int, uint64, int);
int (*write)(int, uint64, int);
};
extern struct devsw devsw[];
#define CONSOLE 1