提交 e08fc045 编写于 作者: M Miklos Szeredi 提交者: Linus Torvalds

[PATCH] cifs_create() fix

cifs_create() did totally the wrong thing with nd->intent.open.flags:
it interpreted nd->intent.open.flags as the original open flags, not
the one transformed for open_namei().  Also it used the intent data
even if it was not filled in (if called from sys_mknod()).
Signed-off-by: NMiklos Szeredi <miklos@szeredi.hu>
Cc: <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Steven French <sfrench@us.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 e922efc3
...@@ -145,24 +145,23 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -145,24 +145,23 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
return -ENOMEM; return -ENOMEM;
} }
if(nd) { if(nd && (nd->flags & LOOKUP_OPEN)) {
if ((nd->intent.open.flags & O_ACCMODE) == O_RDONLY) int oflags = nd->intent.open.flags;
desiredAccess = GENERIC_READ;
else if ((nd->intent.open.flags & O_ACCMODE) == O_WRONLY) { desiredAccess = 0;
desiredAccess = GENERIC_WRITE; if (oflags & FMODE_READ)
write_only = TRUE; desiredAccess |= GENERIC_READ;
} else if ((nd->intent.open.flags & O_ACCMODE) == O_RDWR) { if (oflags & FMODE_WRITE) {
/* GENERIC_ALL is too much permission to request */ desiredAccess |= GENERIC_WRITE;
/* can cause unnecessary access denied on create */ if (!(oflags & FMODE_READ))
/* desiredAccess = GENERIC_ALL; */ write_only = TRUE;
desiredAccess = GENERIC_READ | GENERIC_WRITE;
} }
if((nd->intent.open.flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) if((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
disposition = FILE_CREATE; disposition = FILE_CREATE;
else if((nd->intent.open.flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) else if((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
disposition = FILE_OVERWRITE_IF; disposition = FILE_OVERWRITE_IF;
else if((nd->intent.open.flags & O_CREAT) == O_CREAT) else if((oflags & O_CREAT) == O_CREAT)
disposition = FILE_OPEN_IF; disposition = FILE_OPEN_IF;
else { else {
cFYI(1,("Create flag not set in create function")); cFYI(1,("Create flag not set in create function"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册