]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/Include/sys/file.h
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / StdLib / Include / sys / file.h
CommitLineData
d7ce7006 1/*\r
2 * Copyright (c) 1982, 1986, 1989, 1993\r
3 * The Regents of the University of California. All rights reserved.\r
4 *\r
5 * Redistribution and use in source and binary forms, with or without\r
6 * modification, are permitted provided that the following conditions\r
7 * are met:\r
8 * 1. Redistributions of source code must retain the above copyright\r
9 * notice, this list of conditions and the following disclaimer.\r
10 * 2. Redistributions in binary form must reproduce the above copyright\r
11 * notice, this list of conditions and the following disclaimer in the\r
12 * documentation and/or other materials provided with the distribution.\r
13 * 3. All advertising materials mentioning features or use of this software\r
14 * must display the following acknowledgement:\r
15 * This product includes software developed by the University of\r
16 * California, Berkeley and its contributors.\r
17 * 4. Neither the name of the University nor the names of its contributors\r
18 * may be used to endorse or promote products derived from this software\r
19 * without specific prior written permission.\r
20 *\r
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
31 * SUCH DAMAGE.\r
32 *\r
33 * @(#)file.h 8.3 (Berkeley) 1/9/95\r
34 * $Id: file.h,v 1.1.1.1 2006/05/30 06:12:53 hhzhou Exp $\r
35 */\r
36\r
37#ifndef _SYS_FILE_H_\r
38#define _SYS_FILE_H_\r
39\r
40#ifndef KERNEL\r
41#include <sys/fcntl.h>\r
42#include <sys/unistd.h>\r
43#endif\r
44\r
45#ifdef KERNEL\r
46#include <sys/queue.h>\r
47\r
48struct proc;\r
49struct uio;\r
50\r
51/*\r
52 * Kernel descriptor table.\r
53 * One entry for each open kernel vnode and socket.\r
54 */\r
55struct file {\r
56 LIST_ENTRY(file) f_list;/* list of active files */\r
57 short f_flag; /* see fcntl.h */\r
58#define DTYPE_VNODE 1 /* file */\r
59#define DTYPE_SOCKET 2 /* communications endpoint */\r
60#define DTYPE_PIPE 3 /* pipe */\r
61#define DTYPE_FIFO 4 /* fifo (named pipe) */\r
62 short f_type; /* descriptor type */\r
63 short f_count; /* reference count */\r
64 short f_msgcount; /* references from message queue */\r
65 struct ucred *f_cred; /* credentials associated with descriptor */\r
66 struct fileops {\r
67 int (*fo_read) __P((struct file *fp, struct uio *uio,\r
68 struct ucred *cred, int flags));\r
69 int (*fo_write) __P((struct file *fp, struct uio *uio,\r
70 struct ucred *cred, int flags));\r
71#define FOF_OFFSET 1\r
72 int (*fo_ioctl) __P((struct file *fp, u_long com,\r
73 caddr_t data, struct proc *p));\r
74 int (*fo_poll) __P((struct file *fp, int events,\r
75 struct ucred *cred, struct proc *p));\r
76 int (*fo_close) __P((struct file *fp, struct proc *p));\r
77 } *f_ops;\r
78 int f_seqcount; /*\r
79 * count of sequential accesses -- cleared\r
80 * by most seek operations.\r
81 */\r
82 off_t f_nextread; /*\r
83 * offset of next expected read\r
84 */\r
85 off_t f_offset;\r
86 caddr_t f_data; /* vnode or socket */\r
87};\r
88\r
89#ifdef MALLOC_DECLARE\r
90MALLOC_DECLARE(M_FILE);\r
91#endif\r
92\r
93LIST_HEAD(filelist, file);\r
94extern struct filelist filehead; /* head of list of open files */\r
95extern struct fileops vnops;\r
96extern int maxfiles; /* kernel limit on number of open files */\r
97extern int maxfilesperproc; /* per process limit on number of open files */\r
98extern int nfiles; /* actual number of open files */\r
99\r
100#endif /* KERNEL */\r
101\r
102#endif /* !SYS_FILE_H */\r