Hitoshi Mitake | e38be99 | 2009-06-22 11:11:20 +0900 | [diff] [blame] | 1 | #ifndef FS_MINIX_H |
| 2 | #define FS_MINIX_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/fs.h> |
| 5 | #include <linux/pagemap.h> |
| 6 | #include <linux/minix_fs.h> |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #define INODE_VERSION(inode) minix_sb(inode->i_sb)->s_version |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #define MINIX_V1 0x0001 /* original minix fs */ |
| 10 | #define MINIX_V2 0x0002 /* minix V2 fs */ |
Andries Brouwer | 939b00d | 2007-02-12 00:52:49 -0800 | [diff] [blame] | 11 | #define MINIX_V3 0x0003 /* minix V3 fs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | /* |
| 14 | * minix fs inode data in memory |
| 15 | */ |
| 16 | struct 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 | */ |
| 27 | struct 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | struct buffer_head ** s_imap; |
| 38 | struct buffer_head ** s_zmap; |
| 39 | struct buffer_head * s_sbh; |
| 40 | struct minix_super_block * s_ms; |
| 41 | unsigned short s_mount_state; |
| 42 | unsigned short s_version; |
| 43 | }; |
| 44 | |
David Howells | a90a0880 | 2008-02-07 00:15:44 -0800 | [diff] [blame] | 45 | extern struct inode *minix_iget(struct super_block *, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
| 47 | extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
Al Viro | 4f45ba3 | 2011-07-26 02:48:39 -0400 | [diff] [blame] | 48 | extern struct inode * minix_new_inode(const struct inode *, umode_t, int *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | extern void minix_free_inode(struct inode * inode); |
Josh Boyer | 016e8d4 | 2011-08-19 14:50:26 -0400 | [diff] [blame] | 50 | extern unsigned long minix_count_free_inodes(struct super_block *sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | extern int minix_new_block(struct inode * inode); |
Andries Brouwer | 939b00d | 2007-02-12 00:52:49 -0800 | [diff] [blame] | 52 | extern void minix_free_block(struct inode *inode, unsigned long block); |
Josh Boyer | 016e8d4 | 2011-08-19 14:50:26 -0400 | [diff] [blame] | 53 | extern unsigned long minix_count_free_blocks(struct super_block *sb); |
David Howells | a528d35 | 2017-01-31 16:46:22 +0000 | [diff] [blame] | 54 | extern int minix_getattr(const struct path *, struct kstat *, u32, unsigned int); |
Christoph Hellwig | f4e420d | 2010-06-04 11:29:56 +0200 | [diff] [blame] | 55 | extern int minix_prepare_chunk(struct page *page, loff_t pos, unsigned len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | extern void V1_minix_truncate(struct inode *); |
| 58 | extern void V2_minix_truncate(struct inode *); |
| 59 | extern void minix_truncate(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern void minix_set_inode(struct inode *, dev_t); |
| 61 | extern int V1_minix_get_block(struct inode *, long, struct buffer_head *, int); |
| 62 | extern int V2_minix_get_block(struct inode *, long, struct buffer_head *, int); |
Andries Brouwer | 939b00d | 2007-02-12 00:52:49 -0800 | [diff] [blame] | 63 | extern unsigned V1_minix_blocks(loff_t, struct super_block *); |
| 64 | extern unsigned V2_minix_blocks(loff_t, struct super_block *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | extern struct minix_dir_entry *minix_find_entry(struct dentry*, struct page**); |
| 67 | extern int minix_add_link(struct dentry*, struct inode*); |
| 68 | extern int minix_delete_entry(struct minix_dir_entry*, struct page*); |
| 69 | extern int minix_make_empty(struct inode*, struct inode*); |
| 70 | extern int minix_empty_dir(struct inode*); |
| 71 | extern void minix_set_link(struct minix_dir_entry*, struct page*, struct inode*); |
| 72 | extern struct minix_dir_entry *minix_dotdot(struct inode*, struct page**); |
| 73 | extern ino_t minix_inode_by_name(struct dentry*); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 75 | extern const struct inode_operations minix_file_inode_operations; |
| 76 | extern const struct inode_operations minix_dir_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 77 | extern const struct file_operations minix_file_operations; |
| 78 | extern const struct file_operations minix_dir_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
| 80 | static inline struct minix_sb_info *minix_sb(struct super_block *sb) |
| 81 | { |
| 82 | return sb->s_fs_info; |
| 83 | } |
| 84 | |
| 85 | static inline struct minix_inode_info *minix_i(struct inode *inode) |
| 86 | { |
Rasmus Villemoes | db6172c | 2015-03-19 12:28:04 +0100 | [diff] [blame] | 87 | return container_of(inode, struct minix_inode_info, vfs_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
Hitoshi Mitake | e38be99 | 2009-06-22 11:11:20 +0900 | [diff] [blame] | 89 | |
Josh Boyer | 016e8d4 | 2011-08-19 14:50:26 -0400 | [diff] [blame] | 90 | static inline unsigned minix_blocks_needed(unsigned bits, unsigned blocksize) |
| 91 | { |
| 92 | return DIV_ROUND_UP(bits, blocksize * 8); |
| 93 | } |
| 94 | |
Akinobu Mita | 61f2e7b | 2011-03-23 16:42:16 -0700 | [diff] [blame] | 95 | #if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \ |
| 96 | defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED) |
| 97 | |
| 98 | #error Minix file system byte order broken |
| 99 | |
| 100 | #elif defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) |
| 101 | |
| 102 | /* |
| 103 | * big-endian 32 or 64 bit indexed bitmaps on big-endian system or |
| 104 | * little-endian bitmaps on little-endian system |
| 105 | */ |
| 106 | |
| 107 | #define minix_test_and_set_bit(nr, addr) \ |
| 108 | __test_and_set_bit((nr), (unsigned long *)(addr)) |
| 109 | #define minix_set_bit(nr, addr) \ |
| 110 | __set_bit((nr), (unsigned long *)(addr)) |
| 111 | #define minix_test_and_clear_bit(nr, addr) \ |
| 112 | __test_and_clear_bit((nr), (unsigned long *)(addr)) |
| 113 | #define minix_test_bit(nr, addr) \ |
| 114 | test_bit((nr), (unsigned long *)(addr)) |
| 115 | #define minix_find_first_zero_bit(addr, size) \ |
| 116 | find_first_zero_bit((unsigned long *)(addr), (size)) |
| 117 | |
| 118 | #elif defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED) |
| 119 | |
| 120 | /* |
| 121 | * big-endian 16bit indexed bitmaps |
| 122 | */ |
| 123 | |
| 124 | static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size) |
| 125 | { |
| 126 | const unsigned short *p = vaddr, *addr = vaddr; |
| 127 | unsigned short num; |
| 128 | |
| 129 | if (!size) |
| 130 | return 0; |
| 131 | |
Al Viro | f1fd306 | 2011-08-26 22:38:50 -0400 | [diff] [blame] | 132 | size >>= 4; |
Akinobu Mita | 61f2e7b | 2011-03-23 16:42:16 -0700 | [diff] [blame] | 133 | while (*p++ == 0xffff) { |
| 134 | if (--size == 0) |
| 135 | return (p - addr) << 4; |
| 136 | } |
| 137 | |
| 138 | num = *--p; |
| 139 | return ((p - addr) << 4) + ffz(num); |
| 140 | } |
| 141 | |
| 142 | #define minix_test_and_set_bit(nr, addr) \ |
| 143 | __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr)) |
| 144 | #define minix_set_bit(nr, addr) \ |
| 145 | __set_bit((nr) ^ 16, (unsigned long *)(addr)) |
| 146 | #define minix_test_and_clear_bit(nr, addr) \ |
| 147 | __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr)) |
| 148 | |
| 149 | static inline int minix_test_bit(int nr, const void *vaddr) |
| 150 | { |
| 151 | const unsigned short *p = vaddr; |
| 152 | return (p[nr >> 4] & (1U << (nr & 15))) != 0; |
| 153 | } |
| 154 | |
| 155 | #else |
| 156 | |
| 157 | /* |
| 158 | * little-endian bitmaps |
| 159 | */ |
| 160 | |
| 161 | #define minix_test_and_set_bit __test_and_set_bit_le |
| 162 | #define minix_set_bit __set_bit_le |
| 163 | #define minix_test_and_clear_bit __test_and_clear_bit_le |
| 164 | #define minix_test_bit test_bit_le |
| 165 | #define minix_find_first_zero_bit find_first_zero_bit_le |
| 166 | |
| 167 | #endif |
| 168 | |
Hitoshi Mitake | e38be99 | 2009-06-22 11:11:20 +0900 | [diff] [blame] | 169 | #endif /* FS_MINIX_H */ |