* [PATCH 2/2] Shared flags: use in cifs client
@ 2008-11-10 13:58 Pavel Shilovsky
2008-11-10 14:34 ` Benny Halevy
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Shilovsky @ 2008-11-10 13:58 UTC (permalink / raw)
To: linux-fsdevel
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 57ecdc8..1d08705 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -591,7 +591,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen,
struct inode *inode,
int oplock = 0;
/* open file */
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
- READ_CONTROL, 0, &fid, &oplock, NULL,
+ READ_CONTROL, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc != 0) {
@@ -645,7 +645,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd,
__u32 acllen,
int oplock = 0;
/* open file */
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
- WRITE_DAC, 0, &fid, &oplock, NULL,
+ WRITE_DAC, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc != 0) {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 0cff7fe..88732bc 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -261,7 +261,7 @@ extern int CIFSSMBQueryReparseLinkInfo(const int xid,
extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
const char *fileName, const int disposition,
- const int access_flags, const int omode,
+ const int access_flags, const int share_flags, const int omode,
__u16 *netfid, int *pOplock, FILE_ALL_INFO *,
const struct nls_table *nls_codepage, int remap);
extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 843a85f..39c30c9 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1322,7 +1322,7 @@ OldOpenRetry:
int
CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
const char *fileName, const int openDisposition,
- const int access_flags, const int create_options, __u16 *netfid,
+ const int access_flags, const int share_flags, const int
create_options, __u16 *netfid,
int *pOplock, FILE_ALL_INFO *pfile_info,
const struct nls_table *nls_codepage, int remap)
{
@@ -1379,7 +1379,7 @@ openRetry:
if (create_options & CREATE_OPTION_READONLY)
pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
- pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
+ pSMB->ShareAccess = cpu_to_le32(share_flags);
pSMB->CreateDisposition = cpu_to_le32(openDisposition);
pSMB->CreateOptions = cpu_to_le32(create_options &
CREATE_OPTIONS_MASK);
/* BB Expirement with various impersonation levels and verify */
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e962e75..f440996 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -207,7 +207,7 @@ cifs_create(struct inode *inode, struct dentry
*direntry, int mode,
if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
- desiredAccess, create_options,
+ desiredAccess, FILE_SHARE_ALL, create_options,
&fileHandle, &oplock, buf, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
else
@@ -417,6 +417,7 @@ int cifs_mknod(struct inode *inode, struct dentry
*direntry, int mode,
WRITE_OWNER | WRITE_DAC be better? */,
/* Create a file and set the
file attribute to SYSTEM */
+ FILE_SHARE_ALL,
CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
&fileHandle, &oplock, buf,
cifs_sb->local_nls,
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 5a57581..9dc88ca 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -89,7 +89,7 @@ int cifs_dir_notify(struct file *file, unsigned long arg)
} else {
cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
- GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
+ GENERIC_READ | SYNCHRONIZE, FILE_SHARE_ALL, 0 /* create
options */,
&netfid, &oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
/* BB fixme - add this handle to a notify handle list */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 62d8bd8..4981d75 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -96,6 +96,11 @@ static inline int cifs_get_disposition(unsigned int
flags)
return FILE_OPEN;
}
+static inline int cifs_get_share_flags(unsigned int flags)
+{
+ return ((~(flags>>21))&7);
+}
+
/* all arguments to this function must be checked for validity in caller */
static inline int cifs_open_inode_helper(struct inode *inode, struct
file *file,
struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,
@@ -173,6 +178,7 @@ int cifs_open(struct inode *inode, struct file *file)
struct list_head *tmp;
char *full_path = NULL;
int desiredAccess;
+ int desiredShare;
int disposition;
__u16 netfid;
FILE_ALL_INFO *buf = NULL;
@@ -221,6 +227,7 @@ int cifs_open(struct inode *inode, struct file *file)
cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
inode, file->f_flags, full_path));
desiredAccess = cifs_convert_flags(file->f_flags);
+ desiredShare = cifs_get_share_flags(file->f_flags);
/*********************************************************************
* open flag mapping table:
@@ -270,7 +277,7 @@ int cifs_open(struct inode *inode, struct file *file)
if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
- desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
+ desiredAccess, desiredShare, CREATE_NOT_DIR, &netfid,
&oplock, buf,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR);
else
@@ -355,6 +362,7 @@ static int cifs_reopen_file(struct file *file, bool
can_flush)
struct inode *inode;
char *full_path = NULL;
int desiredAccess;
+ int desiredShare;
int disposition = FILE_OPEN;
__u16 netfid;
@@ -405,6 +413,7 @@ reopen_error_exit:
cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
inode, file->f_flags, full_path));
desiredAccess = cifs_convert_flags(file->f_flags);
+ desiredShare = cifs_get_share_flags(file->f_flags);
if (oplockEnabled)
oplock = REQ_OPLOCK;
@@ -417,7 +426,7 @@ reopen_error_exit:
and server version of file size can be stale. If we knew for sure
that inode was not dirty locally we could do this */
- rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
+ rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
desiredShare,
CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index d54fa8a..66d8785 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -294,7 +294,7 @@ static int decode_sfu_inode(struct inode *inode,
__u64 size,
return -EINVAL; /* EOPNOTSUPP? */
}
- rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
+ rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
FILE_SHARE_ALL,
CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
@@ -740,7 +740,7 @@ cifs_set_file_info(struct inode *inode, struct iattr
*attrs, int xid,
cFYI(1, ("calling SetFileInfo since SetPathInfo for "
"times not supported by this server"));
rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
- SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
+ SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL,
CREATE_NOT_DIR, &netfid, &oplock,
NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
@@ -786,7 +786,7 @@ cifs_rename_pending_delete(char *full_path, struct
dentry *dentry, int xid)
FILE_BASIC_INFO *info_buf = NULL;
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
- DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
+ DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL, CREATE_NOT_DIR,
&netfid, &oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc != 0)
@@ -1268,7 +1268,7 @@ cifs_do_rename(int xid, struct dentry
*from_dentry, const char *fromPath,
return rc;
/* open the file to be renamed -- we need DELETE perms */
- rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
+ rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
FILE_SHARE_ALL,
CREATE_NOT_DIR, &srcfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 63f6440..7c9f495 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -279,7 +279,7 @@ cifs_readlink(struct dentry *direntry, char __user
*pBuffer, int buflen)
cERROR(1, ("SFU style symlinks not implemented yet"));
/* add open and read as in fs/cifs/inode.c */
} else {
- rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
+ rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
GENERIC_READ, FILE_SHARE_ALL,
OPEN_REPARSE_POINT, &fid, &oplock, NULL,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index e9527ee..059211c 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -269,7 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const
char *ea_name,
__u32 buflen = 0;
if (experimEnabled)
rc = CIFSSMBOpen(xid, pTcon, full_path,
- FILE_OPEN, GENERIC_READ, 0, &fid,
+ FILE_OPEN, GENERIC_READ, FILE_SHARE_ALL, 0, &fid,
&oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] Shared flags: use in cifs client
2008-11-10 13:58 Pavel Shilovsky
@ 2008-11-10 14:34 ` Benny Halevy
0 siblings, 0 replies; 3+ messages in thread
From: Benny Halevy @ 2008-11-10 14:34 UTC (permalink / raw)
To: Pavel Shilovsky; +Cc: linux-fsdevel
On Nov. 10, 2008, 15:58 +0200, Pavel Shilovsky <piastry@etersoft.ru> wrote:
> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> index 57ecdc8..1d08705 100644
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -591,7 +591,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen,
> struct inode *inode,
> int oplock = 0;
> /* open file */
> rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
> - READ_CONTROL, 0, &fid, &oplock, NULL,
> + READ_CONTROL, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
> CIFS_MOUNT_MAP_SPECIAL_CHR);
> if (rc != 0) {
> @@ -645,7 +645,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd,
> __u32 acllen,
> int oplock = 0;
> /* open file */
> rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
> - WRITE_DAC, 0, &fid, &oplock, NULL,
> + WRITE_DAC, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
> CIFS_MOUNT_MAP_SPECIAL_CHR);
> if (rc != 0) {
> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> index 0cff7fe..88732bc 100644
> --- a/fs/cifs/cifsproto.h
> +++ b/fs/cifs/cifsproto.h
> @@ -261,7 +261,7 @@ extern int CIFSSMBQueryReparseLinkInfo(const int xid,
>
> extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
> const char *fileName, const int disposition,
> - const int access_flags, const int omode,
> + const int access_flags, const int share_flags, const int omode,
> __u16 *netfid, int *pOplock, FILE_ALL_INFO *,
> const struct nls_table *nls_codepage, int remap);
> extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 843a85f..39c30c9 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -1322,7 +1322,7 @@ OldOpenRetry:
> int
> CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
> const char *fileName, const int openDisposition,
> - const int access_flags, const int create_options, __u16 *netfid,
> + const int access_flags, const int share_flags, const int
> create_options, __u16 *netfid,
> int *pOplock, FILE_ALL_INFO *pfile_info,
> const struct nls_table *nls_codepage, int remap)
> {
> @@ -1379,7 +1379,7 @@ openRetry:
> if (create_options & CREATE_OPTION_READONLY)
> pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
>
> - pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
> + pSMB->ShareAccess = cpu_to_le32(share_flags);
> pSMB->CreateDisposition = cpu_to_le32(openDisposition);
> pSMB->CreateOptions = cpu_to_le32(create_options &
> CREATE_OPTIONS_MASK);
> /* BB Expirement with various impersonation levels and verify */
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index e962e75..f440996 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -207,7 +207,7 @@ cifs_create(struct inode *inode, struct dentry
> *direntry, int mode,
>
> if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
> rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
> - desiredAccess, create_options,
> + desiredAccess, FILE_SHARE_ALL, create_options,
> &fileHandle, &oplock, buf, cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
> else
> @@ -417,6 +417,7 @@ int cifs_mknod(struct inode *inode, struct dentry
> *direntry, int mode,
> WRITE_OWNER | WRITE_DAC be better? */,
> /* Create a file and set the
> file attribute to SYSTEM */
> + FILE_SHARE_ALL,
> CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
> &fileHandle, &oplock, buf,
> cifs_sb->local_nls,
> diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
> index 5a57581..9dc88ca 100644
> --- a/fs/cifs/fcntl.c
> +++ b/fs/cifs/fcntl.c
> @@ -89,7 +89,7 @@ int cifs_dir_notify(struct file *file, unsigned long arg)
> } else {
> cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
> rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
> - GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
> + GENERIC_READ | SYNCHRONIZE, FILE_SHARE_ALL, 0 /* create
> options */,
> &netfid, &oplock, NULL, cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
> /* BB fixme - add this handle to a notify handle list */
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 62d8bd8..4981d75 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -96,6 +96,11 @@ static inline int cifs_get_disposition(unsigned int
> flags)
> return FILE_OPEN;
> }
>
> +static inline int cifs_get_share_flags(unsigned int flags)
> +{
> + return ((~(flags>>21))&7);
Hmm, 004000000 == (1 << 20)
Aren't you losing one bit?
Benny
> +}
> +
> /* all arguments to this function must be checked for validity in caller */
> static inline int cifs_open_inode_helper(struct inode *inode, struct
> file *file,
> struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,
> @@ -173,6 +178,7 @@ int cifs_open(struct inode *inode, struct file *file)
> struct list_head *tmp;
> char *full_path = NULL;
> int desiredAccess;
> + int desiredShare;
> int disposition;
> __u16 netfid;
> FILE_ALL_INFO *buf = NULL;
> @@ -221,6 +227,7 @@ int cifs_open(struct inode *inode, struct file *file)
> cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
> inode, file->f_flags, full_path));
> desiredAccess = cifs_convert_flags(file->f_flags);
> + desiredShare = cifs_get_share_flags(file->f_flags);
>
> /*********************************************************************
> * open flag mapping table:
> @@ -270,7 +277,7 @@ int cifs_open(struct inode *inode, struct file *file)
>
> if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
> rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
> - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
> + desiredAccess, desiredShare, CREATE_NOT_DIR, &netfid,
> &oplock, buf,
> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
> & CIFS_MOUNT_MAP_SPECIAL_CHR);
> else
> @@ -355,6 +362,7 @@ static int cifs_reopen_file(struct file *file, bool
> can_flush)
> struct inode *inode;
> char *full_path = NULL;
> int desiredAccess;
> + int desiredShare;
> int disposition = FILE_OPEN;
> __u16 netfid;
>
> @@ -405,6 +413,7 @@ reopen_error_exit:
> cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
> inode, file->f_flags, full_path));
> desiredAccess = cifs_convert_flags(file->f_flags);
> + desiredShare = cifs_get_share_flags(file->f_flags);
>
> if (oplockEnabled)
> oplock = REQ_OPLOCK;
> @@ -417,7 +426,7 @@ reopen_error_exit:
> and server version of file size can be stale. If we knew for sure
> that inode was not dirty locally we could do this */
>
> - rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
> + rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
> desiredShare,
> CREATE_NOT_DIR, &netfid, &oplock, NULL,
> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
> CIFS_MOUNT_MAP_SPECIAL_CHR);
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index d54fa8a..66d8785 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -294,7 +294,7 @@ static int decode_sfu_inode(struct inode *inode,
> __u64 size,
> return -EINVAL; /* EOPNOTSUPP? */
> }
>
> - rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
> + rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
> FILE_SHARE_ALL,
> CREATE_NOT_DIR, &netfid, &oplock, NULL,
> cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags &
> @@ -740,7 +740,7 @@ cifs_set_file_info(struct inode *inode, struct iattr
> *attrs, int xid,
> cFYI(1, ("calling SetFileInfo since SetPathInfo for "
> "times not supported by this server"));
> rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
> - SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
> + SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL,
> CREATE_NOT_DIR, &netfid, &oplock,
> NULL, cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags &
> @@ -786,7 +786,7 @@ cifs_rename_pending_delete(char *full_path, struct
> dentry *dentry, int xid)
> FILE_BASIC_INFO *info_buf = NULL;
>
> rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
> - DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
> + DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL, CREATE_NOT_DIR,
> &netfid, &oplock, NULL, cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
> if (rc != 0)
> @@ -1268,7 +1268,7 @@ cifs_do_rename(int xid, struct dentry
> *from_dentry, const char *fromPath,
> return rc;
>
> /* open the file to be renamed -- we need DELETE perms */
> - rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
> + rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
> FILE_SHARE_ALL,
> CREATE_NOT_DIR, &srcfid, &oplock, NULL,
> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
> CIFS_MOUNT_MAP_SPECIAL_CHR);
> diff --git a/fs/cifs/link.c b/fs/cifs/link.c
> index 63f6440..7c9f495 100644
> --- a/fs/cifs/link.c
> +++ b/fs/cifs/link.c
> @@ -279,7 +279,7 @@ cifs_readlink(struct dentry *direntry, char __user
> *pBuffer, int buflen)
> cERROR(1, ("SFU style symlinks not implemented yet"));
> /* add open and read as in fs/cifs/inode.c */
> } else {
> - rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
> + rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
> GENERIC_READ, FILE_SHARE_ALL,
> OPEN_REPARSE_POINT, &fid, &oplock, NULL,
> cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags &
> diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
> index e9527ee..059211c 100644
> --- a/fs/cifs/xattr.c
> +++ b/fs/cifs/xattr.c
> @@ -269,7 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const
> char *ea_name,
> __u32 buflen = 0;
> if (experimEnabled)
> rc = CIFSSMBOpen(xid, pTcon, full_path,
> - FILE_OPEN, GENERIC_READ, 0, &fid,
> + FILE_OPEN, GENERIC_READ, FILE_SHARE_ALL, 0, &fid,
> &oplock, NULL, cifs_sb->local_nls,
> cifs_sb->mnt_cifs_flags &
> CIFS_MOUNT_MAP_SPECIAL_CHR);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] Shared flags: use in cifs client
@ 2008-11-11 7:40 Pavel Shilovsky
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Shilovsky @ 2008-11-11 7:40 UTC (permalink / raw)
To: linux-fsdevel
Benny Halevy wrote:
> On Nov. 10, 2008, 15:58 +0200, Pavel Shilovsky <piastry@etersoft.ru>
> wrote:
>
>> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
>> index 57ecdc8..1d08705 100644
>> --- a/fs/cifs/cifsacl.c
>> +++ b/fs/cifs/cifsacl.c
>> @@ -591,7 +591,7 @@ static struct cifs_ntsd *get_cifs_acl(u32
>> *pacllen, struct inode *inode,
>> int oplock = 0;
>> /* open file */
>> rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
>> - READ_CONTROL, 0, &fid, &oplock, NULL,
>> + READ_CONTROL, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
>> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
>> CIFS_MOUNT_MAP_SPECIAL_CHR);
>> if (rc != 0) {
>> @@ -645,7 +645,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd,
>> __u32 acllen,
>> int oplock = 0;
>> /* open file */
>> rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
>> - WRITE_DAC, 0, &fid, &oplock, NULL,
>> + WRITE_DAC, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
>> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
>> CIFS_MOUNT_MAP_SPECIAL_CHR);
>> if (rc != 0) {
>> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
>> index 0cff7fe..88732bc 100644
>> --- a/fs/cifs/cifsproto.h
>> +++ b/fs/cifs/cifsproto.h
>> @@ -261,7 +261,7 @@ extern int CIFSSMBQueryReparseLinkInfo(const int
>> xid,
>>
>> extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
>> const char *fileName, const int disposition,
>> - const int access_flags, const int omode,
>> + const int access_flags, const int share_flags, const int
>> omode,
>> __u16 *netfid, int *pOplock, FILE_ALL_INFO *,
>> const struct nls_table *nls_codepage, int remap);
>> extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
>> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
>> index 843a85f..39c30c9 100644
>> --- a/fs/cifs/cifssmb.c
>> +++ b/fs/cifs/cifssmb.c
>> @@ -1322,7 +1322,7 @@ OldOpenRetry:
>> int
>> CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
>> const char *fileName, const int openDisposition,
>> - const int access_flags, const int create_options, __u16
>> *netfid,
>> + const int access_flags, const int share_flags, const int
>> create_options, __u16 *netfid,
>> int *pOplock, FILE_ALL_INFO *pfile_info,
>> const struct nls_table *nls_codepage, int remap)
>> {
>> @@ -1379,7 +1379,7 @@ openRetry:
>> if (create_options & CREATE_OPTION_READONLY)
>> pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
>>
>> - pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
>> + pSMB->ShareAccess = cpu_to_le32(share_flags);
>> pSMB->CreateDisposition = cpu_to_le32(openDisposition);
>> pSMB->CreateOptions = cpu_to_le32(create_options &
>> CREATE_OPTIONS_MASK);
>> /* BB Expirement with various impersonation levels and verify */
>> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
>> index e962e75..f440996 100644
>> --- a/fs/cifs/dir.c
>> +++ b/fs/cifs/dir.c
>> @@ -207,7 +207,7 @@ cifs_create(struct inode *inode, struct dentry
>> *direntry, int mode,
>>
>> if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
>> rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
>> - desiredAccess, create_options,
>> + desiredAccess, FILE_SHARE_ALL, create_options,
>> &fileHandle, &oplock, buf, cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
>> else
>> @@ -417,6 +417,7 @@ int cifs_mknod(struct inode *inode, struct dentry
>> *direntry, int mode,
>> WRITE_OWNER | WRITE_DAC be better? */,
>> /* Create a file and set the
>> file attribute to SYSTEM */
>> + FILE_SHARE_ALL,
>> CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
>> &fileHandle, &oplock, buf,
>> cifs_sb->local_nls,
>> diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
>> index 5a57581..9dc88ca 100644
>> --- a/fs/cifs/fcntl.c
>> +++ b/fs/cifs/fcntl.c
>> @@ -89,7 +89,7 @@ int cifs_dir_notify(struct file *file, unsigned
>> long arg)
>> } else {
>> cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
>> rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
>> - GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
>> + GENERIC_READ | SYNCHRONIZE, FILE_SHARE_ALL, 0 /* create
>> options */,
>> &netfid, &oplock, NULL, cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
>> /* BB fixme - add this handle to a notify handle list */
>> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
>> index 62d8bd8..4981d75 100644
>> --- a/fs/cifs/file.c
>> +++ b/fs/cifs/file.c
>> @@ -96,6 +96,11 @@ static inline int cifs_get_disposition(unsigned
>> int flags)
>> return FILE_OPEN;
>> }
>>
>> +static inline int cifs_get_share_flags(unsigned int flags)
>> +{
>> + return ((~(flags>>21))&7);
> Hmm, 004000000 == (1 << 20)
> Aren't you losing one bit?
>
> Benny
>
>
>> +}
>> +
>> /* all arguments to this function must be checked for validity in
>> caller */
>> static inline int cifs_open_inode_helper(struct inode *inode, struct
>> file *file,
>> struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,
>> @@ -173,6 +178,7 @@ int cifs_open(struct inode *inode, struct file
>> *file)
>> struct list_head *tmp;
>> char *full_path = NULL;
>> int desiredAccess;
>> + int desiredShare;
>> int disposition;
>> __u16 netfid;
>> FILE_ALL_INFO *buf = NULL;
>> @@ -221,6 +227,7 @@ int cifs_open(struct inode *inode, struct file
>> *file)
>> cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
>> inode, file->f_flags, full_path));
>> desiredAccess = cifs_convert_flags(file->f_flags);
>> + desiredShare = cifs_get_share_flags(file->f_flags);
>>
>> /*********************************************************************
>> * open flag mapping table:
>> @@ -270,7 +277,7 @@ int cifs_open(struct inode *inode, struct file
>> *file)
>>
>> if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
>> rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
>> - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
>> + desiredAccess, desiredShare, CREATE_NOT_DIR, &netfid,
>> &oplock, buf,
>> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
>> & CIFS_MOUNT_MAP_SPECIAL_CHR);
>> else
>> @@ -355,6 +362,7 @@ static int cifs_reopen_file(struct file *file,
>> bool can_flush)
>> struct inode *inode;
>> char *full_path = NULL;
>> int desiredAccess;
>> + int desiredShare;
>> int disposition = FILE_OPEN;
>> __u16 netfid;
>>
>> @@ -405,6 +413,7 @@ reopen_error_exit:
>> cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
>> inode, file->f_flags, full_path));
>> desiredAccess = cifs_convert_flags(file->f_flags);
>> + desiredShare = cifs_get_share_flags(file->f_flags);
>>
>> if (oplockEnabled)
>> oplock = REQ_OPLOCK;
>> @@ -417,7 +426,7 @@ reopen_error_exit:
>> and server version of file size can be stale. If we knew for
>> sure
>> that inode was not dirty locally we could do this */
>>
>> - rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
>> + rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
>> desiredAccess, desiredShare,
>> CREATE_NOT_DIR, &netfid, &oplock, NULL,
>> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
>> CIFS_MOUNT_MAP_SPECIAL_CHR);
>> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
>> index d54fa8a..66d8785 100644
>> --- a/fs/cifs/inode.c
>> +++ b/fs/cifs/inode.c
>> @@ -294,7 +294,7 @@ static int decode_sfu_inode(struct inode *inode,
>> __u64 size,
>> return -EINVAL; /* EOPNOTSUPP? */
>> }
>>
>> - rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
>> + rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
>> FILE_SHARE_ALL,
>> CREATE_NOT_DIR, &netfid, &oplock, NULL,
>> cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags &
>> @@ -740,7 +740,7 @@ cifs_set_file_info(struct inode *inode, struct
>> iattr *attrs, int xid,
>> cFYI(1, ("calling SetFileInfo since SetPathInfo for "
>> "times not supported by this server"));
>> rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
>> - SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
>> + SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL,
>> CREATE_NOT_DIR, &netfid, &oplock,
>> NULL, cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags &
>> @@ -786,7 +786,7 @@ cifs_rename_pending_delete(char *full_path,
>> struct dentry *dentry, int xid)
>> FILE_BASIC_INFO *info_buf = NULL;
>>
>> rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
>> - DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
>> + DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL,
>> CREATE_NOT_DIR,
>> &netfid, &oplock, NULL, cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
>> if (rc != 0)
>> @@ -1268,7 +1268,7 @@ cifs_do_rename(int xid, struct dentry
>> *from_dentry, const char *fromPath,
>> return rc;
>>
>> /* open the file to be renamed -- we need DELETE perms */
>> - rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
>> + rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
>> FILE_SHARE_ALL,
>> CREATE_NOT_DIR, &srcfid, &oplock, NULL,
>> cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
>> CIFS_MOUNT_MAP_SPECIAL_CHR);
>> diff --git a/fs/cifs/link.c b/fs/cifs/link.c
>> index 63f6440..7c9f495 100644
>> --- a/fs/cifs/link.c
>> +++ b/fs/cifs/link.c
>> @@ -279,7 +279,7 @@ cifs_readlink(struct dentry *direntry, char
>> __user *pBuffer, int buflen)
>> cERROR(1, ("SFU style symlinks not implemented yet"));
>> /* add open and read as in fs/cifs/inode.c */
>> } else {
>> - rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
>> GENERIC_READ,
>> + rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
>> GENERIC_READ, FILE_SHARE_ALL,
>> OPEN_REPARSE_POINT, &fid, &oplock, NULL,
>> cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags &
>> diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
>> index e9527ee..059211c 100644
>> --- a/fs/cifs/xattr.c
>> +++ b/fs/cifs/xattr.c
>> @@ -269,7 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry,
>> const char *ea_name,
>> __u32 buflen = 0;
>> if (experimEnabled)
>> rc = CIFSSMBOpen(xid, pTcon, full_path,
>> - FILE_OPEN, GENERIC_READ, 0, &fid,
>> + FILE_OPEN, GENERIC_READ, FILE_SHARE_ALL, 0, &fid,
>> &oplock, NULL, cifs_sb->local_nls,
>> cifs_sb->mnt_cifs_flags &
>> CIFS_MOUNT_MAP_SPECIAL_CHR);
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-fsdevel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Yes, thanks, you are right - it's our bug...
+static inline int cifs_get_share_flags(unsigned int flags)
+{
+ return ((~(flags>>20))&7);
+}
Pavel Shilovsky
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-11 7:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-11 7:40 [PATCH 2/2] Shared flags: use in cifs client Pavel Shilovsky
-- strict thread matches above, loose matches on Subject: below --
2008-11-10 13:58 Pavel Shilovsky
2008-11-10 14:34 ` Benny Halevy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).