[PATCH][6/7] cifs: file.c cleanups in incremental bits - new helperfunction, cifs_get_disposition

From: Jesper Juhl
Date: Wed Mar 16 2005 - 08:41:00 EST



This (attached) patch adds a new helper function called
cifs_get_disposition and converts cifs_open to use it to further shorten
that very long function.

Signed-off-by: Jesper Juhl <juhl-lkml@xxxxxx>


--
Jesper Juhl

diff -up linux-2.6.11-mm3/fs/cifs/file.c.with_patch_6 linux-2.6.11-mm3/fs/cifs/file.c
--- linux-2.6.11-mm3/fs/cifs/file.c.with_patch_6 2005-03-16 13:39:04.000000000 +0100
+++ linux-2.6.11-mm3/fs/cifs/file.c 2005-03-16 13:41:14.000000000 +0100
@@ -67,6 +67,18 @@ static inline int cifs_convert_flags(uns
return 0x20197;
}

+static inline int cifs_get_disposition(unsigned int flags)
+{
+ if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
+ return FILE_CREATE;
+ else if ((flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
+ return FILE_OVERWRITE_IF;
+ else if ((flags & O_CREAT) == O_CREAT)
+ return FILE_OPEN_IF;
+ else
+ return FILE_OPEN;
+}
+
/* 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,
@@ -221,14 +233,7 @@ int cifs_open(struct inode *inode, struc
* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation
*********************************************************************/

- if ((file->f_flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
- disposition = FILE_CREATE;
- else if ((file->f_flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
- disposition = FILE_OVERWRITE_IF;
- else if ((file->f_flags & O_CREAT) == O_CREAT)
- disposition = FILE_OPEN_IF;
- else
- disposition = FILE_OPEN;
+ disposition = cifs_get_disposition(file->f_flags);

if (oplockEnabled)
oplock = REQ_OPLOCK;