163279Smckusick /*- 2*63370Sbostic * Copyright (c) 1993 3*63370Sbostic * The Regents of the University of California. All rights reserved. 463279Smckusick * 563279Smckusick * %sccs.include.redist.c% 663279Smckusick * 7*63370Sbostic * @(#)stand.h 8.1 (Berkeley) 06/11/93 863279Smckusick */ 963279Smckusick 1063279Smckusick #include <sys/types.h> 1163279Smckusick #include <sys/cdefs.h> 1263279Smckusick #include <sys/errno.h> 1363279Smckusick #include <sys/stat.h> 1463279Smckusick #include <stand/saioctl.h> 1563279Smckusick 1663279Smckusick #define UNIX "/vmunix" 1763279Smckusick 1863279Smckusick #ifndef NULL 1963279Smckusick #define NULL 0 2063279Smckusick #endif 2163279Smckusick 2263279Smckusick extern int errno; 2363279Smckusick 2463279Smckusick struct open_file; 2563279Smckusick 2663279Smckusick /* 2763279Smckusick * This structure is used to define file system operations in a file system 2863279Smckusick * independent way. 2963279Smckusick */ 3063279Smckusick struct fs_ops { 3163279Smckusick int (*open) __P((char *path, struct open_file *f)); 3263279Smckusick int (*close) __P((struct open_file *f)); 3363279Smckusick int (*read) __P((struct open_file *f, char *buf, 3463279Smckusick u_int size, u_int *resid)); 3563279Smckusick int (*write) __P((struct open_file *f, char *buf, 3663279Smckusick u_int size, u_int *resid)); 3763279Smckusick off_t (*seek) __P((struct open_file *f, off_t offset, int where)); 3863279Smckusick int (*stat) __P((struct open_file *f, struct stat *sb)); 3963279Smckusick }; 4063279Smckusick 4163279Smckusick extern struct fs_ops file_system[]; 4263279Smckusick 4363279Smckusick /* where values for lseek(2) */ 4463279Smckusick #define SEEK_SET 0 /* set file offset to offset */ 4563279Smckusick #define SEEK_CUR 1 /* set file offset to current plus offset */ 4663279Smckusick #define SEEK_END 2 /* set file offset to EOF plus offset */ 4763279Smckusick 4863279Smckusick /* Device switch */ 4963279Smckusick struct devsw { 5063279Smckusick char *dv_name; 5163279Smckusick int (*dv_strategy) __P((void *devdata, int rw, 5263279Smckusick daddr_t blk, u_int size, char *buf, u_int *rsize)); 5363279Smckusick int (*dv_open)(); /* (struct open_file *f, ...) */ 5463279Smckusick int (*dv_close) __P((struct open_file *f)); 5563279Smckusick int (*dv_ioctl) __P((struct open_file *f, int cmd, void *data)); 5663279Smckusick }; 5763279Smckusick 5863279Smckusick extern struct devsw devsw[]; /* device array */ 5963279Smckusick extern int ndevs; /* number of elements in devsw[] */ 6063279Smckusick 6163279Smckusick struct open_file { 6263279Smckusick int f_flags; /* see F_* below */ 6363279Smckusick struct devsw *f_dev; /* pointer to device operations */ 6463279Smckusick void *f_devdata; /* device specific data */ 6563279Smckusick struct fs_ops *f_ops; /* pointer to file system operations */ 6663279Smckusick void *f_fsdata; /* file system specific data */ 6763279Smckusick }; 6863279Smckusick 6963279Smckusick #define SOPEN_MAX 4 7063279Smckusick extern struct open_file files[SOPEN_MAX]; 7163279Smckusick 7263279Smckusick /* f_flags values */ 7363279Smckusick #define F_READ 0x0001 /* file opened for reading */ 7463279Smckusick #define F_WRITE 0x0002 /* file opened for writing */ 7563279Smckusick #define F_RAW 0x0004 /* raw device open - no file system */ 7663279Smckusick 7763279Smckusick int devopen __P((struct open_file *f, char *fname, char **file)); 7863279Smckusick void *alloc __P((unsigned size)); 7963279Smckusick void free __P((void *ptr, unsigned size)); 8063279Smckusick struct disklabel; 8163279Smckusick char *getdisklabel __P((const char *buf, struct disklabel *lp)); 82