aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hostfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-06-06 20:42:10 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-08-09 16:48:11 -0400
commitc5322220eb91b9e56ac7b69eb690d9d20fac5725 (patch)
tree410b37be57eeac2302fb6e1fcd50dd42abfe0087 /fs/hostfs
parent4754b825571a6f2f7655245e420e8e486c4458f6 (diff)
hostfs: get rid of inode_dentry_name()
it's equivalent to dentry_name() anyway Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hostfs')
-rw-r--r--fs/hostfs/hostfs_kern.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index b29a2b878f46..3841fb1ca5a2 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -89,7 +89,7 @@ __uml_setup("hostfs=", hostfs_args,
89); 89);
90#endif 90#endif
91 91
92static char *dentry_name(struct dentry *dentry, int extra) 92static char *dentry_name(struct dentry *dentry)
93{ 93{
94 struct dentry *parent; 94 struct dentry *parent;
95 char *root, *name; 95 char *root, *name;
@@ -104,7 +104,7 @@ static char *dentry_name(struct dentry *dentry, int extra)
104 104
105 root = parent->d_sb->s_fs_info; 105 root = parent->d_sb->s_fs_info;
106 len += strlen(root); 106 len += strlen(root);
107 name = kmalloc(len + extra + 1, GFP_KERNEL); 107 name = kmalloc(len + 1, GFP_KERNEL);
108 if (name == NULL) 108 if (name == NULL)
109 return NULL; 109 return NULL;
110 110
@@ -121,12 +121,12 @@ static char *dentry_name(struct dentry *dentry, int extra)
121 return name; 121 return name;
122} 122}
123 123
124static char *inode_name(struct inode *ino, int extra) 124static char *inode_name(struct inode *ino)
125{ 125{
126 struct dentry *dentry; 126 struct dentry *dentry;
127 127
128 dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias); 128 dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
129 return dentry_name(dentry, extra); 129 return dentry_name(dentry);
130} 130}
131 131
132static char *follow_link(char *link) 132static char *follow_link(char *link)
@@ -267,7 +267,7 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
267 unsigned long long next, ino; 267 unsigned long long next, ino;
268 int error, len; 268 int error, len;
269 269
270 name = dentry_name(file->f_path.dentry, 0); 270 name = dentry_name(file->f_path.dentry);
271 if (name == NULL) 271 if (name == NULL)
272 return -ENOMEM; 272 return -ENOMEM;
273 dir = open_dir(name, &error); 273 dir = open_dir(name, &error);
@@ -312,7 +312,7 @@ int hostfs_file_open(struct inode *ino, struct file *file)
312 if (w) 312 if (w)
313 r = 1; 313 r = 1;
314 314
315 name = dentry_name(file->f_path.dentry, 0); 315 name = dentry_name(file->f_path.dentry);
316 if (name == NULL) 316 if (name == NULL)
317 return -ENOMEM; 317 return -ENOMEM;
318 318
@@ -519,7 +519,7 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
519 } 519 }
520 520
521 error = -ENOMEM; 521 error = -ENOMEM;
522 name = dentry_name(dentry, 0); 522 name = dentry_name(dentry);
523 if (name == NULL) 523 if (name == NULL)
524 goto out_put; 524 goto out_put;
525 525
@@ -561,7 +561,7 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
561 } 561 }
562 562
563 err = -ENOMEM; 563 err = -ENOMEM;
564 name = dentry_name(dentry, 0); 564 name = dentry_name(dentry);
565 if (name == NULL) 565 if (name == NULL)
566 goto out_put; 566 goto out_put;
567 567
@@ -585,29 +585,14 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
585 return ERR_PTR(err); 585 return ERR_PTR(err);
586} 586}
587 587
588static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
589{
590 char *file;
591 int len;
592
593 file = inode_name(ino, dentry->d_name.len + 1);
594 if (file == NULL)
595 return NULL;
596 strcat(file, "/");
597 len = strlen(file);
598 strncat(file, dentry->d_name.name, dentry->d_name.len);
599 file[len + dentry->d_name.len] = '\0';
600 return file;
601}
602
603int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from) 588int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
604{ 589{
605 char *from_name, *to_name; 590 char *from_name, *to_name;
606 int err; 591 int err;
607 592
608 if ((from_name = inode_dentry_name(ino, from)) == NULL) 593 if ((from_name = dentry_name(from)) == NULL)
609 return -ENOMEM; 594 return -ENOMEM;
610 to_name = dentry_name(to, 0); 595 to_name = dentry_name(to);
611 if (to_name == NULL) { 596 if (to_name == NULL) {
612 kfree(from_name); 597 kfree(from_name);
613 return -ENOMEM; 598 return -ENOMEM;
@@ -623,7 +608,7 @@ int hostfs_unlink(struct inode *ino, struct dentry *dentry)
623 char *file; 608 char *file;
624 int err; 609 int err;
625 610
626 if ((file = inode_dentry_name(ino, dentry)) == NULL) 611 if ((file = dentry_name(dentry)) == NULL)
627 return -ENOMEM; 612 return -ENOMEM;
628 if (append) 613 if (append)
629 return -EPERM; 614 return -EPERM;
@@ -638,7 +623,7 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
638 char *file; 623 char *file;
639 int err; 624 int err;
640 625
641 if ((file = inode_dentry_name(ino, dentry)) == NULL) 626 if ((file = dentry_name(dentry)) == NULL)
642 return -ENOMEM; 627 return -ENOMEM;
643 err = make_symlink(file, to); 628 err = make_symlink(file, to);
644 kfree(file); 629 kfree(file);
@@ -650,7 +635,7 @@ int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
650 char *file; 635 char *file;
651 int err; 636 int err;
652 637
653 if ((file = inode_dentry_name(ino, dentry)) == NULL) 638 if ((file = dentry_name(dentry)) == NULL)
654 return -ENOMEM; 639 return -ENOMEM;
655 err = do_mkdir(file, mode); 640 err = do_mkdir(file, mode);
656 kfree(file); 641 kfree(file);
@@ -662,7 +647,7 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
662 char *file; 647 char *file;
663 int err; 648 int err;
664 649
665 if ((file = inode_dentry_name(ino, dentry)) == NULL) 650 if ((file = dentry_name(dentry)) == NULL)
666 return -ENOMEM; 651 return -ENOMEM;
667 err = do_rmdir(file); 652 err = do_rmdir(file);
668 kfree(file); 653 kfree(file);
@@ -682,7 +667,7 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
682 } 667 }
683 668
684 err = -ENOMEM; 669 err = -ENOMEM;
685 name = dentry_name(dentry, 0); 670 name = dentry_name(dentry);
686 if (name == NULL) 671 if (name == NULL)
687 goto out_put; 672 goto out_put;
688 673
@@ -715,9 +700,9 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
715 char *from_name, *to_name; 700 char *from_name, *to_name;
716 int err; 701 int err;
717 702
718 if ((from_name = inode_dentry_name(from_ino, from)) == NULL) 703 if ((from_name = dentry_name(from)) == NULL)
719 return -ENOMEM; 704 return -ENOMEM;
720 if ((to_name = inode_dentry_name(to_ino, to)) == NULL) { 705 if ((to_name = dentry_name(to)) == NULL) {
721 kfree(from_name); 706 kfree(from_name);
722 return -ENOMEM; 707 return -ENOMEM;
723 } 708 }
@@ -735,7 +720,7 @@ int hostfs_permission(struct inode *ino, int desired)
735 if (desired & MAY_READ) r = 1; 720 if (desired & MAY_READ) r = 1;
736 if (desired & MAY_WRITE) w = 1; 721 if (desired & MAY_WRITE) w = 1;
737 if (desired & MAY_EXEC) x = 1; 722 if (desired & MAY_EXEC) x = 1;
738 name = inode_name(ino, 0); 723 name = inode_name(ino);
739 if (name == NULL) 724 if (name == NULL)
740 return -ENOMEM; 725 return -ENOMEM;
741 726
@@ -801,7 +786,7 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
801 if (attr->ia_valid & ATTR_MTIME_SET) { 786 if (attr->ia_valid & ATTR_MTIME_SET) {
802 attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET; 787 attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
803 } 788 }
804 name = dentry_name(dentry, 0); 789 name = dentry_name(dentry);
805 if (name == NULL) 790 if (name == NULL)
806 return -ENOMEM; 791 return -ENOMEM;
807 err = set_attr(name, &attrs, fd); 792 err = set_attr(name, &attrs, fd);
@@ -856,7 +841,7 @@ int hostfs_link_readpage(struct file *file, struct page *page)
856 int err; 841 int err;
857 842
858 buffer = kmap(page); 843 buffer = kmap(page);
859 name = inode_name(page->mapping->host, 0); 844 name = inode_name(page->mapping->host);
860 if (name == NULL) 845 if (name == NULL)
861 return -ENOMEM; 846 return -ENOMEM;
862 err = hostfs_do_readlink(name, buffer, PAGE_CACHE_SIZE); 847 err = hostfs_do_readlink(name, buffer, PAGE_CACHE_SIZE);