1 #include <linux/fs.h>
2 #include <linux/minix_fs.h>
3 #include <linux/locks.h>
4 #include <linux/smp_lock.h>
5
6 enum {DIRECT = 7, DEPTH = 4}; /* Have triple indirect */
7
8 typedef u32 block_t; /* 32 bit, host order */
9
block_to_cpu(block_t n)10 static inline unsigned long block_to_cpu(block_t n)
11 {
12 return n;
13 }
14
cpu_to_block(unsigned long n)15 static inline block_t cpu_to_block(unsigned long n)
16 {
17 return n;
18 }
19
i_data(struct inode * inode)20 static inline block_t *i_data(struct inode *inode)
21 {
22 return (block_t *)inode->u.minix_i.u.i2_data;
23 }
24
block_to_path(struct inode * inode,long block,int offsets[DEPTH])25 static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
26 {
27 int n = 0;
28
29 if (block < 0) {
30 printk("minix_bmap: block<0");
31 } else if (block >= (inode->i_sb->u.minix_sb.s_max_size/BLOCK_SIZE)) {
32 printk("minix_bmap: block>big");
33 } else if (block < 7) {
34 offsets[n++] = block;
35 } else if ((block -= 7) < 256) {
36 offsets[n++] = 7;
37 offsets[n++] = block;
38 } else if ((block -= 256) < 256*256) {
39 offsets[n++] = 8;
40 offsets[n++] = block>>8;
41 offsets[n++] = block & 255;
42 } else {
43 block -= 256*256;
44 offsets[n++] = 9;
45 offsets[n++] = block>>16;
46 offsets[n++] = (block>>8) & 255;
47 offsets[n++] = block & 255;
48 }
49 return n;
50 }
51
52 #include "itree_common.c"
53
V2_minix_get_block(struct inode * inode,long block,struct buffer_head * bh_result,int create)54 int V2_minix_get_block(struct inode * inode, long block,
55 struct buffer_head *bh_result, int create)
56 {
57 return get_block(inode, block, bh_result, create);
58 }
59
V2_minix_truncate(struct inode * inode)60 void V2_minix_truncate(struct inode * inode)
61 {
62 truncate(inode);
63 }
64