Windows: Return error for SetToken PIOCTL_LOGON if not LocalSystem
[openafs.git] / src / WINNT / afsd / smb_ioctl.c
index cc8870b..9f38eb8 100644 (file)
@@ -87,6 +87,9 @@ smb_InitIoctl(void)
     smb_ioctlProcsp[VIOC_GETFILETYPE] = smb_IoctlGetFileType;
     smb_ioctlProcsp[VIOC_VOLSTAT_TEST] = smb_IoctlVolStatTest;
     smb_ioctlProcsp[VIOC_UNICODECTL] = smb_IoctlUnicodeControl;
+    smb_ioctlProcsp[VIOC_SETOWNER] = smb_IoctlSetOwner;
+    smb_ioctlProcsp[VIOC_SETGROUP] = smb_IoctlSetGroup;
+    smb_ioctlProcsp[VIOCNEWCELL2] = smb_IoctlNewCell2;
 }       
 
 /* called to make a fid structure into an IOCTL fid structure */
@@ -108,7 +111,7 @@ smb_SetupIoctlFid(smb_fid_t *fidp, cm_space_t *prefix)
     }
     if (prefix) {
         copyPrefix = cm_GetSpace();
-        StringCbCopy(copyPrefix->data, CM_UTILS_SPACESIZE, prefix->data);
+        memcpy(copyPrefix->data, prefix->data, CM_UTILS_SPACESIZE);
         fidp->ioctlp->prefix = copyPrefix;
     }
     lock_ReleaseMutex(&fidp->mx);
@@ -119,7 +122,7 @@ smb_SetupIoctlFid(smb_fid_t *fidp, cm_space_t *prefix)
  * call to the ioctl code.
  */
 afs_int32
-smb_IoctlPrepareRead(struct smb_fid *fidp, smb_ioctl_t *ioctlp, cm_user_t *userp)
+smb_IoctlPrepareRead(struct smb_fid *fidp, smb_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
 {
     afs_int32 opcode;
     smb_ioctlProc_t *procp = NULL;
@@ -127,6 +130,7 @@ smb_IoctlPrepareRead(struct smb_fid *fidp, smb_ioctl_t *ioctlp, cm_user_t *userp
 
     if (ioctlp->ioctl.flags & CM_IOCTLFLAG_DATAIN) {
         ioctlp->ioctl.flags &= ~CM_IOCTLFLAG_DATAIN;
+        ioctlp->ioctl.flags |= CM_IOCTLFLAG_DATAOUT;
 
         /* do the call now, or fail if we didn't get an opcode, or
          * enough of an opcode.
@@ -136,26 +140,31 @@ smb_IoctlPrepareRead(struct smb_fid *fidp, smb_ioctl_t *ioctlp, cm_user_t *userp
         memcpy(&opcode, ioctlp->ioctl.inDatap, sizeof(afs_int32));
         ioctlp->ioctl.inDatap += sizeof(afs_int32);
 
-        osi_Log1(afsd_logp, "Ioctl opcode 0x%x", opcode);
-
+        osi_Log1(afsd_logp, "smb_IoctlPrepareRead opcode 0x%x", opcode);
         /* check for opcode out of bounds */
-        if (opcode < 0 || opcode >= SMB_IOCTL_MAXPROCS)
+        if (opcode < 0 || opcode >= SMB_IOCTL_MAXPROCS) {
+            osi_Log0(afsd_logp, "smb_IoctlPrepareRead - invalid opcode");
             return CM_ERROR_TOOBIG;
+        }
 
         /* check for no such proc */
        procp = smb_ioctlProcsp[opcode];
-        if (procp == NULL) 
-            return CM_ERROR_BADOP;
-
+        if (procp == NULL) {
+            osi_Log0(afsd_logp, "smb_IoctlPrepareRead - unassigned opcode");
+            return CM_ERROR_INVAL;
+        }
         /* otherwise, make the call */
         ioctlp->ioctl.outDatap += sizeof(afs_int32); /* reserve room for return code */
-        code = (*procp)(ioctlp, userp);
-
-        osi_Log1(afsd_logp, "Ioctl return code 0x%x", code);
+        code = (*procp)(ioctlp, userp, pflags);
+        osi_Log1(afsd_logp, "smb_IoctlPrepareRead operation returns code 0x%x", code);
 
         /* copy in return code */
         memcpy(ioctlp->ioctl.outAllocp, &code, sizeof(afs_int32));
+    } else if (!(ioctlp->ioctl.flags & CM_IOCTLFLAG_DATAOUT)) {
+        osi_Log0(afsd_logp, "Ioctl invalid state - dataout expected");
+        return CM_ERROR_INVAL;
     }
+
     return 0;
 }
 
@@ -183,6 +192,7 @@ smb_IoctlPrepareWrite(smb_fid_t *fidp, smb_ioctl_t *ioctlp)
         ioctlp->ioctl.inDatap = ioctlp->ioctl.inAllocp;
         ioctlp->ioctl.outDatap = ioctlp->ioctl.outAllocp;
         ioctlp->ioctl.flags |= CM_IOCTLFLAG_DATAIN;
+        ioctlp->ioctl.flags &= ~CM_IOCTLFLAG_DATAOUT;
     }
 }       
 
@@ -195,21 +205,37 @@ smb_IoctlRead(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *o
     afs_int32 leftToCopy;
     char *op;
     afs_int32 code;
-    cm_user_t *userp;
+    smb_user_t *uidp;
+    cm_user_t *userp = NULL;
+    smb_t *smbp;
+    int isSystem = 0;
 
     iop = fidp->ioctlp;
     count = smb_GetSMBParm(inp, 1);
-    userp = smb_GetUserFromVCP(vcp, inp);
+
+    /* Get the user and determine if it is the local machine account */
+    smbp = (smb_t *) inp;
+    uidp = smb_FindUID(vcp, smbp->uid, 0);
+    if (uidp) {
+        isSystem = smb_userIsLocalSystem(uidp);
+        userp = smb_GetUserFromUID(uidp);
+        smb_ReleaseUID(uidp);
+    }
+
+    if (!userp) {
+        userp = cm_rootUserp;
+        cm_HoldUser(userp);
+    }
 
     /* Identify tree */
     code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &iop->tidPathp);
-    if(code) {
+    if (code) {
         cm_ReleaseUser(userp);
         return CM_ERROR_NOSUCHPATH;
     }
 
     /* turn the connection around, if required */
-    code = smb_IoctlPrepareRead(fidp, iop, userp);
+    code = smb_IoctlPrepareRead(fidp, iop, userp, isSystem ? AFSCALL_FLAG_LOCAL_SYSTEM : 0);
 
     if (code) {
         cm_ReleaseUser(userp);
@@ -217,6 +243,11 @@ smb_IoctlRead(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *o
     }
 
     leftToCopy = (afs_int32)((iop->ioctl.outDatap - iop->ioctl.outAllocp) - iop->ioctl.outCopied);
+    if (leftToCopy < 0) {
+        osi_Log0(afsd_logp, "smb_IoctlRead leftToCopy went negative");
+        cm_ReleaseUser(userp);
+        return CM_ERROR_INVAL;
+    }
     if (count > leftToCopy)
         count = leftToCopy;
 
@@ -338,7 +369,7 @@ afs_int32
 smb_IoctlV3Read(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
 {
     smb_ioctl_t *iop;
-    long count;
+    unsigned short count;
     afs_int32 code;
     long leftToCopy;
     char *op;
@@ -349,6 +380,8 @@ smb_IoctlV3Read(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t
     count = smb_GetSMBParm(inp, 5);
        
     uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
+    if (!uidp)
+        return CM_ERROR_BADSMB;
     userp = smb_GetUserFromUID(uidp);
     osi_assertx(userp != NULL, "null cm_user_t");
     iop->uidp = uidp;
@@ -373,7 +406,7 @@ smb_IoctlV3Read(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t
         return CM_ERROR_NOSUCHPATH;
     }
 
-    code = smb_IoctlPrepareRead(fidp, iop, userp);
+    code = smb_IoctlPrepareRead(fidp, iop, userp, 0);
     if (uidp) {
         iop->uidp = 0;
         smb_ReleaseUID(uidp);
@@ -384,8 +417,13 @@ smb_IoctlV3Read(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t
     }
 
     leftToCopy = (long)((iop->ioctl.outDatap - iop->ioctl.outAllocp) - iop->ioctl.outCopied);
+    if (leftToCopy < 0) {
+        osi_Log0(afsd_logp, "smb_IoctlV3Read leftToCopy went negative");
+        cm_ReleaseUser(userp);
+        return CM_ERROR_INVAL;
+    }
     if (count > leftToCopy) 
-        count = leftToCopy;
+        count = (unsigned short)leftToCopy;
         
     /* 0 and 1 are reserved for request chaining, were setup by our caller,
      * and will be further filled in after we return.
@@ -462,15 +500,20 @@ smb_IoctlReadRaw(smb_fid_t *fidp, smb_vc_t *vcp, smb_packet_t *inp,
         goto done;
     }
 
-    code = smb_IoctlPrepareRead(fidp, iop, userp);
+    code = smb_IoctlPrepareRead(fidp, iop, userp, 0);
     if (code) {
         goto done;
     }
 
     leftToCopy = (long)((iop->ioctl.outDatap - iop->ioctl.outAllocp) - iop->ioctl.outCopied);
+    if (leftToCopy < 0) {
+        osi_Log0(afsd_logp, "smb_IoctlReadRaw leftToCopy went negative");
+        code = CM_ERROR_INVAL;
+        goto done;
+    }
 
     ncbp = outp->ncbp;
-    memset((char *)ncbp, 0, sizeof(NCB));
+    memset(ncbp, 0, sizeof(NCB));
 
     ncbp->ncb_length = (unsigned short) leftToCopy;
     ncbp->ncb_lsn = (unsigned char) vcp->lsn;
@@ -597,7 +640,7 @@ smb_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
         shareFound = smb_FindShare(ioctlp->fidp->vcp, ioctlp->uidp, shareName, &sharePath);
         if ( shareFound ) {
             /* we found a sharename, therefore use the resulting path */
-            code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+            code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                             userp, sharePath, reqp, &substRootp);
             free(sharePath);
@@ -650,7 +693,7 @@ smb_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
             shareName[i] = 0;       /* terminate string */
 
 
-            code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+            code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                             userp, shareName, reqp, &substRootp);
             if (code) {
@@ -687,7 +730,7 @@ smb_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
            }
         }
     } else {
-        code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+        code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                          CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                          userp, ioctlp->tidPathp, reqp, &substRootp);
         if (code) {
@@ -726,11 +769,19 @@ smb_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
     if (substRootp)
        cm_ReleaseSCache(substRootp);
 
-    /* and return success */
-    osi_Log1(afsd_logp,"cm_ParseIoctlPath [8] code 0x%x", code);
-
     if (relativePath)
         free(relativePath);
+
+    /* Ensure that the status object is up to date */
+    lock_ObtainWrite(&(*scpp)->rw);
+    code = cm_SyncOp( *scpp, NULL, userp, reqp, 0,
+                      CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+    if (code == 0)
+        cm_SyncOpDone( *scpp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+    lock_ReleaseWrite(&(*scpp)->rw);
+
+    /* and return success */
+    osi_Log1(afsd_logp,"cm_ParseIoctlPath [8] code 0x%x", code);
     return 0;
 }
 
@@ -840,7 +891,7 @@ smb_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
         shareFound = smb_FindShare(ioctlp->fidp->vcp, ioctlp->uidp, shareName, &sharePath);
         if ( shareFound ) {
             /* we found a sharename, therefore use the resulting path */
-            code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+            code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                             userp, sharePath, reqp, &substRootp);
             free(sharePath);
@@ -867,7 +918,7 @@ smb_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
             shareName[i++] = '/';      /* add trailing slash */
             shareName[i] = 0;       /* terminate string */
 
-            code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+            code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                             userp, shareName, reqp, &substRootp);
             if (code) return code;
@@ -878,7 +929,7 @@ smb_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
             if (code) return code;
         }
     } else {
-        code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->wdata,
+        code = cm_NameI(cm_RootSCachep(userp, reqp), ioctlp->prefix->wdata,
                         CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
                         userp, ioctlp->tidPathp, reqp, &substRootp);
         if (code) return code;
@@ -893,12 +944,20 @@ smb_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
     code = (long)strlen(ioctlp->ioctl.inDatap) + 1;
     ioctlp->ioctl.inDatap += code;
 
+    /* Ensure that the status object is up to date */
+    lock_ObtainWrite(&(*scpp)->rw);
+    code = cm_SyncOp( *scpp, NULL, userp, reqp, 0,
+                      CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+    if (code == 0)
+        cm_SyncOpDone( *scpp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
+    lock_ReleaseWrite(&(*scpp)->rw);
+
     /* and return success */
     return 0;
 }
 
 afs_int32 
-smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     char *saveDataPtr;
     char *tp;
@@ -992,12 +1051,17 @@ smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
             code = CM_ERROR_INVAL;
             goto done;
         }
+
+        if (!(pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
+            code = CM_ERROR_NOACCESS;
+            goto done;
+        }
     } else {
         cellp = cm_data.rootCellp;
         osi_Log0(smb_logp,"cm_IoctlSetToken - no name specified");
     }
 
-    if (flags & PIOCTL_LOGON) {
+    if ((pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
         userp = smb_FindCMUserByName(smbname, ioctlp->fidp->vcp->rname,
                                     SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
        release_userp = 1;
@@ -1034,13 +1098,15 @@ smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
     ucellp->flags |= CM_UCELLFLAG_RXKAD;
     lock_ReleaseMutex(&userp->mx);
 
-    if (flags & PIOCTL_LOGON) {
+    if ((pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
         ioctlp->ioctl.flags |= CM_IOCTLFLAG_LOGON;
     }
 
-    cm_ResetACLCache(userp);
+    cm_ResetACLCache(cellp, userp);
 
   done:
+    SecureZeroMemory(sessionKey, sizeof(sessionKey));
+
     if (release_userp)
        cm_ReleaseUser(userp);
 
@@ -1056,7 +1122,7 @@ smb_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp)
+smb_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
 {
     smb_user_t *uidp = ioctlp->uidp;
 
@@ -1064,8 +1130,7 @@ smb_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp)
         int cch;
 
         cch = cm_ClientStringToUtf8(uidp->unp->name,
-                                    cm_ClientStrLen(uidp->unp->name),
-
+                                    -1,
                                     ioctlp->ioctl.outDatap,
                                     (SMB_IOCTL_MAXDATA -
                                      (ioctlp->ioctl.outDatap - ioctlp->ioctl.outAllocp))
@@ -1078,7 +1143,7 @@ smb_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp)
 }
 
 afs_int32 
-smb_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
+smb_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
 {
     cm_scache_t *scp;
     afs_int32 code;
@@ -1086,7 +1151,7 @@ smb_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1101,6 +1166,7 @@ smb_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
     } else {
         code = smb_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
     }
+
     if (code) 
         return code;
 
@@ -1111,15 +1177,14 @@ smb_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
 }
 
 afs_int32 
-smb_IoctlSetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
+smb_IoctlSetACL(smb_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
 {
     cm_scache_t *scp;
     afs_int32 code;
     cm_req_t req;
-    cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
     if (code) 
@@ -1132,7 +1197,7 @@ smb_IoctlSetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
 }
 
 afs_int32
-smb_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1140,7 +1205,7 @@ smb_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1166,11 +1231,11 @@ smb_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlFlushAllVolumes(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlFlushAllVolumes(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     cm_SkipIoctlPath(&ioctlp->ioctl);  /* we don't care about the path */
 
@@ -1178,7 +1243,7 @@ smb_IoctlFlushAllVolumes(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlFlushVolume(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlFlushVolume(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1186,7 +1251,7 @@ smb_IoctlFlushVolume(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1212,7 +1277,7 @@ smb_IoctlFlushVolume(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlFlushFile(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlFlushFile(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1220,7 +1285,7 @@ smb_IoctlFlushFile(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1245,13 +1310,13 @@ smb_IoctlFlushFile(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &scp, 0);
     if (code) return code;
@@ -1263,7 +1328,7 @@ smb_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1271,7 +1336,7 @@ smb_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
     afs_uint32 flags = 0;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1297,7 +1362,7 @@ smb_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetFid(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetFid(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1305,7 +1370,7 @@ smb_IoctlGetFid(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t * optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1323,7 +1388,7 @@ smb_IoctlGetFid(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetFileType(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetFileType(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1331,7 +1396,7 @@ smb_IoctlGetFileType(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t * optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1357,7 +1422,7 @@ smb_IoctlGetFileType(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetOwner(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetOwner(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1365,7 +1430,7 @@ smb_IoctlGetOwner(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1391,7 +1456,7 @@ smb_IoctlGetOwner(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlWhereIs(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlWhereIs(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1399,7 +1464,7 @@ smb_IoctlWhereIs(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1426,13 +1491,13 @@ smb_IoctlWhereIs(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32 
-smb_IoctlStatMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlStatMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
     if (code)
@@ -1446,13 +1511,13 @@ smb_IoctlStatMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlDeleteMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlDeleteMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
     if (code) 
@@ -1466,7 +1531,7 @@ smb_IoctlDeleteMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlCheckServers(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlCheckServers(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);  /* we don't care about the path */
 
@@ -1474,21 +1539,21 @@ smb_IoctlCheckServers(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGag(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGag(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     /* we don't print anything superfluous, so we don't support the gag call */
     return CM_ERROR_INVAL;
 }
 
 afs_int32 
-smb_IoctlCheckVolumes(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlCheckVolumes(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
     return cm_IoctlCheckVolumes(&ioctlp->ioctl, userp);
 }
 
-afs_int32 smb_IoctlSetCacheSize(struct smb_ioctl *ioctlp, struct cm_user *userp)
+afs_int32 smb_IoctlSetCacheSize(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1497,7 +1562,7 @@ afs_int32 smb_IoctlSetCacheSize(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32 
-smb_IoctlTraceControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlTraceControl(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
        
@@ -1505,7 +1570,7 @@ smb_IoctlTraceControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetCacheParms(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetCacheParms(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
        
@@ -1513,7 +1578,7 @@ smb_IoctlGetCacheParms(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1521,7 +1586,7 @@ smb_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlNewCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlNewCell(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1529,7 +1594,15 @@ smb_IoctlNewCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
+smb_IoctlNewCell2(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
+{
+    cm_SkipIoctlPath(&ioctlp->ioctl);
+
+    return cm_IoctlNewCell2(&ioctlp->ioctl, userp);
+}
+
+afs_int32
+smb_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1537,7 +1610,7 @@ smb_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
 }
 
 afs_int32 
-smb_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1545,7 +1618,7 @@ smb_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1553,7 +1626,7 @@ smb_IoctlGetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlSetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1561,7 +1634,7 @@ smb_IoctlSetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1569,7 +1642,7 @@ smb_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlGetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1577,7 +1650,7 @@ smb_IoctlGetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlStoreBehind(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlStoreBehind(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     /* we ignore default asynchrony since we only have one way
      * of doing this today.
@@ -1586,14 +1659,14 @@ smb_IoctlStoreBehind(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }       
 
 afs_int32
-smb_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     clientchar_t leaf[LEAF_SIZE];
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
         
     code = smb_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
     if (code)
@@ -1606,14 +1679,14 @@ smb_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     clientchar_t leaf[LEAF_SIZE];
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
     if (code) return code;
@@ -1626,13 +1699,13 @@ smb_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
     if (code) return code;
@@ -1644,13 +1717,13 @@ smb_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlIslink(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlIslink(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {/*CHECK FOR VALID SYMLINK*/
     afs_int32 code;
     cm_scache_t *dscp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
     if (code) return code;
@@ -1663,13 +1736,13 @@ smb_IoctlIslink(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlDeletelink(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlDeletelink(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *dscp;
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     code = smb_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
     if (code) return code;
@@ -1682,7 +1755,7 @@ smb_IoctlDeletelink(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32 
-smb_IoctlGetTokenIter(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetTokenIter(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1690,7 +1763,7 @@ smb_IoctlGetTokenIter(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlGetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetToken(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1699,7 +1772,7 @@ smb_IoctlGetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlDelToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlDelToken(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1708,7 +1781,7 @@ smb_IoctlDelToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlDelAllToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlDelAllToken(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1717,7 +1790,7 @@ smb_IoctlDelAllToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlMakeSubmount(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlMakeSubmount(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1725,7 +1798,7 @@ smb_IoctlMakeSubmount(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlGetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlGetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1733,7 +1806,7 @@ smb_IoctlGetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlSetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlSetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1741,7 +1814,7 @@ smb_IoctlSetRxkcrypt(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlRxStatProcess(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlRxStatProcess(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1750,7 +1823,7 @@ smb_IoctlRxStatProcess(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlRxStatPeer(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlRxStatPeer(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1758,7 +1831,7 @@ smb_IoctlRxStatPeer(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlUnicodeControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlUnicodeControl(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1766,7 +1839,7 @@ smb_IoctlUnicodeControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlUUIDControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlUUIDControl(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1775,7 +1848,7 @@ smb_IoctlUUIDControl(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
 
 afs_int32
-smb_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
@@ -1783,7 +1856,7 @@ smb_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlPathAvailability(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlPathAvailability(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     afs_int32 code;
     cm_scache_t *scp;
@@ -1791,7 +1864,7 @@ smb_IoctlPathAvailability(struct smb_ioctl *ioctlp, struct cm_user *userp)
     cm_ioctlQueryOptions_t *optionsp;
     afs_uint32 flags = 0;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
     if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
@@ -1815,13 +1888,104 @@ smb_IoctlPathAvailability(struct smb_ioctl *ioctlp, struct cm_user *userp)
 }
 
 afs_int32
-smb_IoctlVolStatTest(struct smb_ioctl *ioctlp, struct cm_user *userp)
+smb_IoctlVolStatTest(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
 {
     cm_req_t req;
 
-    cm_InitReq(&req);
+    smb_InitReq(&req);
 
     cm_SkipIoctlPath(&ioctlp->ioctl);
 
     return cm_IoctlVolStatTest(&ioctlp->ioctl, userp, &req);
 }
+
+/* 
+ * VIOC_SETOWNER
+ * 
+ * This pioctl requires the use of the cm_ioctlQueryOptions_t structure.
+ *
+ */
+afs_int32 
+smb_IoctlSetOwner(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
+{
+    afs_int32 code;
+    cm_scache_t *scp;
+    cm_req_t req;
+    cm_ioctlQueryOptions_t *optionsp;
+    afs_uint32 flags = 0;
+
+    smb_InitReq(&req);
+
+    optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
+    if (optionsp) {
+        if (CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
+            flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
+
+        if (CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
+            cm_fid_t fid;
+            cm_SkipIoctlPath(&ioctlp->ioctl);
+            cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
+                       optionsp->fid.vnode, optionsp->fid.unique);
+            code = cm_GetSCache(&fid, &scp, userp, &req);
+        } else {
+            code = smb_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
+        }
+        if (code) 
+            return code;
+
+        cm_IoctlSkipQueryOptions(&ioctlp->ioctl, userp);
+    }
+
+    code = cm_IoctlSetOwner(&ioctlp->ioctl, userp, scp, &req);
+
+    cm_ReleaseSCache(scp);
+
+    return code;
+}
+
+/* 
+ * VIOC_GETOWNER
+ * 
+ * This pioctl requires the use of the cm_ioctlQueryOptions_t structure.
+ *
+ */
+afs_int32 
+smb_IoctlSetGroup(struct smb_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
+{
+    afs_int32 code;
+    cm_scache_t *scp;
+    cm_req_t req;
+    cm_ioctlQueryOptions_t *optionsp;
+    afs_uint32 flags = 0;
+
+    smb_InitReq(&req);
+
+    optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
+    if (optionsp) {
+        if (CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
+            flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
+
+        if (CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
+            cm_fid_t fid;
+            cm_SkipIoctlPath(&ioctlp->ioctl);
+            cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
+                       optionsp->fid.vnode, optionsp->fid.unique);
+            code = cm_GetSCache(&fid, &scp, userp, &req);
+        } else {
+            code = smb_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
+        }
+        if (code) 
+            return code;
+
+        cm_IoctlSkipQueryOptions(&ioctlp->ioctl, userp);
+    }
+
+    code = cm_IoctlSetGroup(&ioctlp->ioctl, userp, scp, &req);
+
+    cm_ReleaseSCache(scp);
+
+    return code;
+}
+
+
+