diff mbox

[V9fs-developer,-V2] fs/9p: Add OS dependent open flags in 9p protocol

Message ID 1312965541-19430-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Eric Van Hensbergen
Headers show

Commit Message

Aneesh Kumar K.V Aug. 10, 2011, 8:39 a.m. UTC
Some of the flags are OS/arch dependent we add a 9p
protocol value which maps to asm-generic/fcntl.h values in Linux
Based on the original patch from Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/9p/v9fs_vfs.h       |    2 +
 fs/9p/vfs_file.c       |    2 +-
 fs/9p/vfs_inode.c      |   16 +++++++++++++-
 fs/9p/vfs_inode_dotl.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/net/9p/9p.h    |   24 +++++++++++++++++++++
 5 files changed, 96 insertions(+), 3 deletions(-)

Comments

Aneesh Kumar K.V Aug. 10, 2011, 10:38 a.m. UTC | #1
Hi Eric,

I see that you have pulled -V1 to for-next. Will you be able to update
with this version. I didn't like the large if loop.  I also changed the
authorship, because the patch changed much from what JV sent earlier.

-aneesh

On Wed, 10 Aug 2011 14:09:01 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> Some of the flags are OS/arch dependent we add a 9p
> protocol value which maps to asm-generic/fcntl.h values in Linux
> Based on the original patch from Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  fs/9p/v9fs_vfs.h       |    2 +
>  fs/9p/vfs_file.c       |    2 +-
>  fs/9p/vfs_inode.c      |   16 +++++++++++++-
>  fs/9p/vfs_inode_dotl.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++-
>  include/net/9p/9p.h    |   24 +++++++++++++++++++++
>  5 files changed, 96 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
> index bd86d22..f9a28ea 100644
> --- a/fs/9p/v9fs_vfs.h
> +++ b/fs/9p/v9fs_vfs.h
> @@ -82,4 +82,6 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode)
>  	v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
>  	return;
>  }
> +
> +int v9fs_open_to_dotl_flags(int flags);
>  #endif
> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> index ffed558..56907e4 100644
> --- a/fs/9p/vfs_file.c
> +++ b/fs/9p/vfs_file.c
> @@ -65,7 +65,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
>  	v9inode = V9FS_I(inode);
>  	v9ses = v9fs_inode2v9ses(inode);
>  	if (v9fs_proto_dotl(v9ses))
> -		omode = file->f_flags;
> +		omode = v9fs_open_to_dotl_flags(file->f_flags);
>  	else
>  		omode = v9fs_uflags2omode(file->f_flags,
>  					v9fs_proto_dotu(v9ses));
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index dc645a3..7ced952 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -553,6 +553,19 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
>  }
> 
>  /**
> + * v9fs_at_to_dotl_flags- convert Linux specific AT flags to
> + * plan 9 AT flag.
> + * @flags: flags to convert
> + */
> +static int v9fs_at_to_dotl_flags(int flags)
> +{
> +	int rflags = 0;
> +	if (flags & AT_REMOVEDIR)
> +		rflags |= P9_DOTL_AT_REMOVEDIR;
> +	return rflags;
> +}
> +
> +/**
>   * v9fs_remove - helper function to remove files and directories
>   * @dir: directory inode that is being deleted
>   * @dentry:  dentry that is being deleted
> @@ -579,7 +592,8 @@ static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags)
>  		return retval;
>  	}
>  	if (v9fs_proto_dotl(v9ses))
> -		retval = p9_client_unlinkat(dfid, dentry->d_name.name, flags);
> +		retval = p9_client_unlinkat(dfid, dentry->d_name.name,
> +					    v9fs_at_to_dotl_flags(flags));
>  	if (retval == -EOPNOTSUPP) {
>  		/* Try the one based on path */
>  		v9fid = v9fs_fid_clone(dentry);
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index 818bf6f..c873172 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -191,6 +191,58 @@ v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
>  	return inode;
>  }
> 
> +struct dotl_openflag_map {
> +	int open_flag;
> +	int dotl_flag;
> +};
> +
> +static int v9fs_mapped_dotl_flags(int flags)
> +{
> +	int i;
> +	int rflags = 0;
> +	struct dotl_openflag_map dotl_oflag_map[] = {
> +		{ O_CREAT,	P9_DOTL_CREATE },
> +		{ O_EXCL,	P9_DOTL_EXCL },
> +		{ O_NOCTTY,	P9_DOTL_NOCTTY },
> +		{ O_TRUNC,	P9_DOTL_TRUNC },
> +		{ O_APPEND,	P9_DOTL_APPEND },
> +		{ O_NONBLOCK,	P9_DOTL_NONBLOCK },
> +		{ O_DSYNC,	P9_DOTL_DSYNC },
> +		{ FASYNC,	P9_DOTL_FASYNC },
> +		{ O_DIRECT,	P9_DOTL_DIRECT },
> +		{ O_LARGEFILE,	P9_DOTL_LARGEFILE },
> +		{ O_DIRECTORY,	P9_DOTL_DIRECTORY },
> +		{ O_NOFOLLOW,	P9_DOTL_NOFOLLOW },
> +		{ O_NOATIME,	P9_DOTL_NOATIME },
> +		{ O_CLOEXEC,	P9_DOTL_CLOEXEC },
> +		{ O_SYNC,	P9_DOTL_SYNC},
> +	};
> +	for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
> +		if (flags & dotl_oflag_map[i].open_flag)
> +			rflags |= dotl_oflag_map[i].dotl_flag;
> +	}
> +	return rflags;
> +}
> +
> +/**
> + * v9fs_open_to_dotl_flags- convert Linux specific open flags to
> + * plan 9 open flag.
> + * @flags: flags to convert
> + */
> +int v9fs_open_to_dotl_flags(int flags)
> +{
> +	int rflags = 0;
> +
> +	/*
> +	 * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
> +	 * and P9_DOTL_NOACCESS
> +	 */
> +	rflags |= flags & O_ACCMODE;
> +	rflags |= v9fs_mapped_dotl_flags(flags);
> +
> +	return rflags;
> +}
> +
>  /**
>   * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
>   * @dir: directory inode that is being created
> @@ -259,7 +311,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
>  			   "Failed to get acl values in creat %d\n", err);
>  		goto error;
>  	}
> -	err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
> +	err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
> +				    mode, gid, &qid);
>  	if (err < 0) {
>  		P9_DPRINTK(P9_DEBUG_VFS,
>  				"p9_client_open_dotl failed in creat %d\n",
> diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
> index 700d41e..2063a34 100644
> --- a/include/net/9p/9p.h
> +++ b/include/net/9p/9p.h
> @@ -288,6 +288,30 @@ enum p9_perm_t {
>  	P9_DMSETVTX = 0x00010000,
>  };
> 
> +/* 9p2000.L open flags */
> +#define P9_DOTL_RDONLY        00000000
> +#define P9_DOTL_WRONLY        00000001
> +#define P9_DOTL_RDWR          00000002
> +#define P9_DOTL_NOACCESS      00000003
> +#define P9_DOTL_CREATE        00000100
> +#define P9_DOTL_EXCL          00000200
> +#define P9_DOTL_NOCTTY        00000400
> +#define P9_DOTL_TRUNC         00001000
> +#define P9_DOTL_APPEND        00002000
> +#define P9_DOTL_NONBLOCK      00004000
> +#define P9_DOTL_DSYNC         00010000
> +#define P9_DOTL_FASYNC        00020000
> +#define P9_DOTL_DIRECT        00040000
> +#define P9_DOTL_LARGEFILE     00100000
> +#define P9_DOTL_DIRECTORY     00200000
> +#define P9_DOTL_NOFOLLOW      00400000
> +#define P9_DOTL_NOATIME       01000000
> +#define P9_DOTL_CLOEXEC       02000000
> +#define P9_DOTL_SYNC          04000000
> +
> +/* 9p2000.L at flags */
> +#define P9_DOTL_AT_REMOVEDIR		0x200
> +
>  /**
>   * enum p9_qid_t - QID types
>   * @P9_QTDIR: directory
> -- 
> 1.7.4.1
> 

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
Eric Van Hensbergen Aug. 10, 2011, 12:09 p.m. UTC | #2
Yeah, I can always rebase, nothing is permanent until I send the pull
request to Linus.

On Wed, Aug 10, 2011 at 5:38 AM, Aneesh Kumar K.V
<aneesh.kumar@linux.vnet.ibm.com> wrote:
>
> Hi Eric,
>
> I see that you have pulled -V1 to for-next. Will you be able to update
> with this version. I didn't like the large if loop.  I also changed the
> authorship, because the patch changed much from what JV sent earlier.
>
> -aneesh
>
> On Wed, 10 Aug 2011 14:09:01 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
>> Some of the flags are OS/arch dependent we add a 9p
>> protocol value which maps to asm-generic/fcntl.h values in Linux
>> Based on the original patch from Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>>  fs/9p/v9fs_vfs.h       |    2 +
>>  fs/9p/vfs_file.c       |    2 +-
>>  fs/9p/vfs_inode.c      |   16 +++++++++++++-
>>  fs/9p/vfs_inode_dotl.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++-
>>  include/net/9p/9p.h    |   24 +++++++++++++++++++++
>>  5 files changed, 96 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
>> index bd86d22..f9a28ea 100644
>> --- a/fs/9p/v9fs_vfs.h
>> +++ b/fs/9p/v9fs_vfs.h
>> @@ -82,4 +82,6 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode)
>>       v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
>>       return;
>>  }
>> +
>> +int v9fs_open_to_dotl_flags(int flags);
>>  #endif
>> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
>> index ffed558..56907e4 100644
>> --- a/fs/9p/vfs_file.c
>> +++ b/fs/9p/vfs_file.c
>> @@ -65,7 +65,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
>>       v9inode = V9FS_I(inode);
>>       v9ses = v9fs_inode2v9ses(inode);
>>       if (v9fs_proto_dotl(v9ses))
>> -             omode = file->f_flags;
>> +             omode = v9fs_open_to_dotl_flags(file->f_flags);
>>       else
>>               omode = v9fs_uflags2omode(file->f_flags,
>>                                       v9fs_proto_dotu(v9ses));
>> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
>> index dc645a3..7ced952 100644
>> --- a/fs/9p/vfs_inode.c
>> +++ b/fs/9p/vfs_inode.c
>> @@ -553,6 +553,19 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
>>  }
>>
>>  /**
>> + * v9fs_at_to_dotl_flags- convert Linux specific AT flags to
>> + * plan 9 AT flag.
>> + * @flags: flags to convert
>> + */
>> +static int v9fs_at_to_dotl_flags(int flags)
>> +{
>> +     int rflags = 0;
>> +     if (flags & AT_REMOVEDIR)
>> +             rflags |= P9_DOTL_AT_REMOVEDIR;
>> +     return rflags;
>> +}
>> +
>> +/**
>>   * v9fs_remove - helper function to remove files and directories
>>   * @dir: directory inode that is being deleted
>>   * @dentry:  dentry that is being deleted
>> @@ -579,7 +592,8 @@ static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags)
>>               return retval;
>>       }
>>       if (v9fs_proto_dotl(v9ses))
>> -             retval = p9_client_unlinkat(dfid, dentry->d_name.name, flags);
>> +             retval = p9_client_unlinkat(dfid, dentry->d_name.name,
>> +                                         v9fs_at_to_dotl_flags(flags));
>>       if (retval == -EOPNOTSUPP) {
>>               /* Try the one based on path */
>>               v9fid = v9fs_fid_clone(dentry);
>> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
>> index 818bf6f..c873172 100644
>> --- a/fs/9p/vfs_inode_dotl.c
>> +++ b/fs/9p/vfs_inode_dotl.c
>> @@ -191,6 +191,58 @@ v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
>>       return inode;
>>  }
>>
>> +struct dotl_openflag_map {
>> +     int open_flag;
>> +     int dotl_flag;
>> +};
>> +
>> +static int v9fs_mapped_dotl_flags(int flags)
>> +{
>> +     int i;
>> +     int rflags = 0;
>> +     struct dotl_openflag_map dotl_oflag_map[] = {
>> +             { O_CREAT,      P9_DOTL_CREATE },
>> +             { O_EXCL,       P9_DOTL_EXCL },
>> +             { O_NOCTTY,     P9_DOTL_NOCTTY },
>> +             { O_TRUNC,      P9_DOTL_TRUNC },
>> +             { O_APPEND,     P9_DOTL_APPEND },
>> +             { O_NONBLOCK,   P9_DOTL_NONBLOCK },
>> +             { O_DSYNC,      P9_DOTL_DSYNC },
>> +             { FASYNC,       P9_DOTL_FASYNC },
>> +             { O_DIRECT,     P9_DOTL_DIRECT },
>> +             { O_LARGEFILE,  P9_DOTL_LARGEFILE },
>> +             { O_DIRECTORY,  P9_DOTL_DIRECTORY },
>> +             { O_NOFOLLOW,   P9_DOTL_NOFOLLOW },
>> +             { O_NOATIME,    P9_DOTL_NOATIME },
>> +             { O_CLOEXEC,    P9_DOTL_CLOEXEC },
>> +             { O_SYNC,       P9_DOTL_SYNC},
>> +     };
>> +     for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
>> +             if (flags & dotl_oflag_map[i].open_flag)
>> +                     rflags |= dotl_oflag_map[i].dotl_flag;
>> +     }
>> +     return rflags;
>> +}
>> +
>> +/**
>> + * v9fs_open_to_dotl_flags- convert Linux specific open flags to
>> + * plan 9 open flag.
>> + * @flags: flags to convert
>> + */
>> +int v9fs_open_to_dotl_flags(int flags)
>> +{
>> +     int rflags = 0;
>> +
>> +     /*
>> +      * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
>> +      * and P9_DOTL_NOACCESS
>> +      */
>> +     rflags |= flags & O_ACCMODE;
>> +     rflags |= v9fs_mapped_dotl_flags(flags);
>> +
>> +     return rflags;
>> +}
>> +
>>  /**
>>   * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
>>   * @dir: directory inode that is being created
>> @@ -259,7 +311,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
>>                          "Failed to get acl values in creat %d\n", err);
>>               goto error;
>>       }
>> -     err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
>> +     err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
>> +                                 mode, gid, &qid);
>>       if (err < 0) {
>>               P9_DPRINTK(P9_DEBUG_VFS,
>>                               "p9_client_open_dotl failed in creat %d\n",
>> diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
>> index 700d41e..2063a34 100644
>> --- a/include/net/9p/9p.h
>> +++ b/include/net/9p/9p.h
>> @@ -288,6 +288,30 @@ enum p9_perm_t {
>>       P9_DMSETVTX = 0x00010000,
>>  };
>>
>> +/* 9p2000.L open flags */
>> +#define P9_DOTL_RDONLY        00000000
>> +#define P9_DOTL_WRONLY        00000001
>> +#define P9_DOTL_RDWR          00000002
>> +#define P9_DOTL_NOACCESS      00000003
>> +#define P9_DOTL_CREATE        00000100
>> +#define P9_DOTL_EXCL          00000200
>> +#define P9_DOTL_NOCTTY        00000400
>> +#define P9_DOTL_TRUNC         00001000
>> +#define P9_DOTL_APPEND        00002000
>> +#define P9_DOTL_NONBLOCK      00004000
>> +#define P9_DOTL_DSYNC         00010000
>> +#define P9_DOTL_FASYNC        00020000
>> +#define P9_DOTL_DIRECT        00040000
>> +#define P9_DOTL_LARGEFILE     00100000
>> +#define P9_DOTL_DIRECTORY     00200000
>> +#define P9_DOTL_NOFOLLOW      00400000
>> +#define P9_DOTL_NOATIME       01000000
>> +#define P9_DOTL_CLOEXEC       02000000
>> +#define P9_DOTL_SYNC          04000000
>> +
>> +/* 9p2000.L at flags */
>> +#define P9_DOTL_AT_REMOVEDIR         0x200
>> +
>>  /**
>>   * enum p9_qid_t - QID types
>>   * @P9_QTDIR: directory
>> --
>> 1.7.4.1
>>
>
> ------------------------------------------------------------------------------
> uberSVN's rich system and user administration capabilities and model
> configuration take the hassle out of deploying and managing Subversion and
> the tools developers use with it. Learn more about uberSVN and get a free
> download at:  http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> V9fs-developer mailing list
> V9fs-developer@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/v9fs-developer
>

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
diff mbox

Patch

diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index bd86d22..f9a28ea 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -82,4 +82,6 @@  static inline void v9fs_invalidate_inode_attr(struct inode *inode)
 	v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
 	return;
 }
+
+int v9fs_open_to_dotl_flags(int flags);
 #endif
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index ffed558..56907e4 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -65,7 +65,7 @@  int v9fs_file_open(struct inode *inode, struct file *file)
 	v9inode = V9FS_I(inode);
 	v9ses = v9fs_inode2v9ses(inode);
 	if (v9fs_proto_dotl(v9ses))
-		omode = file->f_flags;
+		omode = v9fs_open_to_dotl_flags(file->f_flags);
 	else
 		omode = v9fs_uflags2omode(file->f_flags,
 					v9fs_proto_dotu(v9ses));
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index dc645a3..7ced952 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -553,6 +553,19 @@  v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
 }
 
 /**
+ * v9fs_at_to_dotl_flags- convert Linux specific AT flags to
+ * plan 9 AT flag.
+ * @flags: flags to convert
+ */
+static int v9fs_at_to_dotl_flags(int flags)
+{
+	int rflags = 0;
+	if (flags & AT_REMOVEDIR)
+		rflags |= P9_DOTL_AT_REMOVEDIR;
+	return rflags;
+}
+
+/**
  * v9fs_remove - helper function to remove files and directories
  * @dir: directory inode that is being deleted
  * @dentry:  dentry that is being deleted
@@ -579,7 +592,8 @@  static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags)
 		return retval;
 	}
 	if (v9fs_proto_dotl(v9ses))
-		retval = p9_client_unlinkat(dfid, dentry->d_name.name, flags);
+		retval = p9_client_unlinkat(dfid, dentry->d_name.name,
+					    v9fs_at_to_dotl_flags(flags));
 	if (retval == -EOPNOTSUPP) {
 		/* Try the one based on path */
 		v9fid = v9fs_fid_clone(dentry);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 818bf6f..c873172 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -191,6 +191,58 @@  v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
 	return inode;
 }
 
+struct dotl_openflag_map {
+	int open_flag;
+	int dotl_flag;
+};
+
+static int v9fs_mapped_dotl_flags(int flags)
+{
+	int i;
+	int rflags = 0;
+	struct dotl_openflag_map dotl_oflag_map[] = {
+		{ O_CREAT,	P9_DOTL_CREATE },
+		{ O_EXCL,	P9_DOTL_EXCL },
+		{ O_NOCTTY,	P9_DOTL_NOCTTY },
+		{ O_TRUNC,	P9_DOTL_TRUNC },
+		{ O_APPEND,	P9_DOTL_APPEND },
+		{ O_NONBLOCK,	P9_DOTL_NONBLOCK },
+		{ O_DSYNC,	P9_DOTL_DSYNC },
+		{ FASYNC,	P9_DOTL_FASYNC },
+		{ O_DIRECT,	P9_DOTL_DIRECT },
+		{ O_LARGEFILE,	P9_DOTL_LARGEFILE },
+		{ O_DIRECTORY,	P9_DOTL_DIRECTORY },
+		{ O_NOFOLLOW,	P9_DOTL_NOFOLLOW },
+		{ O_NOATIME,	P9_DOTL_NOATIME },
+		{ O_CLOEXEC,	P9_DOTL_CLOEXEC },
+		{ O_SYNC,	P9_DOTL_SYNC},
+	};
+	for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
+		if (flags & dotl_oflag_map[i].open_flag)
+			rflags |= dotl_oflag_map[i].dotl_flag;
+	}
+	return rflags;
+}
+
+/**
+ * v9fs_open_to_dotl_flags- convert Linux specific open flags to
+ * plan 9 open flag.
+ * @flags: flags to convert
+ */
+int v9fs_open_to_dotl_flags(int flags)
+{
+	int rflags = 0;
+
+	/*
+	 * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
+	 * and P9_DOTL_NOACCESS
+	 */
+	rflags |= flags & O_ACCMODE;
+	rflags |= v9fs_mapped_dotl_flags(flags);
+
+	return rflags;
+}
+
 /**
  * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
  * @dir: directory inode that is being created
@@ -259,7 +311,8 @@  v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
 			   "Failed to get acl values in creat %d\n", err);
 		goto error;
 	}
-	err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
+	err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
+				    mode, gid, &qid);
 	if (err < 0) {
 		P9_DPRINTK(P9_DEBUG_VFS,
 				"p9_client_open_dotl failed in creat %d\n",
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 700d41e..2063a34 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -288,6 +288,30 @@  enum p9_perm_t {
 	P9_DMSETVTX = 0x00010000,
 };
 
+/* 9p2000.L open flags */
+#define P9_DOTL_RDONLY        00000000
+#define P9_DOTL_WRONLY        00000001
+#define P9_DOTL_RDWR          00000002
+#define P9_DOTL_NOACCESS      00000003
+#define P9_DOTL_CREATE        00000100
+#define P9_DOTL_EXCL          00000200
+#define P9_DOTL_NOCTTY        00000400
+#define P9_DOTL_TRUNC         00001000
+#define P9_DOTL_APPEND        00002000
+#define P9_DOTL_NONBLOCK      00004000
+#define P9_DOTL_DSYNC         00010000
+#define P9_DOTL_FASYNC        00020000
+#define P9_DOTL_DIRECT        00040000
+#define P9_DOTL_LARGEFILE     00100000
+#define P9_DOTL_DIRECTORY     00200000
+#define P9_DOTL_NOFOLLOW      00400000
+#define P9_DOTL_NOATIME       01000000
+#define P9_DOTL_CLOEXEC       02000000
+#define P9_DOTL_SYNC          04000000
+
+/* 9p2000.L at flags */
+#define P9_DOTL_AT_REMOVEDIR		0x200
+
 /**
  * enum p9_qid_t - QID types
  * @P9_QTDIR: directory