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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 298 - (show annotations)
Fri Aug 10 23:15:27 2007 UTC (17 years, 3 months ago) by frodo
File size: 5964 byte(s)
(Frodo)
  Added a new patch for 2.6.15 kernels
  Added debian support for this
  Updated copyrights

1 diff -up -r linux-2.6.15.orig/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
3 +++ linux-2.6.15/fs/fat/dir.c 2007-08-11 00:48:35.000000000 +0200
4 @@ -240,6 +240,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 @@ -286,6 +287,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 @@ -319,6 +322,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 @@ -328,6 +332,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 @@ -455,6 +462,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 @@ -485,6 +494,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 @@ -752,7 +763,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 @@ -1130,6 +1144,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 @@ -1139,6 +1172,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 @@ -1152,7 +1187,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 @@ -1182,6 +1219,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.15.orig/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
134 +++ linux-2.6.15/fs/fat/inode.c 2007-08-11 00:49:24.000000000 +0200
135 @@ -775,6 +775,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_err,
141 };
142
143 @@ -796,6 +797,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 @@ -948,6 +950,10 @@ static int parse_options(char *options,
152 return 0;
153 opts->codepage = option;
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.15.orig/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
164 +++ linux-2.6.15/include/linux/msdos_fs.h 2007-08-11 00:49:24.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 @@ -203,7 +204,9 @@ 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? */
176 atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */
177 - nocase:1; /* Does this need case conversion? 0=need case conversion*/
178 + nocase:1, /* Does this need case conversion? 0=need case conversion*/
179 + epoc:1; /* Filename starting with 0x00 marks end of dir? */
180 +
181 };
182
183 #define FAT_HASH_BITS 8

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