Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Implements VFS switches for 9p2000.L protocol.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

authored by

Sripathi Kodi and committed by
Eric Van Hensbergen
9b6533c9 c56e4acf

+97 -13
+2
fs/9p/v9fs_vfs.h
··· 40 40 extern struct file_system_type v9fs_fs_type; 41 41 extern const struct address_space_operations v9fs_addr_operations; 42 42 extern const struct file_operations v9fs_file_operations; 43 + extern const struct file_operations v9fs_file_operations_dotl; 43 44 extern const struct file_operations v9fs_dir_operations; 45 + extern const struct file_operations v9fs_dir_operations_dotl; 44 46 extern const struct dentry_operations v9fs_dentry_operations; 45 47 extern const struct dentry_operations v9fs_cached_dentry_operations; 46 48
+8
fs/9p/vfs_dir.c
··· 203 203 .open = v9fs_file_open, 204 204 .release = v9fs_dir_release, 205 205 }; 206 + 207 + const struct file_operations v9fs_dir_operations_dotl = { 208 + .read = generic_read_dir, 209 + .llseek = generic_file_llseek, 210 + .readdir = v9fs_dir_readdir, 211 + .open = v9fs_file_open, 212 + .release = v9fs_dir_release, 213 + };
+11
fs/9p/vfs_file.c
··· 296 296 .mmap = generic_file_readonly_mmap, 297 297 .fsync = v9fs_file_fsync, 298 298 }; 299 + 300 + const struct file_operations v9fs_file_operations_dotl = { 301 + .llseek = generic_file_llseek, 302 + .read = v9fs_file_read, 303 + .write = v9fs_file_write, 304 + .open = v9fs_file_open, 305 + .release = v9fs_dir_release, 306 + .lock = v9fs_file_lock, 307 + .mmap = generic_file_readonly_mmap, 308 + .fsync = v9fs_file_fsync, 309 + };
+60 -11
fs/9p/vfs_inode.c
··· 44 44 #include "cache.h" 45 45 46 46 static const struct inode_operations v9fs_dir_inode_operations; 47 - static const struct inode_operations v9fs_dir_inode_operations_ext; 47 + static const struct inode_operations v9fs_dir_inode_operations_dotu; 48 + static const struct inode_operations v9fs_dir_inode_operations_dotl; 48 49 static const struct inode_operations v9fs_file_inode_operations; 50 + static const struct inode_operations v9fs_file_inode_operations_dotl; 49 51 static const struct inode_operations v9fs_symlink_inode_operations; 52 + static const struct inode_operations v9fs_symlink_inode_operations_dotl; 50 53 51 54 /** 52 55 * unixmode2p9mode - convert unix mode bits to plan 9 ··· 278 275 init_special_inode(inode, inode->i_mode, inode->i_rdev); 279 276 break; 280 277 case S_IFREG: 281 - inode->i_op = &v9fs_file_inode_operations; 282 - inode->i_fop = &v9fs_file_operations; 278 + if (v9fs_proto_dotl(v9ses)) { 279 + inode->i_op = &v9fs_file_inode_operations_dotl; 280 + inode->i_fop = &v9fs_file_operations_dotl; 281 + } else { 282 + inode->i_op = &v9fs_file_inode_operations; 283 + inode->i_fop = &v9fs_file_operations; 284 + } 285 + 283 286 break; 287 + 284 288 case S_IFLNK: 285 - if (!v9fs_proto_dotu(v9ses)) { 286 - P9_DPRINTK(P9_DEBUG_ERROR, 287 - "extended modes used w/o 9P2000.u\n"); 289 + if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) { 290 + P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with " 291 + "legacy protocol.\n"); 288 292 err = -EINVAL; 289 293 goto error; 290 294 } 291 - inode->i_op = &v9fs_symlink_inode_operations; 295 + 296 + if (v9fs_proto_dotl(v9ses)) 297 + inode->i_op = &v9fs_symlink_inode_operations_dotl; 298 + else 299 + inode->i_op = &v9fs_symlink_inode_operations; 300 + 292 301 break; 293 302 case S_IFDIR: 294 303 inc_nlink(inode); 295 - if (v9fs_proto_dotu(v9ses)) 296 - inode->i_op = &v9fs_dir_inode_operations_ext; 304 + if (v9fs_proto_dotl(v9ses)) 305 + inode->i_op = &v9fs_dir_inode_operations_dotl; 306 + else if (v9fs_proto_dotu(v9ses)) 307 + inode->i_op = &v9fs_dir_inode_operations_dotu; 297 308 else 298 309 inode->i_op = &v9fs_dir_inode_operations; 299 - inode->i_fop = &v9fs_dir_operations; 310 + 311 + if (v9fs_proto_dotl(v9ses)) 312 + inode->i_fop = &v9fs_dir_operations_dotl; 313 + else 314 + inode->i_fop = &v9fs_dir_operations; 315 + 300 316 break; 301 317 default: 302 318 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", ··· 1230 1208 return retval; 1231 1209 } 1232 1210 1233 - static const struct inode_operations v9fs_dir_inode_operations_ext = { 1211 + static const struct inode_operations v9fs_dir_inode_operations_dotu = { 1212 + .create = v9fs_vfs_create, 1213 + .lookup = v9fs_vfs_lookup, 1214 + .symlink = v9fs_vfs_symlink, 1215 + .link = v9fs_vfs_link, 1216 + .unlink = v9fs_vfs_unlink, 1217 + .mkdir = v9fs_vfs_mkdir, 1218 + .rmdir = v9fs_vfs_rmdir, 1219 + .mknod = v9fs_vfs_mknod, 1220 + .rename = v9fs_vfs_rename, 1221 + .getattr = v9fs_vfs_getattr, 1222 + .setattr = v9fs_vfs_setattr, 1223 + }; 1224 + 1225 + static const struct inode_operations v9fs_dir_inode_operations_dotl = { 1234 1226 .create = v9fs_vfs_create, 1235 1227 .lookup = v9fs_vfs_lookup, 1236 1228 .symlink = v9fs_vfs_symlink, ··· 1275 1239 .setattr = v9fs_vfs_setattr, 1276 1240 }; 1277 1241 1242 + static const struct inode_operations v9fs_file_inode_operations_dotl = { 1243 + .getattr = v9fs_vfs_getattr, 1244 + .setattr = v9fs_vfs_setattr, 1245 + }; 1246 + 1278 1247 static const struct inode_operations v9fs_symlink_inode_operations = { 1248 + .readlink = generic_readlink, 1249 + .follow_link = v9fs_vfs_follow_link, 1250 + .put_link = v9fs_vfs_put_link, 1251 + .getattr = v9fs_vfs_getattr, 1252 + .setattr = v9fs_vfs_setattr, 1253 + }; 1254 + 1255 + static const struct inode_operations v9fs_symlink_inode_operations_dotl = { 1279 1256 .readlink = generic_readlink, 1280 1257 .follow_link = v9fs_vfs_follow_link, 1281 1258 .put_link = v9fs_vfs_put_link,
+16 -2
fs/9p/vfs_super.c
··· 45 45 #include "v9fs_vfs.h" 46 46 #include "fid.h" 47 47 48 - static const struct super_operations v9fs_super_ops; 48 + static const struct super_operations v9fs_super_ops, v9fs_super_ops_dotl; 49 49 50 50 /** 51 51 * v9fs_set_super - set the superblock ··· 76 76 sb->s_blocksize_bits = fls(v9ses->maxdata - 1); 77 77 sb->s_blocksize = 1 << sb->s_blocksize_bits; 78 78 sb->s_magic = V9FS_MAGIC; 79 - sb->s_op = &v9fs_super_ops; 79 + if (v9fs_proto_dotl(v9ses)) 80 + sb->s_op = &v9fs_super_ops_dotl; 81 + else 82 + sb->s_op = &v9fs_super_ops; 80 83 sb->s_bdi = &v9ses->bdi; 81 84 82 85 sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | ··· 215 212 } 216 213 217 214 static const struct super_operations v9fs_super_ops = { 215 + #ifdef CONFIG_9P_FSCACHE 216 + .alloc_inode = v9fs_alloc_inode, 217 + .destroy_inode = v9fs_destroy_inode, 218 + #endif 219 + .statfs = simple_statfs, 220 + .clear_inode = v9fs_clear_inode, 221 + .show_options = generic_show_options, 222 + .umount_begin = v9fs_umount_begin, 223 + }; 224 + 225 + static const struct super_operations v9fs_super_ops_dotl = { 218 226 #ifdef CONFIG_9P_FSCACHE 219 227 .alloc_inode = v9fs_alloc_inode, 220 228 .destroy_inode = v9fs_destroy_inode,