/* * Copyright (c) 1982, 1986, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)file.h 7.4 (Berkeley) 09/06/89 */ #ifdef KERNEL /* * Descriptor table entry. * One for each kernel object. */ struct file { int f_flag; /* see below */ short f_type; /* descriptor type */ short f_count; /* reference count */ short f_msgcount; /* references from message queue */ struct ucred *f_cred; /* credentials associated with descriptor */ struct fileops { int (*fo_read)(); int (*fo_write)(); int (*fo_ioctl)(); int (*fo_select)(); int (*fo_close)(); } *f_ops; caddr_t f_data; /* inode */ off_t f_offset; }; struct file *file, *fileNFILE; int nfile; #endif /* * flags- also for fcntl call. */ #define FOPEN (-1) #define FREAD 00001 /* descriptor read/receive'able */ #define FWRITE 00002 /* descriptor write/send'able */ #ifndef F_DUPFD #define FNDELAY 00004 /* no delay */ #define FAPPEND 00010 /* append on each write */ #endif #define FMARK 00020 /* mark during gc() */ #define FDEFER 00040 /* defer for next gc pass */ #ifndef F_DUPFD #define FASYNC 00100 /* signal pgrp when data ready */ #endif #define FSHLOCK 00200 /* shared lock present */ #define FEXLOCK 00400 /* exclusive lock present */ /* bits to save after open */ #define FMASK (FASYNC|FAPPEND|FNDELAY|FWRITE|FREAD) #define FCNTLCANT (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK) /* open only modes */ #define FCREAT 01000 /* create if nonexistant */ #define FTRUNC 02000 /* truncate to zero length */ #define FEXCL 04000 /* error if already created */ #ifndef F_DUPFD /* fcntl(2) requests--from */ #define F_DUPFD 0 /* Duplicate fildes */ #define F_GETFD 1 /* Get fildes flags */ #define F_SETFD 2 /* Set fildes flags */ #define F_GETFL 3 /* Get file flags */ #define F_SETFL 4 /* Set file flags */ #define F_GETOWN 5 /* Get owner */ #define F_SETOWN 6 /* Set owner */ #endif /* * User definitions. */ /* * Open call. */ #define O_RDONLY 000 /* open for reading */ #define O_WRONLY 001 /* open for writing */ #define O_RDWR 002 /* open for read & write */ #define O_NDELAY FNDELAY /* non-blocking open on file */ #define O_NONBLOCK FNDELAY /* ditto */ #define O_APPEND FAPPEND /* append on each write */ #define O_CREAT FCREAT /* open with file create */ #define O_TRUNC FTRUNC /* open with truncation */ #define O_EXCL FEXCL /* error on create if file exists */ /* * Flock call. */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock */ /* * Access call. */ #define F_OK 0 /* does file exist */ #define X_OK 1 /* is it executable by caller */ #define W_OK 2 /* writable by caller */ #define R_OK 4 /* readable by caller */ /* * Lseek call. */ #define L_SET 0 /* absolute offset */ #define L_INCR 1 /* relative to current offset */ #define L_XTND 2 /* relative to end of file */ #ifdef KERNEL #define DTYPE_VNODE 1 /* file */ #define DTYPE_SOCKET 2 /* communications endpoint */ #endif