struct sfs_super {uint32_t magic; /* magic number, should be SFS_MAGIC */uint32_t blocks; /* # of blocks in fs */uint32_t unused_blocks; /* # of unused blocks in fs */char info[SFS_MAX_INFO_LEN +1]; /* infomation for sfs */};
多年以后,主唱David Lee Roth 在自传中揭示了这一无厘头条款的来由:Van Halen 乐队在当时是把大型摇滚现场演唱会推向高校及二/三线地区的先锋,由于常常会遇到没有处理过这种大场面的承办者,因此合同里有大量条款来确认演出承办者把场地,器材,工作人员安排等等细节都严格按要求准备好。合同里有成章成章的技术细节,包括场地的承重要求,各类出入口的宽度,电源要求,以至于插座的数量和插座之间的间隔。因此,乐队把棕色豆条款夹带在合同里,以确认承办方是否“仔仔细细阅读了所有条款”。David说:“如果我在后台的M&M里找到棕色豆,我就会立马知道承办方(十有八九)是没好好读完全部技术要求,我们肯定会碰上技术问题。某些技术问题绝对会毁了这场演出,甚至害死人。”
// kern/fs/vfs/inode.hstruct inode_ops {unsignedlong vop_magic;int (*vop_open)(struct inode *node,uint32_t open_flags);int (*vop_close)(struct inode *node);int (*vop_read)(struct inode *node,struct iobuf *iob);int (*vop_write)(struct inode *node,struct iobuf *iob);int (*vop_fstat)(struct inode *node,struct stat *stat);int (*vop_fsync)(struct inode *node);int (*vop_namefile)(struct inode *node,struct iobuf *iob);int (*vop_getdirentry)(struct inode *node,struct iobuf *iob);int (*vop_reclaim)(struct inode *node);int (*vop_gettype)(struct inode *node,uint32_t*type_store);int (*vop_tryseek)(struct inode *node,off_t pos);int (*vop_truncate)(struct inode *node,off_t len);int (*vop_create)(struct inode *node,constchar*name,bool excl,struct inode **node_store);int (*vop_lookup)(struct inode *node,char*path,struct inode **node_store);int (*vop_ioctl)(struct inode *node,int op,void*data);};/* * Abstract operations on a inode. * * These are used in the form VOP_FOO(inode, args), which are macros * that expands to inode->inode_ops->vop_foo(inode, args). The operations * "foo" are: * * vop_open - Called on open() of a file. Can be used to * reject illegal or undesired open modes. Note that * various operations can be performed without the * file actually being opened. * The inode need not look at O_CREAT, O_EXCL, or * O_TRUNC, as these are handled in the VFS layer. * * VOP_EACHOPEN should not be called directly from * above the VFS layer - use vfs_open() to open inodes. * This maintains the open count so VOP_LASTCLOSE can * be called at the right time. * * vop_close - To be called on *last* close() of a file. * * VOP_LASTCLOSE should not be called directly from * above the VFS layer - use vfs_close() to close * inodes opened with vfs_open(). * * vop_reclaim - Called when inode is no longer in use. Note that * this may be substantially after vop_lastclose is * called. * ***************************************** * * vop_read - Read data from file to uio, at offset specified * in the uio, updating uio_resid to reflect the * amount read, and updating uio_offset to match. * Not allowed on directories or symlinks. * * vop_getdirentry - Read a single filename from a directory into a * uio, choosing what name based on the offset * field in the uio, and updating that field. * Unlike with I/O on regular files, the value of * the offset field is not interpreted outside * the filesystem and thus need not be a byte * count. However, the uio_resid field should be * handled in the normal fashion. * On non-directory objects, return ENOTDIR. * * vop_write - Write data from uio to file at offset specified * in the uio, updating uio_resid to reflect the * amount written, and updating uio_offset to match. * Not allowed on directories or symlinks. * * vop_ioctl - Perform ioctl operation OP on file using data * DATA. The interpretation of the data is specific * to each ioctl. * * vop_fstat -Return info about a file. The pointer is a * pointer to struct stat; see stat.h. * * vop_gettype - Return type of file. The values for file types * are in sfs.h. * * vop_tryseek - Check if seeking to the specified position within * the file is legal. (For instance, all seeks * are illegal on serial port devices, and seeks * past EOF on files whose sizes are fixed may be * as well.) * * vop_fsync - Force any dirty buffers associated with this file * to stable storage. * * vop_truncate - Forcibly set size of file to the length passed * in, discarding any excess blocks. * * vop_namefile - Compute pathname relative to filesystem root * of the file and copy to the specified io buffer. * Need not work on objects that are not * directories. * ***************************************** * * vop_creat - Create a regular file named NAME in the passed * directory DIR. If boolean EXCL is true, fail if * the file already exists; otherwise, use the * existing file if there is one. Hand back the * inode for the file as per vop_lookup. * ***************************************** * * vop_lookup - Parse PATHNAME relative to the passed directory * DIR, and hand back the inode for the file it * refers to. May destroy PATHNAME. Should increment * refcount on inode handed back. */