comparison packages/io/common/current/include/file.h @ 66:bf00f99aec69 ecos-sw-2000-02-02

Merge from eCos master repository on 2000-02-02-19:16:44-GMT
author jlarmour
date Wed, 02 Feb 2000 19:57:02 +0000
parents
children 435cced73e2f
comparison
equal deleted inserted replaced
65:b4822dd69c33 66:bf00f99aec69
1 //==========================================================================
2 //
3 // io/common/include/file.h
4 //
5 // Defines for high level file I/O
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Red Hat eCos Public License
12 // Version 1.1 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://www.redhat.com/
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //==========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): gthomas
35 // Contributors: gthomas
36 // Date: 2000-01-10
37 // Purpose:
38 // Description:
39 //
40 //
41 //####DESCRIPTIONEND####
42 //
43 //==========================================================================
44
45
46 #ifndef _CYG_IO_FILE_H_
47 #define _CYG_IO_FILE_H_
48
49 // High-level file I/O interfaces
50 // Derived [in part] from OpenBSD <sys/file.h>, <sys/uio.h>, <sys/fcntl.h>
51
52 #include <pkgconf/io.h>
53 #include <cyg/infra/cyg_type.h>
54
55 #define NFILE CYGPKG_IO_NFILE
56
57 struct iovec {
58 void *iov_base; /* Base address. */
59 CYG_ADDRWORD iov_len; /* Length. */
60 };
61
62 enum uio_rw { UIO_READ, UIO_WRITE };
63
64 /* Segment flag values. */
65 enum uio_seg {
66 UIO_USERSPACE, /* from user data space */
67 UIO_SYSSPACE /* from system space */
68 };
69
70 struct uio {
71 struct iovec *uio_iov; /* pointer to array of iovecs */
72 int uio_iovcnt; /* number of iovecs in array */
73 CYG_ADDRWORD uio_offset; /* offset into file this uio corresponds to */
74 CYG_ADDRWORD uio_resid; /* residual i/o count */
75 enum uio_seg uio_segflg; /* see above */
76 enum uio_rw uio_rw; /* see above */
77 };
78
79 /*
80 * Limits
81 */
82 #define UIO_SMALLIOV 8 /* 8 on stack, else malloc */
83
84 // Description of open file
85 struct file {
86 short f_flag; /* file state */
87 short f_type; /* descriptor type */
88 struct fileops {
89 int (*fo_read)(struct file *fp, struct uio *uio);
90 int (*fo_write)(struct file *fp, struct uio *uio);
91 int (*fo_ioctl)(struct file *fp, CYG_ADDRWORD com,
92 CYG_ADDRWORD data);
93 int (*fo_select)(struct file *fp, int which);
94 int (*fo_close)(struct file *fp);
95 } *f_ops;
96 CYG_ADDRWORD f_offset;
97 CYG_ADDRWORD f_data; /* vnode or socket */
98 };
99
100 // File states
101 #define FREAD 0x01
102 #define FWRITE 0x02
103 #define FALLOC 0x80 // File is "busy", i.e. allocated
104
105 // Type of "file"
106 #define DTYPE_VNODE 1 /* file */
107 #define DTYPE_SOCKET 2 /* communications endpoint */
108 #define DTYPE_PIPE 3 /* pipe */
109
110 externC cyg_bool getfp(int fdes, struct file **fp);
111
112 #endif // _CYG_IO_FILE_H_