Messages in this thread Patch in this message | | | Date | Wed, 16 Mar 2005 14:33:56 +0100 (CET) | From | Jesper Juhl <> | Subject | [PATCH][5/7] cifs: file.c cleanups in incremental bits - new cifs_convert_flags helper function |
| |
This patch (attached) adds a new helper function called cifs_convert_flags and uses it in cifs_open and cifs_reopen_file to fill in 'desiredAccess' instead of having two duplicate codeblocks in those functions.
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
-- Jesper Juhl
diff -up linux-2.6.11-mm3/fs/cifs/file.c.with_patch_5 linux-2.6.11-mm3/fs/cifs/file.c --- linux-2.6.11-mm3/fs/cifs/file.c.with_patch_5 2005-03-16 00:59:14.000000000 +0100 +++ linux-2.6.11-mm3/fs/cifs/file.c 2005-03-16 13:35:30.000000000 +0100 @@ -51,6 +51,22 @@ static inline struct cifsFileInfo *cifs_ return private_data; } +static inline int cifs_convert_flags(unsigned int flags) +{ + if ((flags & O_ACCMODE) == O_RDONLY) + return GENERIC_READ; + else if ((flags & O_ACCMODE) == O_WRONLY) + return GENERIC_WRITE; + else if ((flags & O_ACCMODE) == O_RDWR) { + /* GENERIC_ALL is too much permission to request + can cause unnecessary access denied on create */ + /* return GENERIC_ALL; */ + return (GENERIC_READ | GENERIC_WRITE); + } + + return 0x20197; +} + /* 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, @@ -127,7 +143,7 @@ int cifs_open(struct inode *inode, struc struct cifsInodeInfo *pCifsInode; struct list_head *tmp; char *full_path = NULL; - int desiredAccess = 0x20197; + int desiredAccess; int disposition; __u16 netfid; FILE_ALL_INFO *buf = NULL; @@ -177,17 +193,9 @@ int cifs_open(struct inode *inode, struc return -ENOMEM; } - cFYI(1, (" inode = 0x%p file flags are 0x%x for %s", inode, file->f_flags, full_path)); - if ((file->f_flags & O_ACCMODE) == O_RDONLY) - desiredAccess = GENERIC_READ; - else if ((file->f_flags & O_ACCMODE) == O_WRONLY) - desiredAccess = GENERIC_WRITE; - else if ((file->f_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; - } + 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); /********************************************************************* * open flag mapping table: @@ -318,7 +326,7 @@ static int cifs_reopen_file(struct inode struct cifsFileInfo *pCifsFile; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess = 0x20197; + int desiredAccess; int disposition = FILE_OPEN; __u16 netfid; @@ -358,16 +366,7 @@ static int cifs_reopen_file(struct inode cFYI(1, (" inode = 0x%p file flags are 0x%x for %s", inode, file->f_flags,full_path)); - if ((file->f_flags & O_ACCMODE) == O_RDONLY) - desiredAccess = GENERIC_READ; - else if ((file->f_flags & O_ACCMODE) == O_WRONLY) - desiredAccess = GENERIC_WRITE; - else if ((file->f_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; - } + desiredAccess = cifs_convert_flags(file->f_flags); if (oplockEnabled) oplock = REQ_OPLOCK;
| |