aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hostfs/hostfs_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hostfs/hostfs_kern.c')
-rw-r--r--fs/hostfs/hostfs_kern.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index e965eb11d76f..fd301a910122 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -20,7 +20,6 @@
20#include "hostfs.h" 20#include "hostfs.h"
21#include "kern_util.h" 21#include "kern_util.h"
22#include "kern.h" 22#include "kern.h"
23#include "user_util.h"
24#include "init.h" 23#include "init.h"
25 24
26struct hostfs_inode_info { 25struct hostfs_inode_info {
@@ -47,7 +46,7 @@ struct dentry_operations hostfs_dentry_ops = {
47}; 46};
48 47
49/* Changed in hostfs_args before the kernel starts running */ 48/* Changed in hostfs_args before the kernel starts running */
50static char *root_ino = "/"; 49static char *root_ino = "";
51static int append = 0; 50static int append = 0;
52 51
53#define HOSTFS_SUPER_MAGIC 0x00c0ffee 52#define HOSTFS_SUPER_MAGIC 0x00c0ffee
@@ -939,7 +938,7 @@ static const struct address_space_operations hostfs_link_aops = {
939static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) 938static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
940{ 939{
941 struct inode *root_inode; 940 struct inode *root_inode;
942 char *name, *data = d; 941 char *host_root_path, *req_root = d;
943 int err; 942 int err;
944 943
945 sb->s_blocksize = 1024; 944 sb->s_blocksize = 1024;
@@ -947,15 +946,17 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
947 sb->s_magic = HOSTFS_SUPER_MAGIC; 946 sb->s_magic = HOSTFS_SUPER_MAGIC;
948 sb->s_op = &hostfs_sbops; 947 sb->s_op = &hostfs_sbops;
949 948
950 if((data == NULL) || (*data == '\0')) 949 /* NULL is printed as <NULL> by sprintf: avoid that. */
951 data = root_ino; 950 if (req_root == NULL)
951 req_root = "";
952 952
953 err = -ENOMEM; 953 err = -ENOMEM;
954 name = kmalloc(strlen(data) + 1, GFP_KERNEL); 954 host_root_path = kmalloc(strlen(root_ino) + 1
955 if(name == NULL) 955 + strlen(req_root) + 1, GFP_KERNEL);
956 if(host_root_path == NULL)
956 goto out; 957 goto out;
957 958
958 strcpy(name, data); 959 sprintf(host_root_path, "%s/%s", root_ino, req_root);
959 960
960 root_inode = iget(sb, 0); 961 root_inode = iget(sb, 0);
961 if(root_inode == NULL) 962 if(root_inode == NULL)
@@ -965,7 +966,10 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
965 if(err) 966 if(err)
966 goto out_put; 967 goto out_put;
967 968
968 HOSTFS_I(root_inode)->host_filename = name; 969 HOSTFS_I(root_inode)->host_filename = host_root_path;
970 /* Avoid that in the error path, iput(root_inode) frees again
971 * host_root_path through hostfs_destroy_inode! */
972 host_root_path = NULL;
969 973
970 err = -ENOMEM; 974 err = -ENOMEM;
971 sb->s_root = d_alloc_root(root_inode); 975 sb->s_root = d_alloc_root(root_inode);
@@ -977,7 +981,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
977 /* No iput in this case because the dput does that for us */ 981 /* No iput in this case because the dput does that for us */
978 dput(sb->s_root); 982 dput(sb->s_root);
979 sb->s_root = NULL; 983 sb->s_root = NULL;
980 goto out_free; 984 goto out;
981 } 985 }
982 986
983 return(0); 987 return(0);
@@ -985,7 +989,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
985 out_put: 989 out_put:
986 iput(root_inode); 990 iput(root_inode);
987 out_free: 991 out_free:
988 kfree(name); 992 kfree(host_root_path);
989 out: 993 out:
990 return(err); 994 return(err);
991} 995}