linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
To: linux-cifs-client@lists.samba.org,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [patch][3/3] ioctl calls for Named Pipes
Date: Thu, 15 Oct 2009 12:44:06 -0500	[thread overview]
Message-ID: <4a4634330910151044m2933483eydf653406bf599ccf@mail.gmail.com> (raw)

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

                 reply	other threads:[~2009-10-15 17:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a4634330910151044m2933483eydf653406bf599ccf@mail.gmail.com \
    --to=shirishpargaonkar@gmail.com \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).