linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch][3/3] ioctl calls for Named Pipes
@ 2009-10-15 17:44 Shirish Pargaonkar
  0 siblings, 0 replies; only message in thread
From: Shirish Pargaonkar @ 2009-10-15 17:44 UTC (permalink / raw)
  To: linux-cifs-client, linux-fsdevel

ioctl calls to invoke SMBTrans functions/transactions

>From ce2bf9594358470e4bcb0822b0d3777620c023f7 Mon Sep 17 00:00:00 2001
From: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Date: Thu, 15 Oct 2009 08:17:37 -0500
Subject: [PATCH] ioctl functions for Named Pipe support

---
 fs/cifs/ioctl.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 70 insertions(+), 4 deletions(-)

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 */

 	switch (command) {
@@ -75,8 +116,6 @@ long cifs_ioctl(struct file *filep, unsigned int
command, unsigned long arg)
 #ifdef CONFIG_CIFS_POSIX
 		case FS_IOC_GETFLAGS:
 			if (CIFS_UNIX_EXTATTR_CAP & caps) {
-				if (pSMBFile == NULL)
-					break;
 				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
 					&ExtAttrBits, &ExtAttrMask);
 				if (rc == 0)
@@ -92,14 +131,41 @@ long cifs_ioctl(struct file *filep, unsigned int
command, unsigned long arg)
 					rc = -EFAULT;
 					break;
 				}
-				if (pSMBFile == NULL)
-					break;
 				/* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
 					extAttrBits, &ExtAttrMask);*/
 			}
 			cFYI(1, ("set flags not implemented yet"));
 			break;
 #endif /* CONFIG_CIFS_POSIX */
+		case CIFS_QUERYNMPIPE:
+			rc = CIFSSMBTransQNmPipe(xid, tcon, arg,
+				pSMBFile->netfid, cifs_sb->local_nls, 0);
+			break;
+		case CIFS_PEEKNMPIPE:
+			rc = CIFSSMBTransPeekNmPipe(xid, tcon, arg,
+				 pSMBFile->netfid, cifs_sb->local_nls, 0);
+			break;
+		case CIFS_GETNMPIPEHANDSTATE:
+			rc = CIFSSMBTransGetNmPHState(xid, tcon, arg,
+				pSMBFile->netfid, cifs_sb->local_nls, 0);
+			break;
+		case CIFS_SETNMPIPEHANDSTATE:
+			smode = ((struct qnmp_hinfo *)arg)->mode;
+			if (ChkNMPHmode(smode) == -1)
+				break;
+			rc = CIFSSMBTransGetNmPHState(xid, tcon, arg,
+				pSMBFile->netfid, cifs_sb->local_nls, 0);
+			if (rc)
+				break;
+			cmode = ((struct qnmp_hinfo *)arg)->mode;
+			((struct qnmp_hinfo *)arg)->mode =
+					SetNMPHmode(smode, cmode);
+			rc = CIFSSMBTransSetNmPHState(xid, tcon, arg,
+				pSMBFile->netfid, cifs_sb->local_nls, 0);
+			break;
+		case CIFS_TRANSACTNMPIPE:
+			rc = CIFSSMBTransNmPipe(xid, tcon, (char *)arg,
+				pSMBFile->netfid, cifs_sb->local_nls, 0);
 		default:
 			cFYI(1, ("unsupported ioctl"));
 			break;
-- 
1.5.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-15 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15 17:44 [patch][3/3] ioctl calls for Named Pipes Shirish Pargaonkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).