1 /*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)stand.h 8.1 (Berkeley) 06/11/93 8 */ 9 10 #include <sys/types.h> 11 #include <sys/cdefs.h> 12 #include <sys/errno.h> 13 #include <sys/stat.h> 14 #include <stand/saioctl.h> 15 16 #define UNIX "/vmunix" 17 18 #ifndef NULL 19 #define NULL 0 20 #endif 21 22 extern int errno; 23 24 struct open_file; 25 26 /* 27 * This structure is used to define file system operations in a file system 28 * independent way. 29 */ 30 struct fs_ops { 31 int (*open) __P((char *path, struct open_file *f)); 32 int (*close) __P((struct open_file *f)); 33 int (*read) __P((struct open_file *f, char *buf, 34 u_int size, u_int *resid)); 35 int (*write) __P((struct open_file *f, char *buf, 36 u_int size, u_int *resid)); 37 off_t (*seek) __P((struct open_file *f, off_t offset, int where)); 38 int (*stat) __P((struct open_file *f, struct stat *sb)); 39 }; 40 41 extern struct fs_ops file_system[]; 42 43 /* where values for lseek(2) */ 44 #define SEEK_SET 0 /* set file offset to offset */ 45 #define SEEK_CUR 1 /* set file offset to current plus offset */ 46 #define SEEK_END 2 /* set file offset to EOF plus offset */ 47 48 /* Device switch */ 49 struct devsw { 50 char *dv_name; 51 int (*dv_strategy) __P((void *devdata, int rw, 52 daddr_t blk, u_int size, char *buf, u_int *rsize)); 53 int (*dv_open)(); /* (struct open_file *f, ...) */ 54 int (*dv_close) __P((struct open_file *f)); 55 int (*dv_ioctl) __P((struct open_file *f, int cmd, void *data)); 56 }; 57 58 extern struct devsw devsw[]; /* device array */ 59 extern int ndevs; /* number of elements in devsw[] */ 60 61 struct open_file { 62 int f_flags; /* see F_* below */ 63 struct devsw *f_dev; /* pointer to device operations */ 64 void *f_devdata; /* device specific data */ 65 struct fs_ops *f_ops; /* pointer to file system operations */ 66 void *f_fsdata; /* file system specific data */ 67 }; 68 69 #define SOPEN_MAX 4 70 extern struct open_file files[SOPEN_MAX]; 71 72 /* f_flags values */ 73 #define F_READ 0x0001 /* file opened for reading */ 74 #define F_WRITE 0x0002 /* file opened for writing */ 75 #define F_RAW 0x0004 /* raw device open - no file system */ 76 77 int devopen __P((struct open_file *f, char *fname, char **file)); 78 void *alloc __P((unsigned size)); 79 void free __P((void *ptr, unsigned size)); 80 struct disklabel; 81 char *getdisklabel __P((const char *buf, struct disklabel *lp)); 82