/*1* V9FS definitions.2*3* Copyright (C) 2004-2008 by Eric Van Hensbergen <[email protected]>4* Copyright (C) 2002 by Ron Minnich <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License version 28* as published by the Free Software Foundation.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to:17* Free Software Foundation18* 51 Franklin Street, Fifth Floor19* Boston, MA 02111-1301 USA20*21*/22#ifndef FS_9P_V9FS_H23#define FS_9P_V9FS_H2425#include <linux/backing-dev.h>2627/**28* enum p9_session_flags - option flags for each 9P session29* @V9FS_PROTO_2000U: whether or not to use 9P2000.u extensions30* @V9FS_PROTO_2000L: whether or not to use 9P2000.l extensions31* @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy32* @V9FS_ACCESS_USER: a new attach will be issued for every user (default)33* @V9FS_ACCESS_CLIENT: Just like user, but access check is performed on client.34* @V9FS_ACCESS_ANY: use a single attach for all users35* @V9FS_ACCESS_MASK: bit mask of different ACCESS options36* @V9FS_POSIX_ACL: POSIX ACLs are enforced37*38* Session flags reflect options selected by users at mount time39*/40#define V9FS_ACCESS_ANY (V9FS_ACCESS_SINGLE | \41V9FS_ACCESS_USER | \42V9FS_ACCESS_CLIENT)43#define V9FS_ACCESS_MASK V9FS_ACCESS_ANY44#define V9FS_ACL_MASK V9FS_POSIX_ACL4546enum p9_session_flags {47V9FS_PROTO_2000U = 0x01,48V9FS_PROTO_2000L = 0x02,49V9FS_ACCESS_SINGLE = 0x04,50V9FS_ACCESS_USER = 0x08,51V9FS_ACCESS_CLIENT = 0x10,52V9FS_POSIX_ACL = 0x2053};5455/* possible values of ->cache */56/**57* enum p9_cache_modes - user specified cache preferences58* @CACHE_NONE: do not cache data, dentries, or directory contents (default)59* @CACHE_LOOSE: cache data, dentries, and directory contents w/no consistency60*61* eventually support loose, tight, time, session, default always none62*/6364enum p9_cache_modes {65CACHE_NONE,66CACHE_LOOSE,67CACHE_FSCACHE,68};6970/**71* struct v9fs_session_info - per-instance session information72* @flags: session options of type &p9_session_flags73* @nodev: set to 1 to disable device mapping74* @debug: debug level75* @afid: authentication handle76* @cache: cache mode of type &p9_cache_modes77* @cachetag: the tag of the cache associated with this session78* @fscache: session cookie associated with FS-Cache79* @options: copy of options string given by user80* @uname: string user name to mount hierarchy as81* @aname: mount specifier for remote hierarchy82* @maxdata: maximum data to be sent/recvd per protocol message83* @dfltuid: default numeric userid to mount hierarchy as84* @dfltgid: default numeric groupid to mount hierarchy as85* @uid: if %V9FS_ACCESS_SINGLE, the numeric uid which mounted the hierarchy86* @clnt: reference to 9P network client instantiated for this session87* @slist: reference to list of registered 9p sessions88*89* This structure holds state for each session instance established during90* a sys_mount() .91*92* Bugs: there seems to be a lot of state which could be condensed and/or93* removed.94*/9596struct v9fs_session_info {97/* options */98unsigned char flags;99unsigned char nodev;100unsigned short debug;101unsigned int afid;102unsigned int cache;103#ifdef CONFIG_9P_FSCACHE104char *cachetag;105struct fscache_cookie *fscache;106#endif107108char *uname; /* user name to mount as */109char *aname; /* name of remote hierarchy being mounted */110unsigned int maxdata; /* max data for client interface */111unsigned int dfltuid; /* default uid/muid for legacy support */112unsigned int dfltgid; /* default gid for legacy support */113u32 uid; /* if ACCESS_SINGLE, the uid that has access */114struct p9_client *clnt; /* 9p client */115struct list_head slist; /* list of sessions registered with v9fs */116struct backing_dev_info bdi;117struct rw_semaphore rename_sem;118};119120/* cache_validity flags */121#define V9FS_INO_INVALID_ATTR 0x01122123struct v9fs_inode {124#ifdef CONFIG_9P_FSCACHE125spinlock_t fscache_lock;126struct fscache_cookie *fscache;127struct p9_qid *fscache_key;128#endif129unsigned int cache_validity;130struct p9_fid *writeback_fid;131struct mutex v_mutex;132struct inode vfs_inode;133};134135static inline struct v9fs_inode *V9FS_I(const struct inode *inode)136{137return container_of(inode, struct v9fs_inode, vfs_inode);138}139140struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,141char *);142extern void v9fs_session_close(struct v9fs_session_info *v9ses);143extern void v9fs_session_cancel(struct v9fs_session_info *v9ses);144extern void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses);145extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,146struct nameidata *nameidata);147extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);148extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);149extern int v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,150struct inode *new_dir, struct dentry *new_dentry);151extern void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd,152void *p);153extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,154struct p9_fid *fid,155struct super_block *sb);156extern const struct inode_operations v9fs_dir_inode_operations_dotl;157extern const struct inode_operations v9fs_file_inode_operations_dotl;158extern const struct inode_operations v9fs_symlink_inode_operations_dotl;159extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,160struct p9_fid *fid,161struct super_block *sb);162163/* other default globals */164#define V9FS_PORT 564165#define V9FS_DEFUSER "nobody"166#define V9FS_DEFANAME ""167#define V9FS_DEFUID (-2)168#define V9FS_DEFGID (-2)169170static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)171{172return (inode->i_sb->s_fs_info);173}174175static inline struct v9fs_session_info *v9fs_dentry2v9ses(struct dentry *dentry)176{177return dentry->d_sb->s_fs_info;178}179180static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses)181{182return v9ses->flags & V9FS_PROTO_2000U;183}184185static inline int v9fs_proto_dotl(struct v9fs_session_info *v9ses)186{187return v9ses->flags & V9FS_PROTO_2000L;188}189190/**191* v9fs_get_inode_from_fid - Helper routine to populate an inode by192* issuing a attribute request193* @v9ses: session information194* @fid: fid to issue attribute request for195* @sb: superblock on which to create inode196*197*/198static inline struct inode *199v9fs_get_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,200struct super_block *sb)201{202if (v9fs_proto_dotl(v9ses))203return v9fs_inode_from_fid_dotl(v9ses, fid, sb);204else205return v9fs_inode_from_fid(v9ses, fid, sb);206}207#endif208209210