Commit 5e2df28cc62fdc3f4900de23f4ec69e6312f78a4
1 parent
52b209f7b8
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 15 additions and 30 deletions Side-by-side Diff
fs/hostfs/hostfs_kern.c
... | ... | @@ -485,25 +485,16 @@ |
485 | 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; | |
491 | - int type, err = -ENOMEM; | |
490 | + int type; | |
492 | 491 | int maj, min; |
493 | 492 | dev_t rdev = 0; |
494 | 493 | |
495 | - if (dentry) { | |
496 | - name = dentry_name(dentry, 0); | |
497 | - if (name == NULL) | |
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; | |
494 | + type = file_type(path, &maj, &min); | |
495 | + /* Reencode maj and min with the kernel encoding.*/ | |
496 | + rdev = MKDEV(maj, min); | |
505 | 497 | |
506 | - err = 0; | |
507 | 498 | if (type == OS_TYPE_SYMLINK) |
508 | 499 | inode->i_op = &page_symlink_inode_operations; |
509 | 500 | else if (type == OS_TYPE_DIR) |
... | ... | @@ -531,8 +522,6 @@ |
531 | 522 | init_special_inode(inode, S_IFSOCK, 0); |
532 | 523 | break; |
533 | 524 | } |
534 | - out: | |
535 | - return err; | |
536 | 525 | } |
537 | 526 | |
538 | 527 | int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, |
... | ... | @@ -548,10 +537,6 @@ |
548 | 537 | goto out; |
549 | 538 | } |
550 | 539 | |
551 | - error = init_inode(inode, dentry); | |
552 | - if (error) | |
553 | - goto out_put; | |
554 | - | |
555 | 540 | error = -ENOMEM; |
556 | 541 | name = dentry_name(dentry, 0); |
557 | 542 | if (name == NULL) |
558 | 543 | |
... | ... | @@ -561,9 +546,12 @@ |
561 | 546 | mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, |
562 | 547 | mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, |
563 | 548 | mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH); |
564 | - if (fd < 0) | |
549 | + if (fd < 0) { | |
565 | 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 | 556 | kfree(name); |
569 | 557 | if (error) |
570 | 558 | |
... | ... | @@ -593,16 +581,14 @@ |
593 | 581 | goto out; |
594 | 582 | } |
595 | 583 | |
596 | - err = init_inode(inode, dentry); | |
597 | - if (err) | |
598 | - goto out_put; | |
599 | - | |
600 | 584 | err = -ENOMEM; |
601 | 585 | name = dentry_name(dentry, 0); |
602 | 586 | if (name == NULL) |
603 | 587 | goto out_put; |
604 | 588 | |
605 | 589 | err = read_name(inode, name); |
590 | + init_inode(inode, name); | |
591 | + | |
606 | 592 | kfree(name); |
607 | 593 | if (err == -ENOENT) { |
608 | 594 | iput(inode); |
... | ... | @@ -717,10 +703,6 @@ |
717 | 703 | goto out; |
718 | 704 | } |
719 | 705 | |
720 | - err = init_inode(inode, dentry); | |
721 | - if (err) | |
722 | - goto out_put; | |
723 | - | |
724 | 706 | err = -ENOMEM; |
725 | 707 | name = dentry_name(dentry, 0); |
726 | 708 | if (name == NULL) |
... | ... | @@ -732,6 +714,9 @@ |
732 | 714 | goto out_free; |
733 | 715 | |
734 | 716 | err = read_name(inode, name); |
717 | + init_inode(inode, name); | |
718 | + if (err) | |
719 | + goto out_put; | |
735 | 720 | kfree(name); |
736 | 721 | if (err) |
737 | 722 | goto out_put; |