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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 diff -up -r linux-2.6.19.org/fs/fat/dir.c linux-2.6.19/fs/fat/dir.c
2 --- linux-2.6.19.org/fs/fat/dir.c 2007-09-29 15:27:28.000000000 +0200
3 +++ linux-2.6.19/fs/fat/dir.c 2007-09-29 15:28:16.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 @@ -808,7 +819,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 @@ -1186,6 +1200,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 @@ -1195,6 +1228,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 @@ -1208,7 +1243,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 @@ -1238,6 +1275,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 diff -up -r linux-2.6.19.org/fs/fat/inode.c linux-2.6.19/fs/fat/inode.c
133 --- linux-2.6.19.org/fs/fat/inode.c 2007-09-29 15:27:28.000000000 +0200
134 +++ linux-2.6.19/fs/fat/inode.c 2007-09-29 15:29:36.000000000 +0200
135 @@ -854,6 +854,7 @@ 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,
139 + Opt_epoc,
140 Opt_obsolate, Opt_flush, Opt_err,
141 };
142
143 @@ -875,6 +876,7 @@ static match_table_t fat_tokens = {
144 {Opt_showexec, "showexec"},
145 {Opt_debug, "debug"},
146 {Opt_immutable, "sys_immutable"},
147 + {Opt_epoc, "epoc"},
148 {Opt_obsolate, "conv=binary"},
149 {Opt_obsolate, "conv=text"},
150 {Opt_obsolate, "conv=auto"},
151 @@ -1031,6 +1033,10 @@ static int parse_options(char *options,
152 case Opt_flush:
153 opts->flush = 1;
154 break;
155 + case Opt_epoc:
156 + opts->epoc = 1;
157 + break;
158 +
159
160 /* msdos specific */
161 case Opt_dots:
162 diff -up -r linux-2.6.19.org/include/linux/msdos_fs.h linux-2.6.19/include/linux/msdos_fs.h
163 --- linux-2.6.19.org/include/linux/msdos_fs.h 2007-09-29 15:27:43.000000000 +0200
164 +++ linux-2.6.19/include/linux/msdos_fs.h 2007-09-29 15:31:01.000000000 +0200
165 @@ -44,6 +44,7 @@
166 #define CASE_LOWER_EXT 16 /* extension is lower case */
167
168 #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 */
170 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
171
172 /* valid file mode bits */
173 @@ -206,6 +207,7 @@ struct fat_mount_options {
174 atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */
175 flush:1, /* write things quickly */
176 nocase:1; /* Does this need case conversion? 0=need case conversion*/
177 + epoc:1; /* Filename starting with 0x00 marks end of dir? */
178 };
179
180 #define FAT_HASH_BITS 8

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