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