fs/9p: Initialize root inode number for dotl
[deliverable/linux.git] / fs / 9p / v9fs.h
CommitLineData
9e82cf6a
EVH
1/*
2 * V9FS definitions.
3 *
8a0dc95f 4 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
9e82cf6a
EVH
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 *
7 * This program is free software; you can redistribute it and/or modify
42e8c509
EVH
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
9e82cf6a
EVH
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to:
18 * Free Software Foundation
19 * 51 Franklin Street, Fifth Floor
20 * Boston, MA 02111-1301 USA
21 *
22 */
0ed07ddb 23#include <linux/backing-dev.h>
9e82cf6a 24
ee443996
EVH
25/**
26 * enum p9_session_flags - option flags for each 9P session
dd6102fb 27 * @V9FS_PROTO_2000U: whether or not to use 9P2000.u extensions
45bc21ed 28 * @V9FS_PROTO_2000L: whether or not to use 9P2000.l extensions
ee443996
EVH
29 * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy
30 * @V9FS_ACCESS_USER: a new attach will be issued for every user (default)
e782ef71 31 * @V9FS_ACCESS_CLIENT: Just like user, but access check is performed on client.
ee443996
EVH
32 * @V9FS_ACCESS_ANY: use a single attach for all users
33 * @V9FS_ACCESS_MASK: bit mask of different ACCESS options
e782ef71 34 * @V9FS_POSIX_ACL: POSIX ACLs are enforced
ee443996
EVH
35 *
36 * Session flags reflect options selected by users at mount time
37 */
76381a42
AK
38#define V9FS_ACCESS_ANY (V9FS_ACCESS_SINGLE | \
39 V9FS_ACCESS_USER | \
40 V9FS_ACCESS_CLIENT)
41#define V9FS_ACCESS_MASK V9FS_ACCESS_ANY
e782ef71 42#define V9FS_ACL_MASK V9FS_POSIX_ACL
76381a42 43
ee443996 44enum p9_session_flags {
dd6102fb 45 V9FS_PROTO_2000U = 0x01,
45bc21ed 46 V9FS_PROTO_2000L = 0x02,
dd6102fb
SK
47 V9FS_ACCESS_SINGLE = 0x04,
48 V9FS_ACCESS_USER = 0x08,
e782ef71
VJJ
49 V9FS_ACCESS_CLIENT = 0x10,
50 V9FS_POSIX_ACL = 0x20
ee443996
EVH
51};
52
53/* possible values of ->cache */
54/**
55 * enum p9_cache_modes - user specified cache preferences
56 * @CACHE_NONE: do not cache data, dentries, or directory contents (default)
57 * @CACHE_LOOSE: cache data, dentries, and directory contents w/no consistency
58 *
59 * eventually support loose, tight, time, session, default always none
60 */
61
62enum p9_cache_modes {
63 CACHE_NONE,
64 CACHE_LOOSE,
60e78d2c 65 CACHE_FSCACHE,
ee443996
EVH
66};
67
68/**
69 * struct v9fs_session_info - per-instance session information
70 * @flags: session options of type &p9_session_flags
71 * @nodev: set to 1 to disable device mapping
72 * @debug: debug level
73 * @afid: authentication handle
74 * @cache: cache mode of type &p9_cache_modes
60e78d2c
AK
75 * @cachetag: the tag of the cache associated with this session
76 * @fscache: session cookie associated with FS-Cache
ee443996
EVH
77 * @options: copy of options string given by user
78 * @uname: string user name to mount hierarchy as
79 * @aname: mount specifier for remote hierarchy
80 * @maxdata: maximum data to be sent/recvd per protocol message
81 * @dfltuid: default numeric userid to mount hierarchy as
82 * @dfltgid: default numeric groupid to mount hierarchy as
83 * @uid: if %V9FS_ACCESS_SINGLE, the numeric uid which mounted the hierarchy
84 * @clnt: reference to 9P network client instantiated for this session
60e78d2c 85 * @slist: reference to list of registered 9p sessions
ee443996
EVH
86 *
87 * This structure holds state for each session instance established during
88 * a sys_mount() .
89 *
90 * Bugs: there seems to be a lot of state which could be condensed and/or
91 * removed.
92 */
9e82cf6a
EVH
93
94struct v9fs_session_info {
95 /* options */
ee443996
EVH
96 unsigned char flags;
97 unsigned char nodev;
98 unsigned short debug;
99 unsigned int afid;
100 unsigned int cache;
60e78d2c
AK
101#ifdef CONFIG_9P_FSCACHE
102 char *cachetag;
103 struct fscache_cookie *fscache;
104#endif
9e82cf6a 105
ba17674f
LI
106 char *uname; /* user name to mount as */
107 char *aname; /* name of remote hierarchy being mounted */
8a0dc95f 108 unsigned int maxdata; /* max data for client interface */
bd32b82d
LI
109 unsigned int dfltuid; /* default uid/muid for legacy support */
110 unsigned int dfltgid; /* default gid for legacy support */
ba17674f 111 u32 uid; /* if ACCESS_SINGLE, the uid that has access */
bd238fb4 112 struct p9_client *clnt; /* 9p client */
60e78d2c 113 struct list_head slist; /* list of sessions registered with v9fs */
0ed07ddb 114 struct backing_dev_info bdi;
a534c8d1 115 struct rw_semaphore rename_sem;
00ea2df4 116 struct p9_fid *root_fid; /* Used for file system sync */
9e82cf6a
EVH
117};
118
a78ce05d
AK
119struct v9fs_inode {
120#ifdef CONFIG_9P_FSCACHE
121 spinlock_t fscache_lock;
122 struct fscache_cookie *fscache;
123 struct p9_qid *fscache_key;
124#endif
6b39f6d2 125 struct p9_fid *writeback_fid;
a78ce05d
AK
126 struct inode vfs_inode;
127};
128
129static inline struct v9fs_inode *V9FS_I(const struct inode *inode)
130{
131 return container_of(inode, struct v9fs_inode, vfs_inode);
132}
133
bd238fb4
LI
134struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
135 char *);
53c06f4e
AK
136extern void v9fs_session_close(struct v9fs_session_info *v9ses);
137extern void v9fs_session_cancel(struct v9fs_session_info *v9ses);
138extern void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses);
139extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
140 struct nameidata *nameidata);
141extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
142extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
143extern int v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
144 struct inode *new_dir, struct dentry *new_dentry);
145extern void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd,
146 void *p);
a78ce05d
AK
147extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
148 struct p9_fid *fid,
149 struct super_block *sb);
53c06f4e
AK
150extern const struct inode_operations v9fs_dir_inode_operations_dotl;
151extern const struct inode_operations v9fs_file_inode_operations_dotl;
152extern const struct inode_operations v9fs_symlink_inode_operations_dotl;
a78ce05d
AK
153extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,
154 struct p9_fid *fid,
155 struct super_block *sb);
9e82cf6a 156
9e82cf6a 157/* other default globals */
bd32b82d 158#define V9FS_PORT 564
9e82cf6a
EVH
159#define V9FS_DEFUSER "nobody"
160#define V9FS_DEFANAME ""
bd32b82d
LI
161#define V9FS_DEFUID (-2)
162#define V9FS_DEFGID (-2)
9e82cf6a 163
bd238fb4
LI
164static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
165{
166 return (inode->i_sb->s_fs_info);
167}
2405669b 168
dd6102fb 169static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses)
2405669b 170{
dd6102fb
SK
171 return v9ses->flags & V9FS_PROTO_2000U;
172}
173
174static inline int v9fs_proto_dotl(struct v9fs_session_info *v9ses)
175{
45bc21ed 176 return v9ses->flags & V9FS_PROTO_2000L;
2405669b 177}
53c06f4e
AK
178
179/**
a78ce05d 180 * v9fs_get_inode_from_fid - Helper routine to populate an inode by
53c06f4e
AK
181 * issuing a attribute request
182 * @v9ses: session information
183 * @fid: fid to issue attribute request for
184 * @sb: superblock on which to create inode
185 *
186 */
187static inline struct inode *
a78ce05d
AK
188v9fs_get_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
189 struct super_block *sb)
53c06f4e
AK
190{
191 if (v9fs_proto_dotl(v9ses))
a78ce05d 192 return v9fs_inode_from_fid_dotl(v9ses, fid, sb);
53c06f4e 193 else
a78ce05d 194 return v9fs_inode_from_fid(v9ses, fid, sb);
53c06f4e 195}
This page took 0.470438 seconds and 5 git commands to generate.