This source file includes following definitions.
- msdos_bread
- msdos_getblk
- msdos_brelse
- msdos_mark_buffer_dirty
- msdos_set_uptodate
- msdos_is_uptodate
- msdos_ll_rw_block
1
2
3
4
5
6
7 #include <linux/mm.h>
8 #include <linux/malloc.h>
9 #include <linux/string.h>
10 #include <linux/fs.h>
11 #include <linux/msdos_fs.h>
12
13 struct buffer_head *msdos_bread (
14 struct super_block *sb,
15 int block)
16 {
17 struct buffer_head *ret = NULL;
18 if (sb->s_blocksize == 512){
19 ret = bread (sb->s_dev,block,512);
20 }else{
21 struct buffer_head *real = bread (sb->s_dev,block>>1,1024);
22 if (real != NULL){
23 ret = (struct buffer_head *)kmalloc (sizeof(struct buffer_head)
24 ,GFP_KERNEL);
25 if (ret != NULL){
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 memset (ret,0,sizeof(*ret));
56 ret->b_data = real->b_data;
57 if (block & 1) ret->b_data += 512;
58 ret->b_next = real;
59 }else{
60 brelse (real);
61 }
62 }
63 }
64 return ret;
65 }
66 struct buffer_head *msdos_getblk (
67 struct super_block *sb,
68 int block)
69 {
70 struct buffer_head *ret = NULL;
71 if (sb->s_blocksize == 512){
72 ret = getblk (sb->s_dev,block,512);
73 }else{
74
75
76
77
78
79
80 ret = msdos_bread (sb,block);
81 }
82 return ret;
83 }
84
85 void msdos_brelse (
86 struct super_block *sb,
87 struct buffer_head *bh)
88 {
89 if (bh != NULL){
90 if (sb->s_blocksize == 512){
91 brelse (bh);
92 }else{
93 brelse (bh->b_next);
94
95
96
97 kfree (bh);
98 }
99 }
100 }
101
102 void msdos_mark_buffer_dirty (
103 struct super_block *sb,
104 struct buffer_head *bh,
105 int dirty_val)
106 {
107 if (sb->s_blocksize != 512){
108 bh = bh->b_next;
109 }
110 mark_buffer_dirty (bh,dirty_val);
111 }
112
113 void msdos_set_uptodate (
114 struct super_block *sb,
115 struct buffer_head *bh,
116 int val)
117 {
118 if (sb->s_blocksize != 512){
119 bh = bh->b_next;
120 }
121 mark_buffer_uptodate(bh, val);
122 }
123 int msdos_is_uptodate (
124 struct super_block *sb,
125 struct buffer_head *bh)
126 {
127 if (sb->s_blocksize != 512){
128 bh = bh->b_next;
129 }
130 return buffer_uptodate(bh);
131 }
132
133 void msdos_ll_rw_block (
134 struct super_block *sb,
135 int opr,
136 int nbreq,
137 struct buffer_head *bh[32])
138 {
139 if (sb->s_blocksize == 512){
140 ll_rw_block(opr,nbreq,bh);
141 }else{
142 struct buffer_head *tmp[32];
143 int i;
144 for (i=0; i<nbreq; i++){
145 tmp[i] = bh[i]->b_next;
146 }
147 ll_rw_block(opr,nbreq,tmp);
148 }
149 }
150