initial-linux24-support-20001105
[openafs.git] / src / afs / LINUX / osi_vfs.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Linux interpretations of vnode and vfs structs.
12  *
13  * The Linux "inode" has been abstracted to the fs independent part to avoid
14  * wasting 100+bytes per vnode.
15  */
16
17 #ifndef OSI_VFS_H_
18 #define OSI_VFS_H_
19
20 /* The vnode should match the current implementation of the fs independent
21  * part of the Linux inode.
22  */
23 /* The first cut is to continue to use a separate vnode pool. */
24 typedef struct vnode {
25         struct list_head        i_hash;
26         struct list_head        i_list;
27         struct list_head        i_dentry;
28
29         unsigned long           i_ino;
30         unsigned int            i_count;
31         kdev_t                  i_dev;
32         umode_t                 i_mode;
33         nlink_t                 i_nlink;
34         uid_t                   i_uid;
35         gid_t                   i_gid;
36         kdev_t                  i_rdev;
37 #if defined(AFS_LINUX24_ENV)
38         loff_t                  i_size;
39 #else
40         off_t                   i_size;
41 #endif
42         time_t                  i_atime;
43         time_t                  i_mtime;
44         time_t                  i_ctime;
45         unsigned long           i_blksize;
46         unsigned long           i_blocks;
47         unsigned long           i_version;
48 #if !defined(AFS_LINUX24_ENV)
49         unsigned long           i_nrpages;
50 #endif
51         struct semaphore        i_sem;
52 #if defined(AFS_LINUX24_ENV)
53         struct semaphore        i_zombie;
54 #else
55         struct semaphore        i_atomic_write;
56 #endif
57         struct inode_operations *i_op;
58 #if defined(AFS_LINUX24_ENV)
59         struct file_operations  *i_fop;
60 #endif
61         struct super_block      *i_sb;
62 #if defined(AFS_LINUX24_ENV)
63         wait_queue_head_t       i_wait;
64 #else
65         struct wait_queue       *i_wait;
66 #endif
67         struct file_lock        *i_flock;
68 #if defined(AFS_LINUX24_ENV)
69         struct address_space    *i_mapping;
70         struct address_space    i_data;
71 #else
72         struct vm_area_struct   *i_mmap;
73         struct page             *i_pages;
74 #endif
75         struct dquot            *i_dquot[MAXQUOTAS];
76 #if defined(AFS_LINUX24_ENV)
77         struct pipe_inode_info  *i_pipe;
78         struct block_device     *i_bdev;
79 #endif
80
81         unsigned long           i_state;
82
83         unsigned int            i_flags;
84 #if !defined(AFS_LINUX24_ENV)
85         unsigned char           i_pipe;
86 #endif
87         unsigned char           i_sock;
88
89 #if defined(AFS_LINUX24_ENV)
90         atomic_t                i_writecount;
91 #else
92         int                     i_writecount;
93 #endif
94         unsigned int            i_attr_flags;
95 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
96         __u32                   i_generation;
97 #endif
98 #ifdef notdef
99         union {
100                 struct pipe_inode_info          pipe_i;
101                 struct minix_inode_info         minix_i;
102                 struct ext2_inode_info          ext2_i;
103                 struct hpfs_inode_info          hpfs_i;
104                 struct ntfs_inode_info          ntfs_i;
105                 struct msdos_inode_info         msdos_i;
106                 struct umsdos_inode_info        umsdos_i;
107                 struct iso_inode_info           isofs_i;
108                 struct nfs_inode_info           nfs_i;
109                 struct sysv_inode_info          sysv_i;
110                 struct affs_inode_info          affs_i;
111                 struct ufs_inode_info           ufs_i;
112                 struct romfs_inode_info         romfs_i;
113                 struct coda_inode_info          coda_i;
114                 struct smb_inode_info           smbfs_i;
115                 struct hfs_inode_info           hfs_i;
116                 struct adfs_inode_info          adfs_i;
117                 struct qnx4_inode_info          qnx4_i;    
118                 struct socket                   socket_i;
119                 void                            *generic_ip;
120         } u;
121 #endif
122 } vnode_t;
123
124 /* Map vnode fields to inode fields. */
125 #define i_number        i_ino
126 #define v_count         i_count
127 #define v_op            i_op
128 #if defined(AFS_LINUX24_ENV)
129 #define v_fop           i_fop
130 #endif
131 #define v_type          i_mode
132 #define v_vfsp          i_sb
133 #define vfs_vnodecovered s_covered
134
135 /* v_type bits map to mode bits: */
136 #define VNON 0
137 #define VREG S_IFREG
138 #define VDIR S_IFDIR
139 #define VBLK S_IFBLK
140 #define VCHR S_IFCHR
141 #define VLNK S_IFLNK
142 #define VSOCK S_IFSOCK
143
144 /* vcexcl - used only by afs_create */
145 enum vcexcl { EXCL, NONEXCL } ;
146
147 /* afs_open and afs_close needs to distinguish these cases */
148 #define FWRITE  O_WRONLY|O_RDWR|O_APPEND
149 #define FTRUNC  O_TRUNC
150
151
152 #define IO_APPEND O_APPEND
153 #define FSYNC O_SYNC
154
155 #define VTOI(V)  ((struct inode*)V)
156 #define VN_HOLD(V) ((vnode_t*)V)->i_count++;
157 #define VN_RELE(V) osi_iput((struct inode *)V);
158 #define VFS_STATFS(V, S) ((V)->s_op->statfs)((V), (S), sizeof(*(S)))
159
160
161
162 /* Various mode bits */
163 #define VWRITE  S_IWUSR
164 #define VREAD   S_IRUSR
165 #define VEXEC   S_IXUSR
166 #define VSUID   S_ISUID
167 #define VSGID   S_ISGID
168
169
170 #define vfs super_block
171
172 typedef struct vattr {
173     int         va_type;        /* One of v_types above. */
174     size_t      va_size;
175     unsigned long va_blocks;
176     unsigned long va_blocksize;
177     int         va_mask;        /* AT_xxx operation to perform. */
178     umode_t     va_mode;        /* mode bits. */
179     uid_t       va_uid;
180     gid_t       va_gid;
181     int         va_fsid;        /* Not used? */
182     dev_t       va_rdev;
183     ino_t       va_nodeid;      /* Inode number */
184     nlink_t     va_nlink;       /* link count for file. */
185     struct timeval va_atime;
186     struct timeval va_mtime;
187     struct timeval va_ctime;
188 } vattr_t;
189
190 #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
191
192
193 /* va_masks - these should match their respective ATTR_xxx #defines in fs.h.
194  * afs_notify_change has to use the attr bits in both the Linux and AFS
195  * meanings. The glue layer code uses the ATTR_xxx style names.
196  */
197 #define AT_SIZE         ATTR_SIZE
198 #define AT_MODE         ATTR_MODE
199 #define AT_UID          ATTR_UID
200 #define AT_GID          ATTR_GID
201 #define AT_MTIME        ATTR_MTIME
202
203
204 #define vnodeops inode_operations
205
206 #endif /* OSI_VFS_H_ */