1 | diff -up -r linux-2.6.15.orig/fs/fat/dir.c linux-2.6.15/fs/fat/dir.c |
1 | diff -r -u2 -p linux-2.6.15.vanilla/fs/fat/dir.c linux-2.6.15/fs/fat/dir.c |
2 | --- linux-2.6.15.orig/fs/fat/dir.c 2007-08-11 00:52:40.000000000 +0200 |
2 | --- linux-2.6.15.vanilla/fs/fat/dir.c 2007-11-09 12:06:40.000000000 +0100 |
3 | +++ linux-2.6.15/fs/fat/dir.c 2007-08-11 00:48:35.000000000 +0200 |
3 | +++ linux-2.6.15/fs/fat/dir.c 2007-11-09 13:14:08.000000000 +0100 |
4 | @@ -240,6 +240,7 @@ static int fat_parse_long(struct inode * |
4 | @@ -241,4 +241,5 @@ static int fat_parse_long(struct inode * |
5 | { |
|
|
6 | struct msdos_dir_slot *ds; |
5 | struct msdos_dir_slot *ds; |
7 | unsigned char id, slot, slots, alias_checksum; |
6 | unsigned char id, slot, slots, alias_checksum; |
8 | + int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
7 | + int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
9 | |
8 | |
10 | if (!*unicode) { |
9 | if (!*unicode) { |
11 | *unicode = (wchar_t *)__get_free_page(GFP_KERNEL); |
|
|
12 | @@ -286,6 +287,8 @@ parse_long: |
10 | @@ -287,4 +288,8 @@ parse_long: |
13 | } |
|
|
14 | if ((*de)->name[0] == DELETED_FLAG) |
11 | if ((*de)->name[0] == DELETED_FLAG) |
15 | return PARSE_INVALID; |
12 | return PARSE_INVALID; |
16 | + if (epoc && ((*de)->name[0] == EOD_FLAG)) |
13 | + if (epoc && ((*de)->name[0] == EOD_FLAG)) { |
|
|
14 | + while (fat_get_entry(dir, pos, bh, de) >= 0); |
17 | + return PARSE_EOF; |
15 | + return PARSE_EOF; |
|
|
16 | + } |
18 | if ((*de)->attr == ATTR_EXT) |
17 | if ((*de)->attr == ATTR_EXT) |
19 | goto parse_long; |
18 | goto parse_long; |
20 | if (IS_FREE((*de)->name) || ((*de)->attr & ATTR_VOLUME)) |
|
|
21 | @@ -319,6 +322,7 @@ int fat_search_long(struct inode *inode, |
19 | @@ -320,4 +325,5 @@ int fat_search_long(struct inode *inode, |
22 | unsigned short opt_shortname = sbi->options.shortname; |
|
|
23 | loff_t cpos = 0; |
20 | loff_t cpos = 0; |
24 | int chl, i, j, last_u, err; |
21 | int chl, i, j, last_u, err; |
25 | + int epoc = sbi->options.epoc; |
22 | + int epoc = sbi->options.epoc; |
26 | |
23 | |
27 | err = -ENOENT; |
24 | err = -ENOENT; |
28 | while(1) { |
|
|
29 | @@ -328,6 +332,9 @@ parse_record: |
25 | @@ -329,4 +335,8 @@ parse_record: |
30 | nr_slots = 0; |
|
|
31 | if (de->name[0] == DELETED_FLAG) |
26 | if (de->name[0] == DELETED_FLAG) |
32 | continue; |
27 | continue; |
33 | + if (epoc && (de->name[0] == EOD_FLAG)) |
28 | + if (epoc && (de->name[0] == EOD_FLAG)) { |
|
|
29 | + while (fat_get_entry(inode, &cpos, &bh, &de) >= 0); |
34 | + goto EODir; |
30 | + goto EODir; |
35 | + |
31 | + } |
36 | if (de->attr != ATTR_EXT && (de->attr & ATTR_VOLUME)) |
32 | if (de->attr != ATTR_EXT && (de->attr & ATTR_VOLUME)) |
37 | continue; |
33 | continue; |
38 | if (de->attr != ATTR_EXT && IS_FREE(de->name)) |
|
|
39 | @@ -455,6 +462,8 @@ static int __fat_readdir(struct inode *i |
34 | @@ -456,4 +466,6 @@ static int __fat_readdir(struct inode *i |
40 | int chi, chl, i, i2, j, last, last_u, dotoffset = 0; |
|
|
41 | loff_t cpos; |
35 | loff_t cpos; |
42 | int ret = 0; |
36 | int ret = 0; |
43 | + int epoc = MSDOS_SB(sb)->options.epoc; |
37 | + int epoc = MSDOS_SB(sb)->options.epoc; |
44 | + |
38 | + |
45 | |
39 | |
46 | lock_kernel(); |
40 | lock_kernel(); |
47 | |
41 | @@ -486,4 +498,8 @@ parse_record: |
48 | @@ -485,6 +494,8 @@ GetNew: |
|
|
49 | parse_record: |
|
|
50 | long_slots = 0; |
42 | long_slots = 0; |
51 | /* Check for long filename entry */ |
43 | /* Check for long filename entry */ |
52 | + if (epoc && (de->name[0] == EOD_FLAG)) |
44 | + if (epoc && (de->name[0] == EOD_FLAG)) { |
|
|
45 | + while (fat_get_entry(inode, &cpos, &bh, &de) >= 0); |
53 | + goto EODir; |
46 | + goto EODir; |
|
|
47 | + } |
54 | if (isvfat) { |
48 | if (isvfat) { |
55 | if (de->name[0] == DELETED_FLAG) |
49 | if (de->name[0] == DELETED_FLAG) |
56 | goto RecEnd; |
|
|
57 | @@ -752,7 +763,10 @@ static int fat_get_short_entry(struct in |
50 | @@ -753,5 +769,10 @@ static int fat_get_short_entry(struct in |
58 | struct buffer_head **bh, |
|
|
59 | struct msdos_dir_entry **de) |
51 | struct msdos_dir_entry **de) |
60 | { |
52 | { |
61 | + int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
53 | + int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
62 | while (fat_get_entry(dir, pos, bh, de) >= 0) { |
54 | while (fat_get_entry(dir, pos, bh, de) >= 0) { |
63 | + if (epoc && ((*de)->name[0] == EOD_FLAG)) |
55 | + if (epoc && ((*de)->name[0] == EOD_FLAG)) { |
|
|
56 | + while (fat_get_entry(dir, pos, bh, de) >= 0); |
64 | + return -ENOENT; |
57 | + return -ENOENT; |
|
|
58 | + } |
65 | /* free entry or long name entry or volume label */ |
59 | /* free entry or long name entry or volume label */ |
66 | if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME)) |
60 | if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME)) |
67 | return 0; |
|
|
68 | @@ -1130,6 +1144,25 @@ error: |
61 | @@ -1131,4 +1152,23 @@ error: |
69 | return err; |
|
|
70 | } |
62 | } |
71 | |
63 | |
72 | +int fat_write_zero_entry(struct inode *dir, loff_t curr) |
64 | +int fat_write_zero_entry(struct inode *dir, loff_t curr) |
73 | +{ |
65 | +{ |
74 | + struct msdos_dir_entry *de = NULL; |
66 | + struct msdos_dir_entry *de = NULL; |
… | |
… | |
88 | + return err; |
80 | + return err; |
89 | +} |
81 | +} |
90 | + |
82 | + |
91 | int fat_add_entries(struct inode *dir, void *slots, int nr_slots, |
83 | int fat_add_entries(struct inode *dir, void *slots, int nr_slots, |
92 | struct fat_slot_info *sinfo) |
84 | struct fat_slot_info *sinfo) |
93 | { |
|
|
94 | @@ -1139,6 +1172,8 @@ int fat_add_entries(struct inode *dir, v |
85 | @@ -1140,4 +1180,6 @@ int fat_add_entries(struct inode *dir, v |
95 | struct msdos_dir_entry *de; |
|
|
96 | int err, free_slots, i, nr_bhs; |
86 | int err, free_slots, i, nr_bhs; |
97 | loff_t pos, i_pos; |
87 | loff_t pos, i_pos; |
98 | + int epoc = sbi->options.epoc; |
88 | + int epoc = sbi->options.epoc; |
99 | + int last_entry = 0; |
89 | + int last_entry = 0; |
100 | |
90 | |
101 | sinfo->nr_slots = nr_slots; |
91 | sinfo->nr_slots = nr_slots; |
102 | |
|
|
103 | @@ -1152,7 +1187,9 @@ int fat_add_entries(struct inode *dir, v |
92 | @@ -1153,5 +1195,7 @@ int fat_add_entries(struct inode *dir, v |
104 | if (pos >= FAT_MAX_DIR_SIZE) |
|
|
105 | goto error; |
93 | goto error; |
106 | |
94 | |
107 | - if (IS_FREE(de->name)) { |
95 | - if (IS_FREE(de->name)) { |
108 | + if (epoc && (de->name[0] == EOD_FLAG)) |
96 | + if (epoc && (de->name[0] == EOD_FLAG)) |
109 | + last_entry = 1; |
97 | + last_entry = 1; |
110 | + if (last_entry || IS_FREE(de->name)) { |
98 | + if (last_entry || IS_FREE(de->name)) { |
111 | if (prev != bh) { |
99 | if (prev != bh) { |
112 | get_bh(bh); |
100 | get_bh(bh); |
113 | bhs[nr_bhs] = prev = bh; |
|
|
114 | @@ -1182,6 +1219,17 @@ found: |
101 | @@ -1183,4 +1227,15 @@ found: |
115 | err = 0; |
|
|
116 | pos -= free_slots * sizeof(*de); |
102 | pos -= free_slots * sizeof(*de); |
117 | nr_slots -= free_slots; |
103 | nr_slots -= free_slots; |
118 | + |
104 | + |
119 | + /* We need to write an end-of-directory slot. And we do it first, |
105 | + /* We need to write an end-of-directory slot. And we do it first, |
120 | + * because we want to keep the directory in a readble state. |
106 | + * because we want to keep the directory in a readble state. |
… | |
… | |
126 | + if (err) |
112 | + if (err) |
127 | + goto error; |
113 | + goto error; |
128 | + |
114 | + |
129 | if (free_slots) { |
115 | if (free_slots) { |
130 | /* |
116 | /* |
131 | * Second stage: filling the free entries with new entries. |
|
|
132 | diff -up -r linux-2.6.15.orig/fs/fat/inode.c linux-2.6.15/fs/fat/inode.c |
117 | diff -r -u2 -p linux-2.6.15.vanilla/fs/fat/inode.c linux-2.6.15/fs/fat/inode.c |
133 | --- linux-2.6.15.orig/fs/fat/inode.c 2007-08-11 00:52:40.000000000 +0200 |
118 | --- linux-2.6.15.vanilla/fs/fat/inode.c 2007-11-09 12:06:40.000000000 +0100 |
134 | +++ linux-2.6.15/fs/fat/inode.c 2007-08-11 00:49:24.000000000 +0200 |
119 | +++ linux-2.6.15/fs/fat/inode.c 2007-11-09 13:17:33.000000000 +0100 |
135 | @@ -775,6 +775,7 @@ enum { |
120 | @@ -777,4 +777,5 @@ enum { |
136 | Opt_charset, Opt_shortname_lower, Opt_shortname_win95, |
|
|
137 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, |
|
|
138 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
121 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
|
|
122 | Opt_obsolate, Opt_err, |
139 | + Opt_epoc, |
123 | + Opt_epoc, |
140 | Opt_obsolate, Opt_err, |
|
|
141 | }; |
124 | }; |
142 | |
125 | |
143 | @@ -796,6 +797,7 @@ static match_table_t fat_tokens = { |
126 | @@ -797,4 +798,5 @@ static match_table_t fat_tokens = { |
144 | {Opt_showexec, "showexec"}, |
|
|
145 | {Opt_debug, "debug"}, |
127 | {Opt_debug, "debug"}, |
146 | {Opt_immutable, "sys_immutable"}, |
128 | {Opt_immutable, "sys_immutable"}, |
147 | + {Opt_epoc, "epoc"}, |
129 | + {Opt_epoc, "epoc"}, |
148 | {Opt_obsolate, "conv=binary"}, |
130 | {Opt_obsolate, "conv=binary"}, |
149 | {Opt_obsolate, "conv=text"}, |
131 | {Opt_obsolate, "conv=text"}, |
150 | {Opt_obsolate, "conv=auto"}, |
|
|
151 | @@ -948,6 +950,10 @@ static int parse_options(char *options, |
132 | @@ -949,4 +951,7 @@ static int parse_options(char *options, |
152 | return 0; |
|
|
153 | opts->codepage = option; |
133 | opts->codepage = option; |
154 | break; |
134 | break; |
155 | + case Opt_epoc: |
135 | + case Opt_epoc: |
156 | + opts->epoc = 1; |
136 | + opts->epoc = 1; |
157 | + break; |
137 | + break; |
158 | + |
|
|
159 | |
138 | |
160 | /* msdos specific */ |
139 | /* msdos specific */ |
|
|
140 | @@ -1002,4 +1007,5 @@ static int parse_options(char *options, |
|
|
141 | break; |
|
|
142 | |
|
|
143 | + |
|
|
144 | /* obsolete mount options */ |
161 | case Opt_dots: |
145 | case Opt_obsolate: |
162 | diff -up -r linux-2.6.15.orig/include/linux/msdos_fs.h linux-2.6.15/include/linux/msdos_fs.h |
146 | diff -r -u2 -p linux-2.6.15.vanilla/include/linux/msdos_fs.h linux-2.6.15/include/linux/msdos_fs.h |
163 | --- linux-2.6.15.orig/include/linux/msdos_fs.h 2007-08-11 00:52:45.000000000 +0200 |
147 | --- linux-2.6.15.vanilla/include/linux/msdos_fs.h 2007-11-09 12:06:42.000000000 +0100 |
164 | +++ linux-2.6.15/include/linux/msdos_fs.h 2007-08-11 00:49:24.000000000 +0200 |
148 | +++ linux-2.6.15/include/linux/msdos_fs.h 2007-11-09 13:14:08.000000000 +0100 |
165 | @@ -44,6 +44,7 @@ |
149 | @@ -45,4 +45,5 @@ |
166 | #define CASE_LOWER_EXT 16 /* extension is lower case */ |
|
|
167 | |
150 | |
168 | #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ |
151 | #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ |
169 | +#define EOD_FLAG 0x00 /* marks end of directory when in name[0] for old fats */ |
152 | +#define EOD_FLAG 0x00 /* marks end of directory when in name[0] for old fats */ |
170 | #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) |
153 | #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) |
171 | |
154 | |
172 | /* valid file mode bits */ |
|
|
173 | @@ -203,7 +204,9 @@ struct fat_mount_options { |
155 | @@ -204,5 +205,6 @@ struct fat_mount_options { |
174 | unicode_xlate:1, /* create escape sequences for unhandled Unicode */ |
|
|
175 | numtail:1, /* Does first alias have a numeric '~1' type tail? */ |
156 | numtail:1, /* Does first alias have a numeric '~1' type tail? */ |
176 | atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */ |
157 | atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */ |
177 | - nocase:1; /* Does this need case conversion? 0=need case conversion*/ |
158 | - nocase:1; /* Does this need case conversion? 0=need case conversion*/ |
178 | + nocase:1, /* Does this need case conversion? 0=need case conversion*/ |
159 | + nocase:1, /* Does this need case conversion? 0=need case conversion*/ |
179 | + epoc:1; /* Filename starting with 0x00 marks end of dir? */ |
160 | + epoc:1; /* Filename starting with 0x00 marks end of dir? */ |
180 | + |
|
|
181 | }; |
161 | }; |
182 | |
162 | |
183 | #define FAT_HASH_BITS 8 |
|
|