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