1 |
frodo |
281 |
--- kernel-source-2.4.20/fs/fat/dir.c.org 2003-03-19 15:29:25.000000000 +0100 |
2 |
|
|
+++ kernel-source-2.4.20/fs/fat/dir.c 2003-03-19 16:07:52.000000000 +0100 |
3 |
|
|
@@ -201,4 +201,5 @@ |
4 |
|
|
int ino, chl, i, j, last_u, res = 0; |
5 |
|
|
loff_t cpos = 0; |
6 |
|
|
+ int last_entry = 0; |
7 |
|
|
|
8 |
|
|
while(1) { |
9 |
|
|
@@ -207,4 +208,8 @@ |
10 |
|
|
parse_record: |
11 |
|
|
long_slots = 0; |
12 |
|
|
+ if (!de->name[0]) |
13 |
|
|
+ last_entry = 1; |
14 |
|
|
+ if (last_entry) |
15 |
|
|
+ continue; |
16 |
|
|
if (de->name[0] == (__s8) DELETED_FLAG) |
17 |
|
|
continue; |
18 |
|
|
@@ -266,4 +271,8 @@ |
19 |
|
|
goto parse_long; |
20 |
|
|
} |
21 |
|
|
+ if (!de->name[0]) |
22 |
|
|
+ last_entry = 1; |
23 |
|
|
+ if (last_entry) |
24 |
|
|
+ continue; |
25 |
|
|
if (de->name[0] == (__s8) DELETED_FLAG) |
26 |
|
|
continue; |
27 |
|
|
@@ -371,4 +380,5 @@ |
28 |
|
|
int ino, inum, chi, chl, i, i2, j, last, last_u, dotoffset = 0; |
29 |
|
|
loff_t cpos; |
30 |
|
|
+ int last_entry = 0; |
31 |
|
|
|
32 |
|
|
cpos = filp->f_pos; |
33 |
|
|
@@ -395,4 +405,10 @@ |
34 |
|
|
if (fat_get_entry(inode,&cpos,&bh,&de,&ino) == -1) |
35 |
|
|
goto EODir; |
36 |
|
|
+ |
37 |
|
|
+ if (!de->name[0]) |
38 |
|
|
+ last_entry = 1; |
39 |
|
|
+ if (last_entry) |
40 |
|
|
+ goto RecEnd; |
41 |
|
|
+ |
42 |
|
|
/* Check for long filename entry */ |
43 |
|
|
if (isvfat) { |
44 |
|
|
@@ -462,4 +478,8 @@ |
45 |
|
|
goto ParseLong; |
46 |
|
|
} |
47 |
|
|
+ if (!de->name[0]) |
48 |
|
|
+ last_entry = 1; |
49 |
|
|
+ if (last_entry) |
50 |
|
|
+ goto RecEnd; |
51 |
|
|
if (de->name[0] == (__s8) DELETED_FLAG) |
52 |
|
|
goto RecEnd; |
53 |
|
|
@@ -724,4 +744,5 @@ |
54 |
|
|
int row; |
55 |
|
|
struct buffer_head *new_bh; |
56 |
|
|
+ int last_entry = 0; |
57 |
|
|
|
58 |
|
|
offset = curr = 0; |
59 |
|
|
@@ -729,7 +750,19 @@ |
60 |
|
|
row = 0; |
61 |
|
|
while (fat_get_entry(dir,&curr,bh,de,ino) > -1) { |
62 |
|
|
- if (IS_FREE((*de)->name)) { |
63 |
|
|
- if (++row == slots) |
64 |
|
|
+ if (!(*de)->name[0]) |
65 |
|
|
+ last_entry = 1; |
66 |
|
|
+ if (last_entry || IS_FREE((*de)->name)) { |
67 |
|
|
+ if (++row == slots) { |
68 |
|
|
+ /* If we encountered a last_entry, we need to |
69 |
|
|
+ * mark the entry after the one to be inserted |
70 |
|
|
+ * as last_entry now! */ |
71 |
|
|
+ if (last_entry) { |
72 |
|
|
+ if (fat_get_entry(dir,&curr,bh,de,ino) > -1) { |
73 |
|
|
+ (*de)->name[0] = 0; |
74 |
|
|
+ mark_inode_dirty(dir); |
75 |
|
|
+ } |
76 |
|
|
+ } |
77 |
|
|
return offset; |
78 |
|
|
+ } |
79 |
|
|
} else { |
80 |
|
|
row = 0; |