linux-ext3-adds-items-to-struct-inode-and-so-do-we-20010807
[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 #if defined(AFS_LINUX24_ENV)
29         struct list_head        i_dirty_buffers;
30 #endif
31         unsigned long           i_ino;
32         unsigned int            i_count;
33         kdev_t                  i_dev;
34         umode_t                 i_mode;
35         nlink_t                 i_nlink;
36         uid_t                   i_uid;
37         gid_t                   i_gid;
38         kdev_t                  i_rdev;
39 #if defined(AFS_LINUX24_ENV) || defined(pgoff2loff) 
40         loff_t                  i_size;
41 #else
42         off_t                   i_size;
43 #endif
44         time_t                  i_atime;
45         time_t                  i_mtime;
46         time_t                  i_ctime;
47         unsigned long           i_blksize;
48         unsigned long           i_blocks;
49         unsigned long           i_version;
50 #if !defined(AFS_LINUX24_ENV)
51         unsigned long           i_nrpages;
52 #endif
53 #ifdef STRUCT_INODE_HAS_I_BYTES
54         unsigned short          i_bytes;
55 #endif
56         struct semaphore        i_sem;
57 #ifdef STRUCT_INODE_HAS_I_TRUNCATE_SEM
58         struct rw_semaphore     i_truncate_sem;
59 #endif
60 #if defined(AFS_LINUX24_ENV)
61         struct semaphore        i_zombie;
62 #else
63         struct semaphore        i_atomic_write;
64 #endif
65         struct inode_operations *i_op;
66 #if defined(AFS_LINUX24_ENV)
67         struct file_operations  *i_fop;
68 #endif
69         struct super_block      *i_sb;
70 #if defined(AFS_LINUX24_ENV)
71         wait_queue_head_t       i_wait;
72 #else
73         struct wait_queue       *i_wait;
74 #endif
75         struct file_lock        *i_flock;
76 #if defined(AFS_LINUX24_ENV)
77         struct address_space    *i_mapping;
78         struct address_space    i_data;
79 #else
80         struct vm_area_struct   *i_mmap;
81         struct page             *i_pages;
82 #endif
83         struct dquot            *i_dquot[MAXQUOTAS];
84 #if defined(AFS_LINUX24_ENV)
85         struct pipe_inode_info  *i_pipe;
86         struct block_device     *i_bdev;
87 #if defined(STRUCT_INODE_HAS_I_CDEV)
88         struct char_device      *i_cdev;
89 #endif
90         unsigned long           i_dnotify_mask;
91         struct dnotify_struct   *i_dnotify;
92 #endif
93
94         unsigned long           i_state;
95
96         unsigned int            i_flags;
97 #if !defined(AFS_LINUX24_ENV)
98         unsigned char           i_pipe;
99 #endif
100         unsigned char           i_sock;
101
102 #if defined(AFS_LINUX24_ENV)
103         atomic_t                i_writecount;
104 #else
105         int                     i_writecount;
106 #endif
107         unsigned int            i_attr_flags;
108 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
109         __u32                   i_generation;
110 #endif
111 #ifdef notdef
112         union {
113                 struct pipe_inode_info          pipe_i;
114                 struct minix_inode_info         minix_i;
115                 struct ext2_inode_info          ext2_i;
116                 struct hpfs_inode_info          hpfs_i;
117                 struct ntfs_inode_info          ntfs_i;
118                 struct msdos_inode_info         msdos_i;
119                 struct umsdos_inode_info        umsdos_i;
120                 struct iso_inode_info           isofs_i;
121                 struct nfs_inode_info           nfs_i;
122                 struct sysv_inode_info          sysv_i;
123                 struct affs_inode_info          affs_i;
124                 struct ufs_inode_info           ufs_i;
125                 struct romfs_inode_info         romfs_i;
126                 struct coda_inode_info          coda_i;
127                 struct smb_inode_info           smbfs_i;
128                 struct hfs_inode_info           hfs_i;
129                 struct adfs_inode_info          adfs_i;
130                 struct qnx4_inode_info          qnx4_i;    
131                 struct socket                   socket_i;
132                 void                            *generic_ip;
133         } u;
134 #endif
135 } vnode_t;
136
137 /* Map vnode fields to inode fields. */
138 #define i_number        i_ino
139 #define v_count         i_count
140 #define v_op            i_op
141 #if defined(AFS_LINUX24_ENV)
142 #define v_fop           i_fop
143 #endif
144 #define v_type          i_mode
145 #define v_vfsp          i_sb
146 #define vfs_vnodecovered s_covered
147
148 /* v_type bits map to mode bits: */
149 #define VNON 0
150 #define VREG S_IFREG
151 #define VDIR S_IFDIR
152 #define VBLK S_IFBLK
153 #define VCHR S_IFCHR
154 #define VLNK S_IFLNK
155 #define VSOCK S_IFSOCK
156
157 /* vcexcl - used only by afs_create */
158 enum vcexcl { EXCL, NONEXCL } ;
159
160 /* afs_open and afs_close needs to distinguish these cases */
161 #define FWRITE  O_WRONLY|O_RDWR|O_APPEND
162 #define FTRUNC  O_TRUNC
163
164
165 #define IO_APPEND O_APPEND
166 #define FSYNC O_SYNC
167
168 #define VTOI(V)  ((struct inode*)V)
169 #define VN_HOLD(V) ((vnode_t*)V)->i_count++;
170 #define VN_RELE(V) osi_iput((struct inode *)V);
171 #define VFS_STATFS(V, S) ((V)->s_op->statfs)((V), (S), sizeof(*(S)))
172
173
174
175 /* Various mode bits */
176 #define VWRITE  S_IWUSR
177 #define VREAD   S_IRUSR
178 #define VEXEC   S_IXUSR
179 #define VSUID   S_ISUID
180 #define VSGID   S_ISGID
181
182
183 #define vfs super_block
184
185 typedef struct vattr {
186     int         va_type;        /* One of v_types above. */
187     size_t      va_size;
188     unsigned long va_blocks;
189     unsigned long va_blocksize;
190     int         va_mask;        /* AT_xxx operation to perform. */
191     umode_t     va_mode;        /* mode bits. */
192     uid_t       va_uid;
193     gid_t       va_gid;
194     int         va_fsid;        /* Not used? */
195     dev_t       va_rdev;
196     ino_t       va_nodeid;      /* Inode number */
197     nlink_t     va_nlink;       /* link count for file. */
198     struct timeval va_atime;
199     struct timeval va_mtime;
200     struct timeval va_ctime;
201 } vattr_t;
202
203 #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
204
205
206 /* va_masks - these should match their respective ATTR_xxx #defines in fs.h.
207  * afs_notify_change has to use the attr bits in both the Linux and AFS
208  * meanings. The glue layer code uses the ATTR_xxx style names.
209  */
210 #define AT_SIZE         ATTR_SIZE
211 #define AT_MODE         ATTR_MODE
212 #define AT_UID          ATTR_UID
213 #define AT_GID          ATTR_GID
214 #define AT_MTIME        ATTR_MTIME
215
216
217 #define vnodeops inode_operations
218
219 #endif /* OSI_VFS_H_ */