/[public]/fat-epoc/trunk/fat-epoc-2.6.22.diff
ViewVC logotype

Contents of /fat-epoc/trunk/fat-epoc-2.6.22.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 303 - (show annotations)
Sat Sep 29 23:49:51 2007 UTC (17 years, 2 months ago) by frodo
File size: 5892 byte(s)
(Frodo) Added patches for 2.6.18 upto 2.6.22 kernels, including debian support

1 diff -up -r linux-2.6.22.org/fs/fat/dir.c linux-2.6.22/fs/fat/dir.c
2 --- linux-2.6.22.org/fs/fat/dir.c 2007-09-29 15:55:34.000000000 +0200
3 +++ linux-2.6.22/fs/fat/dir.c 2007-09-29 15:56:24.000000000 +0200
4 @@ -241,6 +241,7 @@ static int fat_parse_long(struct inode *
5 {
6 struct msdos_dir_slot *ds;
7 unsigned char id, slot, slots, alias_checksum;
8 + int epoc = MSDOS_SB(dir->i_sb)->options.epoc;
9
10 if (!*unicode) {
11 *unicode = (wchar_t *)__get_free_page(GFP_KERNEL);
12 @@ -287,6 +288,8 @@ parse_long:
13 }
14 if ((*de)->name[0] == DELETED_FLAG)
15 return PARSE_INVALID;
16 + if (epoc && ((*de)->name[0] == EOD_FLAG))
17 + return PARSE_EOF;
18 if ((*de)->attr == ATTR_EXT)
19 goto parse_long;
20 if (IS_FREE((*de)->name) || ((*de)->attr & ATTR_VOLUME))
21 @@ -320,6 +323,7 @@ int fat_search_long(struct inode *inode,
22 unsigned short opt_shortname = sbi->options.shortname;
23 loff_t cpos = 0;
24 int chl, i, j, last_u, err;
25 + int epoc = sbi->options.epoc;
26
27 err = -ENOENT;
28 while(1) {
29 @@ -329,6 +333,9 @@ parse_record:
30 nr_slots = 0;
31 if (de->name[0] == DELETED_FLAG)
32 continue;
33 + if (epoc && (de->name[0] == EOD_FLAG))
34 + goto EODir;
35 +
36 if (de->attr != ATTR_EXT && (de->attr & ATTR_VOLUME))
37 continue;
38 if (de->attr != ATTR_EXT && IS_FREE(de->name))
39 @@ -456,6 +463,8 @@ static int __fat_readdir(struct inode *i
40 int chi, chl, i, i2, j, last, last_u, dotoffset = 0;
41 loff_t cpos;
42 int ret = 0;
43 + int epoc = MSDOS_SB(sb)->options.epoc;
44 +
45
46 lock_kernel();
47
48 @@ -486,6 +495,8 @@ GetNew:
49 parse_record:
50 long_slots = 0;
51 /* Check for long filename entry */
52 + if (epoc && (de->name[0] == EOD_FLAG))
53 + goto EODir;
54 if (isvfat) {
55 if (de->name[0] == DELETED_FLAG)
56 goto RecEnd;
57 @@ -809,7 +820,10 @@ static int fat_get_short_entry(struct in
58 struct buffer_head **bh,
59 struct msdos_dir_entry **de)
60 {
61 + int epoc = MSDOS_SB(dir->i_sb)->options.epoc;
62 while (fat_get_entry(dir, pos, bh, de) >= 0) {
63 + if (epoc && ((*de)->name[0] == EOD_FLAG))
64 + return -ENOENT;
65 /* free entry or long name entry or volume label */
66 if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME))
67 return 0;
68 @@ -1187,6 +1201,25 @@ error:
69 return err;
70 }
71
72 +int fat_write_zero_entry(struct inode *dir, loff_t curr)
73 +{
74 + struct msdos_dir_entry *de = NULL;
75 + struct buffer_head *bh = NULL;
76 + loff_t pos;
77 + int err = 0;
78 +
79 + pos = curr;
80 + if (fat_get_entry(dir,&pos,&bh,&de) < 0)
81 + return 0;
82 +
83 + de->name[0] = EOD_FLAG;
84 + mark_buffer_dirty(bh);
85 + if (IS_DIRSYNC(dir))
86 + err = sync_dirty_buffer(bh);
87 + brelse(bh);
88 + return err;
89 +}
90 +
91 int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
92 struct fat_slot_info *sinfo)
93 {
94 @@ -1196,6 +1229,8 @@ int fat_add_entries(struct inode *dir, v
95 struct msdos_dir_entry *de;
96 int err, free_slots, i, nr_bhs;
97 loff_t pos, i_pos;
98 + int epoc = sbi->options.epoc;
99 + int last_entry = 0;
100
101 sinfo->nr_slots = nr_slots;
102
103 @@ -1209,7 +1244,9 @@ int fat_add_entries(struct inode *dir, v
104 if (pos >= FAT_MAX_DIR_SIZE)
105 goto error;
106
107 - if (IS_FREE(de->name)) {
108 + if (epoc && (de->name[0] == EOD_FLAG))
109 + last_entry = 1;
110 + if (last_entry || IS_FREE(de->name)) {
111 if (prev != bh) {
112 get_bh(bh);
113 bhs[nr_bhs] = prev = bh;
114 @@ -1239,6 +1276,17 @@ found:
115 err = 0;
116 pos -= free_slots * sizeof(*de);
117 nr_slots -= free_slots;
118 +
119 + /* 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.
121 + * Note that there is no need to remove it on error, as it is beyond
122 + * the visible end of directory anyway.
123 + */
124 + if (epoc && !nr_slots && last_entry)
125 + err = fat_write_zero_entry(dir, pos + free_slots * sizeof(*de));
126 + if (err)
127 + goto error;
128 +
129 if (free_slots) {
130 /*
131 * Second stage: filling the free entries with new entries.
132 Only in linux-2.6.22/fs/fat: dir.c.orig
133 diff -up -r linux-2.6.22.org/fs/fat/inode.c linux-2.6.22/fs/fat/inode.c
134 --- linux-2.6.22.org/fs/fat/inode.c 2007-09-29 15:55:34.000000000 +0200
135 +++ linux-2.6.22/fs/fat/inode.c 2007-09-29 15:56:24.000000000 +0200
136 @@ -856,6 +856,7 @@ enum {
137 Opt_charset, Opt_shortname_lower, Opt_shortname_win95,
138 Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
139 Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
140 + Opt_epoc,
141 Opt_obsolate, Opt_flush, Opt_err,
142 };
143
144 @@ -878,6 +879,7 @@ static match_table_t fat_tokens = {
145 {Opt_showexec, "showexec"},
146 {Opt_debug, "debug"},
147 {Opt_immutable, "sys_immutable"},
148 + {Opt_epoc, "epoc"},
149 {Opt_obsolate, "conv=binary"},
150 {Opt_obsolate, "conv=text"},
151 {Opt_obsolate, "conv=auto"},
152 @@ -1037,6 +1039,10 @@ static int parse_options(char *options,
153 case Opt_flush:
154 opts->flush = 1;
155 break;
156 + case Opt_epoc:
157 + opts->epoc = 1;
158 + break;
159 +
160
161 /* msdos specific */
162 case Opt_dots:
163 Only in linux-2.6.22/fs/fat: inode.c.orig
164 diff -up -r linux-2.6.22.org/include/linux/msdos_fs.h linux-2.6.22/include/linux/msdos_fs.h
165 --- linux-2.6.22.org/include/linux/msdos_fs.h 2007-09-29 15:55:56.000000000 +0200
166 +++ linux-2.6.22/include/linux/msdos_fs.h 2007-09-29 15:57:26.000000000 +0200
167 @@ -44,6 +44,7 @@
168 #define CASE_LOWER_EXT 16 /* extension is lower case */
169
170 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
171 +#define EOD_FLAG 0x00 /* marks end of directory when in name[0] for old fats */
172 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
173
174 /* valid file mode bits */
175 @@ -206,6 +207,7 @@ struct fat_mount_options {
176 atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */
177 flush:1, /* write things quickly */
178 nocase:1, /* Does this need case conversion? 0=need case conversion*/
179 + epoc:1; /* Filename starting with 0x00 marks end of dir? */
180 usefree:1; /* Use free_clusters for FAT32 */
181 };
182

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26