Commit 9b6533c9 authored by Sripathi Kodi's avatar Sripathi Kodi Committed by Eric Van Hensbergen

9p: VFS switches for 9p2000.L: VFS switches

Implements VFS switches for 9p2000.L protocol.
Signed-off-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent c56e4acf
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
extern struct file_system_type v9fs_fs_type; extern struct file_system_type v9fs_fs_type;
extern const struct address_space_operations v9fs_addr_operations; extern const struct address_space_operations v9fs_addr_operations;
extern const struct file_operations v9fs_file_operations; extern const struct file_operations v9fs_file_operations;
extern const struct file_operations v9fs_file_operations_dotl;
extern const struct file_operations v9fs_dir_operations; extern const struct file_operations v9fs_dir_operations;
extern const struct file_operations v9fs_dir_operations_dotl;
extern const struct dentry_operations v9fs_dentry_operations; extern const struct dentry_operations v9fs_dentry_operations;
extern const struct dentry_operations v9fs_cached_dentry_operations; extern const struct dentry_operations v9fs_cached_dentry_operations;
......
...@@ -203,3 +203,11 @@ const struct file_operations v9fs_dir_operations = { ...@@ -203,3 +203,11 @@ const struct file_operations v9fs_dir_operations = {
.open = v9fs_file_open, .open = v9fs_file_open,
.release = v9fs_dir_release, .release = v9fs_dir_release,
}; };
const struct file_operations v9fs_dir_operations_dotl = {
.read = generic_read_dir,
.llseek = generic_file_llseek,
.readdir = v9fs_dir_readdir,
.open = v9fs_file_open,
.release = v9fs_dir_release,
};
...@@ -296,3 +296,14 @@ const struct file_operations v9fs_file_operations = { ...@@ -296,3 +296,14 @@ const struct file_operations v9fs_file_operations = {
.mmap = generic_file_readonly_mmap, .mmap = generic_file_readonly_mmap,
.fsync = v9fs_file_fsync, .fsync = v9fs_file_fsync,
}; };
const struct file_operations v9fs_file_operations_dotl = {
.llseek = generic_file_llseek,
.read = v9fs_file_read,
.write = v9fs_file_write,
.open = v9fs_file_open,
.release = v9fs_dir_release,
.lock = v9fs_file_lock,
.mmap = generic_file_readonly_mmap,
.fsync = v9fs_file_fsync,
};
...@@ -44,9 +44,12 @@ ...@@ -44,9 +44,12 @@
#include "cache.h" #include "cache.h"
static const struct inode_operations v9fs_dir_inode_operations; static const struct inode_operations v9fs_dir_inode_operations;
static const struct inode_operations v9fs_dir_inode_operations_ext; static const struct inode_operations v9fs_dir_inode_operations_dotu;
static const struct inode_operations v9fs_dir_inode_operations_dotl;
static const struct inode_operations v9fs_file_inode_operations; static const struct inode_operations v9fs_file_inode_operations;
static const struct inode_operations v9fs_file_inode_operations_dotl;
static const struct inode_operations v9fs_symlink_inode_operations; static const struct inode_operations v9fs_symlink_inode_operations;
static const struct inode_operations v9fs_symlink_inode_operations_dotl;
/** /**
* unixmode2p9mode - convert unix mode bits to plan 9 * unixmode2p9mode - convert unix mode bits to plan 9
...@@ -275,25 +278,44 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) ...@@ -275,25 +278,44 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
init_special_inode(inode, inode->i_mode, inode->i_rdev); init_special_inode(inode, inode->i_mode, inode->i_rdev);
break; break;
case S_IFREG: case S_IFREG:
inode->i_op = &v9fs_file_inode_operations; if (v9fs_proto_dotl(v9ses)) {
inode->i_fop = &v9fs_file_operations; inode->i_op = &v9fs_file_inode_operations_dotl;
inode->i_fop = &v9fs_file_operations_dotl;
} else {
inode->i_op = &v9fs_file_inode_operations;
inode->i_fop = &v9fs_file_operations;
}
break; break;
case S_IFLNK: case S_IFLNK:
if (!v9fs_proto_dotu(v9ses)) { if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
"extended modes used w/o 9P2000.u\n"); "legacy protocol.\n");
err = -EINVAL; err = -EINVAL;
goto error; goto error;
} }
inode->i_op = &v9fs_symlink_inode_operations;
if (v9fs_proto_dotl(v9ses))
inode->i_op = &v9fs_symlink_inode_operations_dotl;
else
inode->i_op = &v9fs_symlink_inode_operations;
break; break;
case S_IFDIR: case S_IFDIR:
inc_nlink(inode); inc_nlink(inode);
if (v9fs_proto_dotu(v9ses)) if (v9fs_proto_dotl(v9ses))
inode->i_op = &v9fs_dir_inode_operations_ext; inode->i_op = &v9fs_dir_inode_operations_dotl;
else if (v9fs_proto_dotu(v9ses))
inode->i_op = &v9fs_dir_inode_operations_dotu;
else else
inode->i_op = &v9fs_dir_inode_operations; inode->i_op = &v9fs_dir_inode_operations;
inode->i_fop = &v9fs_dir_operations;
if (v9fs_proto_dotl(v9ses))
inode->i_fop = &v9fs_dir_operations_dotl;
else
inode->i_fop = &v9fs_dir_operations;
break; break;
default: default:
P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
...@@ -1208,7 +1230,21 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) ...@@ -1208,7 +1230,21 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
return retval; return retval;
} }
static const struct inode_operations v9fs_dir_inode_operations_ext = { static const struct inode_operations v9fs_dir_inode_operations_dotu = {
.create = v9fs_vfs_create,
.lookup = v9fs_vfs_lookup,
.symlink = v9fs_vfs_symlink,
.link = v9fs_vfs_link,
.unlink = v9fs_vfs_unlink,
.mkdir = v9fs_vfs_mkdir,
.rmdir = v9fs_vfs_rmdir,
.mknod = v9fs_vfs_mknod,
.rename = v9fs_vfs_rename,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};
static const struct inode_operations v9fs_dir_inode_operations_dotl = {
.create = v9fs_vfs_create, .create = v9fs_vfs_create,
.lookup = v9fs_vfs_lookup, .lookup = v9fs_vfs_lookup,
.symlink = v9fs_vfs_symlink, .symlink = v9fs_vfs_symlink,
...@@ -1239,6 +1275,11 @@ static const struct inode_operations v9fs_file_inode_operations = { ...@@ -1239,6 +1275,11 @@ static const struct inode_operations v9fs_file_inode_operations = {
.setattr = v9fs_vfs_setattr, .setattr = v9fs_vfs_setattr,
}; };
static const struct inode_operations v9fs_file_inode_operations_dotl = {
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};
static const struct inode_operations v9fs_symlink_inode_operations = { static const struct inode_operations v9fs_symlink_inode_operations = {
.readlink = generic_readlink, .readlink = generic_readlink,
.follow_link = v9fs_vfs_follow_link, .follow_link = v9fs_vfs_follow_link,
...@@ -1246,3 +1287,11 @@ static const struct inode_operations v9fs_symlink_inode_operations = { ...@@ -1246,3 +1287,11 @@ static const struct inode_operations v9fs_symlink_inode_operations = {
.getattr = v9fs_vfs_getattr, .getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr, .setattr = v9fs_vfs_setattr,
}; };
static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
.readlink = generic_readlink,
.follow_link = v9fs_vfs_follow_link,
.put_link = v9fs_vfs_put_link,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "v9fs_vfs.h" #include "v9fs_vfs.h"
#include "fid.h" #include "fid.h"
static const struct super_operations v9fs_super_ops; static const struct super_operations v9fs_super_ops, v9fs_super_ops_dotl;
/** /**
* v9fs_set_super - set the superblock * v9fs_set_super - set the superblock
...@@ -76,7 +76,10 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, ...@@ -76,7 +76,10 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
sb->s_blocksize_bits = fls(v9ses->maxdata - 1); sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
sb->s_blocksize = 1 << sb->s_blocksize_bits; sb->s_blocksize = 1 << sb->s_blocksize_bits;
sb->s_magic = V9FS_MAGIC; sb->s_magic = V9FS_MAGIC;
sb->s_op = &v9fs_super_ops; if (v9fs_proto_dotl(v9ses))
sb->s_op = &v9fs_super_ops_dotl;
else
sb->s_op = &v9fs_super_ops;
sb->s_bdi = &v9ses->bdi; sb->s_bdi = &v9ses->bdi;
sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
...@@ -222,6 +225,17 @@ static const struct super_operations v9fs_super_ops = { ...@@ -222,6 +225,17 @@ static const struct super_operations v9fs_super_ops = {
.umount_begin = v9fs_umount_begin, .umount_begin = v9fs_umount_begin,
}; };
static const struct super_operations v9fs_super_ops_dotl = {
#ifdef CONFIG_9P_FSCACHE
.alloc_inode = v9fs_alloc_inode,
.destroy_inode = v9fs_destroy_inode,
#endif
.statfs = simple_statfs,
.clear_inode = v9fs_clear_inode,
.show_options = generic_show_options,
.umount_begin = v9fs_umount_begin,
};
struct file_system_type v9fs_fs_type = { struct file_system_type v9fs_fs_type = {
.name = "9p", .name = "9p",
.get_sb = v9fs_get_sb, .get_sb = v9fs_get_sb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment