xref: /reactos/drivers/filesystems/ext2/inc/linux/fs.h (revision ebaf247c)
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 inode {
79     __u32               i_ino;              /* inode number */
80     loff_t			    i_size;             /* size */
81     __u32               i_atime;	        /* Access time */
82     __u32               i_ctime;	        /* Creation time */
83     __u32               i_mtime;	        /* Modification time */
84     __u32               i_dtime;	        /* Deletion Time */
85     __u64               i_blocks;
86     __u32               i_block[15];
87     umode_t			    i_mode;             /* mode */
88     uid_t               i_uid;
89     gid_t               i_gid;
90     atomic_t            i_count;            /* ref count */
91     __u16               i_nlink;
92     __u32               i_generation;
93     __u32               i_version;
94     __u32               i_flags;
95 
96     struct super_block *i_sb;               /* super_block */
97     void               *i_priv;             /* EXT2_MCB */
98 
99     __u16               i_extra_isize;      /* extra fields' size */
100     __u64               i_file_acl;
101 };
102 
103 //
104 //  Inode state bits
105 //
106 
107 #define I_DIRTY_SYNC        1 /* Not dirty enough for O_DATASYNC */
108 #define I_DIRTY_DATASYNC    2 /* Data-related inode changes pending */
109 #define I_DIRTY_PAGES       4 /* Data-related inode changes pending */
110 #define I_LOCK              8
111 #define I_FREEING          16
112 #define I_CLEAR            32
113 
114 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
115 
116 
117 struct dentry {
118     atomic_t                d_count;
119     struct {
120         int             len;
121         char           *name;
122     } d_name;
123     struct inode           *d_inode;
124     struct dentry          *d_parent;
125     void                   *d_fsdata;
126     struct super_block     *d_sb;
127 };
128 
129 struct file {
130 
131     unsigned int    f_flags;
132     umode_t         f_mode;
133     __u32           f_version;
134     __int64         f_size;
135     loff_t          f_pos;
136     struct dentry  *f_dentry;
137     void           *private_data;
138 };
139 
140 /*
141  * File types
142  *
143  * NOTE! These match bits 12..15 of stat.st_mode
144  * (ie "(i_mode >> 12) & 15").
145  */
146 #define DT_UNKNOWN	0
147 #define DT_FIFO		1
148 #define DT_CHR		2
149 #define DT_DIR		4
150 #define DT_BLK		6
151 #define DT_REG		8
152 #define DT_LNK		10
153 #define DT_SOCK		12
154 #define DT_WHT		14
155 
156 void iget(struct inode *inode);
157 void iput(struct inode *inode);
158 ULONGLONG bmap(struct inode *i, ULONGLONG b);
159 
160 #endif /*_LINUX_FS_INCLUDE_*/
161