X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=fs%2Fhostfs%2Fhostfs_kern.c;h=d0549cb4fb23640a79d0221262b14742b5c1a468;hb=f3aafa6c2535d36542a6dfc8647cd2fdb5999648;hp=c77862032e844262a199549d01ca16489b0578f8;hpb=5e16e3f0e24dadb79b96b6134cd3303f0d42f0c5;p=cascardo%2Flinux.git diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index c77862032e84..d0549cb4fb23 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -6,21 +6,15 @@ * 2003-02-10 Petr Baudis */ -#include #include #include -#include -#include +#include #include -#include -#include #include -#include -#include +#include #include "hostfs.h" -#include "kern_util.h" -#include "kern.h" #include "init.h" +#include "kern.h" struct hostfs_inode_info { char *host_filename; @@ -61,18 +55,18 @@ static int __init hostfs_args(char *options, int *add) char *ptr; ptr = strchr(options, ','); - if(ptr != NULL) + if (ptr != NULL) *ptr++ = '\0'; - if(*options != '\0') + if (*options != '\0') root_ino = options; options = ptr; - while(options){ + while (options) { ptr = strchr(options, ','); - if(ptr != NULL) + if (ptr != NULL) *ptr++ = '\0'; - if(*options != '\0'){ - if(!strcmp(options, "append")) + if (*options != '\0') { + if (!strcmp(options, "append")) append = 1; else printf("hostfs_args - unsupported option - %s\n", options); @@ -102,7 +96,7 @@ static char *dentry_name(struct dentry *dentry, int extra) len = 0; parent = dentry; - while(parent->d_parent != parent){ + while (parent->d_parent != parent) { len += parent->d_name.len + 1; parent = parent->d_parent; } @@ -110,12 +104,12 @@ 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) + if (name == NULL) return NULL; name[len] = '\0'; parent = dentry; - while(parent->d_parent != parent){ + while (parent->d_parent != parent) { len -= parent->d_name.len + 1; name[len] = '/'; strncpy(&name[len + 1], parent->d_name.name, @@ -136,7 +130,8 @@ static char *inode_name(struct inode *ino, int extra) static int read_name(struct inode *ino, char *name) { - /* The non-int inode fields are copied into ints by stat_file and + /* + * The non-int inode fields are copied into ints by stat_file and * then copied into the inode because passing the actual pointers * in and having them treated as int * breaks on big-endian machines */ @@ -149,7 +144,7 @@ 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, -1); - if(err) + if (err) return err; ino->i_ino = i_ino; @@ -166,33 +161,33 @@ static char *follow_link(char *link) char *name, *resolved, *end; len = 64; - while(1){ + while (1) { n = -ENOMEM; name = kmalloc(len, GFP_KERNEL); - if(name == NULL) + if (name == NULL) goto out; n = do_readlink(link, name, len); - if(n < len) + if (n < len) break; len *= 2; kfree(name); } - if(n < 0) + if (n < 0) goto out_free; - if(*name == '/') + if (*name == '/') return name; end = strrchr(link, '/'); - if(end == NULL) + if (end == NULL) return name; *(end + 1) = '\0'; len = strlen(link) + strlen(name) + 1; resolved = kmalloc(len, GFP_KERNEL); - if(resolved == NULL){ + if (resolved == NULL) { n = -ENOMEM; goto out_free; } @@ -208,25 +203,26 @@ static char *follow_link(char *link) return ERR_PTR(n); } -static int read_inode(struct inode *ino) +static int hostfs_read_inode(struct inode *ino) { char *name; int err = 0; - /* Unfortunately, we are called from iget() when we don't have a dentry + /* + * Unfortunately, we are called from iget() when we don't have a dentry * allocated yet. */ - if(list_empty(&ino->i_dentry)) + if (list_empty(&ino->i_dentry)) goto out; err = -ENOMEM; name = inode_name(ino, 0); - if(name == NULL) + if (name == NULL) goto out; - if(file_type(name, NULL, NULL) == OS_TYPE_SYMLINK){ + if (file_type(name, NULL, NULL) == OS_TYPE_SYMLINK) { name = follow_link(name); - if(IS_ERR(name)){ + if (IS_ERR(name)) { err = PTR_ERR(name); goto out; } @@ -238,9 +234,29 @@ static int read_inode(struct inode *ino) return err; } +static struct inode *hostfs_iget(struct super_block *sb) +{ + struct inode *inode; + long ret; + + inode = iget_locked(sb, 0); + if (!inode) + return ERR_PTR(-ENOMEM); + if (inode->i_state & I_NEW) { + ret = hostfs_read_inode(inode); + if (ret < 0) { + iget_failed(inode); + return ERR_PTR(ret); + } + unlock_new_inode(inode); + } + return inode; +} + int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) { - /* do_statfs uses struct statfs64 internally, but the linux kernel + /* + * do_statfs uses struct statfs64 internally, but the linux kernel * struct statfs still has 32-bit versions for most of these fields, * so we convert them here */ @@ -255,7 +271,7 @@ int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) &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) + if (err) return err; sf->f_blocks = f_blocks; sf->f_bfree = f_bfree; @@ -271,7 +287,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) struct hostfs_inode_info *hi; hi = kmalloc(sizeof(*hi), GFP_KERNEL); - if(hi == NULL) + if (hi == NULL) return NULL; *hi = ((struct hostfs_inode_info) { .host_filename = NULL, @@ -284,7 +300,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) static void hostfs_delete_inode(struct inode *inode) { truncate_inode_pages(&inode->i_data, 0); - if(HOSTFS_I(inode)->fd != -1) { + if (HOSTFS_I(inode)->fd != -1) { close_file(&HOSTFS_I(inode)->fd); HOSTFS_I(inode)->fd = -1; } @@ -295,9 +311,11 @@ static void hostfs_destroy_inode(struct inode *inode) { kfree(HOSTFS_I(inode)->host_filename); - /*XXX: This should not happen, probably. The check is here for - * additional safety.*/ - if(HOSTFS_I(inode)->fd != -1) { + /* + * XXX: This should not happen, probably. The check is here for + * additional safety. + */ + if (HOSTFS_I(inode)->fd != -1) { close_file(&HOSTFS_I(inode)->fd); printk(KERN_DEBUG "Closing host fd in .destroy_inode\n"); } @@ -305,9 +323,16 @@ static void hostfs_destroy_inode(struct inode *inode) kfree(HOSTFS_I(inode)); } -static void hostfs_read_inode(struct inode *inode) +static int hostfs_show_options(struct seq_file *seq, struct vfsmount *vfs) { - read_inode(inode); + struct inode *root = vfs->mnt_sb->s_root->d_inode; + const char *root_path = HOSTFS_I(root)->host_filename; + size_t offset = strlen(root_ino) + 1; + + if (strlen(root_path) > offset) + seq_printf(seq, ",%s", root_path + offset); + + return 0; } static const struct super_operations hostfs_sbops = { @@ -315,8 +340,8 @@ static const struct super_operations hostfs_sbops = { .drop_inode = generic_delete_inode, .delete_inode = hostfs_delete_inode, .destroy_inode = hostfs_destroy_inode, - .read_inode = hostfs_read_inode, .statfs = hostfs_statfs, + .show_options = hostfs_show_options, }; int hostfs_readdir(struct file *file, void *ent, filldir_t filldir) @@ -327,17 +352,17 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir) int error, len; name = dentry_name(file->f_path.dentry, 0); - if(name == NULL) + if (name == NULL) return -ENOMEM; dir = open_dir(name, &error); kfree(name); - if(dir == NULL) + if (dir == NULL) return -error; next = file->f_pos; - while((name = read_dir(dir, &next, &ino, &len)) != NULL){ + while ((name = read_dir(dir, &next, &ino, &len)) != NULL) { error = (*filldir)(ent, name, len, file->f_pos, ino, DT_UNKNOWN); - if(error) break; + if (error) break; file->f_pos = next; } close_dir(dir); @@ -350,32 +375,33 @@ int hostfs_file_open(struct inode *ino, struct file *file) int mode = 0, r = 0, w = 0, fd; mode = file->f_mode & (FMODE_READ | FMODE_WRITE); - if((mode & HOSTFS_I(ino)->mode) == mode) + if ((mode & HOSTFS_I(ino)->mode) == mode) return 0; - /* The file may already have been opened, but with the wrong access, + /* + * The file may already have been opened, but with the wrong access, * so this resets things and reopens the file with the new access. */ - if(HOSTFS_I(ino)->fd != -1){ + if (HOSTFS_I(ino)->fd != -1) { close_file(&HOSTFS_I(ino)->fd); HOSTFS_I(ino)->fd = -1; } HOSTFS_I(ino)->mode |= mode; - if(HOSTFS_I(ino)->mode & FMODE_READ) + if (HOSTFS_I(ino)->mode & FMODE_READ) r = 1; - if(HOSTFS_I(ino)->mode & FMODE_WRITE) + if (HOSTFS_I(ino)->mode & FMODE_WRITE) w = 1; - if(w) + if (w) r = 1; name = dentry_name(file->f_path.dentry, 0); - if(name == NULL) + if (name == NULL) return -ENOMEM; fd = open_file(name, r, w, append); kfree(name); - if(fd < 0) + if (fd < 0) return fd; FILE_HOSTFS_I(file)->fd = fd; @@ -423,7 +449,7 @@ int hostfs_writepage(struct page *page, struct writeback_control *wbc) base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT; err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count); - if(err != count){ + if (err != count) { ClearPageUptodate(page); goto out; } @@ -452,7 +478,8 @@ int hostfs_readpage(struct file *file, struct page *page) buffer = kmap(page); err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer, PAGE_CACHE_SIZE); - if(err < 0) goto out; + if (err < 0) + goto out; memset(&buffer[err], 0, PAGE_CACHE_SIZE - err); @@ -466,56 +493,43 @@ int hostfs_readpage(struct file *file, struct page *page) 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; + err = write_file(FILE_HOSTFS_I(file)->fd, &pos, buffer + from, copied); + kunmap(page); - /* Actually, if !err, write_file has added to-from to start, so, despite - * the appearance, we are comparing i_size against the _last_ written - * location, as we should. */ + if (!PageUptodate(page) && err == PAGE_CACHE_SIZE) + SetPageUptodate(page); - if(!err && (start > inode->i_size)) - inode->i_size = start; + /* + * 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); - kunmap(page); return err; } @@ -523,8 +537,8 @@ 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) @@ -534,28 +548,28 @@ static int init_inode(struct inode *inode, struct dentry *dentry) int maj, min; dev_t rdev = 0; - if(dentry){ + if (dentry) { name = dentry_name(dentry, 0); - if(name == NULL) + if (name == NULL) goto out; type = file_type(name, &maj, &min); - /*Reencode maj and min with the kernel encoding.*/ + /* Reencode maj and min with the kernel encoding.*/ rdev = MKDEV(maj, min); kfree(name); } else type = OS_TYPE_DIR; err = 0; - if(type == OS_TYPE_SYMLINK) + if (type == OS_TYPE_SYMLINK) inode->i_op = &page_symlink_inode_operations; - else if(type == OS_TYPE_DIR) + else if (type == OS_TYPE_DIR) inode->i_op = &hostfs_dir_iops; else inode->i_op = &hostfs_iops; - if(type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops; + if (type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops; else inode->i_fop = &hostfs_file_fops; - if(type == OS_TYPE_SYMLINK) + if (type == OS_TYPE_SYMLINK) inode->i_mapping->a_ops = &hostfs_link_aops; else inode->i_mapping->a_ops = &hostfs_aops; @@ -578,35 +592,37 @@ static int init_inode(struct inode *inode, struct dentry *dentry) } int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, - struct nameidata *nd) + struct nameidata *nd) { struct inode *inode; char *name; int error, fd; - error = -ENOMEM; - inode = iget(dir->i_sb, 0); - if(inode == NULL) goto out; + inode = hostfs_iget(dir->i_sb); + if (IS_ERR(inode)) { + error = PTR_ERR(inode); + goto out; + } error = init_inode(inode, dentry); - if(error) + if (error) goto out_put; error = -ENOMEM; name = dentry_name(dentry, 0); - if(name == NULL) + if (name == NULL) goto out_put; fd = file_create(name, mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH); - if(fd < 0) + if (fd < 0) error = fd; else error = read_name(inode, name); kfree(name); - if(error) + if (error) goto out_put; HOSTFS_I(inode)->fd = fd; @@ -627,27 +643,28 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, char *name; int err; - err = -ENOMEM; - inode = iget(ino->i_sb, 0); - if(inode == NULL) + inode = hostfs_iget(ino->i_sb); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); goto out; + } err = init_inode(inode, dentry); - if(err) + if (err) goto out_put; err = -ENOMEM; name = dentry_name(dentry, 0); - if(name == NULL) + if (name == NULL) goto out_put; err = read_name(inode, name); kfree(name); - if(err == -ENOENT){ + if (err == -ENOENT) { iput(inode); inode = NULL; } - else if(err) + else if (err) goto out_put; d_add(dentry, inode); @@ -666,7 +683,7 @@ static char *inode_dentry_name(struct inode *ino, struct dentry *dentry) int len; file = inode_name(ino, dentry->d_name.len + 1); - if(file == NULL) + if (file == NULL) return NULL; strcat(file, "/"); len = strlen(file); @@ -680,10 +697,10 @@ int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from) char *from_name, *to_name; int err; - if((from_name = inode_dentry_name(ino, from)) == NULL) + if ((from_name = inode_dentry_name(ino, from)) == NULL) return -ENOMEM; to_name = dentry_name(to, 0); - if(to_name == NULL){ + if (to_name == NULL) { kfree(from_name); return -ENOMEM; } @@ -698,9 +715,9 @@ int hostfs_unlink(struct inode *ino, struct dentry *dentry) char *file; int err; - if((file = inode_dentry_name(ino, dentry)) == NULL) + if ((file = inode_dentry_name(ino, dentry)) == NULL) return -ENOMEM; - if(append) + if (append) return -EPERM; err = unlink_file(file); @@ -713,7 +730,7 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to) char *file; int err; - if((file = inode_dentry_name(ino, dentry)) == NULL) + if ((file = inode_dentry_name(ino, dentry)) == NULL) return -ENOMEM; err = make_symlink(file, to); kfree(file); @@ -725,7 +742,7 @@ int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode) char *file; int err; - if((file = inode_dentry_name(ino, dentry)) == NULL) + if ((file = inode_dentry_name(ino, dentry)) == NULL) return -ENOMEM; err = do_mkdir(file, mode); kfree(file); @@ -737,7 +754,7 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry) char *file; int err; - if((file = inode_dentry_name(ino, dentry)) == NULL) + if ((file = inode_dentry_name(ino, dentry)) == NULL) return -ENOMEM; err = do_rmdir(file); kfree(file); @@ -748,29 +765,31 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { struct inode *inode; char *name; - int err = -ENOMEM; + int err; - inode = iget(dir->i_sb, 0); - if(inode == NULL) + inode = hostfs_iget(dir->i_sb); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); goto out; + } err = init_inode(inode, dentry); - if(err) + if (err) goto out_put; err = -ENOMEM; name = dentry_name(dentry, 0); - if(name == NULL) + if (name == NULL) goto out_put; init_special_inode(inode, mode, dev); err = do_mknod(name, mode, MAJOR(dev), MINOR(dev)); - if(err) + if (err) goto out_free; err = read_name(inode, name); kfree(name); - if(err) + if (err) goto out_put; d_instantiate(dentry, inode); @@ -790,9 +809,9 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from, char *from_name, *to_name; int err; - if((from_name = inode_dentry_name(from_ino, from)) == NULL) + if ((from_name = inode_dentry_name(from_ino, from)) == NULL) return -ENOMEM; - if((to_name = inode_dentry_name(to_ino, to)) == NULL){ + if ((to_name = inode_dentry_name(to_ino, to)) == NULL) { kfree(from_name); return -ENOMEM; } @@ -815,12 +834,12 @@ int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) return -ENOMEM; if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) || - S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode)) + S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode)) err = 0; else err = access_file(name, r, w, x); kfree(name); - if(!err) + if (!err) err = generic_permission(ino, desired, NULL); return err; } @@ -837,62 +856,55 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr) if (err) return err; - if(append) + if (append) attr->ia_valid &= ~ATTR_SIZE; attrs.ia_valid = 0; - if(attr->ia_valid & ATTR_MODE){ + if (attr->ia_valid & ATTR_MODE) { attrs.ia_valid |= HOSTFS_ATTR_MODE; attrs.ia_mode = attr->ia_mode; } - if(attr->ia_valid & ATTR_UID){ + if (attr->ia_valid & ATTR_UID) { attrs.ia_valid |= HOSTFS_ATTR_UID; attrs.ia_uid = attr->ia_uid; } - if(attr->ia_valid & ATTR_GID){ + if (attr->ia_valid & ATTR_GID) { attrs.ia_valid |= HOSTFS_ATTR_GID; attrs.ia_gid = attr->ia_gid; } - if(attr->ia_valid & ATTR_SIZE){ + if (attr->ia_valid & ATTR_SIZE) { attrs.ia_valid |= HOSTFS_ATTR_SIZE; attrs.ia_size = attr->ia_size; } - if(attr->ia_valid & ATTR_ATIME){ + if (attr->ia_valid & ATTR_ATIME) { attrs.ia_valid |= HOSTFS_ATTR_ATIME; attrs.ia_atime = attr->ia_atime; } - if(attr->ia_valid & ATTR_MTIME){ + if (attr->ia_valid & ATTR_MTIME) { attrs.ia_valid |= HOSTFS_ATTR_MTIME; attrs.ia_mtime = attr->ia_mtime; } - if(attr->ia_valid & ATTR_CTIME){ + if (attr->ia_valid & ATTR_CTIME) { attrs.ia_valid |= HOSTFS_ATTR_CTIME; attrs.ia_ctime = attr->ia_ctime; } - if(attr->ia_valid & ATTR_ATIME_SET){ + if (attr->ia_valid & ATTR_ATIME_SET) { attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET; } - if(attr->ia_valid & ATTR_MTIME_SET){ + if (attr->ia_valid & ATTR_MTIME_SET) { attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET; } name = dentry_name(dentry, 0); - if(name == NULL) + if (name == NULL) return -ENOMEM; err = set_attr(name, &attrs, fd); kfree(name); - if(err) + if (err) return err; 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; -} - static const struct inode_operations hostfs_iops = { .create = hostfs_create, .link = hostfs_link, @@ -904,7 +916,6 @@ static const struct inode_operations hostfs_iops = { .rename = hostfs_rename, .permission = hostfs_permission, .setattr = hostfs_setattr, - .getattr = hostfs_getattr, }; static const struct inode_operations hostfs_dir_iops = { @@ -919,7 +930,6 @@ static const struct inode_operations hostfs_dir_iops = { .rename = hostfs_rename, .permission = hostfs_permission, .setattr = hostfs_setattr, - .getattr = hostfs_getattr, }; int hostfs_link_readpage(struct file *file, struct page *page) @@ -929,13 +939,13 @@ int hostfs_link_readpage(struct file *file, struct page *page) buffer = kmap(page); name = inode_name(page->mapping->host, 0); - if(name == NULL) + if (name == NULL) return -ENOMEM; err = do_readlink(name, buffer, PAGE_CACHE_SIZE); kfree(name); - if(err == PAGE_CACHE_SIZE) + if (err == PAGE_CACHE_SIZE) err = -E2BIG; - else if(err > 0){ + else if (err > 0) { flush_dcache_page(page); SetPageUptodate(page); if (PageError(page)) ClearPageError(page); @@ -968,31 +978,35 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) err = -ENOMEM; host_root_path = kmalloc(strlen(root_ino) + 1 + strlen(req_root) + 1, GFP_KERNEL); - if(host_root_path == NULL) + if (host_root_path == NULL) goto out; sprintf(host_root_path, "%s/%s", root_ino, req_root); - root_inode = iget(sb, 0); - if(root_inode == NULL) + root_inode = hostfs_iget(sb); + if (IS_ERR(root_inode)) { + err = PTR_ERR(root_inode); goto out_free; + } err = init_inode(root_inode, NULL); - if(err) + if (err) goto out_put; 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! */ + /* + * 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); - if(sb->s_root == NULL) + if (sb->s_root == NULL) goto out_put; - err = read_inode(root_inode); - if(err){ + err = hostfs_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;