[EXT2]
[reactos.git] / reactos / drivers / filesystems / ext2 / inc / linux / fs.h
1 #ifndef _LINUX_FS_INCLUDE_
2 #define _LINUX_FS_INCLUDE_
3
4 #include <linux/types.h>
5 #include <linux/atomic.h>
6 #include <linux/rbtree.h>
7
8 //
9 // kdev
10 //
11
12 #define NODEV 0
13
14 typedef struct block_device * kdev_t;
15
16 #define MINORBITS 8
17 #define MINORMASK ((1U << MINORBITS) - 1)
18
19 #define MAJOR(dev) ((unsigned int)((int)(dev) >> MINORBITS))
20 #define MINOR(dev) ((unsigned int)((int)(dev) & MINORMASK))
21
22 static inline unsigned int kdev_t_to_nr(kdev_t dev) {
23 /*return (unsigned int)(MAJOR(dev)<<8) | MINOR(dev);*/
24 return 0;
25 }
26
27 #define NODEV 0
28 #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
29
30 static inline kdev_t to_kdev_t(int dev)
31 {
32 #if 0
33 int major, minor;
34 #if 0
35 major = (dev >> 16);
36 if (!major) {
37 major = (dev >> 8);
38 minor = (dev & 0xff);
39 } else
40 minor = (dev & 0xffff);
41 #else
42 major = (dev >> 8);
43 minor = (dev & 0xff);
44 #endif
45 return (kdev_t) MKDEV(major, minor);
46 #endif
47 return 0;
48 }
49
50
51 //
52 // file system specific structures
53 //
54
55 /*
56 * Kernel pointers have redundant information, so we can use a
57 * scheme where we can return either an error code or a dentry
58 * pointer with the same return value.
59 *
60 * This should be a per-architecture thing, to allow different
61 * error and pointer decisions.
62 */
63
64 struct super_block {
65 unsigned long s_magic;
66 unsigned long s_flags;
67 unsigned long s_blocksize; /* blocksize */
68 unsigned long long s_maxbytes;
69 unsigned char s_blocksize_bits; /* bits of blocksize */
70 unsigned char s_dirt; /* any thing */
71 char s_id[30]; /* id string */
72 kdev_t s_bdev; /* block_device */
73 void * s_priv; /* EXT2_VCB */
74 struct dentry *s_root;
75 void *s_fs_info;
76 };
77
78 struct xattr_entry {
79 char xe_name_index;
80 char *xe_name;
81 char xe_name_len;
82 char *xe_value;
83 int xe_value_size;
84 int xe_value_buf_size;
85 struct rb_node xe_node;
86 };
87
88 #define XATTR_FLAG_DIRTY 0x1
89 #define XATTR_FLAG_LOADED 0x2
90
91 struct xattr_handle {
92 int xh_flags;
93 int xh_total_size;
94 struct rb_root xh_root;
95 };
96
97 struct inode {
98 __u32 i_ino; /* inode number */
99 loff_t i_size; /* size */
100 __u32 i_atime; /* Access time */
101 __u32 i_ctime; /* Creation time */
102 __u32 i_mtime; /* Modification time */
103 __u32 i_dtime; /* Deletion Time */
104 __u64 i_blocks;
105 __u32 i_block[15];
106 umode_t i_mode; /* mode */
107 uid_t i_uid;
108 gid_t i_gid;
109 atomic_t i_count; /* ref count */
110 __u16 i_nlink;
111 __u32 i_generation;
112 __u32 i_version;
113 __u32 i_flags;
114
115 struct super_block *i_sb; /* super_block */
116 void *i_priv; /* EXT2_MCB */
117
118 __u16 i_extra_isize; /* extra fields' size */
119 __u64 i_file_acl;
120 };
121
122 //
123 // Inode state bits
124 //
125
126 #define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
127 #define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
128 #define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
129 #define I_LOCK 8
130 #define I_FREEING 16
131 #define I_CLEAR 32
132
133 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
134
135
136 struct dentry {
137 atomic_t d_count;
138 struct {
139 int len;
140 char *name;
141 } d_name;
142 struct inode *d_inode;
143 struct dentry *d_parent;
144 void *d_fsdata;
145 struct super_block *d_sb;
146 };
147
148 struct file {
149
150 unsigned int f_flags;
151 umode_t f_mode;
152 __u32 f_version;
153 __int64 f_size;
154 loff_t f_pos;
155 struct dentry *f_dentry;
156 void *private_data;
157 };
158
159 /*
160 * File types
161 *
162 * NOTE! These match bits 12..15 of stat.st_mode
163 * (ie "(i_mode >> 12) & 15").
164 */
165 #define DT_UNKNOWN 0
166 #define DT_FIFO 1
167 #define DT_CHR 2
168 #define DT_DIR 4
169 #define DT_BLK 6
170 #define DT_REG 8
171 #define DT_LNK 10
172 #define DT_SOCK 12
173 #define DT_WHT 14
174
175 void iget(struct inode *inode);
176 void iput(struct inode *inode);
177 ULONGLONG bmap(struct inode *i, ULONGLONG b);
178
179 #endif /*_LINUX_FS_INCLUDE_*/