* Re: [PATCH 7/8] cifs_create() fix @ 2005-08-24 21:42 Steve French 0 siblings, 0 replies; 2+ messages in thread From: Steve French @ 2005-08-24 21:42 UTC (permalink / raw) To: linux-kernel; +Cc: miklos OK - that fix looks fine and is now in the cifs-2.6.git (I will wait for 2.6.13 to push that and the other 20+ cifs changesets). Thanks. ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 0/8] filesystem related cleanups and fixes @ 2005-08-23 20:22 Miklos Szeredi 2005-08-23 20:24 ` [PATCH 1/8] remove ia_attr_flags Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:22 UTC (permalink / raw) To: akpm; +Cc: linux-kernel Hi Andrew! The following patches are small cleanups and fixes, I hope none of them are too controversial. It's probably safe to apply ;) Miklos ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/8] remove ia_attr_flags 2005-08-23 20:22 [PATCH 0/8] filesystem related cleanups and fixes Miklos Szeredi @ 2005-08-23 20:24 ` Miklos Szeredi 2005-08-23 20:26 ` [PATCH 2/8] namei cleanup Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:24 UTC (permalink / raw) To: akpm; +Cc: linux-kernel Remove unused ia_attr_flags from struct iattr, and related defines. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/fs/hostfs/hostfs.h =================================================================== --- linux.orig/fs/hostfs/hostfs.h 2005-08-19 14:13:47.000000000 +0200 +++ linux/fs/hostfs/hostfs.h 2005-08-19 15:01:48.000000000 +0200 @@ -49,7 +49,6 @@ struct hostfs_iattr { struct timespec ia_atime; struct timespec ia_mtime; struct timespec ia_ctime; - unsigned int ia_attr_flags; }; extern int stat_file(const char *path, unsigned long long *inode_out, Index: linux/include/linux/fs.h =================================================================== --- linux.orig/include/linux/fs.h 2005-08-19 14:58:53.000000000 +0200 +++ linux/include/linux/fs.h 2005-08-19 15:01:06.000000000 +0200 @@ -283,19 +283,9 @@ struct iattr { struct timespec ia_atime; struct timespec ia_mtime; struct timespec ia_ctime; - unsigned int ia_attr_flags; }; /* - * This is the inode attributes flag definitions - */ -#define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */ -#define ATTR_FLAG_NOATIME 2 /* Don't update atime */ -#define ATTR_FLAG_APPEND 4 /* Append-only file */ -#define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */ -#define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */ - -/* * Includes for diskquotas. */ #include <linux/quota.h> ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/8] namei cleanup 2005-08-23 20:24 ` [PATCH 1/8] remove ia_attr_flags Miklos Szeredi @ 2005-08-23 20:26 ` Miklos Szeredi 2005-08-23 20:30 ` [PATCH 3/8] use get_fs_struct() in proc Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:26 UTC (permalink / raw) To: akpm; +Cc: linux-kernel, viro Extract common code into inline functions to make reading easier. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/fs/namei.c =================================================================== --- linux.orig/fs/namei.c 2005-08-23 20:25:53.000000000 +0200 +++ linux/fs/namei.c 2005-08-23 21:00:02.000000000 +0200 @@ -525,6 +525,22 @@ static inline int __do_follow_link(struc return error; } +static inline void dput_path(struct path *path, struct nameidata *nd) +{ + dput(path->dentry); + if (path->mnt != nd->mnt) + mntput(path->mnt); +} + +static inline void path_to_nameidata(struct path *path, struct nameidata *nd) +{ + dput(nd->dentry); + if (nd->mnt != path->mnt) + mntput(nd->mnt); + nd->mnt = path->mnt; + nd->dentry = path->dentry; +} + /* * This limits recursive symlink follows to 8, while * limiting consecutive symlinks to 40. @@ -552,9 +568,7 @@ static inline int do_follow_link(struct nd->depth--; return err; loop: - dput(path->dentry); - if (path->mnt != nd->mnt) - mntput(path->mnt); + dput_path(path, nd); path_release(nd); return err; } @@ -813,13 +827,8 @@ static fastcall int __link_path_walk(con err = -ENOTDIR; if (!inode->i_op) break; - } else { - dput(nd->dentry); - if (nd->mnt != next.mnt) - mntput(nd->mnt); - nd->mnt = next.mnt; - nd->dentry = next.dentry; - } + } else + path_to_nameidata(&next, nd); err = -ENOTDIR; if (!inode->i_op->lookup) break; @@ -859,13 +868,8 @@ last_component: if (err) goto return_err; inode = nd->dentry->d_inode; - } else { - dput(nd->dentry); - if (nd->mnt != next.mnt) - mntput(nd->mnt); - nd->mnt = next.mnt; - nd->dentry = next.dentry; - } + } else + path_to_nameidata(&next, nd); err = -ENOENT; if (!inode) break; @@ -901,9 +905,7 @@ return_reval: return_base: return 0; out_dput: - dput(next.dentry); - if (nd->mnt != next.mnt) - mntput(next.mnt); + dput_path(&next, nd); break; } path_release(nd); @@ -1505,11 +1507,7 @@ do_last: if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) goto do_link; - dput(nd->dentry); - nd->dentry = path.dentry; - if (nd->mnt != path.mnt) - mntput(nd->mnt); - nd->mnt = path.mnt; + path_to_nameidata(&path, nd); error = -EISDIR; if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode)) goto exit; @@ -1520,9 +1518,7 @@ ok: return 0; exit_dput: - dput(path.dentry); - if (nd->mnt != path.mnt) - mntput(path.mnt); + dput_path(&path, nd); exit: path_release(nd); return error; ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 3/8] use get_fs_struct() in proc 2005-08-23 20:26 ` [PATCH 2/8] namei cleanup Miklos Szeredi @ 2005-08-23 20:30 ` Miklos Szeredi 2005-08-23 20:33 ` [PATCH 4/8] fix enum pid_directory_inos in proc/base.c Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:30 UTC (permalink / raw) To: akpm; +Cc: linux-kernel This patch cleans up proc_cwd_link() and proc_root_link() by factoring out common code into get_fs_struct(). Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/fs/proc/base.c =================================================================== --- linux.orig/fs/proc/base.c 2005-08-19 14:47:20.000000000 +0200 +++ linux/fs/proc/base.c 2005-08-19 14:47:35.000000000 +0200 @@ -298,15 +298,21 @@ static int proc_fd_link(struct inode *in return -ENOENT; } -static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) +static struct fs_struct *get_fs_struct(struct task_struct *task) { struct fs_struct *fs; - int result = -ENOENT; - task_lock(proc_task(inode)); - fs = proc_task(inode)->fs; + task_lock(task); + fs = task->fs; if(fs) atomic_inc(&fs->count); - task_unlock(proc_task(inode)); + task_unlock(task); + return fs; +} + +static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) +{ + struct fs_struct *fs = get_fs_struct(proc_task(inode)); + int result = -ENOENT; if (fs) { read_lock(&fs->lock); *mnt = mntget(fs->pwdmnt); @@ -320,13 +326,8 @@ static int proc_cwd_link(struct inode *i static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) { - struct fs_struct *fs; + struct fs_struct *fs = get_fs_struct(proc_task(inode)); int result = -ENOENT; - task_lock(proc_task(inode)); - fs = proc_task(inode)->fs; - if(fs) - atomic_inc(&fs->count); - task_unlock(proc_task(inode)); if (fs) { read_lock(&fs->lock); *mnt = mntget(fs->rootmnt); ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 4/8] fix enum pid_directory_inos in proc/base.c 2005-08-23 20:30 ` [PATCH 3/8] use get_fs_struct() in proc Miklos Szeredi @ 2005-08-23 20:33 ` Miklos Szeredi 2005-08-23 20:36 ` [PATCH 5/8] remove duplicated code from proc and ptrace Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:33 UTC (permalink / raw) To: akpm; +Cc: linux-kernel This patch fixes wrongly placed elements in the pid_directory_inos enum. Also add comment so this mistake is not repeated. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/fs/proc/base.c =================================================================== --- linux.orig/fs/proc/base.c 2005-08-19 14:47:35.000000000 +0200 +++ linux/fs/proc/base.c 2005-08-19 14:47:36.000000000 +0200 @@ -120,7 +120,6 @@ enum pid_directory_inos { #ifdef CONFIG_AUDITSYSCALL PROC_TGID_LOGINUID, #endif - PROC_TGID_FD_DIR, PROC_TGID_OOM_SCORE, PROC_TGID_OOM_ADJUST, PROC_TID_INO, @@ -159,9 +158,11 @@ enum pid_directory_inos { #ifdef CONFIG_AUDITSYSCALL PROC_TID_LOGINUID, #endif - PROC_TID_FD_DIR = 0x8000, /* 0x8000-0xffff */ PROC_TID_OOM_SCORE, PROC_TID_OOM_ADJUST, + + /* Add new entries before this */ + PROC_TID_FD_DIR = 0x8000, /* 0x8000-0xffff */ }; struct pid_entry { ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 5/8] remove duplicated code from proc and ptrace 2005-08-23 20:33 ` [PATCH 4/8] fix enum pid_directory_inos in proc/base.c Miklos Szeredi @ 2005-08-23 20:36 ` Miklos Szeredi 2005-08-23 20:43 ` [PATCH 6/8] remove duplicated sys_open32() code from 64bit archs Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:36 UTC (permalink / raw) To: akpm; +Cc: linux-kernel Extract common code used by ptrace_attach() and may_ptrace_attach() into a separate function. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/kernel/ptrace.c =================================================================== --- linux.orig/kernel/ptrace.c 2005-08-19 14:47:20.000000000 +0200 +++ linux/kernel/ptrace.c 2005-08-19 14:47:36.000000000 +0200 @@ -118,6 +118,33 @@ int ptrace_check_attach(struct task_stru return ret; } +static int may_attach(struct task_struct *task) +{ + if (!task->mm) + return -EPERM; + if (((current->uid != task->euid) || + (current->uid != task->suid) || + (current->uid != task->uid) || + (current->gid != task->egid) || + (current->gid != task->sgid) || + (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) + return -EPERM; + smp_rmb(); + if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) + return -EPERM; + + return security_ptrace(current, task); +} + +int ptrace_may_attach(struct task_struct *task) +{ + int err; + task_lock(task); + err = may_attach(task); + task_unlock(task); + return !err; +} + int ptrace_attach(struct task_struct *task) { int retval; @@ -127,22 +154,10 @@ int ptrace_attach(struct task_struct *ta goto bad; if (task == current) goto bad; - if (!task->mm) - goto bad; - if(((current->uid != task->euid) || - (current->uid != task->suid) || - (current->uid != task->uid) || - (current->gid != task->egid) || - (current->gid != task->sgid) || - (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) - goto bad; - smp_rmb(); - if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) - goto bad; /* the same process cannot be attached many times */ if (task->ptrace & PT_PTRACED) goto bad; - retval = security_ptrace(current, task); + retval = may_attach(task); if (retval) goto bad; Index: linux/include/linux/ptrace.h =================================================================== --- linux.orig/include/linux/ptrace.h 2005-08-19 14:47:20.000000000 +0200 +++ linux/include/linux/ptrace.h 2005-08-19 14:47:36.000000000 +0200 @@ -90,6 +90,7 @@ extern void __ptrace_link(struct task_st struct task_struct *new_parent); extern void __ptrace_unlink(struct task_struct *child); extern void ptrace_untrace(struct task_struct *child); +extern int ptrace_may_attach(struct task_struct *task); static inline void ptrace_link(struct task_struct *child, struct task_struct *new_parent) Index: linux/fs/proc/base.c =================================================================== --- linux.orig/fs/proc/base.c 2005-08-19 14:47:36.000000000 +0200 +++ linux/fs/proc/base.c 2005-08-19 14:47:36.000000000 +0200 @@ -347,33 +347,6 @@ static int proc_root_link(struct inode * (task->state == TASK_STOPPED || task->state == TASK_TRACED) && \ security_ptrace(current,task) == 0)) -static int may_ptrace_attach(struct task_struct *task) -{ - int retval = 0; - - task_lock(task); - - if (!task->mm) - goto out; - if (((current->uid != task->euid) || - (current->uid != task->suid) || - (current->uid != task->uid) || - (current->gid != task->egid) || - (current->gid != task->sgid) || - (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) - goto out; - rmb(); - if (task->mm->dumpable != 1 && !capable(CAP_SYS_PTRACE)) - goto out; - if (security_ptrace(current, task)) - goto out; - - retval = 1; -out: - task_unlock(task); - return retval; -} - static int proc_pid_environ(struct task_struct *task, char * buffer) { int res = 0; @@ -383,7 +356,7 @@ static int proc_pid_environ(struct task_ if (len > PAGE_SIZE) len = PAGE_SIZE; res = access_process_vm(task, mm->env_start, buffer, len, 0); - if (!may_ptrace_attach(task)) + if (!ptrace_may_attach(task)) res = -ESRCH; mmput(mm); } @@ -686,7 +659,7 @@ static ssize_t mem_read(struct file * fi int ret = -ESRCH; struct mm_struct *mm; - if (!MAY_PTRACE(task) || !may_ptrace_attach(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) goto out; ret = -ENOMEM; @@ -712,7 +685,7 @@ static ssize_t mem_read(struct file * fi this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; retval = access_process_vm(task, src, page, this_len, 0); - if (!retval || !MAY_PTRACE(task) || !may_ptrace_attach(task)) { + if (!retval || !MAY_PTRACE(task) || !ptrace_may_attach(task)) { if (!ret) ret = -EIO; break; @@ -750,7 +723,7 @@ static ssize_t mem_write(struct file * f struct task_struct *task = proc_task(file->f_dentry->d_inode); unsigned long dst = *ppos; - if (!MAY_PTRACE(task) || !may_ptrace_attach(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) return -ESRCH; page = (char *)__get_free_page(GFP_USER); ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 6/8] remove duplicated sys_open32() code from 64bit archs 2005-08-23 20:36 ` [PATCH 5/8] remove duplicated code from proc and ptrace Miklos Szeredi @ 2005-08-23 20:43 ` Miklos Szeredi 2005-08-23 20:45 ` [PATCH 7/8] cifs_create() fix Miklos Szeredi 0 siblings, 1 reply; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:43 UTC (permalink / raw) To: akpm; +Cc: linux-kernel 64 bit architectures all implement their own compatibility sys_open(), when in fact the difference is simply not forcing the O_LARGEFILE flag. So use the a common function instead. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Index: linux/include/linux/fs.h =================================================================== --- linux.orig/include/linux/fs.h 2005-08-23 21:00:01.000000000 +0200 +++ linux/include/linux/fs.h 2005-08-23 21:00:18.000000000 +0200 @@ -1286,6 +1286,7 @@ static inline int break_lease(struct ino /* fs/open.c */ extern int do_truncate(struct dentry *, loff_t start); +extern long do_sys_open(const char __user *filename, int flags, int mode); extern struct file *filp_open(const char *, int, int); extern struct file * dentry_open(struct dentry *, struct vfsmount *, int); extern int filp_close(struct file *, fl_owner_t id); Index: linux/fs/open.c =================================================================== --- linux.orig/fs/open.c 2005-08-23 20:25:54.000000000 +0200 +++ linux/fs/open.c 2005-08-23 21:00:18.000000000 +0200 @@ -938,16 +938,11 @@ void fastcall fd_install(unsigned int fd EXPORT_SYMBOL(fd_install); -asmlinkage long sys_open(const char __user * filename, int flags, int mode) +long do_sys_open(const char __user *filename, int flags, int mode) { - char * tmp; - int fd; + char *tmp = getname(filename); + int fd = PTR_ERR(tmp); - if (force_o_largefile()) - flags |= O_LARGEFILE; - - tmp = getname(filename); - fd = PTR_ERR(tmp); if (!IS_ERR(tmp)) { fd = get_unused_fd(); if (fd >= 0) { @@ -964,6 +959,14 @@ asmlinkage long sys_open(const char __us } return fd; } + +asmlinkage long sys_open(const char __user *filename, int flags, int mode) +{ + if (force_o_largefile()) + flags |= O_LARGEFILE; + + return do_sys_open(filename, flags, mode); +} EXPORT_SYMBOL_GPL(sys_open); #ifndef __alpha__ Index: linux/arch/x86_64/ia32/sys_ia32.c =================================================================== --- linux.orig/arch/x86_64/ia32/sys_ia32.c 2005-08-23 20:22:33.000000000 +0200 +++ linux/arch/x86_64/ia32/sys_ia32.c 2005-08-23 21:00:19.000000000 +0200 @@ -971,28 +971,7 @@ long sys32_kill(int pid, int sig) asmlinkage long sys32_open(const char __user * filename, int flags, int mode) { - char * tmp; - int fd, error; - - /* don't force O_LARGEFILE */ - tmp = getname(filename); - fd = PTR_ERR(tmp); - if (!IS_ERR(tmp)) { - fd = get_unused_fd(); - if (fd >= 0) { - struct file *f = filp_open(tmp, flags, mode); - error = PTR_ERR(f); - if (IS_ERR(f)) { - put_unused_fd(fd); - fd = error; - } else { - fsnotify_open(f->f_dentry); - fd_install(fd, f); - } - } - putname(tmp); - } - return fd; + return do_sys_open(filename, flags, mode); } extern asmlinkage long Index: linux/arch/ppc64/kernel/sys_ppc32.c =================================================================== --- linux.orig/arch/ppc64/kernel/sys_ppc32.c 2005-08-23 20:22:31.000000000 +0200 +++ linux/arch/ppc64/kernel/sys_ppc32.c 2005-08-23 21:00:19.000000000 +0200 @@ -873,29 +873,7 @@ off_t ppc32_lseek(unsigned int fd, u32 o */ asmlinkage long sys32_open(const char __user * filename, int flags, int mode) { - char * tmp; - int fd, error; - - tmp = getname(filename); - fd = PTR_ERR(tmp); - if (!IS_ERR(tmp)) { - fd = get_unused_fd(); - if (fd >= 0) { - struct file * f = filp_open(tmp, flags, mode); - error = PTR_ERR(f); - if (IS_ERR(f)) - goto out_error; - fd_install(fd, f); - } -out: - putname(tmp); - } - return fd; - -out_error: - put_unused_fd(fd); - fd = error; - goto out; + return do_sys_open(filename, flags, mode); } /* Note: it is necessary to treat bufsiz as an unsigned int, Index: linux/arch/ia64/ia32/sys_ia32.c =================================================================== --- linux.orig/arch/ia64/ia32/sys_ia32.c 2005-06-17 21:48:29.000000000 +0200 +++ linux/arch/ia64/ia32/sys_ia32.c 2005-08-23 21:00:19.000000000 +0200 @@ -2365,29 +2365,7 @@ sys32_brk (unsigned int brk) asmlinkage long sys32_open (const char __user * filename, int flags, int mode) { - char * tmp; - int fd, error; - - tmp = getname(filename); - fd = PTR_ERR(tmp); - if (!IS_ERR(tmp)) { - fd = get_unused_fd(); - if (fd >= 0) { - struct file *f = filp_open(tmp, flags, mode); - error = PTR_ERR(f); - if (IS_ERR(f)) - goto out_error; - fd_install(fd, f); - } -out: - putname(tmp); - } - return fd; - -out_error: - put_unused_fd(fd); - fd = error; - goto out; + return do_sys_open(filename, flags, mode); } /* Structure for ia32 emulation on ia64 */ Index: linux/arch/sparc64/kernel/sys_sparc32.c =================================================================== --- linux.orig/arch/sparc64/kernel/sys_sparc32.c 2005-06-17 21:48:29.000000000 +0200 +++ linux/arch/sparc64/kernel/sys_sparc32.c 2005-08-23 21:00:19.000000000 +0200 @@ -1002,29 +1002,7 @@ asmlinkage long sys32_adjtimex(struct ti asmlinkage long sparc32_open(const char __user *filename, int flags, int mode) { - char * tmp; - int fd, error; - - tmp = getname(filename); - fd = PTR_ERR(tmp); - if (!IS_ERR(tmp)) { - fd = get_unused_fd(); - if (fd >= 0) { - struct file * f = filp_open(tmp, flags, mode); - error = PTR_ERR(f); - if (IS_ERR(f)) - goto out_error; - fd_install(fd, f); - } -out: - putname(tmp); - } - return fd; - -out_error: - put_unused_fd(fd); - fd = error; - goto out; + return do_sys_open(filename, flags, mode); } extern unsigned long do_mremap(unsigned long addr, ^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 7/8] cifs_create() fix 2005-08-23 20:43 ` [PATCH 6/8] remove duplicated sys_open32() code from 64bit archs Miklos Szeredi @ 2005-08-23 20:45 ` Miklos Szeredi 0 siblings, 0 replies; 2+ messages in thread From: Miklos Szeredi @ 2005-08-23 20:45 UTC (permalink / raw) To: akpm; +Cc: linux-kernel, smfrench 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: Miklos Szeredi <miklos@szeredi.hu> Index: linux/fs/cifs/dir.c =================================================================== --- linux.orig/fs/cifs/dir.c 2005-08-23 11:01:58.000000000 +0200 +++ linux/fs/cifs/dir.c 2005-08-23 11:09:03.000000000 +0200 @@ -145,24 +145,23 @@ cifs_create(struct inode *inode, struct return -ENOMEM; } - if(nd) { - if ((nd->intent.open.flags & O_ACCMODE) == O_RDONLY) - desiredAccess = GENERIC_READ; - else if ((nd->intent.open.flags & O_ACCMODE) == O_WRONLY) { - desiredAccess = GENERIC_WRITE; - write_only = TRUE; - } else if ((nd->intent.open.flags & O_ACCMODE) == O_RDWR) { - /* GENERIC_ALL is too much permission to request */ - /* can cause unnecessary access denied on create */ - /* desiredAccess = GENERIC_ALL; */ - desiredAccess = GENERIC_READ | GENERIC_WRITE; + if(nd && (nd->flags & LOOKUP_OPEN)) { + int oflags = nd->intent.open.flags; + + desiredAccess = 0; + if (oflags & FMODE_READ) + desiredAccess |= GENERIC_READ; + if (oflags & FMODE_WRITE) { + desiredAccess |= GENERIC_WRITE; + if (!(oflags & FMODE_READ)) + write_only = TRUE; } - 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; - 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; - else if((nd->intent.open.flags & O_CREAT) == O_CREAT) + else if((oflags & O_CREAT) == O_CREAT) disposition = FILE_OPEN_IF; else { cFYI(1,("Create flag not set in create function")); ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-08-24 21:45 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-08-24 21:42 [PATCH 7/8] cifs_create() fix Steve French -- strict thread matches above, loose matches on Subject: below -- 2005-08-23 20:22 [PATCH 0/8] filesystem related cleanups and fixes Miklos Szeredi 2005-08-23 20:24 ` [PATCH 1/8] remove ia_attr_flags Miklos Szeredi 2005-08-23 20:26 ` [PATCH 2/8] namei cleanup Miklos Szeredi 2005-08-23 20:30 ` [PATCH 3/8] use get_fs_struct() in proc Miklos Szeredi 2005-08-23 20:33 ` [PATCH 4/8] fix enum pid_directory_inos in proc/base.c Miklos Szeredi 2005-08-23 20:36 ` [PATCH 5/8] remove duplicated code from proc and ptrace Miklos Szeredi 2005-08-23 20:43 ` [PATCH 6/8] remove duplicated sys_open32() code from 64bit archs Miklos Szeredi 2005-08-23 20:45 ` [PATCH 7/8] cifs_create() fix Miklos Szeredi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®