9p: define session flags

Create more general flags field in the v9fs_session_info struct and move the
'extended' flag as a bit in the flags.

Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
This commit is contained in:
Latchesar Ionkov 2007-10-17 14:31:07 -05:00 committed by Eric Van Hensbergen
parent a80d923e13
commit 2405669b25
3 changed files with 27 additions and 17 deletions

View File

@ -128,7 +128,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
/* setup defaults */ /* setup defaults */
v9ses->maxdata = 8192; v9ses->maxdata = 8192;
v9ses->extended = 1; v9ses->flags = V9FS_EXTENDED;
v9ses->afid = ~0; v9ses->afid = ~0;
v9ses->debug = 0; v9ses->debug = 0;
v9ses->cache = 0; v9ses->cache = 0;
@ -178,7 +178,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
match_strcpy(v9ses->remotename, &args[0]); match_strcpy(v9ses->remotename, &args[0]);
break; break;
case Opt_legacy: case Opt_legacy:
v9ses->extended = 0; v9ses->flags &= ~V9FS_EXTENDED;
break; break;
case Opt_nodevmap: case Opt_nodevmap:
v9ses->nodev = 1; v9ses->nodev = 1;
@ -244,7 +244,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
v9ses->maxdata = v9ses->trans->maxsize-P9_IOHDRSZ; v9ses->maxdata = v9ses->trans->maxsize-P9_IOHDRSZ;
v9ses->clnt = p9_client_create(trans, v9ses->maxdata+P9_IOHDRSZ, v9ses->clnt = p9_client_create(trans, v9ses->maxdata+P9_IOHDRSZ,
v9ses->extended); v9fs_extended(v9ses));
if (IS_ERR(v9ses->clnt)) { if (IS_ERR(v9ses->clnt)) {
retval = PTR_ERR(v9ses->clnt); retval = PTR_ERR(v9ses->clnt);

View File

@ -29,7 +29,7 @@
struct v9fs_session_info { struct v9fs_session_info {
/* options */ /* options */
unsigned int maxdata; unsigned int maxdata;
unsigned char extended; /* set to 1 if we are using UNIX extensions */ unsigned char flags; /* session flags */
unsigned char nodev; /* set to 1 if no disable device mapping */ unsigned char nodev; /* set to 1 if no disable device mapping */
unsigned short debug; /* debug level */ unsigned short debug; /* debug level */
unsigned int afid; /* authentication fid */ unsigned int afid; /* authentication fid */
@ -45,6 +45,11 @@ struct v9fs_session_info {
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
}; };
/* session flags */
enum {
V9FS_EXTENDED,
};
/* possible values of ->cache */ /* possible values of ->cache */
/* eventually support loose, tight, time, session, default always none */ /* eventually support loose, tight, time, session, default always none */
enum { enum {
@ -70,3 +75,8 @@ static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
{ {
return (inode->i_sb->s_fs_info); return (inode->i_sb->s_fs_info);
} }
static inline int v9fs_extended(struct v9fs_session_info *v9ses)
{
return v9ses->flags & V9FS_EXTENDED;
}

View File

@ -59,7 +59,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
res = mode & 0777; res = mode & 0777;
if (S_ISDIR(mode)) if (S_ISDIR(mode))
res |= P9_DMDIR; res |= P9_DMDIR;
if (v9ses->extended) { if (v9fs_extended(v9ses)) {
if (S_ISLNK(mode)) if (S_ISLNK(mode))
res |= P9_DMSYMLINK; res |= P9_DMSYMLINK;
if (v9ses->nodev == 0) { if (v9ses->nodev == 0) {
@ -99,21 +99,21 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
if ((mode & P9_DMDIR) == P9_DMDIR) if ((mode & P9_DMDIR) == P9_DMDIR)
res |= S_IFDIR; res |= S_IFDIR;
else if ((mode & P9_DMSYMLINK) && (v9ses->extended)) else if ((mode & P9_DMSYMLINK) && (v9fs_extended(v9ses)))
res |= S_IFLNK; res |= S_IFLNK;
else if ((mode & P9_DMSOCKET) && (v9ses->extended) else if ((mode & P9_DMSOCKET) && (v9fs_extended(v9ses))
&& (v9ses->nodev == 0)) && (v9ses->nodev == 0))
res |= S_IFSOCK; res |= S_IFSOCK;
else if ((mode & P9_DMNAMEDPIPE) && (v9ses->extended) else if ((mode & P9_DMNAMEDPIPE) && (v9fs_extended(v9ses))
&& (v9ses->nodev == 0)) && (v9ses->nodev == 0))
res |= S_IFIFO; res |= S_IFIFO;
else if ((mode & P9_DMDEVICE) && (v9ses->extended) else if ((mode & P9_DMDEVICE) && (v9fs_extended(v9ses))
&& (v9ses->nodev == 0)) && (v9ses->nodev == 0))
res |= S_IFBLK; res |= S_IFBLK;
else else
res |= S_IFREG; res |= S_IFREG;
if (v9ses->extended) { if (v9fs_extended(v9ses)) {
if ((mode & P9_DMSETUID) == P9_DMSETUID) if ((mode & P9_DMSETUID) == P9_DMSETUID)
res |= S_ISUID; res |= S_ISUID;
@ -214,7 +214,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
case S_IFBLK: case S_IFBLK:
case S_IFCHR: case S_IFCHR:
case S_IFSOCK: case S_IFSOCK:
if(!v9ses->extended) { if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
"special files without extended mode\n"); "special files without extended mode\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
@ -227,7 +227,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
inode->i_fop = &v9fs_file_operations; inode->i_fop = &v9fs_file_operations;
break; break;
case S_IFLNK: case S_IFLNK:
if(!v9ses->extended) { if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
"extended modes used w/o 9P2000.u\n"); "extended modes used w/o 9P2000.u\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
@ -236,7 +236,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
break; break;
case S_IFDIR: case S_IFDIR:
inc_nlink(inode); inc_nlink(inode);
if(v9ses->extended) if (v9fs_extended(v9ses))
inode->i_op = &v9fs_dir_inode_operations_ext; inode->i_op = &v9fs_dir_inode_operations_ext;
else else
inode->i_op = &v9fs_dir_inode_operations; inode->i_op = &v9fs_dir_inode_operations;
@ -768,7 +768,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (iattr->ia_valid & ATTR_SIZE) if (iattr->ia_valid & ATTR_SIZE)
wstat.length = iattr->ia_size; wstat.length = iattr->ia_size;
if (v9ses->extended) { if (v9fs_extended(v9ses)) {
if (iattr->ia_valid & ATTR_UID) if (iattr->ia_valid & ATTR_UID)
wstat.n_uid = iattr->ia_uid; wstat.n_uid = iattr->ia_uid;
@ -808,7 +808,7 @@ v9fs_stat2inode(struct p9_stat *stat, struct inode *inode,
inode->i_uid = v9ses->uid; inode->i_uid = v9ses->uid;
inode->i_gid = v9ses->gid; inode->i_gid = v9ses->gid;
if (v9ses->extended) { if (v9fs_extended(v9ses)) {
inode->i_uid = stat->n_uid; inode->i_uid = stat->n_uid;
inode->i_gid = stat->n_gid; inode->i_gid = stat->n_gid;
} }
@ -890,7 +890,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
if(IS_ERR(fid)) if(IS_ERR(fid))
return PTR_ERR(fid); return PTR_ERR(fid);
if (!v9ses->extended) if (!v9fs_extended(v9ses))
return -EBADF; return -EBADF;
st = p9_client_stat(fid); st = p9_client_stat(fid);
@ -1011,7 +1011,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
struct p9_fid *fid; struct p9_fid *fid;
v9ses = v9fs_inode2v9ses(dir); v9ses = v9fs_inode2v9ses(dir);
if (!v9ses->extended) { if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n"); P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n");
return -EPERM; return -EPERM;
} }