1 |
diff -r -u2 kernel-source-2.6.11-clean/fs/fat/dir.c kernel-source-2.6.11/fs/fat/dir.c |
2 |
--- kernel-source-2.6.11-clean/fs/fat/dir.c 2005-03-02 08:38:34.000000000 +0100 |
3 |
+++ kernel-source-2.6.11/fs/fat/dir.c 2005-03-27 18:36:51.422359632 +0200 |
4 |
@@ -153,4 +153,5 @@ |
5 |
int chl, i, j, last_u, res = 0; |
6 |
loff_t i_pos, cpos = 0; |
7 |
+ int epoc = MSDOS_SB(sb)->options.epoc; |
8 |
|
9 |
while(1) { |
10 |
@@ -159,4 +160,6 @@ |
11 |
parse_record: |
12 |
long_slots = 0; |
13 |
+ if (epoc && (de->name[0] == EOD_FLAG)) |
14 |
+ goto EODir; |
15 |
if (de->name[0] == DELETED_FLAG) |
16 |
continue; |
17 |
@@ -218,4 +221,6 @@ |
18 |
goto parse_long; |
19 |
} |
20 |
+ if (epoc && (de->name[0] == EOD_FLAG)) |
21 |
+ goto EODir; |
22 |
if (de->name[0] == DELETED_FLAG) |
23 |
continue; |
24 |
@@ -322,4 +327,6 @@ |
25 |
unsigned char long_slots; |
26 |
const char *fill_name; |
27 |
+ int epoc = MSDOS_SB(sb)->options.epoc; |
28 |
+ int last_entry = 0; |
29 |
int fill_len; |
30 |
wchar_t bufuname[14]; |
31 |
@@ -364,4 +371,8 @@ |
32 |
if (fat_get_entry(inode,&cpos,&bh,&de,&i_pos) == -1) |
33 |
goto EODir; |
34 |
+ if (epoc && (de->name[0] == EOD_FLAG)) |
35 |
+ last_entry = 1; |
36 |
+ if (last_entry) |
37 |
+ goto RecEnd; |
38 |
/* Check for long filename entry */ |
39 |
if (isvfat) { |
40 |
@@ -431,4 +442,8 @@ |
41 |
goto ParseLong; |
42 |
} |
43 |
+ if (epoc && (de->name[0] == EOD_FLAG)) { |
44 |
+ last_entry = 1; |
45 |
+ goto RecEnd; |
46 |
+ } |
47 |
if (de->name[0] == DELETED_FLAG) |
48 |
goto RecEnd; |
49 |
@@ -679,5 +694,8 @@ |
50 |
struct msdos_dir_entry **de, loff_t *i_pos) |
51 |
{ |
52 |
+ int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
53 |
while (fat_get_entry(dir, pos, bh, de, i_pos) >= 0) { |
54 |
+ if (epoc && ((*de)->name[0] == EOD_FLAG)) |
55 |
+ return -ENOENT; |
56 |
/* free entry or long name entry or volume label */ |
57 |
if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME)) |
58 |
@@ -794,4 +812,20 @@ |
59 |
} |
60 |
|
61 |
+/* Set the first character of the next entry to zero. */ |
62 |
+void fat_write_zero_entry(struct inode *dir, loff_t curr) |
63 |
+{ |
64 |
+ struct msdos_dir_entry *de = NULL; |
65 |
+ struct buffer_head *bh = NULL; |
66 |
+ loff_t ipos,pos; |
67 |
+ |
68 |
+ pos = curr; |
69 |
+ if (fat_get_entry(dir,&pos,&bh,&de,&ipos) < 0) |
70 |
+ return; |
71 |
+ |
72 |
+ de->name[0] = EOD_FLAG; |
73 |
+ mark_buffer_dirty(bh); |
74 |
+ brelse(bh); |
75 |
+} |
76 |
+ |
77 |
/* This assumes that size of cluster is above the 32*slots */ |
78 |
|
79 |
@@ -803,4 +837,6 @@ |
80 |
int row; |
81 |
struct buffer_head *new_bh; |
82 |
+ int epoc = MSDOS_SB(dir->i_sb)->options.epoc; |
83 |
+ int last_entry = 0; |
84 |
|
85 |
offset = curr = 0; |
86 |
@@ -814,7 +850,12 @@ |
87 |
} |
88 |
|
89 |
- if (IS_FREE((*de)->name)) { |
90 |
- if (++row == slots) |
91 |
+ if ((epoc && ((*de)->name[0] == EOD_FLAG))) |
92 |
+ last_entry = 1; |
93 |
+ if (last_entry || IS_FREE((*de)->name)) { |
94 |
+ if (++row == slots) { |
95 |
+ if (last_entry) |
96 |
+ fat_write_zero_entry(dir,curr); |
97 |
return offset; |
98 |
+ } |
99 |
} else { |
100 |
row = 0; |
101 |
@@ -837,4 +878,6 @@ |
102 |
EXPORT_SYMBOL(fat_add_entries); |
103 |
|
104 |
+ |
105 |
+ |
106 |
int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat) |
107 |
{ |
108 |
diff -r -u2 kernel-source-2.6.11-clean/fs/fat/inode.c kernel-source-2.6.11/fs/fat/inode.c |
109 |
--- kernel-source-2.6.11-clean/fs/fat/inode.c 2005-03-02 08:38:08.000000000 +0100 |
110 |
+++ kernel-source-2.6.11/fs/fat/inode.c 2005-03-27 18:32:53.238179115 +0200 |
111 |
@@ -748,4 +748,5 @@ |
112 |
Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, |
113 |
Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
114 |
+ Opt_epoc, |
115 |
Opt_obsolate, Opt_err, |
116 |
}; |
117 |
@@ -769,4 +770,5 @@ |
118 |
{Opt_debug, "debug"}, |
119 |
{Opt_immutable, "sys_immutable"}, |
120 |
+ {Opt_epoc, "epoc"}, |
121 |
{Opt_obsolate, "conv=binary"}, |
122 |
{Opt_obsolate, "conv=text"}, |
123 |
@@ -921,4 +923,8 @@ |
124 |
opts->codepage = option; |
125 |
break; |
126 |
+ case Opt_epoc: |
127 |
+ opts->epoc = 1; |
128 |
+ break; |
129 |
+ |
130 |
|
131 |
/* msdos specific */ |
132 |
diff -r -u2 kernel-source-2.6.11-clean/include/linux/msdos_fs.h kernel-source-2.6.11/include/linux/msdos_fs.h |
133 |
--- kernel-source-2.6.11-clean/include/linux/msdos_fs.h 2005-03-02 08:38:18.000000000 +0100 |
134 |
+++ kernel-source-2.6.11/include/linux/msdos_fs.h 2005-03-27 18:38:10.000000000 +0200 |
135 |
@@ -45,4 +45,5 @@ |
136 |
|
137 |
#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ |
138 |
+#define EOD_FLAG 0x00 /* marks end of directory when in name[0] for old fats */ |
139 |
#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) |
140 |
|
141 |
@@ -205,5 +206,7 @@ |
142 |
numtail:1, /* Does first alias have a numeric '~1' type tail? */ |
143 |
atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */ |
144 |
- nocase:1; /* Does this need case conversion? 0=need case conversion*/ |
145 |
+ nocase:1, /* Does this need case conversion? 0=need case conversion*/ |
146 |
+ epoc:1; /* Filename starting with 0x00 marks end of dir? */ |
147 |
+ |
148 |
}; |
149 |
|