1 #ifndef _LINUX_MINIX_FS_H
2 #define _LINUX_MINIX_FS_H
3 
4 /*
5  * The minix filesystem constants/structures
6  */
7 
8 /*
9  * Thanks to Kees J Bot for sending me the definitions of the new
10  * minix filesystem (aka V2) with bigger inodes and 32-bit block
11  * pointers.
12  */
13 
14 #define MINIX_ROOT_INO 1
15 
16 /* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
17 #define MINIX_LINK_MAX	250
18 #define MINIX2_LINK_MAX	65530
19 
20 #define MINIX_I_MAP_SLOTS	8
21 #define MINIX_Z_MAP_SLOTS	64
22 #define MINIX_SUPER_MAGIC	0x137F		/* original minix fs */
23 #define MINIX_SUPER_MAGIC2	0x138F		/* minix fs, 30 char names */
24 #define MINIX2_SUPER_MAGIC	0x2468		/* minix V2 fs */
25 #define MINIX2_SUPER_MAGIC2	0x2478		/* minix V2 fs, 30 char names */
26 #define MINIX_VALID_FS		0x0001		/* Clean fs. */
27 #define MINIX_ERROR_FS		0x0002		/* fs has errors. */
28 
29 #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
30 #define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
31 
32 #define MINIX_V1		0x0001		/* original minix fs */
33 #define MINIX_V2		0x0002		/* minix V2 fs */
34 
35 #define INODE_VERSION(inode)	inode->i_sb->u.minix_sb.s_version
36 
37 /*
38  * This is the original minix inode layout on disk.
39  * Note the 8-bit gid and atime and ctime.
40  */
41 struct minix_inode {
42 	__u16 i_mode;
43 	__u16 i_uid;
44 	__u32 i_size;
45 	__u32 i_time;
46 	__u8  i_gid;
47 	__u8  i_nlinks;
48 	__u16 i_zone[9];
49 };
50 
51 /*
52  * The new minix inode has all the time entries, as well as
53  * long block numbers and a third indirect block (7+1+1+1
54  * instead of 7+1+1). Also, some previously 8-bit values are
55  * now 16-bit. The inode is now 64 bytes instead of 32.
56  */
57 struct minix2_inode {
58 	__u16 i_mode;
59 	__u16 i_nlinks;
60 	__u16 i_uid;
61 	__u16 i_gid;
62 	__u32 i_size;
63 	__u32 i_atime;
64 	__u32 i_mtime;
65 	__u32 i_ctime;
66 	__u32 i_zone[10];
67 };
68 
69 /*
70  * minix super-block data on disk
71  */
72 struct minix_super_block {
73 	__u16 s_ninodes;
74 	__u16 s_nzones;
75 	__u16 s_imap_blocks;
76 	__u16 s_zmap_blocks;
77 	__u16 s_firstdatazone;
78 	__u16 s_log_zone_size;
79 	__u32 s_max_size;
80 	__u16 s_magic;
81 	__u16 s_state;
82 	__u32 s_zones;
83 };
84 
85 struct minix_dir_entry {
86 	__u16 inode;
87 	char name[0];
88 };
89 
90 #ifdef __KERNEL__
91 
92 /*
93  * change the define below to 0 if you want names > info->s_namelen chars to be
94  * truncated. Else they will be disallowed (ENAMETOOLONG).
95  */
96 #define NO_TRUNCATE 1
97 
98 extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
99 extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
100 extern struct inode * minix_new_inode(const struct inode * dir, int * error);
101 extern void minix_free_inode(struct inode * inode);
102 extern unsigned long minix_count_free_inodes(struct super_block *sb);
103 extern int minix_new_block(struct inode * inode);
104 extern void minix_free_block(struct inode * inode, int block);
105 extern unsigned long minix_count_free_blocks(struct super_block *sb);
106 
107 extern void V1_minix_truncate(struct inode *);
108 extern void V2_minix_truncate(struct inode *);
109 extern void minix_truncate(struct inode *);
110 extern int minix_sync_inode(struct inode *);
111 extern void minix_set_inode(struct inode *, dev_t);
112 extern int V1_minix_get_block(struct inode *, long, struct buffer_head *, int);
113 extern int V2_minix_get_block(struct inode *, long, struct buffer_head *, int);
114 
115 extern struct minix_dir_entry *minix_find_entry(struct dentry*, struct page**);
116 extern int minix_add_link(struct dentry*, struct inode*);
117 extern int minix_delete_entry(struct minix_dir_entry*, struct page*);
118 extern int minix_make_empty(struct inode*, struct inode*);
119 extern int minix_empty_dir(struct inode*);
120 extern void minix_set_link(struct minix_dir_entry*, struct page*, struct inode*);
121 extern struct minix_dir_entry *minix_dotdot(struct inode*, struct page**);
122 extern ino_t minix_inode_by_name(struct dentry*);
123 
124 extern int minix_sync_file(struct file *, struct dentry *, int);
125 
126 extern struct inode_operations minix_file_inode_operations;
127 extern struct inode_operations minix_dir_inode_operations;
128 extern struct file_operations minix_file_operations;
129 extern struct file_operations minix_dir_operations;
130 extern struct dentry_operations minix_dentry_operations;
131 
132 #endif /* __KERNEL__ */
133 
134 #endif
135