diff options
Diffstat (limited to 'fs/hpfs/namei.c')
-rw-r--r-- | fs/hpfs/namei.c | 106 |
1 files changed, 30 insertions, 76 deletions
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index d5f8c8a19023..1f05839c27a7 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -29,7 +29,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); | 29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
30 | if (!fnode) | 30 | if (!fnode) |
31 | goto bail; | 31 | goto bail; |
32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); | 32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0); |
33 | if (!dnode) | 33 | if (!dnode) |
34 | goto bail1; | 34 | goto bail1; |
35 | memset(&dee, 0, sizeof dee); | 35 | memset(&dee, 0, sizeof dee); |
@@ -37,8 +37,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
37 | if (!(mode & 0222)) dee.read_only = 1; | 37 | if (!(mode & 0222)) dee.read_only = 1; |
38 | /*dee.archive = 0;*/ | 38 | /*dee.archive = 0;*/ |
39 | dee.hidden = name[0] == '.'; | 39 | dee.hidden = name[0] == '.'; |
40 | dee.fnode = fno; | 40 | dee.fnode = cpu_to_le32(fno); |
41 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 41 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
42 | result = new_inode(dir->i_sb); | 42 | result = new_inode(dir->i_sb); |
43 | if (!result) | 43 | if (!result) |
44 | goto bail2; | 44 | goto bail2; |
@@ -46,7 +46,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
46 | result->i_ino = fno; | 46 | result->i_ino = fno; |
47 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 47 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
48 | hpfs_i(result)->i_dno = dno; | 48 | hpfs_i(result)->i_dno = dno; |
49 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 49 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
50 | result->i_ctime.tv_nsec = 0; | 50 | result->i_ctime.tv_nsec = 0; |
51 | result->i_mtime.tv_nsec = 0; | 51 | result->i_mtime.tv_nsec = 0; |
52 | result->i_atime.tv_nsec = 0; | 52 | result->i_atime.tv_nsec = 0; |
@@ -60,8 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
60 | if (dee.read_only) | 60 | if (dee.read_only) |
61 | result->i_mode &= ~0222; | 61 | result->i_mode &= ~0222; |
62 | 62 | ||
63 | mutex_lock(&hpfs_i(dir)->i_mutex); | 63 | r = hpfs_add_dirent(dir, name, len, &dee); |
64 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
65 | if (r == 1) | 64 | if (r == 1) |
66 | goto bail3; | 65 | goto bail3; |
67 | if (r == -1) { | 66 | if (r == -1) { |
@@ -70,21 +69,21 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
70 | } | 69 | } |
71 | fnode->len = len; | 70 | fnode->len = len; |
72 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 71 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
73 | fnode->up = dir->i_ino; | 72 | fnode->up = cpu_to_le32(dir->i_ino); |
74 | fnode->dirflag = 1; | 73 | fnode->dirflag = 1; |
75 | fnode->btree.n_free_nodes = 7; | 74 | fnode->btree.n_free_nodes = 7; |
76 | fnode->btree.n_used_nodes = 1; | 75 | fnode->btree.n_used_nodes = 1; |
77 | fnode->btree.first_free = 0x14; | 76 | fnode->btree.first_free = cpu_to_le16(0x14); |
78 | fnode->u.external[0].disk_secno = dno; | 77 | fnode->u.external[0].disk_secno = cpu_to_le32(dno); |
79 | fnode->u.external[0].file_secno = -1; | 78 | fnode->u.external[0].file_secno = cpu_to_le32(-1); |
80 | dnode->root_dnode = 1; | 79 | dnode->root_dnode = 1; |
81 | dnode->up = fno; | 80 | dnode->up = cpu_to_le32(fno); |
82 | de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); | 81 | de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); |
83 | de->creation_date = de->write_date = de->read_date = gmt_to_local(dir->i_sb, get_seconds()); | 82 | de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
84 | if (!(mode & 0222)) de->read_only = 1; | 83 | if (!(mode & 0222)) de->read_only = 1; |
85 | de->first = de->directory = 1; | 84 | de->first = de->directory = 1; |
86 | /*de->hidden = de->system = 0;*/ | 85 | /*de->hidden = de->system = 0;*/ |
87 | de->fnode = fno; | 86 | de->fnode = cpu_to_le32(fno); |
88 | mark_buffer_dirty(bh); | 87 | mark_buffer_dirty(bh); |
89 | brelse(bh); | 88 | brelse(bh); |
90 | hpfs_mark_4buffers_dirty(&qbh0); | 89 | hpfs_mark_4buffers_dirty(&qbh0); |
@@ -101,11 +100,9 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
101 | hpfs_write_inode_nolock(result); | 100 | hpfs_write_inode_nolock(result); |
102 | } | 101 | } |
103 | d_instantiate(dentry, result); | 102 | d_instantiate(dentry, result); |
104 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
105 | hpfs_unlock(dir->i_sb); | 103 | hpfs_unlock(dir->i_sb); |
106 | return 0; | 104 | return 0; |
107 | bail3: | 105 | bail3: |
108 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
109 | iput(result); | 106 | iput(result); |
110 | bail2: | 107 | bail2: |
111 | hpfs_brelse4(&qbh0); | 108 | hpfs_brelse4(&qbh0); |
@@ -140,8 +137,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
140 | if (!(mode & 0222)) dee.read_only = 1; | 137 | if (!(mode & 0222)) dee.read_only = 1; |
141 | dee.archive = 1; | 138 | dee.archive = 1; |
142 | dee.hidden = name[0] == '.'; | 139 | dee.hidden = name[0] == '.'; |
143 | dee.fnode = fno; | 140 | dee.fnode = cpu_to_le32(fno); |
144 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 141 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
145 | 142 | ||
146 | result = new_inode(dir->i_sb); | 143 | result = new_inode(dir->i_sb); |
147 | if (!result) | 144 | if (!result) |
@@ -154,9 +151,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
154 | result->i_op = &hpfs_file_iops; | 151 | result->i_op = &hpfs_file_iops; |
155 | result->i_fop = &hpfs_file_ops; | 152 | result->i_fop = &hpfs_file_ops; |
156 | result->i_nlink = 1; | 153 | result->i_nlink = 1; |
157 | hpfs_decide_conv(result, name, len); | ||
158 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 154 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
159 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 155 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
160 | result->i_ctime.tv_nsec = 0; | 156 | result->i_ctime.tv_nsec = 0; |
161 | result->i_mtime.tv_nsec = 0; | 157 | result->i_mtime.tv_nsec = 0; |
162 | result->i_atime.tv_nsec = 0; | 158 | result->i_atime.tv_nsec = 0; |
@@ -168,8 +164,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
168 | result->i_data.a_ops = &hpfs_aops; | 164 | result->i_data.a_ops = &hpfs_aops; |
169 | hpfs_i(result)->mmu_private = 0; | 165 | hpfs_i(result)->mmu_private = 0; |
170 | 166 | ||
171 | mutex_lock(&hpfs_i(dir)->i_mutex); | 167 | r = hpfs_add_dirent(dir, name, len, &dee); |
172 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
173 | if (r == 1) | 168 | if (r == 1) |
174 | goto bail2; | 169 | goto bail2; |
175 | if (r == -1) { | 170 | if (r == -1) { |
@@ -178,7 +173,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
178 | } | 173 | } |
179 | fnode->len = len; | 174 | fnode->len = len; |
180 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 175 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
181 | fnode->up = dir->i_ino; | 176 | fnode->up = cpu_to_le32(dir->i_ino); |
182 | mark_buffer_dirty(bh); | 177 | mark_buffer_dirty(bh); |
183 | brelse(bh); | 178 | brelse(bh); |
184 | 179 | ||
@@ -193,12 +188,10 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
193 | hpfs_write_inode_nolock(result); | 188 | hpfs_write_inode_nolock(result); |
194 | } | 189 | } |
195 | d_instantiate(dentry, result); | 190 | d_instantiate(dentry, result); |
196 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
197 | hpfs_unlock(dir->i_sb); | 191 | hpfs_unlock(dir->i_sb); |
198 | return 0; | 192 | return 0; |
199 | 193 | ||
200 | bail2: | 194 | bail2: |
201 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
202 | iput(result); | 195 | iput(result); |
203 | bail1: | 196 | bail1: |
204 | brelse(bh); | 197 | brelse(bh); |
@@ -232,8 +225,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
232 | if (!(mode & 0222)) dee.read_only = 1; | 225 | if (!(mode & 0222)) dee.read_only = 1; |
233 | dee.archive = 1; | 226 | dee.archive = 1; |
234 | dee.hidden = name[0] == '.'; | 227 | dee.hidden = name[0] == '.'; |
235 | dee.fnode = fno; | 228 | dee.fnode = cpu_to_le32(fno); |
236 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 229 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
237 | 230 | ||
238 | result = new_inode(dir->i_sb); | 231 | result = new_inode(dir->i_sb); |
239 | if (!result) | 232 | if (!result) |
@@ -242,7 +235,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
242 | hpfs_init_inode(result); | 235 | hpfs_init_inode(result); |
243 | result->i_ino = fno; | 236 | result->i_ino = fno; |
244 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 237 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
245 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 238 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
246 | result->i_ctime.tv_nsec = 0; | 239 | result->i_ctime.tv_nsec = 0; |
247 | result->i_mtime.tv_nsec = 0; | 240 | result->i_mtime.tv_nsec = 0; |
248 | result->i_atime.tv_nsec = 0; | 241 | result->i_atime.tv_nsec = 0; |
@@ -254,8 +247,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
254 | result->i_blocks = 1; | 247 | result->i_blocks = 1; |
255 | init_special_inode(result, mode, rdev); | 248 | init_special_inode(result, mode, rdev); |
256 | 249 | ||
257 | mutex_lock(&hpfs_i(dir)->i_mutex); | 250 | r = hpfs_add_dirent(dir, name, len, &dee); |
258 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
259 | if (r == 1) | 251 | if (r == 1) |
260 | goto bail2; | 252 | goto bail2; |
261 | if (r == -1) { | 253 | if (r == -1) { |
@@ -264,19 +256,17 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
264 | } | 256 | } |
265 | fnode->len = len; | 257 | fnode->len = len; |
266 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 258 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
267 | fnode->up = dir->i_ino; | 259 | fnode->up = cpu_to_le32(dir->i_ino); |
268 | mark_buffer_dirty(bh); | 260 | mark_buffer_dirty(bh); |
269 | 261 | ||
270 | insert_inode_hash(result); | 262 | insert_inode_hash(result); |
271 | 263 | ||
272 | hpfs_write_inode_nolock(result); | 264 | hpfs_write_inode_nolock(result); |
273 | d_instantiate(dentry, result); | 265 | d_instantiate(dentry, result); |
274 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
275 | brelse(bh); | 266 | brelse(bh); |
276 | hpfs_unlock(dir->i_sb); | 267 | hpfs_unlock(dir->i_sb); |
277 | return 0; | 268 | return 0; |
278 | bail2: | 269 | bail2: |
279 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
280 | iput(result); | 270 | iput(result); |
281 | bail1: | 271 | bail1: |
282 | brelse(bh); | 272 | brelse(bh); |
@@ -310,8 +300,8 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
310 | memset(&dee, 0, sizeof dee); | 300 | memset(&dee, 0, sizeof dee); |
311 | dee.archive = 1; | 301 | dee.archive = 1; |
312 | dee.hidden = name[0] == '.'; | 302 | dee.hidden = name[0] == '.'; |
313 | dee.fnode = fno; | 303 | dee.fnode = cpu_to_le32(fno); |
314 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); | 304 | dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds())); |
315 | 305 | ||
316 | result = new_inode(dir->i_sb); | 306 | result = new_inode(dir->i_sb); |
317 | if (!result) | 307 | if (!result) |
@@ -319,7 +309,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
319 | result->i_ino = fno; | 309 | result->i_ino = fno; |
320 | hpfs_init_inode(result); | 310 | hpfs_init_inode(result); |
321 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 311 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
322 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 312 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); |
323 | result->i_ctime.tv_nsec = 0; | 313 | result->i_ctime.tv_nsec = 0; |
324 | result->i_mtime.tv_nsec = 0; | 314 | result->i_mtime.tv_nsec = 0; |
325 | result->i_atime.tv_nsec = 0; | 315 | result->i_atime.tv_nsec = 0; |
@@ -333,8 +323,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
333 | result->i_op = &page_symlink_inode_operations; | 323 | result->i_op = &page_symlink_inode_operations; |
334 | result->i_data.a_ops = &hpfs_symlink_aops; | 324 | result->i_data.a_ops = &hpfs_symlink_aops; |
335 | 325 | ||
336 | mutex_lock(&hpfs_i(dir)->i_mutex); | 326 | r = hpfs_add_dirent(dir, name, len, &dee); |
337 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
338 | if (r == 1) | 327 | if (r == 1) |
339 | goto bail2; | 328 | goto bail2; |
340 | if (r == -1) { | 329 | if (r == -1) { |
@@ -343,7 +332,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
343 | } | 332 | } |
344 | fnode->len = len; | 333 | fnode->len = len; |
345 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 334 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
346 | fnode->up = dir->i_ino; | 335 | fnode->up = cpu_to_le32(dir->i_ino); |
347 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); | 336 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); |
348 | mark_buffer_dirty(bh); | 337 | mark_buffer_dirty(bh); |
349 | brelse(bh); | 338 | brelse(bh); |
@@ -352,11 +341,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
352 | 341 | ||
353 | hpfs_write_inode_nolock(result); | 342 | hpfs_write_inode_nolock(result); |
354 | d_instantiate(dentry, result); | 343 | d_instantiate(dentry, result); |
355 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
356 | hpfs_unlock(dir->i_sb); | 344 | hpfs_unlock(dir->i_sb); |
357 | return 0; | 345 | return 0; |
358 | bail2: | 346 | bail2: |
359 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
360 | iput(result); | 347 | iput(result); |
361 | bail1: | 348 | bail1: |
362 | brelse(bh); | 349 | brelse(bh); |
@@ -374,7 +361,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
374 | struct hpfs_dirent *de; | 361 | struct hpfs_dirent *de; |
375 | struct inode *inode = dentry->d_inode; | 362 | struct inode *inode = dentry->d_inode; |
376 | dnode_secno dno; | 363 | dnode_secno dno; |
377 | fnode_secno fno; | ||
378 | int r; | 364 | int r; |
379 | int rep = 0; | 365 | int rep = 0; |
380 | int err; | 366 | int err; |
@@ -382,8 +368,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
382 | hpfs_lock(dir->i_sb); | 368 | hpfs_lock(dir->i_sb); |
383 | hpfs_adjust_length(name, &len); | 369 | hpfs_adjust_length(name, &len); |
384 | again: | 370 | again: |
385 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
386 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
387 | err = -ENOENT; | 371 | err = -ENOENT; |
388 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 372 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
389 | if (!de) | 373 | if (!de) |
@@ -397,7 +381,6 @@ again: | |||
397 | if (de->directory) | 381 | if (de->directory) |
398 | goto out1; | 382 | goto out1; |
399 | 383 | ||
400 | fno = de->fnode; | ||
401 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); | 384 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
402 | switch (r) { | 385 | switch (r) { |
403 | case 1: | 386 | case 1: |
@@ -410,8 +393,6 @@ again: | |||
410 | if (rep++) | 393 | if (rep++) |
411 | break; | 394 | break; |
412 | 395 | ||
413 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
414 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
415 | dentry_unhash(dentry); | 396 | dentry_unhash(dentry); |
416 | if (!d_unhashed(dentry)) { | 397 | if (!d_unhashed(dentry)) { |
417 | dput(dentry); | 398 | dput(dentry); |
@@ -445,8 +426,6 @@ again: | |||
445 | out1: | 426 | out1: |
446 | hpfs_brelse4(&qbh); | 427 | hpfs_brelse4(&qbh); |
447 | out: | 428 | out: |
448 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
449 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
450 | hpfs_unlock(dir->i_sb); | 429 | hpfs_unlock(dir->i_sb); |
451 | return err; | 430 | return err; |
452 | } | 431 | } |
@@ -459,15 +438,12 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
459 | struct hpfs_dirent *de; | 438 | struct hpfs_dirent *de; |
460 | struct inode *inode = dentry->d_inode; | 439 | struct inode *inode = dentry->d_inode; |
461 | dnode_secno dno; | 440 | dnode_secno dno; |
462 | fnode_secno fno; | ||
463 | int n_items = 0; | 441 | int n_items = 0; |
464 | int err; | 442 | int err; |
465 | int r; | 443 | int r; |
466 | 444 | ||
467 | hpfs_adjust_length(name, &len); | 445 | hpfs_adjust_length(name, &len); |
468 | hpfs_lock(dir->i_sb); | 446 | hpfs_lock(dir->i_sb); |
469 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
470 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
471 | err = -ENOENT; | 447 | err = -ENOENT; |
472 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 448 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
473 | if (!de) | 449 | if (!de) |
@@ -486,7 +462,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
486 | if (n_items) | 462 | if (n_items) |
487 | goto out1; | 463 | goto out1; |
488 | 464 | ||
489 | fno = de->fnode; | ||
490 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); | 465 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
491 | switch (r) { | 466 | switch (r) { |
492 | case 1: | 467 | case 1: |
@@ -505,8 +480,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
505 | out1: | 480 | out1: |
506 | hpfs_brelse4(&qbh); | 481 | hpfs_brelse4(&qbh); |
507 | out: | 482 | out: |
508 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
509 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
510 | hpfs_unlock(dir->i_sb); | 483 | hpfs_unlock(dir->i_sb); |
511 | return err; | 484 | return err; |
512 | } | 485 | } |
@@ -568,12 +541,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
568 | 541 | ||
569 | hpfs_lock(i->i_sb); | 542 | hpfs_lock(i->i_sb); |
570 | /* order doesn't matter, due to VFS exclusion */ | 543 | /* order doesn't matter, due to VFS exclusion */ |
571 | mutex_lock(&hpfs_i(i)->i_parent_mutex); | ||
572 | if (new_inode) | ||
573 | mutex_lock(&hpfs_i(new_inode)->i_parent_mutex); | ||
574 | mutex_lock(&hpfs_i(old_dir)->i_mutex); | ||
575 | if (new_dir != old_dir) | ||
576 | mutex_lock(&hpfs_i(new_dir)->i_mutex); | ||
577 | 544 | ||
578 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ | 545 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ |
579 | if (new_inode && S_ISDIR(new_inode->i_mode)) { | 546 | if (new_inode && S_ISDIR(new_inode->i_mode)) { |
@@ -610,9 +577,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
610 | 577 | ||
611 | if (new_dir == old_dir) hpfs_brelse4(&qbh); | 578 | if (new_dir == old_dir) hpfs_brelse4(&qbh); |
612 | 579 | ||
613 | hpfs_lock_creation(i->i_sb); | 580 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) { |
614 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) { | ||
615 | hpfs_unlock_creation(i->i_sb); | ||
616 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); | 581 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); |
617 | err = r == 1 ? -ENOSPC : -EFSERROR; | 582 | err = r == 1 ? -ENOSPC : -EFSERROR; |
618 | if (new_dir != old_dir) hpfs_brelse4(&qbh); | 583 | if (new_dir != old_dir) hpfs_brelse4(&qbh); |
@@ -621,20 +586,17 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
621 | 586 | ||
622 | if (new_dir == old_dir) | 587 | if (new_dir == old_dir) |
623 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { | 588 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
624 | hpfs_unlock_creation(i->i_sb); | ||
625 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); | 589 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); |
626 | err = -ENOENT; | 590 | err = -ENOENT; |
627 | goto end1; | 591 | goto end1; |
628 | } | 592 | } |
629 | 593 | ||
630 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { | 594 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { |
631 | hpfs_unlock_creation(i->i_sb); | ||
632 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); | 595 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); |
633 | err = r == 2 ? -ENOSPC : -EFSERROR; | 596 | err = r == 2 ? -ENOSPC : -EFSERROR; |
634 | goto end1; | 597 | goto end1; |
635 | } | 598 | } |
636 | hpfs_unlock_creation(i->i_sb); | 599 | |
637 | |||
638 | end: | 600 | end: |
639 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; | 601 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; |
640 | if (S_ISDIR(i->i_mode)) { | 602 | if (S_ISDIR(i->i_mode)) { |
@@ -642,22 +604,14 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
642 | drop_nlink(old_dir); | 604 | drop_nlink(old_dir); |
643 | } | 605 | } |
644 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { | 606 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { |
645 | fnode->up = new_dir->i_ino; | 607 | fnode->up = cpu_to_le32(new_dir->i_ino); |
646 | fnode->len = new_len; | 608 | fnode->len = new_len; |
647 | memcpy(fnode->name, new_name, new_len>15?15:new_len); | 609 | memcpy(fnode->name, new_name, new_len>15?15:new_len); |
648 | if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); | 610 | if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); |
649 | mark_buffer_dirty(bh); | 611 | mark_buffer_dirty(bh); |
650 | brelse(bh); | 612 | brelse(bh); |
651 | } | 613 | } |
652 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; | ||
653 | hpfs_decide_conv(i, new_name, new_len); | ||
654 | end1: | 614 | end1: |
655 | if (old_dir != new_dir) | ||
656 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); | ||
657 | mutex_unlock(&hpfs_i(old_dir)->i_mutex); | ||
658 | mutex_unlock(&hpfs_i(i)->i_parent_mutex); | ||
659 | if (new_inode) | ||
660 | mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); | ||
661 | hpfs_unlock(i->i_sb); | 615 | hpfs_unlock(i->i_sb); |
662 | return err; | 616 | return err; |
663 | } | 617 | } |