0001
0002
0003
0004
0005
0006
0007
0008 #ifndef FS_9P_V9FS_H
0009 #define FS_9P_V9FS_H
0010
0011 #include <linux/backing-dev.h>
0012 #include <linux/netfs.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #define V9FS_ACCESS_ANY (V9FS_ACCESS_SINGLE | \
0028 V9FS_ACCESS_USER | \
0029 V9FS_ACCESS_CLIENT)
0030 #define V9FS_ACCESS_MASK V9FS_ACCESS_ANY
0031 #define V9FS_ACL_MASK V9FS_POSIX_ACL
0032
0033 enum p9_session_flags {
0034 V9FS_PROTO_2000U = 0x01,
0035 V9FS_PROTO_2000L = 0x02,
0036 V9FS_ACCESS_SINGLE = 0x04,
0037 V9FS_ACCESS_USER = 0x08,
0038 V9FS_ACCESS_CLIENT = 0x10,
0039 V9FS_POSIX_ACL = 0x20
0040 };
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 enum p9_cache_modes {
0052 CACHE_NONE,
0053 CACHE_MMAP,
0054 CACHE_LOOSE,
0055 CACHE_FSCACHE,
0056 nr__p9_cache_modes
0057 };
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 struct v9fs_session_info {
0085
0086 unsigned char flags;
0087 unsigned char nodev;
0088 unsigned short debug;
0089 unsigned int afid;
0090 unsigned int cache;
0091 #ifdef CONFIG_9P_FSCACHE
0092 char *cachetag;
0093 struct fscache_volume *fscache;
0094 #endif
0095
0096 char *uname;
0097 char *aname;
0098 unsigned int maxdata;
0099 kuid_t dfltuid;
0100 kgid_t dfltgid;
0101 kuid_t uid;
0102 struct p9_client *clnt;
0103 struct list_head slist;
0104 struct rw_semaphore rename_sem;
0105 long session_lock_timeout;
0106 };
0107
0108
0109 #define V9FS_INO_INVALID_ATTR 0x01
0110
0111 struct v9fs_inode {
0112 struct netfs_inode netfs;
0113 struct p9_qid qid;
0114 unsigned int cache_validity;
0115 struct p9_fid *writeback_fid;
0116 struct mutex v_mutex;
0117 };
0118
0119 static inline struct v9fs_inode *V9FS_I(const struct inode *inode)
0120 {
0121 return container_of(inode, struct v9fs_inode, netfs.inode);
0122 }
0123
0124 static inline struct fscache_cookie *v9fs_inode_cookie(struct v9fs_inode *v9inode)
0125 {
0126 #ifdef CONFIG_9P_FSCACHE
0127 return netfs_i_cookie(&v9inode->netfs);
0128 #else
0129 return NULL;
0130 #endif
0131 }
0132
0133 static inline struct fscache_volume *v9fs_session_cache(struct v9fs_session_info *v9ses)
0134 {
0135 #ifdef CONFIG_9P_FSCACHE
0136 return v9ses->fscache;
0137 #else
0138 return NULL;
0139 #endif
0140 }
0141
0142
0143 extern int v9fs_show_options(struct seq_file *m, struct dentry *root);
0144
0145 struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
0146 const char *dev_name, char *data);
0147 extern void v9fs_session_close(struct v9fs_session_info *v9ses);
0148 extern void v9fs_session_cancel(struct v9fs_session_info *v9ses);
0149 extern void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses);
0150 extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
0151 unsigned int flags);
0152 extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
0153 extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
0154 extern int v9fs_vfs_rename(struct user_namespace *mnt_userns,
0155 struct inode *old_dir, struct dentry *old_dentry,
0156 struct inode *new_dir, struct dentry *new_dentry,
0157 unsigned int flags);
0158 extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
0159 struct p9_fid *fid,
0160 struct super_block *sb, int new);
0161 extern const struct inode_operations v9fs_dir_inode_operations_dotl;
0162 extern const struct inode_operations v9fs_file_inode_operations_dotl;
0163 extern const struct inode_operations v9fs_symlink_inode_operations_dotl;
0164 extern const struct netfs_request_ops v9fs_req_ops;
0165 extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,
0166 struct p9_fid *fid,
0167 struct super_block *sb, int new);
0168
0169
0170 #define V9FS_PORT 564
0171 #define V9FS_DEFUSER "nobody"
0172 #define V9FS_DEFANAME ""
0173 #define V9FS_DEFUID KUIDT_INIT(-2)
0174 #define V9FS_DEFGID KGIDT_INIT(-2)
0175
0176 static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
0177 {
0178 return inode->i_sb->s_fs_info;
0179 }
0180
0181 static inline struct v9fs_session_info *v9fs_dentry2v9ses(struct dentry *dentry)
0182 {
0183 return dentry->d_sb->s_fs_info;
0184 }
0185
0186 static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses)
0187 {
0188 return v9ses->flags & V9FS_PROTO_2000U;
0189 }
0190
0191 static inline int v9fs_proto_dotl(struct v9fs_session_info *v9ses)
0192 {
0193 return v9ses->flags & V9FS_PROTO_2000L;
0194 }
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 static inline struct inode *
0205 v9fs_get_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
0206 struct super_block *sb)
0207 {
0208 if (v9fs_proto_dotl(v9ses))
0209 return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 0);
0210 else
0211 return v9fs_inode_from_fid(v9ses, fid, sb, 0);
0212 }
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222 static inline struct inode *
0223 v9fs_get_new_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
0224 struct super_block *sb)
0225 {
0226 if (v9fs_proto_dotl(v9ses))
0227 return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 1);
0228 else
0229 return v9fs_inode_from_fid(v9ses, fid, sb, 1);
0230 }
0231
0232 #endif