diff options
author | David S. Miller <davem@davemloft.net> | 2008-04-03 17:33:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-03 17:33:42 -0400 |
commit | 3bb5da3837cc1aa17736b05139c9a22c3794851a (patch) | |
tree | c92d5684a866542b1cb20641607ac1643ce03a47 /fs/romfs/inode.c | |
parent | 7feb49c82a74bc7c091b8ab2a3f96baa33d08ece (diff) | |
parent | 9597362d354f8655ece324b01d0c640a0e99c077 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'fs/romfs/inode.c')
-rw-r--r-- | fs/romfs/inode.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c index 00b6f0a518c8..3f13d491c7c7 100644 --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c | |||
@@ -340,8 +340,9 @@ static struct dentry * | |||
340 | romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 340 | romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) |
341 | { | 341 | { |
342 | unsigned long offset, maxoff; | 342 | unsigned long offset, maxoff; |
343 | int fslen, res; | 343 | long res; |
344 | struct inode *inode; | 344 | int fslen; |
345 | struct inode *inode = NULL; | ||
345 | char fsname[ROMFS_MAXFN]; /* XXX dynamic? */ | 346 | char fsname[ROMFS_MAXFN]; /* XXX dynamic? */ |
346 | struct romfs_inode ri; | 347 | struct romfs_inode ri; |
347 | const char *name; /* got from dentry */ | 348 | const char *name; /* got from dentry */ |
@@ -351,7 +352,7 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
351 | offset = dir->i_ino & ROMFH_MASK; | 352 | offset = dir->i_ino & ROMFH_MASK; |
352 | lock_kernel(); | 353 | lock_kernel(); |
353 | if (romfs_copyfrom(dir, &ri, offset, ROMFH_SIZE) <= 0) | 354 | if (romfs_copyfrom(dir, &ri, offset, ROMFH_SIZE) <= 0) |
354 | goto out; | 355 | goto error; |
355 | 356 | ||
356 | maxoff = romfs_maxsize(dir->i_sb); | 357 | maxoff = romfs_maxsize(dir->i_sb); |
357 | offset = be32_to_cpu(ri.spec) & ROMFH_MASK; | 358 | offset = be32_to_cpu(ri.spec) & ROMFH_MASK; |
@@ -364,9 +365,9 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
364 | 365 | ||
365 | for(;;) { | 366 | for(;;) { |
366 | if (!offset || offset >= maxoff) | 367 | if (!offset || offset >= maxoff) |
367 | goto out0; | 368 | goto success; /* negative success */ |
368 | if (romfs_copyfrom(dir, &ri, offset, ROMFH_SIZE) <= 0) | 369 | if (romfs_copyfrom(dir, &ri, offset, ROMFH_SIZE) <= 0) |
369 | goto out; | 370 | goto error; |
370 | 371 | ||
371 | /* try to match the first 16 bytes of name */ | 372 | /* try to match the first 16 bytes of name */ |
372 | fslen = romfs_strnlen(dir, offset+ROMFH_SIZE, ROMFH_SIZE); | 373 | fslen = romfs_strnlen(dir, offset+ROMFH_SIZE, ROMFH_SIZE); |
@@ -397,23 +398,14 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
397 | inode = romfs_iget(dir->i_sb, offset); | 398 | inode = romfs_iget(dir->i_sb, offset); |
398 | if (IS_ERR(inode)) { | 399 | if (IS_ERR(inode)) { |
399 | res = PTR_ERR(inode); | 400 | res = PTR_ERR(inode); |
400 | goto out; | 401 | goto error; |
401 | } | 402 | } |
402 | 403 | ||
403 | /* | 404 | success: |
404 | * it's a bit funky, _lookup needs to return an error code | 405 | d_add(dentry, inode); |
405 | * (negative) or a NULL, both as a dentry. ENOENT should not | ||
406 | * be returned, instead we need to create a negative dentry by | ||
407 | * d_add(dentry, NULL); and return 0 as no error. | ||
408 | * (Although as I see, it only matters on writable file | ||
409 | * systems). | ||
410 | */ | ||
411 | |||
412 | out0: inode = NULL; | ||
413 | res = 0; | 406 | res = 0; |
414 | d_add (dentry, inode); | 407 | error: |
415 | 408 | unlock_kernel(); | |
416 | out: unlock_kernel(); | ||
417 | return ERR_PTR(res); | 409 | return ERR_PTR(res); |
418 | } | 410 | } |
419 | 411 | ||