hostfs: convert to new aops
[safe/jmp/linux-2.6] / fs / hostfs / hostfs_kern.c
index 3aac164..8a21289 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  *
  * Ported the filesystem routines to 2.5.
@@ -20,7 +20,6 @@
 #include "hostfs.h"
 #include "kern_util.h"
 #include "kern.h"
-#include "user_util.h"
 #include "init.h"
 
 struct hostfs_inode_info {
@@ -32,14 +31,14 @@ struct hostfs_inode_info {
 
 static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
 {
-       return(list_entry(inode, struct hostfs_inode_info, vfs_inode));
+       return list_entry(inode, struct hostfs_inode_info, vfs_inode);
 }
 
-#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_dentry->d_inode)
+#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode)
 
 int hostfs_d_delete(struct dentry *dentry)
 {
-       return(1);
+       return 1;
 }
 
 struct dentry_operations hostfs_dentry_ops = {
@@ -47,14 +46,14 @@ struct dentry_operations hostfs_dentry_ops = {
 };
 
 /* Changed in hostfs_args before the kernel starts running */
-static char *root_ino = "/";
+static char *root_ino = "";
 static int append = 0;
 
 #define HOSTFS_SUPER_MAGIC 0x00c0ffee
 
-static struct inode_operations hostfs_iops;
-static struct inode_operations hostfs_dir_iops;
-static struct address_space_operations hostfs_link_aops;
+static const struct inode_operations hostfs_iops;
+static const struct inode_operations hostfs_dir_iops;
+static const struct address_space_operations hostfs_link_aops;
 
 #ifndef MODULE
 static int __init hostfs_args(char *options, int *add)
@@ -80,7 +79,7 @@ static int __init hostfs_args(char *options, int *add)
                }
                options = ptr;
        }
-       return(0);
+       return 0;
 }
 
 __uml_setup("hostfs=", hostfs_args,
@@ -111,7 +110,8 @@ static char *dentry_name(struct dentry *dentry, int extra)
        root = HOSTFS_I(parent->d_inode)->host_filename;
        len += strlen(root);
        name = kmalloc(len + extra + 1, GFP_KERNEL);
-       if(name == NULL) return(NULL);
+       if(name == NULL)
+               return NULL;
 
        name[len] = '\0';
        parent = dentry;
@@ -123,7 +123,7 @@ static char *dentry_name(struct dentry *dentry, int extra)
                parent = parent->d_parent;
        }
        strncpy(name, root, strlen(root));
-       return(name);
+       return name;
 }
 
 static char *inode_name(struct inode *ino, int extra)
@@ -131,7 +131,7 @@ static char *inode_name(struct inode *ino, int extra)
        struct dentry *dentry;
 
        dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
-       return(dentry_name(dentry, extra));
+       return dentry_name(dentry, extra);
 }
 
 static int read_name(struct inode *ino, char *name)
@@ -148,17 +148,16 @@ static int read_name(struct inode *ino, char *name)
 
        err = stat_file(name, &i_ino, &i_mode, &i_nlink, &ino->i_uid,
                        &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime,
-                       &ino->i_ctime, &i_blksize, &i_blocks);
+                       &ino->i_ctime, &i_blksize, &i_blocks, -1);
        if(err)
-               return(err);
+               return err;
 
        ino->i_ino = i_ino;
        ino->i_mode = i_mode;
        ino->i_nlink = i_nlink;
        ino->i_size = i_size;
-       ino->i_blksize = i_blksize;
        ino->i_blocks = i_blocks;
-       return(0);
+       return 0;
 }
 
 static char *follow_link(char *link)
@@ -183,11 +182,11 @@ static char *follow_link(char *link)
                goto out_free;
 
        if(*name == '/')
-               return(name);
+               return name;
 
        end = strrchr(link, '/');
        if(end == NULL)
-               return(name);
+               return name;
 
        *(end + 1) = '\0';
        len = strlen(link) + strlen(name) + 1;
@@ -201,12 +200,12 @@ static char *follow_link(char *link)
        sprintf(resolved, "%s%s", link, name);
        kfree(name);
        kfree(link);
-       return(resolved);
+       return resolved;
 
  out_free:
        kfree(name);
  out:
-       return(ERR_PTR(n));
+       return ERR_PTR(n);
 }
 
 static int read_inode(struct inode *ino)
@@ -236,10 +235,10 @@ static int read_inode(struct inode *ino)
        err = read_name(ino, name);
        kfree(name);
  out:
-       return(err);
+       return err;
 }
 
-int hostfs_statfs(struct super_block *sb, struct kstatfs *sf)
+int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
 {
        /* do_statfs uses struct statfs64 internally, but the linux kernel
         * struct statfs still has 32-bit versions for most of these fields,
@@ -252,18 +251,19 @@ int hostfs_statfs(struct super_block *sb, struct kstatfs *sf)
        long long f_files;
        long long f_ffree;
 
-       err = do_statfs(HOSTFS_I(sb->s_root->d_inode)->host_filename,
+       err = do_statfs(HOSTFS_I(dentry->d_sb->s_root->d_inode)->host_filename,
                        &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
                        &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
                        &sf->f_namelen, sf->f_spare);
-       if(err) return(err);
+       if(err)
+               return err;
        sf->f_blocks = f_blocks;
        sf->f_bfree = f_bfree;
        sf->f_bavail = f_bavail;
        sf->f_files = f_files;
        sf->f_ffree = f_ffree;
        sf->f_type = HOSTFS_SUPER_MAGIC;
-       return(0);
+       return 0;
 }
 
 static struct inode *hostfs_alloc_inode(struct super_block *sb)
@@ -272,13 +272,13 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb)
 
        hi = kmalloc(sizeof(*hi), GFP_KERNEL);
        if(hi == NULL)
-               return(NULL);
+               return NULL;
 
        *hi = ((struct hostfs_inode_info) { .host_filename      = NULL,
                                            .fd                 = -1,
                                            .mode               = 0 });
        inode_init_once(&hi->vfs_inode);
-       return(&hi->vfs_inode);
+       return &hi->vfs_inode;
 }
 
 static void hostfs_delete_inode(struct inode *inode)
@@ -310,7 +310,7 @@ static void hostfs_read_inode(struct inode *inode)
        read_inode(inode);
 }
 
-static struct super_operations hostfs_sbops = {
+static const struct super_operations hostfs_sbops = {
        .alloc_inode    = hostfs_alloc_inode,
        .drop_inode     = generic_delete_inode,
        .delete_inode   = hostfs_delete_inode,
@@ -326,11 +326,13 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
        unsigned long long next, ino;
        int error, len;
 
-       name = dentry_name(file->f_dentry, 0);
-       if(name == NULL) return(-ENOMEM);
+       name = dentry_name(file->f_path.dentry, 0);
+       if(name == NULL)
+               return -ENOMEM;
        dir = open_dir(name, &error);
        kfree(name);
-       if(dir == NULL) return(-error);
+       if(dir == NULL)
+               return -error;
        next = file->f_pos;
        while((name = read_dir(dir, &next, &ino, &len)) != NULL){
                error = (*filldir)(ent, name, len, file->f_pos,
@@ -339,7 +341,7 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
                file->f_pos = next;
        }
        close_dir(dir);
-       return(0);
+       return 0;
 }
 
 int hostfs_file_open(struct inode *ino, struct file *file)
@@ -349,7 +351,7 @@ int hostfs_file_open(struct inode *ino, struct file *file)
 
        mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
        if((mode & HOSTFS_I(ino)->mode) == mode)
-               return(0);
+               return 0;
 
        /* The file may already have been opened, but with the wrong access,
         * so this resets things and reopens the file with the new access.
@@ -367,16 +369,17 @@ int hostfs_file_open(struct inode *ino, struct file *file)
        if(w)
                r = 1;
 
-       name = dentry_name(file->f_dentry, 0);
+       name = dentry_name(file->f_path.dentry, 0);
        if(name == NULL)
-               return(-ENOMEM);
+               return -ENOMEM;
 
        fd = open_file(name, r, w, append);
        kfree(name);
-       if(fd < 0) return(fd);
+       if(fd < 0)
+               return fd;
        FILE_HOSTFS_I(file)->fd = fd;
 
-       return(0);
+       return 0;
 }
 
 int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
@@ -384,22 +387,20 @@ int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
        return fsync_file(HOSTFS_I(dentry->d_inode)->fd, datasync);
 }
 
-static struct file_operations hostfs_file_fops = {
+static const struct file_operations hostfs_file_fops = {
        .llseek         = generic_file_llseek,
-       .read           = generic_file_read,
-       .sendfile       = generic_file_sendfile,
+       .read           = do_sync_read,
+       .splice_read    = generic_file_splice_read,
        .aio_read       = generic_file_aio_read,
        .aio_write      = generic_file_aio_write,
-       .readv          = generic_file_readv,
-       .writev         = generic_file_writev,
-       .write          = generic_file_write,
+       .write          = do_sync_write,
        .mmap           = generic_file_mmap,
        .open           = hostfs_file_open,
        .release        = NULL,
        .fsync          = hostfs_fsync,
 };
 
-static struct file_operations hostfs_dir_fops = {
+static const struct file_operations hostfs_dir_fops = {
        .llseek         = generic_file_llseek,
        .readdir        = hostfs_readdir,
        .read           = generic_read_dir,
@@ -462,63 +463,54 @@ int hostfs_readpage(struct file *file, struct page *page)
  out:
        kunmap(page);
        unlock_page(page);
-       return(err);
+       return err;
 }
 
-int hostfs_prepare_write(struct file *file, struct page *page,
-                        unsigned int from, unsigned int to)
+int hostfs_write_begin(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned flags,
+                       struct page **pagep, void **fsdata)
 {
-       char *buffer;
-       long long start, tmp;
-       int err;
+       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
 
-       start = (long long) page->index << PAGE_CACHE_SHIFT;
-       buffer = kmap(page);
-       if(from != 0){
-               tmp = start;
-               err = read_file(FILE_HOSTFS_I(file)->fd, &tmp, buffer,
-                               from);
-               if(err < 0) goto out;
-       }
-       if(to != PAGE_CACHE_SIZE){
-               start += to;
-               err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer + to,
-                               PAGE_CACHE_SIZE - to);
-               if(err < 0) goto out;
-       }
-       err = 0;
- out:
-       kunmap(page);
-       return(err);
+       *pagep = __grab_cache_page(mapping, index);
+       if (!*pagep)
+               return -ENOMEM;
+       return 0;
 }
 
-int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
-                unsigned to)
+int hostfs_write_end(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned copied,
+                       struct page *page, void *fsdata)
 {
-       struct address_space *mapping = page->mapping;
        struct inode *inode = mapping->host;
-       char *buffer;
-       long long start;
-       int err = 0;
+       void *buffer;
+       unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+       int err;
 
-       start = (long long) (page->index << PAGE_CACHE_SHIFT) + from;
        buffer = kmap(page);
-       err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from,
-                        to - from);
-       if(err > 0) err = 0;
-       if(!err && (start > inode->i_size))
-               inode->i_size = start;
-
+       err = write_file(FILE_HOSTFS_I(file)->fd, &pos, buffer + from, copied);
        kunmap(page);
-       return(err);
+
+       if (!PageUptodate(page) && err == PAGE_CACHE_SIZE)
+               SetPageUptodate(page);
+
+       /* If err > 0, write_file has added err to pos, so we are comparing
+        * i_size against the last byte written.
+        */
+       if (err > 0 && (pos > inode->i_size))
+               inode->i_size = pos;
+       unlock_page(page);
+       page_cache_release(page);
+
+       return err;
 }
 
-static struct address_space_operations hostfs_aops = {
+static const struct address_space_operations hostfs_aops = {
        .writepage      = hostfs_writepage,
        .readpage       = hostfs_readpage,
        .set_page_dirty = __set_page_dirty_nobuffers,
-       .prepare_write  = hostfs_prepare_write,
-       .commit_write   = hostfs_commit_write
+       .write_begin    = hostfs_write_begin,
+       .write_end      = hostfs_write_end,
 };
 
 static int init_inode(struct inode *inode, struct dentry *dentry)
@@ -568,7 +560,7 @@ static int init_inode(struct inode *inode, struct dentry *dentry)
                break;
        }
  out:
-       return(err);
+       return err;
 }
 
 int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
@@ -606,16 +598,16 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
        HOSTFS_I(inode)->fd = fd;
        HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE;
        d_instantiate(dentry, inode);
-       return(0);
+       return 0;
 
  out_put:
        iput(inode);
  out:
-       return(error);
+       return error;
 }
 
 struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
-                            struct nameidata *nd)
+                            struct nameidata *nd)
 {
        struct inode *inode;
        char *name;
@@ -646,44 +638,45 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
 
        d_add(dentry, inode);
        dentry->d_op = &hostfs_dentry_ops;
-       return(NULL);
+       return NULL;
 
  out_put:
        iput(inode);
  out:
-       return(ERR_PTR(err));
+       return ERR_PTR(err);
 }
 
 static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
 {
-        char *file;
+       char *file;
        int len;
 
        file = inode_name(ino, dentry->d_name.len + 1);
-       if(file == NULL) return(NULL);
-        strcat(file, "/");
+       if(file == NULL)
+               return NULL;
+       strcat(file, "/");
        len = strlen(file);
-        strncat(file, dentry->d_name.name, dentry->d_name.len);
+       strncat(file, dentry->d_name.name, dentry->d_name.len);
        file[len + dentry->d_name.len] = '\0';
-        return(file);
+       return file;
 }
 
 int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
 {
-        char *from_name, *to_name;
-        int err;
+       char *from_name, *to_name;
+       int err;
 
-        if((from_name = inode_dentry_name(ino, from)) == NULL)
-                return(-ENOMEM);
-        to_name = dentry_name(to, 0);
+       if((from_name = inode_dentry_name(ino, from)) == NULL)
+               return -ENOMEM;
+       to_name = dentry_name(to, 0);
        if(to_name == NULL){
                kfree(from_name);
-               return(-ENOMEM);
+               return -ENOMEM;
        }
-        err = link_file(to_name, from_name);
-        kfree(from_name);
-        kfree(to_name);
-        return(err);
+       err = link_file(to_name, from_name);
+       kfree(from_name);
+       kfree(to_name);
+       return err;
 }
 
 int hostfs_unlink(struct inode *ino, struct dentry *dentry)
@@ -691,13 +684,14 @@ int hostfs_unlink(struct inode *ino, struct dentry *dentry)
        char *file;
        int err;
 
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
+       if((file = inode_dentry_name(ino, dentry)) == NULL)
+               return -ENOMEM;
        if(append)
-               return(-EPERM);
+               return -EPERM;
 
        err = unlink_file(file);
        kfree(file);
-       return(err);
+       return err;
 }
 
 int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
@@ -705,10 +699,11 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
        char *file;
        int err;
 
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
+       if((file = inode_dentry_name(ino, dentry)) == NULL)
+               return -ENOMEM;
        err = make_symlink(file, to);
        kfree(file);
-       return(err);
+       return err;
 }
 
 int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
@@ -716,10 +711,11 @@ int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
        char *file;
        int err;
 
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
+       if((file = inode_dentry_name(ino, dentry)) == NULL)
+               return -ENOMEM;
        err = do_mkdir(file, mode);
        kfree(file);
-       return(err);
+       return err;
 }
 
 int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
@@ -727,10 +723,11 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
        char *file;
        int err;
 
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
+       if((file = inode_dentry_name(ino, dentry)) == NULL)
+               return -ENOMEM;
        err = do_rmdir(file);
        kfree(file);
-       return(err);
+       return err;
 }
 
 int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
@@ -753,7 +750,7 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
                goto out_put;
 
        init_special_inode(inode, mode, dev);
-       err = do_mknod(name, mode, dev);
+       err = do_mknod(name, mode, MAJOR(dev), MINOR(dev));
        if(err)
                goto out_free;
 
@@ -763,14 +760,14 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
                goto out_put;
 
        d_instantiate(dentry, inode);
-       return(0);
+       return 0;
 
  out_free:
        kfree(name);
  out_put:
        iput(inode);
  out:
-       return(err);
+       return err;
 }
 
 int hostfs_rename(struct inode *from_ino, struct dentry *from,
@@ -780,15 +777,15 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
        int err;
 
        if((from_name = inode_dentry_name(from_ino, from)) == NULL)
-               return(-ENOMEM);
+               return -ENOMEM;
        if((to_name = inode_dentry_name(to_ino, to)) == NULL){
                kfree(from_name);
-               return(-ENOMEM);
+               return -ENOMEM;
        }
        err = rename_file(from_name, to_name);
        kfree(from_name);
        kfree(to_name);
-       return(err);
+       return err;
 }
 
 int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
@@ -800,7 +797,8 @@ int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
        if (desired & MAY_WRITE) w = 1;
        if (desired & MAY_EXEC) x = 1;
        name = inode_name(ino, 0);
-       if (name == NULL) return(-ENOMEM);
+       if (name == NULL)
+               return -ENOMEM;
 
        if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) ||
                        S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode))
@@ -819,6 +817,8 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
        char *name;
        int err;
 
+       int fd = HOSTFS_I(dentry->d_inode)->fd;
+
        err = inode_change_ok(dentry->d_inode, attr);
        if (err)
                return err;
@@ -862,23 +862,24 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
                attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
        }
        name = dentry_name(dentry, 0);
-       if(name == NULL) return(-ENOMEM);
-       err = set_attr(name, &attrs);
+       if(name == NULL)
+               return -ENOMEM;
+       err = set_attr(name, &attrs, fd);
        kfree(name);
        if(err)
-               return(err);
+               return err;
 
-       return(inode_setattr(dentry->d_inode, attr));
+       return inode_setattr(dentry->d_inode, attr);
 }
 
 int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
           struct kstat *stat)
 {
        generic_fillattr(dentry->d_inode, stat);
-       return(0);
+       return 0;
 }
 
-static struct inode_operations hostfs_iops = {
+static const struct inode_operations hostfs_iops = {
        .create         = hostfs_create,
        .link           = hostfs_link,
        .unlink         = hostfs_unlink,
@@ -892,7 +893,7 @@ static struct inode_operations hostfs_iops = {
        .getattr        = hostfs_getattr,
 };
 
-static struct inode_operations hostfs_dir_iops = {
+static const struct inode_operations hostfs_dir_iops = {
        .create         = hostfs_create,
        .lookup         = hostfs_lookup,
        .link           = hostfs_link,
@@ -914,7 +915,8 @@ int hostfs_link_readpage(struct file *file, struct page *page)
 
        buffer = kmap(page);
        name = inode_name(page->mapping->host, 0);
-       if(name == NULL) return(-ENOMEM);
+       if(name == NULL)
+               return -ENOMEM;
        err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
        kfree(name);
        if(err == PAGE_CACHE_SIZE)
@@ -927,17 +929,17 @@ int hostfs_link_readpage(struct file *file, struct page *page)
        }
        kunmap(page);
        unlock_page(page);
-       return(err);
+       return err;
 }
 
-static struct address_space_operations hostfs_link_aops = {
+static const struct address_space_operations hostfs_link_aops = {
        .readpage       = hostfs_link_readpage,
 };
 
 static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
 {
        struct inode *root_inode;
-       char *name, *data = d;
+       char *host_root_path, *req_root = d;
        int err;
 
        sb->s_blocksize = 1024;
@@ -945,15 +947,17 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
        sb->s_magic = HOSTFS_SUPER_MAGIC;
        sb->s_op = &hostfs_sbops;
 
-       if((data == NULL) || (*data == '\0'))
-               data = root_ino;
+       /* NULL is printed as <NULL> by sprintf: avoid that. */
+       if (req_root == NULL)
+               req_root = "";
 
        err = -ENOMEM;
-       name = kmalloc(strlen(data) + 1, GFP_KERNEL);
-       if(name == NULL)
+       host_root_path = kmalloc(strlen(root_ino) + 1
+                                + strlen(req_root) + 1, GFP_KERNEL);
+       if(host_root_path == NULL)
                goto out;
 
-       strcpy(name, data);
+       sprintf(host_root_path, "%s/%s", root_ino, req_root);
 
        root_inode = iget(sb, 0);
        if(root_inode == NULL)
@@ -963,7 +967,10 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
        if(err)
                goto out_put;
 
-       HOSTFS_I(root_inode)->host_filename = name;
+       HOSTFS_I(root_inode)->host_filename = host_root_path;
+       /* Avoid that in the error path, iput(root_inode) frees again
+        * host_root_path through hostfs_destroy_inode! */
+       host_root_path = NULL;
 
        err = -ENOMEM;
        sb->s_root = d_alloc_root(root_inode);
@@ -972,27 +979,27 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
 
        err = read_inode(root_inode);
        if(err){
-                /* No iput in this case because the dput does that for us */
-                dput(sb->s_root);
-                sb->s_root = NULL;
-               goto out_free;
-        }
+               /* No iput in this case because the dput does that for us */
+               dput(sb->s_root);
+               sb->s_root = NULL;
+               goto out;
+       }
 
-       return(0);
+       return 0;
 
- out_put:
-        iput(root_inode);
- out_free:
-       kfree(name);
- out:
-       return(err);
+out_put:
+       iput(root_inode);
+out_free:
+       kfree(host_root_path);
+out:
+       return err;
 }
 
-static struct super_block *hostfs_read_sb(struct file_system_type *type,
-                                            int flags, const char *dev_name,
-                                            void *data)
+static int hostfs_read_sb(struct file_system_type *type,
+                         int flags, const char *dev_name,
+                         void *data, struct vfsmount *mnt)
 {
-       return(get_sb_nodev(type, flags, data, hostfs_fill_sb_common));
+       return get_sb_nodev(type, flags, data, hostfs_fill_sb_common, mnt);
 }
 
 static struct file_system_type hostfs_type = {
@@ -1005,7 +1012,7 @@ static struct file_system_type hostfs_type = {
 
 static int __init init_hostfs(void)
 {
-       return(register_filesystem(&hostfs_type));
+       return register_filesystem(&hostfs_type);
 }
 
 static void __exit exit_hostfs(void)
@@ -1016,14 +1023,3 @@ static void __exit exit_hostfs(void)
 module_init(init_hostfs)
 module_exit(exit_hostfs)
 MODULE_LICENSE("GPL");
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */