blob: 341e2122879a7604611426d4f702f211ee3ed59a [file] [log] [blame]
Hitoshi Mitakee38be992009-06-22 11:11:20 +09001#ifndef FS_MINIX_H
2#define FS_MINIX_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/fs.h>
5#include <linux/pagemap.h>
6#include <linux/minix_fs.h>
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#define INODE_VERSION(inode) minix_sb(inode->i_sb)->s_version
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#define MINIX_V1 0x0001 /* original minix fs */
10#define MINIX_V2 0x0002 /* minix V2 fs */
Andries Brouwer939b00d2007-02-12 00:52:49 -080011#define MINIX_V3 0x0003 /* minix V3 fs */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13/*
14 * minix fs inode data in memory
15 */
16struct minix_inode_info {
17 union {
18 __u16 i1_data[16];
19 __u32 i2_data[16];
20 } u;
21 struct inode vfs_inode;
22};
23
24/*
25 * minix super-block data in memory
26 */
27struct minix_sb_info {
28 unsigned long s_ninodes;
29 unsigned long s_nzones;
30 unsigned long s_imap_blocks;
31 unsigned long s_zmap_blocks;
32 unsigned long s_firstdatazone;
33 unsigned long s_log_zone_size;
34 unsigned long s_max_size;
35 int s_dirsize;
36 int s_namelen;
37 int s_link_max;
38 struct buffer_head ** s_imap;
39 struct buffer_head ** s_zmap;
40 struct buffer_head * s_sbh;
41 struct minix_super_block * s_ms;
42 unsigned short s_mount_state;
43 unsigned short s_version;
44};
45
David Howellsa90a08802008-02-07 00:15:44 -080046extern struct inode *minix_iget(struct super_block *, unsigned long);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
48extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
Dmitry Monakhov9eed1fb2010-03-04 17:32:14 +030049extern struct inode * minix_new_inode(const struct inode *, int, int *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050extern void minix_free_inode(struct inode * inode);
51extern unsigned long minix_count_free_inodes(struct minix_sb_info *sbi);
52extern int minix_new_block(struct inode * inode);
Andries Brouwer939b00d2007-02-12 00:52:49 -080053extern void minix_free_block(struct inode *inode, unsigned long block);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *);
Christoph Hellwigf4e420d2010-06-04 11:29:56 +020056extern int minix_prepare_chunk(struct page *page, loff_t pos, unsigned len);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058extern void V1_minix_truncate(struct inode *);
59extern void V2_minix_truncate(struct inode *);
60extern void minix_truncate(struct inode *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061extern void minix_set_inode(struct inode *, dev_t);
62extern int V1_minix_get_block(struct inode *, long, struct buffer_head *, int);
63extern int V2_minix_get_block(struct inode *, long, struct buffer_head *, int);
Andries Brouwer939b00d2007-02-12 00:52:49 -080064extern unsigned V1_minix_blocks(loff_t, struct super_block *);
65extern unsigned V2_minix_blocks(loff_t, struct super_block *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67extern struct minix_dir_entry *minix_find_entry(struct dentry*, struct page**);
68extern int minix_add_link(struct dentry*, struct inode*);
69extern int minix_delete_entry(struct minix_dir_entry*, struct page*);
70extern int minix_make_empty(struct inode*, struct inode*);
71extern int minix_empty_dir(struct inode*);
72extern void minix_set_link(struct minix_dir_entry*, struct page*, struct inode*);
73extern struct minix_dir_entry *minix_dotdot(struct inode*, struct page**);
74extern ino_t minix_inode_by_name(struct dentry*);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Arjan van de Ven92e1d5b2007-02-12 00:55:39 -080076extern const struct inode_operations minix_file_inode_operations;
77extern const struct inode_operations minix_dir_inode_operations;
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -080078extern const struct file_operations minix_file_operations;
79extern const struct file_operations minix_dir_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81static inline struct minix_sb_info *minix_sb(struct super_block *sb)
82{
83 return sb->s_fs_info;
84}
85
86static inline struct minix_inode_info *minix_i(struct inode *inode)
87{
88 return list_entry(inode, struct minix_inode_info, vfs_inode);
89}
Hitoshi Mitakee38be992009-06-22 11:11:20 +090090
Akinobu Mita61f2e7b2011-03-23 16:42:16 -070091#if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \
92 defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)
93
94#error Minix file system byte order broken
95
96#elif defined(CONFIG_MINIX_FS_NATIVE_ENDIAN)
97
98/*
99 * big-endian 32 or 64 bit indexed bitmaps on big-endian system or
100 * little-endian bitmaps on little-endian system
101 */
102
103#define minix_test_and_set_bit(nr, addr) \
104 __test_and_set_bit((nr), (unsigned long *)(addr))
105#define minix_set_bit(nr, addr) \
106 __set_bit((nr), (unsigned long *)(addr))
107#define minix_test_and_clear_bit(nr, addr) \
108 __test_and_clear_bit((nr), (unsigned long *)(addr))
109#define minix_test_bit(nr, addr) \
110 test_bit((nr), (unsigned long *)(addr))
111#define minix_find_first_zero_bit(addr, size) \
112 find_first_zero_bit((unsigned long *)(addr), (size))
113
114#elif defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)
115
116/*
117 * big-endian 16bit indexed bitmaps
118 */
119
120static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
121{
122 const unsigned short *p = vaddr, *addr = vaddr;
123 unsigned short num;
124
125 if (!size)
126 return 0;
127
128 size = (size >> 4) + ((size & 15) > 0);
129 while (*p++ == 0xffff) {
130 if (--size == 0)
131 return (p - addr) << 4;
132 }
133
134 num = *--p;
135 return ((p - addr) << 4) + ffz(num);
136}
137
138#define minix_test_and_set_bit(nr, addr) \
139 __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr))
140#define minix_set_bit(nr, addr) \
141 __set_bit((nr) ^ 16, (unsigned long *)(addr))
142#define minix_test_and_clear_bit(nr, addr) \
143 __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr))
144
145static inline int minix_test_bit(int nr, const void *vaddr)
146{
147 const unsigned short *p = vaddr;
148 return (p[nr >> 4] & (1U << (nr & 15))) != 0;
149}
150
151#else
152
153/*
154 * little-endian bitmaps
155 */
156
157#define minix_test_and_set_bit __test_and_set_bit_le
158#define minix_set_bit __set_bit_le
159#define minix_test_and_clear_bit __test_and_clear_bit_le
160#define minix_test_bit test_bit_le
161#define minix_find_first_zero_bit find_first_zero_bit_le
162
163#endif
164
Hitoshi Mitakee38be992009-06-22 11:11:20 +0900165#endif /* FS_MINIX_H */