Loading fs/hostfs/hostfs.h +6 −3 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ #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. */ Loading @@ -21,7 +22,8 @@ #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */ #define HOSTFS_ATTR_ATTR_FLAG 1024 /* If you are very careful, you'll notice that these two are missing: /* * If you are very careful, you'll notice that these two are missing: * * #define ATTR_KILL_SUID 2048 * #define ATTR_KILL_SGID 4096 Loading Loading @@ -76,7 +78,8 @@ extern int make_symlink(const char *from, const char *to); extern int unlink_file(const char *file); extern int do_mkdir(const char *file, int mode); extern int do_rmdir(const char *file); extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor); extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor); extern int link_file(const char *from, const char *to); extern int do_readlink(char *file, char *buf, int size); extern int rename_file(char *from, char *to); Loading fs/hostfs/hostfs_kern.c +115 −111 Original line number Diff line number Diff line Loading @@ -6,21 +6,14 @@ * 2003-02-10 Petr Baudis <pasky@ucw.cz> */ #include <linux/stddef.h> #include <linux/fs.h> #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/blkdev.h> #include <linux/list.h> #include <linux/statfs.h> #include <linux/kdev_t.h> #include <asm/uaccess.h> #include "hostfs.h" #include "kern_util.h" #include "kern.h" #include "init.h" #include "kern.h" struct hostfs_inode_info { char *host_filename; Loading Loading @@ -136,7 +129,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 */ Loading Loading @@ -213,7 +207,8 @@ static int 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)) Loading @@ -240,7 +235,8 @@ static int read_inode(struct inode *ino) 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 */ Loading Loading @@ -295,8 +291,10 @@ 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.*/ /* * 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"); Loading Loading @@ -353,7 +351,8 @@ int hostfs_file_open(struct inode *ino, struct file *file) 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) { Loading Loading @@ -452,7 +451,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); Loading Loading @@ -494,7 +494,8 @@ int hostfs_write_end(struct file *file, struct address_space *mapping, if (!PageUptodate(page) && err == PAGE_CACHE_SIZE) SetPageUptodate(page); /* If err > 0, write_file has added err to pos, so we are comparing /* * 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)) Loading Loading @@ -572,7 +573,8 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, error = -ENOMEM; inode = iget(dir->i_sb, 0); if(inode == NULL) goto out; if (inode == NULL) goto out; error = init_inode(inode, dentry); if (error) Loading Loading @@ -959,8 +961,10 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) 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; Loading fs/hostfs/hostfs_user.c +81 −58 Original line number Diff line number Diff line Loading @@ -3,19 +3,21 @@ * Licensed under the GPL */ #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <stddef.h> #include <unistd.h> #include <dirent.h> #include <errno.h> #include <utime.h> #include <fcntl.h> #include <string.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/vfs.h> #include "hostfs.h" #include "kern_util.h" #include "os.h" #include "user.h" #include <utime.h> int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, int *nlink_out, int *uid_out, int *gid_out, Loading @@ -32,12 +34,18 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, return -errno; } if(inode_out != NULL) *inode_out = buf.st_ino; if(mode_out != NULL) *mode_out = buf.st_mode; if(nlink_out != NULL) *nlink_out = buf.st_nlink; if(uid_out != NULL) *uid_out = buf.st_uid; if(gid_out != NULL) *gid_out = buf.st_gid; if(size_out != NULL) *size_out = buf.st_size; if (inode_out != NULL) *inode_out = buf.st_ino; if (mode_out != NULL) *mode_out = buf.st_mode; if (nlink_out != NULL) *nlink_out = buf.st_nlink; if (uid_out != NULL) *uid_out = buf.st_uid; if (gid_out != NULL) *gid_out = buf.st_gid; if (size_out != NULL) *size_out = buf.st_size; if (atime_out != NULL) { atime_out->tv_sec = buf.st_atime; atime_out->tv_nsec = 0; Loading @@ -50,8 +58,10 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, ctime_out->tv_sec = buf.st_ctime; ctime_out->tv_nsec = 0; } if(blksize_out != NULL) *blksize_out = buf.st_blksize; if(blocks_out != NULL) *blocks_out = buf.st_blocks; if (blksize_out != NULL) *blksize_out = buf.st_blksize; if (blocks_out != NULL) *blocks_out = buf.st_blocks; return 0; } Loading @@ -61,19 +71,27 @@ int file_type(const char *path, int *maj, int *min) if (lstat64(path, &buf) < 0) return -errno; /*We cannot pass rdev as is because glibc and the kernel disagree *about its definition.*/ /* * We cannot pass rdev as is because glibc and the kernel disagree * about its definition. */ if (maj != NULL) *maj = major(buf.st_rdev); if (min != NULL) *min = minor(buf.st_rdev); if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; else if(S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; else if(S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; else if(S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; else if(S_ISFIFO(buf.st_mode))return OS_TYPE_FIFO; else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK; if (S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; else if (S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; else if (S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; else if (S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; else if (S_ISFIFO(buf.st_mode)) return OS_TYPE_FIFO; else if (S_ISSOCK(buf.st_mode)) return OS_TYPE_SOCK; else return OS_TYPE_FILE; } Loading @@ -81,9 +99,12 @@ int access_file(char *path, int r, int w, int x) { int mode = 0; if(r) mode = R_OK; if(w) mode |= W_OK; if(x) mode |= X_OK; if (r) mode = R_OK; if (w) mode |= W_OK; if (x) mode |= X_OK; if (access(path, mode) != 0) return -errno; else return 0; Loading Loading @@ -251,9 +272,11 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) } } /* Update accessed and/or modified time, in two parts: first set /* * Update accessed and/or modified time, in two parts: first set * times according to the changes to perform, and then call futimes() * or utimes() to apply them. */ * or utimes() to apply them. */ ma = (HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET); if (attrs->ia_valid & ma) { err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, Loading Loading
fs/hostfs/hostfs.h +6 −3 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ #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. */ Loading @@ -21,7 +22,8 @@ #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */ #define HOSTFS_ATTR_ATTR_FLAG 1024 /* If you are very careful, you'll notice that these two are missing: /* * If you are very careful, you'll notice that these two are missing: * * #define ATTR_KILL_SUID 2048 * #define ATTR_KILL_SGID 4096 Loading Loading @@ -76,7 +78,8 @@ extern int make_symlink(const char *from, const char *to); extern int unlink_file(const char *file); extern int do_mkdir(const char *file, int mode); extern int do_rmdir(const char *file); extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor); extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor); extern int link_file(const char *from, const char *to); extern int do_readlink(char *file, char *buf, int size); extern int rename_file(char *from, char *to); Loading
fs/hostfs/hostfs_kern.c +115 −111 Original line number Diff line number Diff line Loading @@ -6,21 +6,14 @@ * 2003-02-10 Petr Baudis <pasky@ucw.cz> */ #include <linux/stddef.h> #include <linux/fs.h> #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/blkdev.h> #include <linux/list.h> #include <linux/statfs.h> #include <linux/kdev_t.h> #include <asm/uaccess.h> #include "hostfs.h" #include "kern_util.h" #include "kern.h" #include "init.h" #include "kern.h" struct hostfs_inode_info { char *host_filename; Loading Loading @@ -136,7 +129,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 */ Loading Loading @@ -213,7 +207,8 @@ static int 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)) Loading @@ -240,7 +235,8 @@ static int read_inode(struct inode *ino) 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 */ Loading Loading @@ -295,8 +291,10 @@ 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.*/ /* * 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"); Loading Loading @@ -353,7 +351,8 @@ int hostfs_file_open(struct inode *ino, struct file *file) 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) { Loading Loading @@ -452,7 +451,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); Loading Loading @@ -494,7 +494,8 @@ int hostfs_write_end(struct file *file, struct address_space *mapping, if (!PageUptodate(page) && err == PAGE_CACHE_SIZE) SetPageUptodate(page); /* If err > 0, write_file has added err to pos, so we are comparing /* * 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)) Loading Loading @@ -572,7 +573,8 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, error = -ENOMEM; inode = iget(dir->i_sb, 0); if(inode == NULL) goto out; if (inode == NULL) goto out; error = init_inode(inode, dentry); if (error) Loading Loading @@ -959,8 +961,10 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) 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; Loading
fs/hostfs/hostfs_user.c +81 −58 Original line number Diff line number Diff line Loading @@ -3,19 +3,21 @@ * Licensed under the GPL */ #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <stddef.h> #include <unistd.h> #include <dirent.h> #include <errno.h> #include <utime.h> #include <fcntl.h> #include <string.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/vfs.h> #include "hostfs.h" #include "kern_util.h" #include "os.h" #include "user.h" #include <utime.h> int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, int *nlink_out, int *uid_out, int *gid_out, Loading @@ -32,12 +34,18 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, return -errno; } if(inode_out != NULL) *inode_out = buf.st_ino; if(mode_out != NULL) *mode_out = buf.st_mode; if(nlink_out != NULL) *nlink_out = buf.st_nlink; if(uid_out != NULL) *uid_out = buf.st_uid; if(gid_out != NULL) *gid_out = buf.st_gid; if(size_out != NULL) *size_out = buf.st_size; if (inode_out != NULL) *inode_out = buf.st_ino; if (mode_out != NULL) *mode_out = buf.st_mode; if (nlink_out != NULL) *nlink_out = buf.st_nlink; if (uid_out != NULL) *uid_out = buf.st_uid; if (gid_out != NULL) *gid_out = buf.st_gid; if (size_out != NULL) *size_out = buf.st_size; if (atime_out != NULL) { atime_out->tv_sec = buf.st_atime; atime_out->tv_nsec = 0; Loading @@ -50,8 +58,10 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, ctime_out->tv_sec = buf.st_ctime; ctime_out->tv_nsec = 0; } if(blksize_out != NULL) *blksize_out = buf.st_blksize; if(blocks_out != NULL) *blocks_out = buf.st_blocks; if (blksize_out != NULL) *blksize_out = buf.st_blksize; if (blocks_out != NULL) *blocks_out = buf.st_blocks; return 0; } Loading @@ -61,19 +71,27 @@ int file_type(const char *path, int *maj, int *min) if (lstat64(path, &buf) < 0) return -errno; /*We cannot pass rdev as is because glibc and the kernel disagree *about its definition.*/ /* * We cannot pass rdev as is because glibc and the kernel disagree * about its definition. */ if (maj != NULL) *maj = major(buf.st_rdev); if (min != NULL) *min = minor(buf.st_rdev); if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; else if(S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; else if(S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; else if(S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; else if(S_ISFIFO(buf.st_mode))return OS_TYPE_FIFO; else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK; if (S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; else if (S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; else if (S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; else if (S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; else if (S_ISFIFO(buf.st_mode)) return OS_TYPE_FIFO; else if (S_ISSOCK(buf.st_mode)) return OS_TYPE_SOCK; else return OS_TYPE_FILE; } Loading @@ -81,9 +99,12 @@ int access_file(char *path, int r, int w, int x) { int mode = 0; if(r) mode = R_OK; if(w) mode |= W_OK; if(x) mode |= X_OK; if (r) mode = R_OK; if (w) mode |= W_OK; if (x) mode |= X_OK; if (access(path, mode) != 0) return -errno; else return 0; Loading Loading @@ -251,9 +272,11 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) } } /* Update accessed and/or modified time, in two parts: first set /* * Update accessed and/or modified time, in two parts: first set * times according to the changes to perform, and then call futimes() * or utimes() to apply them. */ * or utimes() to apply them. */ ma = (HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET); if (attrs->ia_valid & ma) { err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, Loading