@@ -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 */
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(-) 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;