From patchwork Thu Oct 15 17:44:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 36135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by ozlabs.org (Postfix) with ESMTP id A2D71B7B83 for ; Fri, 16 Oct 2009 04:44:14 +1100 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 66674AD24B; Thu, 15 Oct 2009 11:43:03 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.8 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mail-yw0-f194.google.com (mail-yw0-f194.google.com [209.85.211.194]) by lists.samba.org (Postfix) with ESMTP id 798CEAD186 for ; Thu, 15 Oct 2009 11:42:57 -0600 (MDT) Received: by ywh32 with SMTP id 32so1006356ywh.14 for ; Thu, 15 Oct 2009 10:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=VGPA8fvwKbeULuadCZuMkeTqyHPTVoocbsG2ywZ0iHA=; b=TrFKy4ZFopuhDg3xfg6DumFtjbh7tVF2/0jbVaTn1ol/he0JgxfmFne/8RdiYlWCEB 50chp2NhVvK13VxHblLGd7oLPpV5uGv4pwL4gLO9hhJ16jXAZ6fRkO6e2kmMa0L5hugs RIrY4+0v0H5R8S9gKUQzNHJVJ8eE1V9LCIjS0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=WREg/Zalgl31/cxIjInrFfKVkygQTmGuu1UNIyOX6OV5DoYFdXYr0ynv0pSWzglN/o m0kWoqA+kEItGODT3Snpy1z0AdZXpxDrdt+8kO9v9Ux4UFTIZsV/srPVV9IcON5LtRNT JbzxRXy04qNAJgjm9UKi+ArW7/L+GGEQI1Qto= MIME-Version: 1.0 Received: by 10.100.235.1 with SMTP id i1mr558083anh.40.1255628647242; Thu, 15 Oct 2009 10:44:07 -0700 (PDT) Date: Thu, 15 Oct 2009 12:44:06 -0500 Message-ID: <4a4634330910151044m2933483eydf653406bf599ccf@mail.gmail.com> From: Shirish Pargaonkar To: linux-cifs-client@lists.samba.org, linux-fsdevel Subject: [linux-cifs-client] [patch][3/3] ioctl calls for Named Pipes X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org ioctl calls to invoke SMBTrans functions/transactions From ce2bf9594358470e4bcb0822b0d3777620c023f7 Mon Sep 17 00:00:00 2001 From: Shirish Pargaonkar 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; 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 */