Index: linux-2.6.17/fs/externfs/externfs.c =================================================================== --- linux-2.6.17.orig/fs/externfs/externfs.c 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/externfs.c 2007-11-19 20:02:47.000000000 -0500 @@ -1,26 +1,18 @@ /* - * Copyright (C) 2000 - 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include #include -#include -#include -#include +#include +#include #include -#include -#include #include -#include +#include +#include #include -#include -#include +#include #include "hostfs.h" -#include "kern_util.h" -#include "kern.h" -#include "mem.h" -#include "filehandle.h" struct externfs { struct list_head list; @@ -49,18 +41,18 @@ static char *dentry_name(struct dentry * len = 0; parent = dentry; - while(parent->d_parent != parent){ + while (parent->d_parent != parent) { len += parent->d_name.len + 1; parent = parent->d_parent; } name = kmalloc(len + extra + 1, GFP_KERNEL); - if(name == NULL) + if (name == NULL) return ERR_PTR(-ENOMEM); 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, @@ -75,7 +67,7 @@ static char *inode_name(struct inode *in { struct dentry *dentry; - if(list_empty(&ino->i_dentry)) + if (list_empty(&ino->i_dentry)) return ERR_PTR(-ENOENT); dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias); @@ -90,7 +82,7 @@ char *externfs_name_prefix(struct extern len = strlen(prefix); name = inode_name(inode, len); - if(IS_ERR(name)) + if (IS_ERR(name)) return name; memmove(&name[len], name, strlen(name) + 1); @@ -104,7 +96,7 @@ static char *inode_dentry_name(struct in int len; file = inode_name(ino, dentry->d_name.len + 1); - if(IS_ERR(file)) + if (IS_ERR(file)) return file; strcat(file, "/"); @@ -114,7 +106,8 @@ static char *inode_dentry_name(struct in return file; } -/* Directory removal is deferred to here, when the dentry is finally +/* + * Directory removal is deferred to here, when the dentry is finally * dropped, rather than when ->rmdir is called because some process * may be cd-ed into it, in which case, it shouldn't be removed. It * can be removed at this point because switching to a new directory @@ -128,22 +121,22 @@ static int externfs_delete_dentry(struct char *file; int err; - if((inode == NULL) || !(inode->i_mode & S_IFDIR) || + if ((inode == NULL) || !(inode->i_mode & S_IFDIR) || (inode->i_nlink != 0)) return 0; ed = inode->i_sb->s_fs_info; ops = EXTERNFS_I(inode)->ops; file = dentry_name(dentry, 0); - if(IS_ERR(file)){ - printk("externfs_delete_dentry - didn't get file name, " - "err = %lu\n", PTR_ERR(file)); + if (IS_ERR(file)) { + printk(KERN_ERR "externfs_delete_dentry - didn't get file " + "name, err = %lu\n", PTR_ERR(file)); return 1; } err = (*ops->remove_dir)(file, ed); - if(err) - printk("externfs_delete_dentry - ->remove_dir failed, " + if (err) + printk(KERN_ERR "externfs_delete_dentry - ->remove_dir failed, " "err = %d\n", err); return 1; @@ -174,7 +167,8 @@ static void copy_inode_info(struct inode ino->i_size = info->size; ino->i_blocks = info->blocks; - /* atime is set automatically by the host, so there's no need to + /* + * atime is set automatically by the host, so there's no need to * sync it out ourselves. */ ino->i_flags |= S_NOATIME; @@ -198,19 +192,19 @@ static int externfs_readdir(struct file struct externfs_data *ed = file->f_path.dentry->d_inode->i_sb->s_fs_info; name = dentry_name(file->f_path.dentry, 0); - if(IS_ERR(name)) + if (IS_ERR(name)) return PTR_ERR(name); dir = (*ops->open_dir)(name, current->fsuid, current->fsgid, ed); kfree(name); - if(IS_ERR(dir)) + if (IS_ERR(dir)) return PTR_ERR(dir); next = file->f_pos; - while((name = (*ops->read_dir)(dir, &next, &ino, &len, ed)) != NULL){ + while ((name = (*ops->read_dir)(dir, &next, &ino, &len, ed)) != NULL) { error = (*filldir)(ent, name, len, file->f_pos, ino, DT_UNKNOWN); - if(error) + if (error) break; file->f_pos = next; } @@ -231,9 +225,9 @@ static void externfs_finish_writepage(ch { struct wp_info *wp = arg; - if(res == wp->count){ + if (res == wp->count) { ClearPageError(wp->page); - if(wp->start + res > wp->size) + if (wp->start + res > wp->size) (*wp->truncate)(wp->ei, wp->size); } else { @@ -269,7 +263,7 @@ static int externfs_writepage(struct pag err = -ENOMEM; wp = kmalloc(sizeof(*wp), GFP_KERNEL); - if(wp == NULL) + if (wp == NULL) goto out_unlock; *wp = ((struct wp_info) { .page = page, @@ -295,13 +289,13 @@ static void externfs_finish_readpage(cha struct page *page = arg; struct inode *inode; - if(res < 0){ + if (res < 0) { SetPageError(page); goto out; } inode = page->mapping->host; - if(inode->i_size >> PAGE_CACHE_SHIFT == page->index) + if (inode->i_size >> PAGE_CACHE_SHIFT == page->index) res = inode->i_size % PAGE_CACHE_SIZE; memset(&buffer[res], 0, PAGE_CACHE_SIZE - res); @@ -326,19 +320,19 @@ static int externfs_readpage(struct file start = (long long) page->index << PAGE_CACHE_SHIFT; buffer = kmap(page); - if(ops->map_file_page != NULL){ + if (ops->map_file_page != NULL) { /* XXX What happens when PAGE_SIZE != PAGE_CACHE_SIZE? */ err = (*ops->map_file_page)(file_externfs_i(file), start, buffer, file->f_mode & FMODE_WRITE); - if(!err) + if (!err) err = PAGE_CACHE_SIZE; } else err = (*ops->read_file)(file_externfs_i(file), start, buffer, PAGE_CACHE_SIZE, 0, 0, externfs_finish_readpage, page); - if(err > 0) + if (err > 0) err = 0; return err; } @@ -379,7 +373,7 @@ int externfs_prepare_write(struct file * return 0; buffer = kmap(page); - if(ops->map_file_page != NULL){ + if (ops->map_file_page != NULL) { err = (*ops->map_file_page)(file_externfs_i(file), start, buffer, file->f_mode & FMODE_WRITE); @@ -390,14 +384,14 @@ int externfs_prepare_write(struct file * PAGE_CACHE_SIZE, from, to, externfs_finish_prepare, &wp); wait_for_completion(&wp.completion); - if(err < 0) + if (err < 0) goto out; err = wp.res; - if(err < 0){ - if(from > 0) + if (err < 0) { + if (from > 0) memset(buffer, 0, from); - if(to < PAGE_CACHE_SIZE) + if (to < PAGE_CACHE_SIZE) memset(buffer + to, 0, PAGE_CACHE_SIZE - to); goto out; } @@ -421,11 +415,11 @@ static int externfs_commit_write(struct start = (((long long) page->index) << PAGE_CACHE_SHIFT); - if(ops->map_file_page != NULL) + if (ops->map_file_page != NULL) err = 0; else { size = start + to; - if(size > inode->i_size){ + if (size > inode->i_size) { inode->i_size = size; mark_inode_dirty(inode); } @@ -442,7 +436,7 @@ static int externfs_file_open(struct ino char *name = inode_name(ino, 0); int err; - if(IS_ERR(name)) + if (IS_ERR(name)) return PTR_ERR(name); err = (*ops->open_file)(ext, name, current->fsuid, current->fsgid); @@ -493,9 +487,9 @@ static void externfs_read_inode(struct i int err = -EIO, pid = os_getpid(), mode; spin_lock(&inode_info_lock); - list_for_each(ele, &inode_info){ + list_for_each(ele, &inode_info) { info = list_entry(ele, struct read_inode_info, list); - if(info->pid == pid){ + if (info->pid == pid) { spin_unlock(&inode_info_lock); goto found; } @@ -509,31 +503,32 @@ found: err = 0; mode = info->stat.mode; - if(S_ISLNK(mode)) + if (S_ISLNK(mode)) ino->i_op = &page_symlink_inode_operations; - else if(S_ISDIR(mode)) + else if (S_ISDIR(mode)) ino->i_op = &externfs_dir_iops; else ino->i_op = &externfs_iops; - if(S_ISDIR(mode)) + if (S_ISDIR(mode)) ino->i_fop = &externfs_dir_fops; else ino->i_fop = &externfs_file_fops; - if(S_ISLNK(mode)) + if (S_ISLNK(mode)) ino->i_mapping->a_ops = &externfs_link_aops; else ino->i_mapping->a_ops = &externfs_aops; - if(S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) + if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) init_special_inode(ino, mode & S_IFMT, info->stat.rdev); out: - if(err) + if (err) make_bad_inode(ino); } static int externfs_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 */ @@ -549,7 +544,7 @@ static int externfs_statfs(struct dentry &f_bavail, &f_files, &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid), &sf->f_namelen, sf->f_spare, ed); - if(err) + if (err) return err; sf->f_blocks = f_blocks; @@ -567,7 +562,7 @@ static struct inode *externfs_alloc_inod struct externfs_inode *ext; ext = (*ed->mount_ops->init_file)(ed); - if(ext == NULL) + if (ext == NULL) return NULL; *ext = ((struct externfs_inode) { .ops = ed->file_ops }); @@ -632,23 +627,23 @@ int externfs_create(struct inode *dir, s int err; file = inode_dentry_name(dir, dentry); - if(IS_ERR(file)){ + if (IS_ERR(file)) { err = PTR_ERR(file); goto out; } err = (*ops->create_file)(file, mode, current->fsuid, current->fsgid, ed); - if(err) + if (err) goto out_free; err = (*ops->stat_file)(file, ed, &info.stat); - if(err) + if (err) goto out_rm; err = -ENOMEM; inode = do_iget(dir->i_sb, file, &info); - if(inode == NULL) + if (inode == NULL) goto out_rm; err = 0; @@ -676,19 +671,19 @@ struct dentry *externfs_lookup(struct in int err = -ENOMEM; name = dentry_name(dentry, 0); - if(IS_ERR(name)){ + if (IS_ERR(name)) { err = PTR_ERR(name); goto out; } err = (*ops->stat_file)(name, ed, &info.stat); - if(err && (err != -ENOENT)) + if (err && (err != -ENOENT)) goto out_free; - if(!err){ + if (!err) { inode = do_iget(ino->i_sb, name, &info); err = -ENOMEM; - if(inode == NULL) + if (inode == NULL) goto out_free; } @@ -710,20 +705,20 @@ int externfs_link(struct dentry *to, str int err; from_name = inode_dentry_name(dir, from); - if(IS_ERR(from_name)){ + if (IS_ERR(from_name)) { err = PTR_ERR(from_name); goto out; } to_name = dentry_name(to, 0); - if(IS_ERR(to_name)){ + if (IS_ERR(to_name)) { err = PTR_ERR(to_name); goto out_free_from; } err = (*ops->link_file)(to_name, from_name, current->fsuid, current->fsgid, ed); - if(err) + if (err) goto out_free_to; inode->i_ctime = CURRENT_TIME_SEC; @@ -749,17 +744,17 @@ int externfs_unlink(struct inode *ino, s int err; file = inode_dentry_name(ino, dentry); - if(IS_ERR(file)) + if (IS_ERR(file)) return PTR_ERR(file); inode = dentry->d_inode; - if((inode->i_nlink == 1) && (ops->invisible != NULL)) + if ((inode->i_nlink == 1) && (ops->invisible != NULL)) (*ops->invisible)(EXTERNFS_I(inode)); err = (*ops->unlink_file)(file, ed); kfree(file); - if(!err){ + if (!err) { inode->i_ctime = ino->i_ctime; drop_nlink(inode); } @@ -778,23 +773,23 @@ static int externfs_symlink(struct inode int err; file = inode_dentry_name(ino, dentry); - if(IS_ERR(file)){ + if (IS_ERR(file)) { err = PTR_ERR(file); goto out; } err = (*ops->make_symlink)(file, to, current->fsuid, current->fsgid, ed); - if(err) + if (err) goto out_free; err = (*ops->stat_file)(file, ed, &info.stat); - if(err) + if (err) goto out_rm; err = -ENOMEM; inode = do_iget(ino->i_sb, file, &info); - if(inode == NULL) + if (inode == NULL) goto out_rm; dentry->d_op = &externfs_dentry_ops; @@ -821,22 +816,22 @@ static int externfs_make_dir(struct inod int err; file = inode_dentry_name(dir, dentry); - if(IS_ERR(file)){ + if (IS_ERR(file)) { err = PTR_ERR(file); goto out; } err = (*ops->make_dir)(file, mode, current->fsuid, current->fsgid, ed); - if(err) + if (err) goto out_free; err = (*ops->stat_file)(file, ed, &info.stat); - if(err) + if (err) goto out_rm; err = -ENOMEM; inode = do_iget(dir->i_sb, file, &info); - if(inode == NULL) + if (inode == NULL) goto out_rm; /* No bumping of inode nlink since we just read that from the host */ @@ -881,7 +876,7 @@ int externfs_make_node(struct inode *dir int err; name = dentry_name(dentry, 0); - if(IS_ERR(name)){ + if (IS_ERR(name)) { err = PTR_ERR(name); goto out; } @@ -889,16 +884,16 @@ int externfs_make_node(struct inode *dir err = (*ops->make_node)(name, mode & S_IRWXUGO, current->fsuid, current->fsgid, mode & S_IFMT, MAJOR(dev), MINOR(dev), ed); - if(err) + if (err) goto out_free; err = (*ops->stat_file)(name, ed, &info.stat); - if(err) + if (err) goto out_rm; err = -ENOMEM; inode = do_iget(dir->i_sb, name, &info); - if(inode == NULL) + if (inode == NULL) goto out_rm; err = 0; @@ -925,23 +920,23 @@ int externfs_rename(struct inode *from_d int err; from_name = inode_dentry_name(from_dir, from); - if(IS_ERR(from_name)){ + if (IS_ERR(from_name)) { err = PTR_ERR(from_name); goto out; } to_name = inode_dentry_name(to_dir, to); - if(IS_ERR(to_name)){ + if (IS_ERR(to_name)) { err = PTR_ERR(to_name); goto out_free_from; } err = (*ops->rename_file)(from_name, to_name, ed); - if(err) + if (err) goto out_free_to; inc_nlink(from_ino); - if(to_ino != NULL){ + if (to_ino != NULL) { drop_nlink(to_ino); to_ino->i_ctime = CURRENT_TIME; } @@ -974,12 +969,12 @@ int externfs_permission(struct inode *in char *name; int r = 0, w = 0, x = 0, err = 0; - if(ops->access_file != NULL){ - if(desired & MAY_READ) r = 1; - if(desired & MAY_WRITE) w = 1; - if(desired & MAY_EXEC) x = 1; + if (ops->access_file != NULL) { + if (desired & MAY_READ) r = 1; + if (desired & MAY_WRITE) w = 1; + if (desired & MAY_EXEC) x = 1; name = inode_name(ino, 0); - if(IS_ERR(name)) + if (IS_ERR(name)) return PTR_ERR(name); err = (*ops->access_file)(name, r, w, x, current->fsuid, @@ -987,7 +982,7 @@ int externfs_permission(struct inode *in kfree(name); } - if(!err) + if (!err) err = generic_permission(ino, desired, NULL); return err; } @@ -1011,58 +1006,60 @@ int externfs_setattr(struct dentry *dent int err; attrs.ia_valid = 0; - if(attr->ia_valid & ATTR_MODE){ + if (attr->ia_valid & ATTR_MODE) { attrs.ia_valid |= EXTERNFS_ATTR_MODE; attrs.ia_mode = attr->ia_mode; } - if(attr->ia_valid & ATTR_UID){ + if (attr->ia_valid & ATTR_UID) { attrs.ia_valid |= EXTERNFS_ATTR_UID; attrs.ia_uid = attr->ia_uid; } - if(attr->ia_valid & ATTR_GID){ + if (attr->ia_valid & ATTR_GID) { attrs.ia_valid |= EXTERNFS_ATTR_GID; attrs.ia_gid = attr->ia_gid; } - if(attr->ia_valid & ATTR_SIZE){ + if (attr->ia_valid & ATTR_SIZE) { attrs.ia_valid |= EXTERNFS_ATTR_SIZE; attrs.ia_size = attr->ia_size; } - if(attr->ia_valid & ATTR_ATIME){ + if (attr->ia_valid & ATTR_ATIME) { attrs.ia_valid |= EXTERNFS_ATTR_ATIME; attrs.ia_atime = attr->ia_atime.tv_sec; } - if(attr->ia_valid & ATTR_MTIME){ + if (attr->ia_valid & ATTR_MTIME) { attrs.ia_valid |= EXTERNFS_ATTR_MTIME; attrs.ia_mtime = attr->ia_mtime.tv_sec; } - if(attr->ia_valid & ATTR_CTIME){ + if (attr->ia_valid & ATTR_CTIME) { attrs.ia_valid |= EXTERNFS_ATTR_CTIME; attrs.ia_ctime = attr->ia_ctime.tv_sec; } - if(attr->ia_valid & ATTR_ATIME_SET){ + if (attr->ia_valid & ATTR_ATIME_SET) { attrs.ia_valid |= EXTERNFS_ATTR_ATIME_SET; attrs.ia_atime = attr->ia_atime.tv_sec; } - if(attr->ia_valid & ATTR_MTIME_SET){ + if (attr->ia_valid & ATTR_MTIME_SET) { attrs.ia_valid |= EXTERNFS_ATTR_MTIME_SET; } name = dentry_name(dentry, 0); - if(IS_ERR(name)) + if (IS_ERR(name)) return PTR_ERR(name); err = (*ops->set_attr)(name, &attrs, ed); kfree(name); - if(err) + if (err) return err; - /* This marks the inode dirty and there seems to be nothing I + /* + * This marks the inode dirty and there seems to be nothing I * can do about it except sync it by hand afterwards. */ err = inode_setattr(dentry->d_inode, attr); - if(err) + if (err) return err; - /* Get the inode marked clean (because the host is already + /* + * Get the inode marked clean (because the host is already * synced up) so that it will be freed when i_count goes to * zero and that, when after this file is deleted and a new * file is created with the same inode number, it doesn't @@ -1122,7 +1119,7 @@ int externfs_link_readpage(struct file * buffer = kmap(page); name = inode_name(ino, 0); - if(IS_ERR(name)){ + if (IS_ERR(name)) { err = PTR_ERR(name); goto out; } @@ -1130,9 +1127,9 @@ int externfs_link_readpage(struct file * err = (*ops->read_link)(name, buffer, PAGE_CACHE_SIZE, ed); 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)) @@ -1164,9 +1161,9 @@ static struct externfs *find_externfs(st struct externfs *fs; down(&externfs_sem); - list_for_each(ele, &externfses){ + list_for_each(ele, &externfses) { fs = list_entry(ele, struct externfs, list); - if(&fs->type == type) + if (&fs->type == type) goto out; } fs = NULL; @@ -1181,7 +1178,7 @@ char *host_root_filename(char *mount_arg { char *root = DEFAULT_ROOT; - if((mount_arg != NULL) && (*mount_arg != '\0')) + if ((mount_arg != NULL) && (*mount_arg != '\0')) root = mount_arg; return uml_strdup(root); @@ -1203,17 +1200,18 @@ static int externfs_fill_sb(struct super sb->s_op = &externfs_sbops; fs = find_externfs(sb->s_type); - if(fs == NULL){ - printk("Couldn't find externfs for filesystem '%s'\n", + if (fs == NULL) { + printk(KERN_ERR "Couldn't find externfs for filesystem '%s'\n", sb->s_type->name); goto out; } - /* XXX Does this allocate anything which needs freeing on later + /* + * XXX Does this allocate anything which needs freeing on later * failure? */ sb_data = (*fs->mount_ops->mount)(data); - if(IS_ERR(sb_data)){ + if (IS_ERR(sb_data)) { err = PTR_ERR(sb_data); goto out; } @@ -1222,16 +1220,16 @@ static int externfs_fill_sb(struct super sb_data->mount_ops = fs->mount_ops; err = (*sb_data->file_ops->stat_file)("/", sb_data, &info.stat); - if(err) + if (err) goto out_umount; root_inode = do_iget(sb, "/", &info); - if(root_inode == NULL) + if (root_inode == NULL) goto out_umount; err = -ENOMEM; sb->s_root = d_alloc_root(root_inode); - if(sb->s_root == NULL) + if (sb->s_root == NULL) goto out_put; err = 0; @@ -1263,7 +1261,7 @@ int register_externfs(char *name, struct int err = -ENOMEM; new = kmalloc(sizeof(*new), GFP_KERNEL); - if(new == NULL) + if (new == NULL) goto out; memset(new, 0, sizeof(*new)); @@ -1277,7 +1275,7 @@ int register_externfs(char *name, struct list_add(&new->list, &externfses); err = register_filesystem(&new->type); - if(err) + if (err) goto out_del; return 0; @@ -1294,9 +1292,9 @@ void unregister_externfs(char *name) struct externfs *fs; down(&externfs_sem); - list_for_each(ele, &externfses){ + list_for_each(ele, &externfses) { fs = list_entry(ele, struct externfs, list); - if(!strcmp(fs->type.name, name)){ + if (!strcmp(fs->type.name, name)) { list_del(ele); kfree(fs); up(&externfs_sem); @@ -1304,5 +1302,6 @@ void unregister_externfs(char *name) } } up(&externfs_sem); - printk("Unregister_externfs - filesystem '%s' not found\n", name); + printk(KERN_ERR "Unregister_externfs - filesystem '%s' not found\n", + name); } Index: linux-2.6.17/fs/externfs/host_file.c =================================================================== --- linux-2.6.17.orig/fs/externfs/host_file.c 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/host_file.c 2007-11-19 20:02:47.000000000 -0500 @@ -1,17 +1,14 @@ /* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include "linux/stddef.h" -#include "linux/string.h" -#include "linux/errno.h" -#include "linux/types.h" -#include "linux/slab.h" -#include "linux/fs.h" -#include "asm/fcntl.h" -#include "hostfs.h" +#include +#include +#include +#include #include "filehandle.h" +#include "hostfs.h" #if 0 extern int append; @@ -23,24 +20,24 @@ char *get_path(const char *path[], char char *p; int new = 1; - for(s = path; *s != NULL; s++){ + for (s = path; *s != NULL; s++) { new += strlen(*s); - if((*(s + 1) != NULL) && (strlen(*s) > 0) && + if ((*(s + 1) != NULL) && (strlen(*s) > 0) && ((*s)[strlen(*s) - 1] != '/')) new++; } - if(new > size){ + if (new > size) { buf = kmalloc(new, GFP_KERNEL); - if(buf == NULL) + if (buf == NULL) return NULL; } p = buf; - for(s = path; *s != NULL; s++){ + for (s = path; *s != NULL; s++) { strcpy(p, *s); p += strlen(*s); - if((*(s + 1) != NULL) && (strlen(*s) > 0) && + if ((*(s + 1) != NULL) && (strlen(*s) > 0) && ((*s)[strlen(*s) - 1] != '/')) strcpy(p++, "/"); } @@ -50,7 +47,7 @@ char *get_path(const char *path[], char void free_path(const char *buf, char *tmp) { - if((buf != tmp) && (buf != NULL)) + if ((buf != tmp) && (buf != NULL)) kfree((char *) buf); } @@ -66,16 +63,16 @@ int host_open_file(const char *path[], i flags = of_read(flags); if (w) flags = of_write(flags); - if(append) + if (append) flags = of_append(flags); err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = open_filehandle(file, flags, mode, fh); - if(err) + if (err) goto out_free; is_reclaimable(fh, get_name, arg); @@ -92,7 +89,7 @@ void *host_open_dir(const char *path[]) void *dir = ERR_PTR(-ENOMEM); file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; dir = open_dir(file); @@ -108,14 +105,14 @@ char *host_read_dir(void *stream, unsign char *name; err = os_seek_dir(stream, *pos); - if(err) + if (err) return ERR_PTR(err); err = os_read_dir(stream, ino_out, &name); - if(err) + if (err) return ERR_PTR(err); - if(name == NULL) + if (name == NULL) return NULL; *len_out = strlen(name); @@ -131,12 +128,12 @@ int host_file_type(const char *path[], i ret = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; - if(rdev != NULL){ + if (rdev != NULL) { ret = os_lstat_file(file, &buf); - if(ret) + if (ret) goto out; *rdev = MKDEV(buf.ust_rmajor, buf.ust_rminor); } @@ -153,11 +150,11 @@ int host_create_file(const char *path[], int fd, err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; fd = open_file(file, of_create(of_rdwr(OPENFLAGS())), mode); - if(fd < 0){ + if (fd < 0) { err = fd; goto out_free; } @@ -176,7 +173,7 @@ static int do_stat_file(const char *path int err; err = os_lstat_file(path, &buf); - if(err < 0) + if (err < 0) return err; *info_out = ((struct externfs_inode_info) @@ -204,7 +201,7 @@ int host_stat_file(const char *path[], s err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = do_stat_file(file, info_out); @@ -220,68 +217,68 @@ int host_set_attr(const char *path[], st int err = 0, ma; #if 0 - if(append && (attrs->ia_valid & EXTERNFS_ATTR_SIZE)) + if (append && (attrs->ia_valid & EXTERNFS_ATTR_SIZE)) return -EPERM; #endif err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; - if(attrs->ia_valid & EXTERNFS_ATTR_MODE){ + if (attrs->ia_valid & EXTERNFS_ATTR_MODE) { err = os_set_file_perms(file, attrs->ia_mode); - if(err < 0) + if (err < 0) goto out; } - if(attrs->ia_valid & EXTERNFS_ATTR_UID){ + if (attrs->ia_valid & EXTERNFS_ATTR_UID) { err = os_set_file_owner(file, attrs->ia_uid, -1); - if(err < 0) + if (err < 0) goto out; } - if(attrs->ia_valid & EXTERNFS_ATTR_GID){ + if (attrs->ia_valid & EXTERNFS_ATTR_GID) { err = os_set_file_owner(file, -1, attrs->ia_gid); - if(err < 0) + if (err < 0) goto out; } - if(attrs->ia_valid & EXTERNFS_ATTR_SIZE){ + if (attrs->ia_valid & EXTERNFS_ATTR_SIZE) { err = os_truncate_file(file, attrs->ia_size); - if(err < 0) + if (err < 0) goto out; } ma = EXTERNFS_ATTR_ATIME_SET | EXTERNFS_ATTR_MTIME_SET; - if((attrs->ia_valid & ma) == ma){ + if ((attrs->ia_valid & ma) == ma) { err = os_set_file_time(file, attrs->ia_atime, attrs->ia_mtime); - if(err) + if (err) goto out; } else { - if(attrs->ia_valid & EXTERNFS_ATTR_ATIME_SET){ + if (attrs->ia_valid & EXTERNFS_ATTR_ATIME_SET) { err = do_stat_file(file, &info); - if(err != 0) + if (err != 0) goto out; err = os_set_file_time(file, attrs->ia_atime, info.atime); - if(err) + if (err) goto out; } - if(attrs->ia_valid & EXTERNFS_ATTR_MTIME_SET){ + if (attrs->ia_valid & EXTERNFS_ATTR_MTIME_SET) { err = do_stat_file(file, &info); - if(err != 0) + if (err != 0) goto out; err = os_set_file_time(file, info.mtime, attrs->ia_mtime); - if(err) + if (err) goto out; } } - if(attrs->ia_valid & EXTERNFS_ATTR_CTIME) + if (attrs->ia_valid & EXTERNFS_ATTR_CTIME) ; - if(attrs->ia_valid & (EXTERNFS_ATTR_ATIME | EXTERNFS_ATTR_MTIME)){ + if (attrs->ia_valid & (EXTERNFS_ATTR_ATIME | EXTERNFS_ATTR_MTIME)) { err = do_stat_file(file, &info); - if(err != 0) + if (err != 0) goto out; attrs->ia_atime = info.atime; @@ -300,7 +297,7 @@ int host_make_symlink(const char *from[] int err = -ENOMEM; file = get_path(from, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_make_symlink(to, file); @@ -315,12 +312,12 @@ int host_unlink_file(const char *path[]) int err = -ENOMEM; #if 0 - if(append) + if (append) return -EPERM; #endif file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_remove_file(file); @@ -335,7 +332,7 @@ int host_make_dir(const char *path[], in int err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_make_dir(file, mode); @@ -350,7 +347,7 @@ int host_remove_dir(const char *path[]) int err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_remove_dir(file); @@ -366,7 +363,7 @@ int host_link_file(const char *to[], con f = get_path(from, from_tmp, sizeof(from_tmp)); t = get_path(to, to_tmp, sizeof(to_tmp)); - if((f == NULL) || (t == NULL)) + if ((f == NULL) || (t == NULL)) goto out; err = os_link_file(t, f); @@ -382,11 +379,11 @@ int host_read_link(const char *path[], c int n = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; n = os_read_symlink(file, buf, size); - if(n < size) + if (n < size) buf[n] = '\0'; out: @@ -401,7 +398,7 @@ int host_rename_file(const char *from[], f = get_path(from, from_tmp, sizeof(from_tmp)); t = get_path(to, to_tmp, sizeof(to_tmp)); - if((f == NULL) || (t == NULL)) + if ((f == NULL) || (t == NULL)) goto out; err = os_move_file(f, t); @@ -420,7 +417,7 @@ int host_stat_fs(const char *path[], lon int err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_stat_filesystem(file, bsize_out, blocks_out, bfree_out, Index: linux-2.6.17/fs/externfs/host_fs.c =================================================================== --- linux-2.6.17.orig/fs/externfs/host_fs.c 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/host_fs.c 2007-11-19 20:02:47.000000000 -0500 @@ -1,23 +1,19 @@ /* - * Copyright (C) 2000 - 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include "linux/stddef.h" -#include "linux/string.h" -#include "linux/types.h" -#include "linux/errno.h" -#include "linux/slab.h" +#include +#include #include "linux/list.h" -#include "linux/init.h" -#include "linux/fs.h" -#include "linux/stat.h" +#include +#include +#include "filehandle.h" #include "hostfs.h" -#include "kern.h" #include "init.h" +#include "kern.h" #include "kern_util.h" #include "mconsole_kern.h" -#include "filehandle.h" #include "os.h" /* Changed in hostfs_args before the kernel starts running */ @@ -29,18 +25,18 @@ static int hostfs_args(char *options, in char *ptr; ptr = strchr(options, ','); - if(ptr != NULL) + if (ptr != NULL) *ptr++ = '\0'; - if(*options != '\0') + if (*options != '\0') jail_dir = 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); @@ -56,7 +52,7 @@ static int hostfs_config(char *str, char { str++; str = uml_strdup(str); - if(str == NULL){ + if (str == NULL) { *error_out = "Failed to strdup hostfs config string"; return -ENOMEM; } @@ -79,7 +75,7 @@ static struct mc_device hostfs_mc = { .list = LIST_HEAD_INIT(hostfs_mc.list), .name = "hostfs", .config = hostfs_config, - .get_config = hostfs_get_config, + .get_config = hostfs_get_config, }; static int hostfs_mc_init(void) @@ -122,13 +118,13 @@ static int hostfs_access_file(char *file char tmp[HOSTFS_BUFSIZE]; int err, mode = 0; - if(r) mode = OS_ACC_R_OK; - if(w) mode |= OS_ACC_W_OK; - if(x) mode |= OS_ACC_X_OK; + if (r) mode = OS_ACC_R_OK; + if (w) mode |= OS_ACC_W_OK; + if (x) mode |= OS_ACC_X_OK; err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_access(file, mode); @@ -147,7 +143,7 @@ static int hostfs_make_node(const char * int err = -ENOMEM; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; /* XXX Pass type in an OS-independent way */ @@ -191,7 +187,7 @@ static struct externfs_inode *hostfs_ini struct hostfs_file *hf; hf = kmalloc(sizeof(*hf), GFP_KERNEL); - if(hf == NULL) + if (hf == NULL) return NULL; init_filehandle(&hf->fh, -ENOENT, OPENFLAGS()); @@ -208,14 +204,14 @@ static int hostfs_open_file(struct exter const char *path[] = { jail_dir, mount, file, NULL }; int err; - if(hf->fh.fd >= 0) + if (hf->fh.fd >= 0) return 0; err = host_open_file(path, 1, 1, append, &hf->fh, hostfs_name, ext); - if(err == -EISDIR) + if (err == -EISDIR) goto out; - if(err == -EACCES) + if (err == -EACCES) err = host_open_file(path, 1, 0, append, &hf->fh, hostfs_name, ext); out: @@ -253,13 +249,13 @@ static int hostfs_read_file(struct exter struct hostfs_file *hf = container_of(ext, struct hostfs_file, ext); int err = 0; - if(ignore_start != 0){ + if (ignore_start != 0) { err = read_file(&hf->fh, offset, buf, ignore_start); - if(err < 0) + if (err < 0) goto out; } - if(ignore_end != len) + if (ignore_end != len) err = read_file(&hf->fh, offset + ignore_end, buf + ignore_end, len - ignore_end); @@ -385,13 +381,13 @@ static int hostfs_stat_fs(long *bsize_ou } static void hostfs_close_file(struct externfs_inode *ext, - unsigned long long size) + unsigned long long size) { struct hostfs_file *hf = container_of(ext, struct hostfs_file, ext); - if(hf->fh.fd == -ENOENT){ - if(!list_empty(&hf->fh.list)) - printk("Non-empty list\n"); + if (hf->fh.fd == -ENOENT) { + if (!list_empty(&hf->fh.list)) + printk(KERN_ERR "Non-empty list\n"); return; } @@ -453,7 +449,8 @@ static struct externfs_file_ops hostfs_f ((a).ust_major == (b).ust_major) && \ ((a).ust_minor == (b).ust_minor)) -/* This does a careful check of whether it's being asked to mount something +/* + * This does a careful check of whether it's being asked to mount something * that's outside the hostfs jail. It does so by cd-ing to the requested * directory and "cd .." until it either reaches / or the jail directory. * If it reaches /, then we were outside the jail and we return -EPERM. @@ -471,45 +468,45 @@ static int escaping_jail(char *root) char tmp[HOSTFS_BUFSIZE], *file; err = os_stat_file(jail_dir, &jail_inode); - if(err) + if (err) goto out; save_pwd = os_open_file(".", of_read(OPENFLAGS()), 0); - if(save_pwd < 0) + if (save_pwd < 0) goto out; file = get_path(path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out_close; err = os_change_dir(file); - if(err) + if (err) goto out_free; err = os_stat_file(".", &cur_dir); - if(err) + if (err) goto out_back; do { - if(SAME_INO(cur_dir, jail_inode)){ + if (SAME_INO(cur_dir, jail_inode)) { escaping = 0; break; } err = os_change_dir(".."); - if(err) + if (err) goto out_back; last_dir = cur_dir; err = os_stat_file(".", &cur_dir); - if(err) + if (err) goto out_back; - } while(!SAME_INO(last_dir, cur_dir)); + } while (!SAME_INO(last_dir, cur_dir)); err = os_fchange_dir(save_pwd); - if(err) + if (err) goto out_close; free_path(file, tmp); @@ -533,15 +530,15 @@ static struct externfs_data *mount_fs(ch int err = -ENOMEM; hd = kmalloc(sizeof(*hd), GFP_KERNEL); - if(hd == NULL) + if (hd == NULL) goto out; hd->mount = host_root_filename(mount_arg); - if(hd->mount == NULL) + if (hd->mount == NULL) goto out_free; err = escaping_jail(hd->mount); - if(err) + if (err) goto out_free_mount; init_externfs(&hd->ext, &hostfs_file_ops); Index: linux-2.6.17/fs/externfs/hostfs.h =================================================================== --- linux-2.6.17.orig/fs/externfs/hostfs.h 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/hostfs.h 2007-11-19 20:02:47.000000000 -0500 @@ -1,16 +1,17 @@ /* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ #ifndef __UM_FS_HOSTFS #define __UM_FS_HOSTFS -#include "linux/fs.h" +#include #include "filehandle.h" #include "os.h" -/* These are exactly the same definitions as in fs.h, but the names are +/* + * These are exactly the same definitions as in fs.h, but the names are * changed so that this file can be included in both kernel and user files. */ Index: linux-2.6.17/fs/externfs/humfs.c =================================================================== --- linux-2.6.17.orig/fs/externfs/humfs.c 2007-11-19 19:54:14.000000000 -0500 +++ linux-2.6.17/fs/externfs/humfs.c 2007-11-19 20:04:22.000000000 -0500 @@ -1,29 +1,19 @@ /* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include -#include -#include -#include -#include -#include +#include #include -#include -#include #include +#include +#include #include -#include -#include "hostfs.h" -#include "mem.h" -#include "os.h" #include "aio.h" -#include "irq_user.h" -#include "irq_kern.h" +#include "aio-restart.h" #include "filehandle.h" +#include "hostfs.h" #include "metadata.h" -#include "aio-restart.h" #define HUMFS_VERSION 2 @@ -453,7 +443,7 @@ static int humfs_make_node(const char *p break; default: err = -EINVAL; - printk("make_node - bad node type : %d\n", type); + printk(KERN_ERR "make_node - bad node type : %d\n", type); goto out_rm; } @@ -764,7 +754,7 @@ static struct humfs *read_superblock(cha err = host_open_file(path, 1, 0, 0, fh, NULL, NULL); if(err){ - printk("Failed to open %s/%s, errno = %d\n", path[0], + printk(KERN_ERR "Failed to open %s/%s, errno = %d\n", path[0], path[1], err); goto err_free_fh; } @@ -789,17 +779,17 @@ static struct humfs *read_superblock(cha newline = strchr(line, '\n'); if(newline == NULL){ - printk("read_superblock - line too long : '%s'\n", - line); + printk(KERN_ERR "read_superblock - line too long : " + "'%s'\n", line); goto err_free_fh; } newline++; if(sscanf(line, "version %d\n", &version) == 1){ if(version != HUMFS_VERSION){ - printk("humfs version mismatch - want version " - "%d, got version %d.\n", HUMFS_VERSION, - version); + printk(KERN_ERR "humfs version mismatch - want " + "version %d, got version %d.\n", + HUMFS_VERSION, version); goto err_free_fh; } } @@ -808,13 +798,14 @@ static struct humfs *read_superblock(cha else if(sscanf(line, "metadata %32s\n", meta_buf) == 1){ meta = find_meta(meta_buf); if(meta == NULL){ - printk("read_superblock - meta api \"%s\" not " - "registered\n", meta_buf); + printk(KERN_ERR "read_superblock - meta api " + "\"%s\" not registered\n", meta_buf); goto err_free_fh; } } else { - printk("read_superblock - bogus line : '%s'\n", line); + printk(KERN_ERR "read_superblock - bogus line : " + "'%s'\n", line); goto err_free_fh; } @@ -824,17 +815,18 @@ static struct humfs *read_superblock(cha } if(used == 0){ - printk("read_superblock - used not specified or set to " - "zero\n"); + printk(KERN_ERR "read_superblock - used not specified or set " + "to zero\n"); goto err_free_fh; } if(total == 0){ - printk("read_superblock - total not specified or set to " - "zero\n"); + printk(KERN_ERR "read_superblock - total not specified or set " + "to zero\n"); goto err_free_fh; } if(used > total){ - printk("read_superblock - used is greater than total\n"); + printk(KERN_ERR "read_superblock - used is greater than " + "total\n"); goto err_free_fh; } @@ -842,7 +834,8 @@ static struct humfs *read_superblock(cha meta = find_meta("shadow_fs"); if(meta == NULL){ - printk("read_superblock - valid meta api was not specified\n"); + printk(KERN_ERR "read_superblock - valid meta api was not " + "specified\n"); goto err_free_fh; } @@ -929,7 +922,7 @@ static struct externfs_data *mount_fs(ch int err, do_mmap = 0; if(mount_arg == NULL){ - printk("humfs - no host directory specified\n"); + printk(KERN_ERR "humfs - no host directory specified\n"); return ERR_PTR(-EINVAL); } Index: linux-2.6.17/fs/externfs/meta_fs.c =================================================================== --- linux-2.6.17.orig/fs/externfs/meta_fs.c 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/meta_fs.c 2007-11-19 20:02:47.000000000 -0500 @@ -1,13 +1,11 @@ /* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include #include -#include "hostfs.h" +#include #include "metadata.h" -#include "kern_util.h" #define METADATA_FILE_PATH(meta) (meta)->root, "file_metadata" #define METADATA_DIR_PATH(meta) (meta)->root, "dir_metadata" @@ -33,24 +31,24 @@ static char *meta_file_name(const char * char *file; int type, i = 0; - if(data_file == NULL) + if (data_file == NULL) return NULL; strcpy(meta_name, "metadata"); type = os_file_type(data_file); - while(1){ - if(type == OS_TYPE_DIR){ + while (1) { + if (type == OS_TYPE_DIR) { meta_path[1] = "dir_metadata"; meta_path[3] = meta_name; } else meta_path[1] = "file_metadata"; file = get_path(meta_path, file_buf, file_len); - if(file == NULL) + if (file == NULL) return NULL; - if((type != OS_TYPE_DIR) || + if ((type != OS_TYPE_DIR) || (os_file_type(file) == OS_TYPE_FILE)) break; @@ -70,7 +68,7 @@ static char *meta_fs_name(void *arg) char tmp[HOSTFS_BUFSIZE], *name, *file; file = meta_file_name("", meta, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) return NULL; name = humfs_name_prefix(hf, file); @@ -88,14 +86,14 @@ static int open_meta_file(const char *pa int err = -ENOMEM; meta_file = meta_file_name(path, meta, meta_tmp, sizeof(meta_tmp)); - if(meta_file == NULL) + if (meta_file == NULL) goto out; err = open_filehandle(meta_file, of_rdwr(OPENFLAGS()), 0, fh); - if(err) + if (err) goto out; - if(mf != NULL) + if (mf != NULL) is_reclaimable(fh, meta_fs_name, mf); out: free_path(meta_file, meta_tmp); @@ -115,7 +113,7 @@ static struct humfs_file *metafs_init_fi int err = -ENOMEM; mf = kmalloc(sizeof(*mf), GFP_KERNEL); - if(mf == NULL) + if (mf == NULL) return ERR_PTR(err); init_filehandle(&mf->fh, -ENOENT, OPENFLAGS()); @@ -156,18 +154,18 @@ static int metafs_create_file(const char char buf[sizeof("mmmm uuuuuuuuuu gggggggggg")]; int err = -ENOMEM; - if(file == NULL) + if (file == NULL) goto out; err = open_filehandle(file, of_write(of_create(OPENFLAGS())), 0644, &fh); - if(err) + if (err) goto out_free_path; sprintf(buf, "%d %d %d\n", mode & S_IRWXUGO, uid, gid); err = write_file(&fh, 0, buf, strlen(buf)); close_file(&fh); - if(err < 0) + if (err < 0) goto out_rm; free_path(file, tmp); @@ -199,7 +197,7 @@ static int metafs_remove_file(const char char *file = get_path(metadata_path, tmp, sizeof(tmp)); int err = -ENOMEM; - if(file == NULL) + if (file == NULL) goto out; err = os_remove_file(file); @@ -221,32 +219,33 @@ static int metafs_create_directory(const int err, fd; err = host_make_dir(dir_path, 0755); - if(err) + if (err) goto out; err = host_make_dir(file_path, 0755); - if(err) + if (err) goto out_rm; - /* This to make the index independent of the number of elements in + /* + * This to make the index independent of the number of elements in * METADATA_DIR_PATH(). */ dir_path[sizeof(dir_path) / sizeof(dir_path[0]) - 2] = "metadata"; err = -ENOMEM; file = get_path(dir_path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out_rm; fd = open_file(file, of_create(of_rdwr(OPENFLAGS())), 0644); - if(fd < 0){ + if (fd < 0) { err = fd; goto out_free; } sprintf(dir_meta, "%d %d %d\n", mode & S_IRWXUGO, uid, gid); err = os_write_file(fd, dir_meta, strlen(dir_meta)); - if(err > 0) + if (err > 0) err = 0; os_close_file(fd); @@ -271,16 +270,17 @@ static int metafs_remove_directory(const err = -ENOMEM; file = get_path(dir_path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_remove_file(file); - if(err) + if (err) goto out_free; slash = strrchr(file, '/'); - if(slash == NULL){ - printk("remove_shadow_directory failed to find last slash\n"); + if (slash == NULL) { + printk(KERN_ERR "remove_shadow_directory failed to find last " + "slash\n"); goto out_free; } *slash = '\0'; @@ -288,7 +288,7 @@ static int metafs_remove_directory(const free_path(file, tmp); file = get_path(file_path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = os_remove_dir(file); @@ -313,16 +313,16 @@ static int metafs_make_node(const char * err = -ENOMEM; file = get_path(metadata_path, tmp, sizeof(tmp)); - if(file == NULL) + if (file == NULL) goto out; err = open_filehandle(file, of_create(of_rdwr(OPENFLAGS())), 0644, &fh); - if(err) + if (err) goto out_free; err = write_file(&fh, 0, buf, strlen(buf)); - if(err > 0) + if (err > 0) err = 0; close_file(&fh); @@ -343,11 +343,11 @@ static int metafs_ownerships(const char char type; err = open_meta_file(path, humfs, &fh, NULL); - if(err) + if (err) goto out; err = os_read_file(fh.fd, buf, sizeof(buf) - 1); - if(err < 0) + if (err < 0) goto out_close; buf[err] = '\0'; @@ -355,26 +355,26 @@ static int metafs_ownerships(const char n = sscanf(buf, "%d %d %d %c %d %d", &mode, &uid, &gid, &type, &maj, &min); - if(n == 3){ + if (n == 3) { maj = -1; min = -1; type = 0; err = 0; } - else if(n != 6) + else if (n != 6) err = -EINVAL; - if(mode_out != NULL) + if (mode_out != NULL) *mode_out = mode; - if(uid_out != NULL) + if (uid_out != NULL) *uid_out = uid; - if(gid_out != NULL) + if (gid_out != NULL) *gid_out = uid; - if(type_out != NULL) + if (type_out != NULL) *type_out = type; - if(maj_out != NULL) + if (maj_out != NULL) *maj_out = maj; - if(min_out != NULL) + if (min_out != NULL) *min_out = min; out_close: @@ -392,37 +392,37 @@ static int metafs_change_ownerships(cons int err = -ENOMEM, old_mode, old_uid, old_gid, n, maj, min; err = open_meta_file(path, humfs, &fh, NULL); - if(err) + if (err) goto out; err = read_file(&fh, 0, buf, sizeof(buf) - 1); - if(err < 0) + if (err < 0) goto out_close; buf[err] = '\0'; n = sscanf(buf, "%d %d %d %c %d %d\n", &old_mode, &old_uid, &old_gid, &type, &maj, &min); - if((n != 3) && (n != 6)){ + if ((n != 3) && (n != 6)) { err = -EINVAL; goto out_close; } - if(mode == -1) + if (mode == -1) mode = old_mode; - if(uid == -1) + if (uid == -1) uid = old_uid; - if(gid == -1) + if (gid == -1) gid = old_gid; - if(n == 3) + if (n == 3) sprintf(buf, "%d %d %d\n", mode & S_IRWXUGO, uid, gid); else sprintf(buf, "%d %d %d %c %d %d\n", mode & S_IRWXUGO, uid, gid, type, maj, min); err = write_file(&fh, 0, buf, strlen(buf)); - if(err > 0) + if (err > 0) err = 0; err = truncate_file(&fh, strlen(buf)); @@ -442,11 +442,11 @@ static int metafs_rename_file(const char int err = -ENOMEM; metadata_from = meta_file_name(from, meta, from_buf, sizeof(from_buf)); - if(metadata_from == NULL) + if (metadata_from == NULL) goto out; metadata_to = meta_file_name(to, meta, to_buf, sizeof(to_buf)); - if(metadata_to == NULL) + if (metadata_to == NULL) goto out_from; err = os_move_file(metadata_from, metadata_to); @@ -471,11 +471,11 @@ static struct humfs *metafs_init_mount(c int err = -ENOMEM; meta = kmalloc(sizeof(*meta), GFP_KERNEL); - if(meta == NULL) + if (meta == NULL) goto out; meta->root = uml_strdup(root); - if(meta->root == NULL) + if (meta->root == NULL) goto out_free_meta; return &meta->humfs; Index: linux-2.6.17/fs/externfs/metadata.h =================================================================== --- linux-2.6.17.orig/fs/externfs/metadata.h 2007-11-19 17:19:40.000000000 -0500 +++ linux-2.6.17/fs/externfs/metadata.h 2007-11-19 20:02:47.000000000 -0500 @@ -1,15 +1,13 @@ /* * Copyright (C) 2004 Piotr Neuman (sikkh@wp.pl) and - * Jeff Dike (jdike@addtoit.com) + * 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ #ifndef __UM_FS_METADATA #define __UM_FS_METADATA -#include "linux/fs.h" -#include "linux/list.h" -#include "os.h" +#include #include "hostfs.h" struct humfs {