diff mbox

[linux-cifs-client,3/3] ioctl calls for Named Pipes

Message ID 4a4634330910151044m2933483eydf653406bf599ccf@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shirish Pargaonkar Oct. 15, 2009, 5:44 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index f946506..d351321 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,11 +30,46 @@ 

 #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)

+int
+ChkNMPHmode(unsigned short smode)
+{
+	int rc = -1;
+
+	if ((smode & BYTESTREAMNMREAD) && (smode & MESSAGENMREAD)) {
+		cFYI(1, ("SetNMPHMode both bye and message read bytes set"));
+		return rc;
+	}
+	if ((smode & BLOCKINGNMPIPE) && (smode & NONBLOCKINGNMPIPE))
+		return rc;
+
+	return 0;
+}
+
+unsigned short
+SetNMPHmode(unsigned short smode, unsigned short cmode)
+{
+	unsigned short mode;
+
+	mode = cmode;
+
+	if (smode & NONBLOCKINGNMPIPE)
+		mode = mode & 0x7FFF;
+	if (smode & BLOCKINGNMPIPE)
+		mode = mode | 0x8000;
+	if (smode & BYTESTREAMNMREAD)
+		mode = mode & 0xFCFF;
+	if (smode & MESSAGENMREAD)
+		mode = mode | 0x0100;
+
+	return mode;
+}
+
 long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
 {
 	struct inode *inode = filep->f_dentry->d_inode;
 	int rc = -ENOTTY; /* strange error - but the precedent */
 	int xid;
+	unsigned short cmode, smode;
 	struct cifs_sb_info *cifs_sb;
 #ifdef CONFIG_CIFS_POSIX
 	__u64	ExtAttrBits = 0;
@@ -60,6 +95,12 @@  long cifs_ioctl(struct file *filep, unsigned int
command, unsigned long arg)
 		FreeXid(xid);
 		return -EIO;
 	}
+
+	if (!pSMBFile && (command != CIFS_IOC_CHECKUMOUNT)) {
+		cFYI(1, ("cifs_ioctl: NULL file pointer"));
+		FreeXid(xid);
+		return -EBADF;
+	}
 #endif /* CONFIG_CIFS_POSIX */