diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-06-06 19:38:18 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:48:09 -0400 |
commit | 5e2df28cc62fdc3f4900de23f4ec69e6312f78a4 (patch) | |
tree | 902335c22ccf03fff3452117b3a3adc7433719b5 /fs/hostfs/hostfs_kern.c | |
parent | 52b209f7b848a28987ed133dc2b48f304b1dc6b8 (diff) |
hostfs: pass pathname to init_inode()
We will calculate it in all callers anyway, so there's no
need to duplicate that inside. Moreover, that way we lose
all failure exits in init_inode(), so it doesn't need to
return anything.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hostfs/hostfs_kern.c')
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 25d79298a98e..5a77ed3dfd7e 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -485,25 +485,16 @@ static const struct address_space_operations hostfs_aops = { | |||
485 | .write_end = hostfs_write_end, | 485 | .write_end = hostfs_write_end, |
486 | }; | 486 | }; |
487 | 487 | ||
488 | static int init_inode(struct inode *inode, struct dentry *dentry) | 488 | static void init_inode(struct inode *inode, char *path) |
489 | { | 489 | { |
490 | char *name; | 490 | int type; |
491 | int type, err = -ENOMEM; | ||
492 | int maj, min; | 491 | int maj, min; |
493 | dev_t rdev = 0; | 492 | dev_t rdev = 0; |
494 | 493 | ||
495 | if (dentry) { | 494 | type = file_type(path, &maj, &min); |
496 | name = dentry_name(dentry, 0); | 495 | /* Reencode maj and min with the kernel encoding.*/ |
497 | if (name == NULL) | 496 | rdev = MKDEV(maj, min); |
498 | goto out; | ||
499 | type = file_type(name, &maj, &min); | ||
500 | /* Reencode maj and min with the kernel encoding.*/ | ||
501 | rdev = MKDEV(maj, min); | ||
502 | kfree(name); | ||
503 | } | ||
504 | else type = OS_TYPE_DIR; | ||
505 | 497 | ||
506 | err = 0; | ||
507 | if (type == OS_TYPE_SYMLINK) | 498 | if (type == OS_TYPE_SYMLINK) |
508 | inode->i_op = &page_symlink_inode_operations; | 499 | inode->i_op = &page_symlink_inode_operations; |
509 | else if (type == OS_TYPE_DIR) | 500 | else if (type == OS_TYPE_DIR) |
@@ -531,8 +522,6 @@ static int init_inode(struct inode *inode, struct dentry *dentry) | |||
531 | init_special_inode(inode, S_IFSOCK, 0); | 522 | init_special_inode(inode, S_IFSOCK, 0); |
532 | break; | 523 | break; |
533 | } | 524 | } |
534 | out: | ||
535 | return err; | ||
536 | } | 525 | } |
537 | 526 | ||
538 | int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | 527 | int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, |
@@ -548,10 +537,6 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
548 | goto out; | 537 | goto out; |
549 | } | 538 | } |
550 | 539 | ||
551 | error = init_inode(inode, dentry); | ||
552 | if (error) | ||
553 | goto out_put; | ||
554 | |||
555 | error = -ENOMEM; | 540 | error = -ENOMEM; |
556 | name = dentry_name(dentry, 0); | 541 | name = dentry_name(dentry, 0); |
557 | if (name == NULL) | 542 | if (name == NULL) |
@@ -561,9 +546,12 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
561 | mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, | 546 | mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, |
562 | mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, | 547 | mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, |
563 | mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH); | 548 | mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH); |
564 | if (fd < 0) | 549 | if (fd < 0) { |
565 | error = fd; | 550 | error = fd; |
566 | else error = read_name(inode, name); | 551 | } else { |
552 | error = read_name(inode, name); | ||
553 | init_inode(inode, name); | ||
554 | } | ||
567 | 555 | ||
568 | kfree(name); | 556 | kfree(name); |
569 | if (error) | 557 | if (error) |
@@ -593,16 +581,14 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, | |||
593 | goto out; | 581 | goto out; |
594 | } | 582 | } |
595 | 583 | ||
596 | err = init_inode(inode, dentry); | ||
597 | if (err) | ||
598 | goto out_put; | ||
599 | |||
600 | err = -ENOMEM; | 584 | err = -ENOMEM; |
601 | name = dentry_name(dentry, 0); | 585 | name = dentry_name(dentry, 0); |
602 | if (name == NULL) | 586 | if (name == NULL) |
603 | goto out_put; | 587 | goto out_put; |
604 | 588 | ||
605 | err = read_name(inode, name); | 589 | err = read_name(inode, name); |
590 | init_inode(inode, name); | ||
591 | |||
606 | kfree(name); | 592 | kfree(name); |
607 | if (err == -ENOENT) { | 593 | if (err == -ENOENT) { |
608 | iput(inode); | 594 | iput(inode); |
@@ -717,10 +703,6 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
717 | goto out; | 703 | goto out; |
718 | } | 704 | } |
719 | 705 | ||
720 | err = init_inode(inode, dentry); | ||
721 | if (err) | ||
722 | goto out_put; | ||
723 | |||
724 | err = -ENOMEM; | 706 | err = -ENOMEM; |
725 | name = dentry_name(dentry, 0); | 707 | name = dentry_name(dentry, 0); |
726 | if (name == NULL) | 708 | if (name == NULL) |
@@ -732,6 +714,9 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
732 | goto out_free; | 714 | goto out_free; |
733 | 715 | ||
734 | err = read_name(inode, name); | 716 | err = read_name(inode, name); |
717 | init_inode(inode, name); | ||
718 | if (err) | ||
719 | goto out_put; | ||
735 | kfree(name); | 720 | kfree(name); |
736 | if (err) | 721 | if (err) |
737 | goto out_put; | 722 | goto out_put; |