2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Copyright (c) 2008 Secure Endpoints, Inc.
12 * Copyright (c) 2009-2011 Your File System, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
18 * - Redistributions of source code must retain the above copyright notice,
19 * this list of conditions and the following disclaimer.
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimer in the documentation
22 * and/or other materials provided with the distribution.
23 * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
24 * may be used to endorse or promote products derived from this software without
25 * specific prior written permission from Secure Endpoints, Inc. and
26 * Your File System, Inc.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include <afsconfig.h>
42 #include <afs/param.h>
61 #include "afs/afsrpc.h"
64 #include "smb_iocons.h"
65 #define RDR_IOCTL_PRIVATE 1
70 static RDR_ioctlProc_t *RDR_ioctlProcsp[CM_IOCTL_MAXPROCS];
72 static RDR_ioctl_t * RDR_allIoctls = NULL, *RDR_allIoctlsLast = NULL;
73 static osi_rwlock_t RDR_globalIoctlLock;
75 extern wchar_t RDR_UNCName[];
82 lock_InitializeRWLock(&RDR_globalIoctlLock, "RDR global ioctl lock", LOCK_HIERARCHY_RDR_GLOBAL);
84 for (i=0; i<CM_IOCTL_MAXPROCS; i++)
85 RDR_ioctlProcsp[i] = NULL;
87 RDR_ioctlProcsp[VIOCGETAL] = RDR_IoctlGetACL;
88 RDR_ioctlProcsp[VIOC_FILE_CELL_NAME] = RDR_IoctlGetFileCellName;
89 RDR_ioctlProcsp[VIOCSETAL] = RDR_IoctlSetACL;
90 RDR_ioctlProcsp[VIOC_FLUSHVOLUME] = RDR_IoctlFlushVolume;
91 RDR_ioctlProcsp[VIOCFLUSH] = RDR_IoctlFlushFile;
92 RDR_ioctlProcsp[VIOCSETVOLSTAT] = RDR_IoctlSetVolumeStatus;
93 RDR_ioctlProcsp[VIOCGETVOLSTAT] = RDR_IoctlGetVolumeStatus;
94 RDR_ioctlProcsp[VIOCWHEREIS] = RDR_IoctlWhereIs;
95 RDR_ioctlProcsp[VIOC_AFS_STAT_MT_PT] = RDR_IoctlStatMountPoint;
96 RDR_ioctlProcsp[VIOC_AFS_DELETE_MT_PT] = RDR_IoctlDeleteMountPoint;
97 RDR_ioctlProcsp[VIOCCKSERV] = RDR_IoctlCheckServers;
98 RDR_ioctlProcsp[VIOC_GAG] = RDR_IoctlGag;
99 RDR_ioctlProcsp[VIOCCKBACK] = RDR_IoctlCheckVolumes;
100 RDR_ioctlProcsp[VIOCSETCACHESIZE] = RDR_IoctlSetCacheSize;
101 RDR_ioctlProcsp[VIOCGETCACHEPARMS] = RDR_IoctlGetCacheParms;
102 RDR_ioctlProcsp[VIOCGETCELL] = RDR_IoctlGetCell;
103 RDR_ioctlProcsp[VIOCNEWCELL] = RDR_IoctlNewCell;
104 RDR_ioctlProcsp[VIOC_GET_WS_CELL] = RDR_IoctlGetWsCell;
105 RDR_ioctlProcsp[VIOC_AFS_SYSNAME] = RDR_IoctlSysName;
106 RDR_ioctlProcsp[VIOC_GETCELLSTATUS] = RDR_IoctlGetCellStatus;
107 RDR_ioctlProcsp[VIOC_SETCELLSTATUS] = RDR_IoctlSetCellStatus;
108 RDR_ioctlProcsp[VIOC_SETSPREFS] = RDR_IoctlSetSPrefs;
109 RDR_ioctlProcsp[VIOC_GETSPREFS] = RDR_IoctlGetSPrefs;
110 RDR_ioctlProcsp[VIOC_STOREBEHIND] = RDR_IoctlStoreBehind;
111 RDR_ioctlProcsp[VIOC_AFS_CREATE_MT_PT] = RDR_IoctlCreateMountPoint;
112 RDR_ioctlProcsp[VIOC_TRACECTL] = RDR_IoctlTraceControl;
113 RDR_ioctlProcsp[VIOCSETTOK] = RDR_IoctlSetToken;
114 RDR_ioctlProcsp[VIOCGETTOK] = RDR_IoctlGetTokenIter;
115 RDR_ioctlProcsp[VIOCNEWGETTOK] = RDR_IoctlGetToken;
116 RDR_ioctlProcsp[VIOCDELTOK] = RDR_IoctlDelToken;
117 RDR_ioctlProcsp[VIOCDELALLTOK] = RDR_IoctlDelAllToken;
118 RDR_ioctlProcsp[VIOC_SYMLINK] = RDR_IoctlSymlink;
119 RDR_ioctlProcsp[VIOC_LISTSYMLINK] = RDR_IoctlListlink;
120 RDR_ioctlProcsp[VIOC_DELSYMLINK] = RDR_IoctlDeletelink;
121 RDR_ioctlProcsp[VIOC_MAKESUBMOUNT] = RDR_IoctlMakeSubmount;
122 RDR_ioctlProcsp[VIOC_GETRXKCRYPT] = RDR_IoctlGetRxkcrypt;
123 RDR_ioctlProcsp[VIOC_SETRXKCRYPT] = RDR_IoctlSetRxkcrypt;
124 RDR_ioctlProcsp[VIOC_ISSYMLINK] = RDR_IoctlIslink;
125 RDR_ioctlProcsp[VIOC_TRACEMEMDUMP] = RDR_IoctlMemoryDump;
126 RDR_ioctlProcsp[VIOC_ISSYMLINK] = RDR_IoctlIslink;
127 RDR_ioctlProcsp[VIOC_FLUSHALL] = RDR_IoctlFlushAllVolumes;
128 RDR_ioctlProcsp[VIOCGETFID] = RDR_IoctlGetFid;
129 RDR_ioctlProcsp[VIOCGETOWNER] = RDR_IoctlGetOwner;
130 RDR_ioctlProcsp[VIOC_RXSTAT_PROC] = RDR_IoctlRxStatProcess;
131 RDR_ioctlProcsp[VIOC_RXSTAT_PEER] = RDR_IoctlRxStatPeer;
132 RDR_ioctlProcsp[VIOC_UUIDCTL] = RDR_IoctlUUIDControl;
133 RDR_ioctlProcsp[VIOC_PATH_AVAILABILITY] = RDR_IoctlPathAvailability;
134 RDR_ioctlProcsp[VIOC_GETFILETYPE] = RDR_IoctlGetFileType;
135 RDR_ioctlProcsp[VIOC_VOLSTAT_TEST] = RDR_IoctlVolStatTest;
136 RDR_ioctlProcsp[VIOC_UNICODECTL] = RDR_IoctlUnicodeControl;
137 RDR_ioctlProcsp[VIOC_SETOWNER] = RDR_IoctlSetOwner;
138 RDR_ioctlProcsp[VIOC_SETGROUP] = RDR_IoctlSetGroup;
139 RDR_ioctlProcsp[VIOCNEWCELL2] = RDR_IoctlNewCell2;
140 RDR_ioctlProcsp[VIOC_GETUNIXMODE] = RDR_IoctlGetUnixMode;
141 RDR_ioctlProcsp[VIOC_SETUNIXMODE] = RDR_IoctlSetUnixMode;
142 RDR_ioctlProcsp[VIOC_GETVERIFYDATA] = RDR_IoctlGetVerifyData;
143 RDR_ioctlProcsp[VIOC_SETVERIFYDATA] = RDR_IoctlSetVerifyData;
146 /* called to make a fid structure into an IOCTL fid structure */
148 RDR_SetupIoctl(ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid, cm_user_t *userp)
155 lock_ObtainWrite(&RDR_globalIoctlLock);
156 for ( iop=RDR_allIoctls; iop; iop=iop->next) {
157 if (iop->index == index)
162 /* we are reusing a previous ioctl */
163 if (cm_FidCmp(&iop->parentFid, parentFid)) {
164 iop->parentFid = *parentFid;
165 if (iop->parentScp) {
166 cm_ReleaseSCache(iop->parentScp);
167 iop->parentScp = NULL;
169 cm_GetSCache(parentFid, &iop->parentScp, userp, &req);
170 iop->rootFid = *rootFid;
173 /* need to allocate a new one */
174 iop = malloc(sizeof(*iop));
175 memset(iop, 0, sizeof(*iop));
176 if (RDR_allIoctls == NULL)
177 RDR_allIoctls = RDR_allIoctlsLast = iop;
179 iop->prev = RDR_allIoctlsLast;
180 RDR_allIoctlsLast->next = iop;
181 RDR_allIoctlsLast = iop;
184 if (parentFid->cell == 0) {
185 iop->parentFid = cm_data.rootFid;
186 iop->parentScp = cm_RootSCachep(userp, &req);
187 cm_HoldSCache(iop->parentScp);
189 iop->parentFid = *parentFid;
190 cm_GetSCache(parentFid, &iop->parentScp, userp, &req);
192 if (rootFid->cell == 0) {
193 iop->rootFid = cm_data.rootFid;
195 iop->rootFid = *rootFid;
198 lock_ReleaseWrite(&RDR_globalIoctlLock);
203 RDR_CleanupIoctl(ULONG index)
207 lock_ObtainWrite(&RDR_globalIoctlLock);
208 for ( iop=RDR_allIoctls; iop; iop=iop->next) {
209 if (iop->index == index)
215 cm_ReleaseSCache(iop->parentScp);
217 if (iop->ioctl.inAllocp)
218 free(iop->ioctl.inAllocp);
219 if (iop->ioctl.outAllocp)
220 free(iop->ioctl.outAllocp);
222 if (RDR_allIoctls == RDR_allIoctlsLast)
223 RDR_allIoctls = RDR_allIoctlsLast = NULL;
225 if (iop->prev == NULL)
226 RDR_allIoctls = iop->next;
228 iop->prev->next = iop->next;
229 if (iop->next == NULL) {
230 RDR_allIoctlsLast = iop->prev;
231 iop->prev->next = NULL;
233 iop->next->prev = iop->prev;
237 lock_ReleaseWrite(&RDR_globalIoctlLock);
241 /* called when we receive a write call. If this is the first write call after
242 * a series of reads (or the very first call), then we start a new call.
243 * We also ensure that things are properly initialized for the start of a call.
246 RDR_IoctlPrepareWrite(RDR_ioctl_t *ioctlp)
248 /* make sure the buffer(s) are allocated */
249 if (!ioctlp->ioctl.inAllocp)
250 ioctlp->ioctl.inAllocp = malloc(CM_IOCTL_MAXDATA);
251 if (!ioctlp->ioctl.outAllocp)
252 ioctlp->ioctl.outAllocp = malloc(CM_IOCTL_MAXDATA);
254 /* Fixes fs la problem. We do a StrToOEM later and if this data isn't initialized we get memory issues. */
255 (void) memset(ioctlp->ioctl.inAllocp, 0, CM_IOCTL_MAXDATA);
256 (void) memset(ioctlp->ioctl.outAllocp, 0, CM_IOCTL_MAXDATA);
258 /* and make sure that we've reset our state for the new incoming request */
259 if (!(ioctlp->ioctl.flags & CM_IOCTLFLAG_DATAIN)) {
260 ioctlp->ioctl.inCopied = 0;
261 ioctlp->ioctl.outCopied = 0;
262 ioctlp->ioctl.inDatap = ioctlp->ioctl.inAllocp;
263 ioctlp->ioctl.outDatap = ioctlp->ioctl.outAllocp;
264 ioctlp->ioctl.flags |= CM_IOCTLFLAG_DATAIN;
268 /* called when we receive a read call, does the send of the received data if
269 * this is the first read call. This is the function that actually makes the
270 * call to the ioctl code.
273 RDR_IoctlPrepareRead(RDR_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
276 RDR_ioctlProc_t *procp = NULL;
279 if (ioctlp->ioctl.flags & CM_IOCTLFLAG_DATAIN) {
280 ioctlp->ioctl.flags &= ~CM_IOCTLFLAG_DATAIN;
282 /* do the call now, or fail if we didn't get an opcode, or
283 * enough of an opcode.
285 if (ioctlp->ioctl.inCopied < sizeof(afs_int32))
286 return CM_ERROR_INVAL;
288 memcpy(&opcode, ioctlp->ioctl.inDatap, sizeof(afs_int32));
289 ioctlp->ioctl.inDatap += sizeof(afs_int32);
291 osi_Log1(afsd_logp, "Ioctl opcode 0x%x", opcode);
293 /* check for opcode out of bounds */
294 if (opcode < 0 || opcode >= CM_IOCTL_MAXPROCS)
295 return CM_ERROR_TOOBIG;
297 /* check for no such proc */
298 procp = RDR_ioctlProcsp[opcode];
300 return CM_ERROR_BADOP;
302 /* otherwise, make the call */
303 ioctlp->ioctl.outDatap += sizeof(afs_int32); /* reserve room for return code */
304 code = (*procp)(ioctlp, userp, pflags);
306 osi_Log1(afsd_logp, "Ioctl return code 0x%x", code);
308 /* copy in return code */
309 memcpy(ioctlp->ioctl.outAllocp, &code, sizeof(afs_int32));
315 RDR_FindIoctl(ULONG index)
319 lock_ObtainRead(&RDR_globalIoctlLock);
320 for ( iop=RDR_allIoctls; iop; iop=iop->next) {
321 if (iop->index == index)
324 lock_ReleaseRead(&RDR_globalIoctlLock);
328 /* called from RDR_ReceiveCoreRead when we receive a read on the ioctl fid */
330 RDR_IoctlRead(cm_user_t *userp, ULONG RequestId, ULONG BufferLength, void *MappedBuffer, ULONG *pBytesProcessed, cm_req_t *reqp, afs_uint32 pflags)
336 iop = RDR_FindIoctl(RequestId);
338 return CM_ERROR_BADFD;
340 /* turn the connection around, if required */
341 code = RDR_IoctlPrepareRead(iop, userp, pflags);
345 count = (afs_int32)((iop->ioctl.outDatap - iop->ioctl.outAllocp) - iop->ioctl.outCopied);
346 if (BufferLength < count)
347 count = BufferLength;
349 /* now copy the data into the response packet */
350 memcpy((char *)MappedBuffer, iop->ioctl.outCopied + iop->ioctl.outAllocp, count);
352 /* and adjust the counters */
353 iop->ioctl.outCopied += count;
355 *pBytesProcessed = count;
360 /* called from RDR_PioctWRite when we receive a write call on the IOCTL
364 RDR_IoctlWrite(cm_user_t *userp, ULONG RequestId, ULONG BufferLength, void *MappedBuffer, cm_req_t *reqp)
368 iop = RDR_FindIoctl(RequestId);
370 return CM_ERROR_BADFD;
372 RDR_IoctlPrepareWrite(iop);
374 if (BufferLength + iop->ioctl.inCopied > CM_IOCTL_MAXDATA)
375 return CM_ERROR_TOOBIG;
378 memcpy(iop->ioctl.inDatap + iop->ioctl.inCopied, (char *)MappedBuffer, BufferLength);
381 iop->ioctl.inCopied += BufferLength;
387 /* parse the passed-in file name and do a namei on it. If we fail,
388 * return an error code, otherwise return the vnode located in *scpp.
390 #define CM_PARSE_FLAG_LITERAL 1
393 RDR_ParseIoctlPath(RDR_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
394 cm_scache_t **scpp, afs_uint32 flags)
397 cm_scache_t *substRootp = NULL;
398 cm_scache_t *iscp = NULL;
400 wchar_t *relativePath = NULL;
401 wchar_t *lastComponent = NULL;
402 afs_uint32 follow = (flags & CM_PARSE_FLAG_LITERAL ? CM_FLAG_NOMOUNTCHASE : CM_FLAG_FOLLOW);
403 int free_path = FALSE;
405 inPath = ioctlp->ioctl.inDatap;
406 /* setup the next data value for the caller to use */
407 ioctlp->ioctl.inDatap += (long)strlen(ioctlp->ioctl.inDatap) + 1;;
409 osi_Log1(afsd_logp, "RDR_ParseIoctlPath inPath %s", osi_LogSaveString(afsd_logp,inPath));
411 /* This is usually the file name, but for StatMountPoint it is the path. */
412 /* ioctlp->inDatap can be either of the form:
415 * \\netbios-name\submount\path\.
416 * \\netbios-name\submount\path\file
419 /* We do not perform path name translation on the ioctl path data
420 * because these paths were not translated by Windows through the
421 * file system API. Therefore, they are not OEM characters but
422 * whatever the display character set is.
425 // TranslateExtendedChars(relativePath);
427 /* This is usually nothing, but for StatMountPoint it is the file name. */
428 // TranslateExtendedChars(ioctlp->ioctl.inDatap);
430 /* If the string starts with our UTF-8 prefix (which is the
431 sequence [ESC,'%','G'] as used by ISO-2022 to designate UTF-8
432 strings), we assume that the provided path is UTF-8. Otherwise
433 we have to convert the string to UTF-8, since that is what we
434 want to use everywhere else.*/
436 if (memcmp(inPath, utf8_prefix, utf8_prefix_size) == 0) {
437 /* String is UTF-8 */
438 inPath += utf8_prefix_size;
439 ioctlp->ioctl.flags |= CM_IOCTLFLAG_USEUTF8;
441 relativePath = cm_Utf8ToClientStringAlloc(inPath, -1, NULL);
442 osi_Log1(afsd_logp, "RDR_ParseIoctlPath UTF8 relativePath %S",
443 osi_LogSaveStringW(afsd_logp,relativePath));
446 /* Not a UTF-8 string */
447 /* TODO: If this is an OEM string, we should convert it to UTF-8. */
448 if (smb_StoreAnsiFilenames) {
449 cch = cm_AnsiToClientString(inPath, -1, NULL, 0);
453 relativePath = malloc(cch * sizeof(clientchar_t));
454 cm_AnsiToClientString(inPath, -1, relativePath, cch);
456 TranslateExtendedChars(inPath);
458 cch = cm_OemToClientString(inPath, -1, NULL, 0);
462 relativePath = malloc(cch * sizeof(clientchar_t));
463 cm_OemToClientString(inPath, -1, relativePath, cch);
465 osi_Log1(afsd_logp, "RDR_ParseIoctlPath ASCII relativePath %S",
466 osi_LogSaveStringW(afsd_logp,relativePath));
469 if (relativePath[0] == relativePath[1] &&
470 relativePath[1] == '\\' &&
471 !cm_ClientStrCmpNI(RDR_UNCName,relativePath+2,(int)wcslen(RDR_UNCName)))
473 wchar_t shareName[256];
478 /* We may have found a UNC path.
479 * If the first component is the RDR UNC Name,
480 * then throw out the second component (the submount)
481 * since it had better expand into the value of ioctl->tidPathp
483 p = relativePath + 2 + wcslen(RDR_UNCName) + 1; /* buffer overflow vuln.? */
484 if ( !cm_ClientStrCmpNI(_C("all"), p, 3) )
487 for (i = 0; *p && *p != '\\'; i++,p++ ) {
490 p++; /* skip past trailing slash */
491 shareName[i] = 0; /* terminate string */
493 shareFound = smb_FindShare(NULL, NULL, shareName, &sharePath);
495 /* we found a sharename, therefore use the resulting path */
496 code = cm_NameI(cm_RootSCachep(userp, reqp), sharePath,
497 CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
498 userp, NULL, reqp, &substRootp);
501 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [1] code 0x%x", code);
507 lastComponent = cm_ClientStrRChr(p, '\\');
508 if (lastComponent && (lastComponent - p) > 1 && wcslen(lastComponent) > 1) {
509 *lastComponent = '\0';
512 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
513 userp, NULL, reqp, &iscp);
515 code = cm_NameI(iscp, lastComponent, CM_FLAG_CASEFOLD | follow,
516 userp, NULL, reqp, scpp);
518 cm_ReleaseSCache(iscp);
520 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD,
521 userp, NULL, reqp, scpp);
523 cm_ReleaseSCache(substRootp);
525 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [2] code 0x%x", code);
531 /* otherwise, treat the name as a cellname mounted off the afs root.
532 * This requires that we reconstruct the shareName string with
533 * leading and trailing slashes.
535 p = relativePath + 2 + wcslen(RDR_UNCName) + 1;
536 if ( !cm_ClientStrCmpNI(_C("all"), p, 3) )
540 for (i = 1; *p && *p != '\\'; i++,p++ ) {
543 p++; /* skip past trailing slash */
544 shareName[i++] = '/'; /* add trailing slash */
545 shareName[i] = 0; /* terminate string */
548 code = cm_NameI(cm_RootSCachep(userp, reqp), shareName,
549 CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
550 userp, NULL, reqp, &substRootp);
552 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [3] code 0x%x", code);
558 lastComponent = cm_ClientStrRChr(p, '\\');
559 if (lastComponent && (lastComponent - p) > 1 && wcslen(lastComponent) > 1) {
560 *lastComponent = '\0';
563 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
564 userp, NULL, reqp, &iscp);
566 code = cm_NameI(iscp, lastComponent, CM_FLAG_CASEFOLD | follow,
567 userp, NULL, reqp, scpp);
569 cm_ReleaseSCache(iscp);
571 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD,
572 userp, NULL, reqp, scpp);
576 cm_ReleaseSCache(substRootp);
577 osi_Log1(afsd_logp,"RDR_ParseIoctlPath code [4] 0x%x", code);
584 code = cm_GetSCache(&ioctlp->parentFid, &substRootp, userp, reqp);
586 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [6] code 0x%x", code);
592 lastComponent = cm_ClientStrRChr(relativePath, '\\');
593 if (lastComponent && (lastComponent - relativePath) > 1 && wcslen(lastComponent) > 1) {
594 *lastComponent = '\0';
597 code = cm_NameI(substRootp, relativePath, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
598 userp, NULL, reqp, &iscp);
600 code = cm_NameI(iscp, lastComponent, CM_FLAG_CASEFOLD | follow,
601 userp, NULL, reqp, scpp);
603 cm_ReleaseSCache(iscp);
605 code = cm_NameI(substRootp, relativePath, CM_FLAG_CASEFOLD | follow,
606 userp, NULL, reqp, scpp);
609 cm_ReleaseSCache(substRootp);
610 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [7] code 0x%x", code);
618 cm_ReleaseSCache(substRootp);
623 /* Ensure that the status object is up to date */
624 lock_ObtainWrite(&(*scpp)->rw);
625 code = cm_SyncOp( *scpp, NULL, userp, reqp, 0,
626 CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
628 cm_SyncOpDone( *scpp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
629 lock_ReleaseWrite(&(*scpp)->rw);
631 /* and return success */
632 osi_Log1(afsd_logp,"RDR_ParseIoctlPath [8] code 0x%x", code);
638 #define LEAF_SIZE 256
639 /* parse the passed-in file name and do a namei on its parent. If we fail,
640 * return an error code, otherwise return the vnode located in *scpp.
643 RDR_ParseIoctlParent(RDR_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
644 cm_scache_t **scpp, wchar_t *leafp)
647 clientchar_t tbuffer[1024];
648 clientchar_t *tp, *jp;
649 cm_scache_t *substRootp = NULL;
650 clientchar_t *inpathp;
652 int free_path = FALSE;
654 inpathdatap = ioctlp->ioctl.inDatap;
656 /* If the string starts with our UTF-8 prefix (which is the
657 sequence [ESC,'%','G'] as used by ISO-2022 to designate UTF-8
658 strings), we assume that the provided path is UTF-8. Otherwise
659 we have to convert the string to UTF-8, since that is what we
660 want to use everywhere else.*/
662 if (memcmp(inpathdatap, utf8_prefix, utf8_prefix_size) == 0) {
663 /* String is UTF-8 */
664 inpathdatap += utf8_prefix_size;
665 ioctlp->ioctl.flags |= CM_IOCTLFLAG_USEUTF8;
667 inpathp = cm_Utf8ToClientStringAlloc(inpathdatap, -1, NULL);
668 osi_Log1(afsd_logp, "RDR_ParseIoctlParent UTF8 inpathp %S",
669 osi_LogSaveStringW(afsd_logp, inpathp));
673 /* Not a UTF-8 string */
674 /* TODO: If this is an OEM string, we should convert it to
676 if (smb_StoreAnsiFilenames) {
677 cch = cm_AnsiToClientString(inpathdatap, -1, NULL, 0);
681 inpathp = malloc(cch * sizeof(clientchar_t));
682 cm_AnsiToClientString(inpathdatap, -1, inpathp, cch);
684 TranslateExtendedChars(inpathdatap);
686 cch = cm_OemToClientString(inpathdatap, -1, NULL, 0);
690 inpathp = malloc(cch * sizeof(clientchar_t));
691 cm_OemToClientString(inpathdatap, -1, inpathp, cch);
693 osi_Log1(afsd_logp, "RDR_ParseIoctlParent ASCII inpathp %S",
694 osi_LogSaveStringW(afsd_logp, inpathp));
697 cm_ClientStrCpy(tbuffer, lengthof(tbuffer), inpathp);
698 tp = cm_ClientStrRChr(tbuffer, '\\');
699 jp = cm_ClientStrRChr(tbuffer, '/');
702 else if (jp && (tp - tbuffer) < (jp - tbuffer))
705 cm_ClientStrCpy(tbuffer, lengthof(tbuffer), _C("\\"));
707 cm_ClientStrCpy(leafp, LEAF_SIZE, inpathp);
712 cm_ClientStrCpy(leafp, LEAF_SIZE, tp+1);
717 inpathp = NULL; /* We don't need this from this point on */
719 if (tbuffer[0] == tbuffer[1] &&
720 tbuffer[1] == '\\' &&
721 !cm_ClientStrCmpNI(RDR_UNCName,tbuffer+2, (int)wcslen(RDR_UNCName)))
723 wchar_t shareName[256];
727 /* We may have found a UNC path.
728 * If the first component is the UNC Name,
729 * then throw out the second component (the submount)
730 * since it had better expand into the value of ioctl->tidPathp
733 p = tbuffer + 2 + cm_ClientStrLen(RDR_UNCName) + 1;
734 if ( !cm_ClientStrCmpNI(_C("all"), p, 3) )
737 for (i = 0; *p && *p != '\\'; i++,p++ ) {
740 p++; /* skip past trailing slash */
741 shareName[i] = 0; /* terminate string */
743 shareFound = smb_FindShare(NULL, NULL, shareName, &sharePath);
745 /* we found a sharename, therefore use the resulting path */
746 code = cm_NameI(cm_RootSCachep(userp, reqp), sharePath,
747 CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
748 userp, NULL, reqp, &substRootp);
751 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [1] code 0x%x", code);
754 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
755 userp, NULL, reqp, scpp);
756 cm_ReleaseSCache(substRootp);
758 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [2] code 0x%x", code);
762 /* otherwise, treat the name as a cellname mounted off the afs root.
763 * This requires that we reconstruct the shareName string with
764 * leading and trailing slashes.
766 p = tbuffer + 2 + wcslen(RDR_UNCName) + 1;
767 if ( !cm_ClientStrCmpNI(_C("all"), p, 3) )
771 for (i = 1; *p && *p != '\\'; i++,p++ ) {
774 p++; /* skip past trailing slash */
775 shareName[i++] = '/'; /* add trailing slash */
776 shareName[i] = 0; /* terminate string */
778 code = cm_NameI(cm_RootSCachep(userp, reqp), shareName,
779 CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
780 userp, NULL, reqp, &substRootp);
782 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [3] code 0x%x", code);
785 code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
786 userp, NULL, reqp, scpp);
787 cm_ReleaseSCache(substRootp);
789 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [4] code 0x%x", code);
794 code = cm_GetSCache(&ioctlp->rootFid, &substRootp, userp, reqp);
796 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [5] code 0x%x", code);
799 code = cm_NameI(substRootp, tbuffer, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
800 userp, NULL, reqp, scpp);
801 cm_ReleaseSCache(substRootp);
803 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [6] code 0x%x", code);
808 /* # of bytes of path */
809 code = (long)strlen(ioctlp->ioctl.inDatap) + 1;
810 ioctlp->ioctl.inDatap += code;
812 /* Ensure that the status object is up to date */
813 lock_ObtainWrite(&(*scpp)->rw);
814 code = cm_SyncOp( *scpp, NULL, userp, reqp, 0,
815 CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
817 cm_SyncOpDone( *scpp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
818 lock_ReleaseWrite(&(*scpp)->rw);
820 /* and return success */
821 osi_Log1(afsd_logp,"RDR_ParseIoctlParent [7] code 0x%x", code);
826 RDR_IoctlSetToken(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
833 struct ClearToken ct;
839 wchar_t *smbname = NULL;
840 wchar_t *uname = NULL;
842 int release_userp = 0;
844 saveDataPtr = ioctlp->ioctl.inDatap;
846 cm_SkipIoctlPath(&ioctlp->ioctl);
848 tp = ioctlp->ioctl.inDatap;
851 memcpy(&ticketLen, tp, sizeof(ticketLen));
852 tp += sizeof(ticketLen);
853 if (ticketLen < MINKTCTICKETLEN || ticketLen > MAXKTCTICKETLEN) {
854 code = CM_ERROR_INVAL;
858 /* remember ticket and skip over it for now */
862 /* clear token size */
863 memcpy(&ctSize, tp, sizeof(ctSize));
864 tp += sizeof(ctSize);
865 if (ctSize != sizeof(struct ClearToken)) {
866 code = CM_ERROR_INVAL;
871 memcpy(&ct, tp, ctSize);
873 if (ct.AuthHandle == -1)
874 ct.AuthHandle = 999; /* more rxvab compat stuff */
876 /* more stuff, if any */
877 if (ioctlp->ioctl.inCopied > tp - saveDataPtr) {
878 /* flags: logon flag */
879 memcpy(&flags, tp, sizeof(int));
883 cellp = cm_GetCell(tp, CM_FLAG_CREATE | CM_FLAG_NOPROBE);
885 code = CM_ERROR_NOSUCHCELL;
888 tp += strlen(tp) + 1;
891 uname = cm_ParseIoctlStringAlloc(&ioctlp->ioctl, tp);
892 tp += strlen(tp) + 1;
894 if (flags & PIOCTL_LOGON) {
895 /* SMB user name with which to associate tokens */
896 smbname = cm_ParseIoctlStringAlloc(&ioctlp->ioctl, tp);
897 tp += strlen(tp) + 1;
898 osi_Log2(afsd_logp,"RDR_IoctlSetToken for user [%S] smbname [%S]",
899 osi_LogSaveStringW(afsd_logp,uname),
900 osi_LogSaveStringW(afsd_logp,smbname));
902 osi_Log1(afsd_logp,"RDR_IoctlSetToken for user [%S]",
903 osi_LogSaveStringW(afsd_logp, uname));
907 memcpy(&uuid, tp, sizeof(uuid));
908 if (!cm_FindTokenEvent(uuid, sessionKey, NULL)) {
909 code = CM_ERROR_INVAL;
913 #if defined(NO_AUTH_GROUPS)
914 /* after obtaining the session key check whether we can use it */
915 if (!(pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
916 code = CM_ERROR_NOACCESS;
921 cellp = cm_data.rootCellp;
922 osi_Log0(afsd_logp,"cm_IoctlSetToken - no name specified");
925 #if defined(NO_AUTH_GROUPS)
926 if ((pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
928 DWORD dwSize1, dwSize2;
929 wchar_t *pszRefDomain = NULL;
930 SID_NAME_USE snu = SidTypeGroup;
931 clientchar_t * secSidString = NULL;
933 static wchar_t cname[MAX_COMPUTERNAME_LENGTH+1] = L"";
935 if ( cname[0] == '\0') {
936 int len = MAX_COMPUTERNAME_LENGTH+1;
937 GetComputerNameW(cname, &len);
942 * The input name is probably not a SID for the user which is how
943 * the user is now being identified as a result of the SMB
944 * extended authentication. See if we can obtain the SID for the
945 * specified name. If we can, use that instead of the name
949 dwSize1 = dwSize2 = 0;
950 LookupAccountNameW( NULL /* System Name to begin Search */,
955 gle = GetLastError();
956 if (gle == ERROR_INSUFFICIENT_BUFFER) {
957 pSid = LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, dwSize1);
959 * Although dwSize2 is supposed to include the terminating
960 * NUL character, on Win7 it does not.
962 pszRefDomain = malloc((dwSize2 + 1) * sizeof(wchar_t));
965 if ( pSid && pszRefDomain ) {
966 if (LookupAccountNameW( NULL /* System Name to begin Search */,
969 pszRefDomain, &dwSize2,
971 ConvertSidToStringSidW(pSid, &secSidString);
975 userp = smb_FindCMUserBySID( secSidString, cname,
976 SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
977 LocalFree(secSidString);
984 if (!ConvertStringSidToSidW( smbname, &pSid)) {
985 userp = smb_FindCMUserBySID( smbname, cname,
986 SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
988 userp = smb_FindCMUserByName( smbname, cname,
989 SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
1002 /* store the token */
1003 lock_ObtainMutex(&userp->mx);
1004 ucellp = cm_GetUCell(userp, cellp);
1005 osi_Log1(afsd_logp,"cm_IoctlSetToken ucellp %lx", ucellp);
1006 ucellp->ticketLen = ticketLen;
1007 if (ucellp->ticketp)
1008 free(ucellp->ticketp); /* Discard old token if any */
1009 ucellp->ticketp = malloc(ticketLen);
1010 memcpy(ucellp->ticketp, ticket, ticketLen);
1012 * Get the session key from the RPC, rather than from the pioctl.
1015 memcpy(&ucellp->sessionKey, ct.HandShakeKey, sizeof(ct.HandShakeKey));
1017 memcpy(ucellp->sessionKey.data, sessionKey, sizeof(sessionKey));
1018 ucellp->kvno = ct.AuthHandle;
1019 ucellp->expirationTime = ct.EndTimestamp;
1022 ucellp->uid = ANONYMOUSID;
1025 cm_ClientStringToFsString(uname, -1, ucellp->userName, MAXKTCNAMELEN);
1027 cm_UsernameToId(uname, ucellp, &ucellp->uid);
1030 ucellp->flags |= CM_UCELLFLAG_RXKAD;
1031 lock_ReleaseMutex(&userp->mx);
1033 if ((pflags & AFSCALL_FLAG_LOCAL_SYSTEM) && (flags & PIOCTL_LOGON)) {
1034 ioctlp->ioctl.flags |= CM_IOCTLFLAG_LOGON;
1037 cm_ResetACLCache(cellp, userp);
1040 SecureZeroMemory(sessionKey, sizeof(sessionKey));
1043 cm_ReleaseUser(userp);
1055 RDR_IoctlGetACL(RDR_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
1060 cm_ioctlQueryOptions_t *optionsp;
1061 afs_uint32 flags = 0;
1065 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1066 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1067 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1069 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1071 cm_SkipIoctlPath(&ioctlp->ioctl);
1072 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1073 optionsp->fid.vnode, optionsp->fid.unique);
1074 code = cm_GetSCache(&fid, &scp, userp, &req);
1076 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1081 code = cm_IoctlGetACL(&ioctlp->ioctl, userp, scp, &req);
1083 cm_ReleaseSCache(scp);
1088 RDR_IoctlSetACL(RDR_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
1094 afs_uint32 flags = 0;
1098 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1102 code = cm_IoctlSetACL(&ioctlp->ioctl, userp, scp, &req);
1104 cm_ReleaseSCache(scp);
1109 RDR_IoctlGetFileCellName(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1114 cm_ioctlQueryOptions_t *optionsp;
1115 afs_uint32 flags = 0;
1119 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1120 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1121 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1123 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1125 cm_SkipIoctlPath(&ioctlp->ioctl);
1126 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1127 optionsp->fid.vnode, optionsp->fid.unique);
1128 code = cm_GetSCache(&fid, &scp, userp, &req);
1130 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1135 code = cm_IoctlGetFileCellName(&ioctlp->ioctl, userp, scp, &req);
1137 cm_ReleaseSCache(scp);
1143 RDR_IoctlFlushAllVolumes(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1149 cm_SkipIoctlPath(&ioctlp->ioctl); /* we don't care about the path */
1151 return cm_IoctlFlushAllVolumes(&ioctlp->ioctl, userp, &req);
1155 RDR_IoctlFlushVolume(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1160 cm_ioctlQueryOptions_t *optionsp;
1161 afs_uint32 flags = 0;
1165 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1166 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1167 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1169 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1171 cm_SkipIoctlPath(&ioctlp->ioctl);
1172 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1173 optionsp->fid.vnode, optionsp->fid.unique);
1174 code = cm_GetSCache(&fid, &scp, userp, &req);
1176 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1181 code = cm_IoctlFlushVolume(&ioctlp->ioctl, userp, scp, &req);
1183 cm_ReleaseSCache(scp);
1189 RDR_IoctlFlushFile(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1194 cm_ioctlQueryOptions_t *optionsp;
1195 afs_uint32 flags = 0;
1199 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1200 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1201 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1203 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1205 cm_SkipIoctlPath(&ioctlp->ioctl);
1206 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1207 optionsp->fid.vnode, optionsp->fid.unique);
1208 code = cm_GetSCache(&fid, &scp, userp, &req);
1210 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1215 code = cm_IoctlFlushFile(&ioctlp->ioctl, userp, scp, &req);
1217 cm_ReleaseSCache(scp);
1222 RDR_IoctlSetVolumeStatus(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1230 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, 0);
1231 if (code) return code;
1233 code = cm_IoctlSetVolumeStatus(&ioctlp->ioctl, userp, scp, &req);
1234 cm_ReleaseSCache(scp);
1240 RDR_IoctlGetVolumeStatus(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1244 cm_ioctlQueryOptions_t *optionsp;
1245 afs_uint32 flags = 0;
1250 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1251 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1252 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1254 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1256 cm_SkipIoctlPath(&ioctlp->ioctl);
1257 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1258 optionsp->fid.vnode, optionsp->fid.unique);
1259 code = cm_GetSCache(&fid, &scp, userp, &req);
1261 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1266 code = cm_IoctlGetVolumeStatus(&ioctlp->ioctl, userp, scp, &req);
1268 cm_ReleaseSCache(scp);
1274 RDR_IoctlGetFid(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1279 cm_ioctlQueryOptions_t * optionsp;
1280 afs_uint32 flags = 0;
1284 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1285 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1286 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1288 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1292 code = cm_IoctlGetFid(&ioctlp->ioctl, userp, scp, &req);
1294 cm_ReleaseSCache(scp);
1300 RDR_IoctlGetFileType(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1305 cm_ioctlQueryOptions_t * optionsp;
1306 afs_uint32 flags = 0;
1310 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1311 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1312 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1314 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1316 cm_SkipIoctlPath(&ioctlp->ioctl);
1317 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1318 optionsp->fid.vnode, optionsp->fid.unique);
1319 code = cm_GetSCache(&fid, &scp, userp, &req);
1321 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1326 code = cm_IoctlGetFileType(&ioctlp->ioctl, userp, scp, &req);
1328 cm_ReleaseSCache(scp);
1334 RDR_IoctlGetOwner(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1339 cm_ioctlQueryOptions_t *optionsp;
1340 afs_uint32 flags = 0;
1344 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1345 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1346 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1348 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1350 cm_SkipIoctlPath(&ioctlp->ioctl);
1351 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1352 optionsp->fid.vnode, optionsp->fid.unique);
1353 code = cm_GetSCache(&fid, &scp, userp, &req);
1355 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1360 code = cm_IoctlGetOwner(&ioctlp->ioctl, userp, scp, &req);
1362 cm_ReleaseSCache(scp);
1368 RDR_IoctlWhereIs(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1373 cm_ioctlQueryOptions_t *optionsp;
1374 afs_uint32 flags = 0;
1378 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1379 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1380 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1382 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1384 cm_SkipIoctlPath(&ioctlp->ioctl);
1385 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1386 optionsp->fid.vnode, optionsp->fid.unique);
1387 code = cm_GetSCache(&fid, &scp, userp, &req);
1389 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1394 code = cm_IoctlWhereIs(&ioctlp->ioctl, userp, scp, &req);
1396 cm_ReleaseSCache(scp);
1403 RDR_IoctlStatMountPoint(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1411 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
1415 code = cm_IoctlStatMountPoint(&ioctlp->ioctl, userp, dscp, &req);
1417 cm_ReleaseSCache(dscp);
1423 RDR_IoctlDeleteMountPoint(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1431 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
1435 code = cm_IoctlDeleteMountPoint(&ioctlp->ioctl, userp, dscp, &req);
1437 cm_ReleaseSCache(dscp);
1443 RDR_IoctlCheckServers(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1445 cm_SkipIoctlPath(&ioctlp->ioctl); /* we don't care about the path */
1447 return cm_IoctlCheckServers(&ioctlp->ioctl, userp);
1451 RDR_IoctlGag(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1453 /* we don't print anything superfluous, so we don't support the gag call */
1454 return CM_ERROR_INVAL;
1458 RDR_IoctlCheckVolumes(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1460 cm_SkipIoctlPath(&ioctlp->ioctl);
1462 return cm_IoctlCheckVolumes(&ioctlp->ioctl, userp);
1465 afs_int32 RDR_IoctlSetCacheSize(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1467 cm_SkipIoctlPath(&ioctlp->ioctl);
1469 return cm_IoctlSetCacheSize(&ioctlp->ioctl, userp);
1474 RDR_IoctlTraceControl(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1476 cm_SkipIoctlPath(&ioctlp->ioctl);
1478 return cm_IoctlTraceControl(&ioctlp->ioctl, userp);
1482 RDR_IoctlGetCacheParms(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1484 cm_SkipIoctlPath(&ioctlp->ioctl);
1486 return cm_IoctlGetCacheParms(&ioctlp->ioctl, userp);
1490 RDR_IoctlGetCell(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1492 cm_SkipIoctlPath(&ioctlp->ioctl);
1494 return cm_IoctlGetCell(&ioctlp->ioctl, userp);
1498 RDR_IoctlNewCell(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1500 cm_SkipIoctlPath(&ioctlp->ioctl);
1502 return cm_IoctlNewCell(&ioctlp->ioctl, userp);
1506 RDR_IoctlNewCell2(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1508 cm_SkipIoctlPath(&ioctlp->ioctl);
1510 return cm_IoctlNewCell2(&ioctlp->ioctl, userp);
1514 RDR_IoctlGetWsCell(RDR_ioctl_t *ioctlp, cm_user_t *userp, afs_uint32 pflags)
1516 cm_SkipIoctlPath(&ioctlp->ioctl);
1518 return cm_IoctlGetWsCell(&ioctlp->ioctl, userp);
1522 RDR_IoctlSysName(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1524 cm_SkipIoctlPath(&ioctlp->ioctl);
1526 return cm_IoctlSysName(&ioctlp->ioctl, userp);
1530 RDR_IoctlGetCellStatus(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1532 cm_SkipIoctlPath(&ioctlp->ioctl);
1534 return cm_IoctlGetCellStatus(&ioctlp->ioctl, userp);
1538 RDR_IoctlSetCellStatus(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1540 cm_SkipIoctlPath(&ioctlp->ioctl);
1542 return cm_IoctlSetCellStatus(&ioctlp->ioctl, userp);
1546 RDR_IoctlSetSPrefs(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1548 cm_SkipIoctlPath(&ioctlp->ioctl);
1550 return cm_IoctlSetSPrefs(&ioctlp->ioctl, userp);
1554 RDR_IoctlGetSPrefs(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1556 cm_SkipIoctlPath(&ioctlp->ioctl);
1558 return cm_IoctlGetSPrefs(&ioctlp->ioctl, userp);
1562 RDR_IoctlStoreBehind(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1564 /* we ignore default asynchrony since we only have one way
1565 * of doing this today.
1571 RDR_IoctlCreateMountPoint(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1575 wchar_t leaf[LEAF_SIZE];
1580 code = RDR_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
1584 code = cm_IoctlCreateMountPoint(&ioctlp->ioctl, userp, dscp, &req, leaf);
1586 cm_ReleaseSCache(dscp);
1591 RDR_IoctlSymlink(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1595 wchar_t leaf[LEAF_SIZE];
1600 code = RDR_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
1601 if (code) return code;
1603 code = cm_IoctlSymlink(&ioctlp->ioctl, userp, dscp, &req, leaf);
1605 cm_ReleaseSCache(dscp);
1611 RDR_IoctlListlink(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1619 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
1620 if (code) return code;
1622 code = cm_IoctlListlink(&ioctlp->ioctl, userp, dscp, &req);
1624 cm_ReleaseSCache(dscp);
1629 RDR_IoctlIslink(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1630 {/*CHECK FOR VALID SYMLINK*/
1637 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
1638 if (code) return code;
1640 code = cm_IoctlIslink(&ioctlp->ioctl, userp, dscp, &req);
1642 cm_ReleaseSCache(dscp);
1648 RDR_IoctlDeletelink(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1656 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &dscp, 0);
1657 if (code) return code;
1659 code = cm_IoctlDeletelink(&ioctlp->ioctl, userp, dscp, &req);
1661 cm_ReleaseSCache(dscp);
1667 RDR_IoctlGetTokenIter(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1669 cm_SkipIoctlPath(&ioctlp->ioctl);
1671 return cm_IoctlGetTokenIter(&ioctlp->ioctl, userp);
1675 RDR_IoctlGetToken(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1677 cm_SkipIoctlPath(&ioctlp->ioctl);
1679 return cm_IoctlGetToken(&ioctlp->ioctl, userp);
1684 RDR_IoctlDelToken(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1686 cm_SkipIoctlPath(&ioctlp->ioctl);
1688 return cm_IoctlDelToken(&ioctlp->ioctl, userp);
1693 RDR_IoctlDelAllToken(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1695 cm_SkipIoctlPath(&ioctlp->ioctl);
1697 return cm_IoctlDelAllToken(&ioctlp->ioctl, userp);
1702 RDR_IoctlMakeSubmount(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1704 cm_SkipIoctlPath(&ioctlp->ioctl);
1706 return cm_IoctlMakeSubmount(&ioctlp->ioctl, userp);
1710 RDR_IoctlGetRxkcrypt(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1712 cm_SkipIoctlPath(&ioctlp->ioctl);
1714 return cm_IoctlGetRxkcrypt(&ioctlp->ioctl, userp);
1718 RDR_IoctlSetRxkcrypt(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1720 cm_SkipIoctlPath(&ioctlp->ioctl);
1722 return cm_IoctlSetRxkcrypt(&ioctlp->ioctl, userp);
1726 RDR_IoctlRxStatProcess(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1728 cm_SkipIoctlPath(&ioctlp->ioctl);
1730 return cm_IoctlRxStatProcess(&ioctlp->ioctl, userp);
1735 RDR_IoctlRxStatPeer(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1737 cm_SkipIoctlPath(&ioctlp->ioctl);
1739 return cm_IoctlRxStatPeer(&ioctlp->ioctl, userp);
1743 RDR_IoctlUnicodeControl(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1745 cm_SkipIoctlPath(&ioctlp->ioctl);
1747 return cm_IoctlUnicodeControl(&ioctlp->ioctl, userp);
1751 RDR_IoctlUUIDControl(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1753 cm_SkipIoctlPath(&ioctlp->ioctl);
1755 return cm_IoctlUUIDControl(&ioctlp->ioctl, userp);
1760 RDR_IoctlMemoryDump(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1762 cm_SkipIoctlPath(&ioctlp->ioctl);
1764 return cm_IoctlMemoryDump(&ioctlp->ioctl, userp);
1768 RDR_IoctlPathAvailability(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1773 cm_ioctlQueryOptions_t *optionsp;
1774 afs_uint32 flags = 0;
1778 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1779 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1780 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1782 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1784 cm_SkipIoctlPath(&ioctlp->ioctl);
1785 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1786 optionsp->fid.vnode, optionsp->fid.unique);
1787 code = cm_GetSCache(&fid, &scp, userp, &req);
1789 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1794 code = cm_IoctlPathAvailability(&ioctlp->ioctl, userp, scp, &req);
1795 cm_ReleaseSCache(scp);
1800 RDR_IoctlVolStatTest(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1806 cm_SkipIoctlPath(&ioctlp->ioctl);
1808 return cm_IoctlVolStatTest(&ioctlp->ioctl, userp, &req);
1814 * This pioctl requires the use of the cm_ioctlQueryOptions_t structure.
1818 RDR_IoctlSetOwner(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1823 cm_ioctlQueryOptions_t *optionsp;
1824 afs_uint32 flags = 0;
1828 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1830 if (CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1831 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1833 if (CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1835 cm_SkipIoctlPath(&ioctlp->ioctl);
1836 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1837 optionsp->fid.vnode, optionsp->fid.unique);
1838 code = cm_GetSCache(&fid, &scp, userp, &req);
1840 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1845 cm_IoctlSkipQueryOptions(&ioctlp->ioctl, userp);
1848 code = cm_IoctlSetOwner(&ioctlp->ioctl, userp, scp, &req);
1850 cm_ReleaseSCache(scp);
1858 * This pioctl requires the use of the cm_ioctlQueryOptions_t structure.
1862 RDR_IoctlSetGroup(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1867 cm_ioctlQueryOptions_t *optionsp;
1868 afs_uint32 flags = 0;
1872 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1874 if (CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1875 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1877 if (CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1879 cm_SkipIoctlPath(&ioctlp->ioctl);
1880 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1881 optionsp->fid.vnode, optionsp->fid.unique);
1882 code = cm_GetSCache(&fid, &scp, userp, &req);
1884 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1889 cm_IoctlSkipQueryOptions(&ioctlp->ioctl, userp);
1892 code = cm_IoctlSetGroup(&ioctlp->ioctl, userp, scp, &req);
1894 cm_ReleaseSCache(scp);
1900 RDR_IoctlGetUnixMode(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1905 cm_ioctlQueryOptions_t *optionsp;
1906 afs_uint32 flags = 0;
1910 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1911 if (optionsp && CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1912 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1914 if (optionsp && CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1916 cm_SkipIoctlPath(&ioctlp->ioctl);
1917 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1918 optionsp->fid.vnode, optionsp->fid.unique);
1919 code = cm_GetSCache(&fid, &scp, userp, &req);
1921 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1926 code = cm_IoctlGetUnixMode(&ioctlp->ioctl, userp, scp, &req);
1928 cm_ReleaseSCache(scp);
1936 * This pioctl requires the use of the cm_ioctlQueryOptions_t structure.
1940 RDR_IoctlSetUnixMode(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1945 cm_ioctlQueryOptions_t *optionsp;
1946 afs_uint32 flags = 0;
1950 optionsp = cm_IoctlGetQueryOptions(&ioctlp->ioctl, userp);
1952 if (CM_IOCTL_QOPTS_HAVE_LITERAL(optionsp))
1953 flags |= (optionsp->literal ? CM_PARSE_FLAG_LITERAL : 0);
1955 if (CM_IOCTL_QOPTS_HAVE_FID(optionsp)) {
1957 cm_SkipIoctlPath(&ioctlp->ioctl);
1958 cm_SetFid(&fid, optionsp->fid.cell, optionsp->fid.volume,
1959 optionsp->fid.vnode, optionsp->fid.unique);
1960 code = cm_GetSCache(&fid, &scp, userp, &req);
1962 code = RDR_ParseIoctlPath(ioctlp, userp, &req, &scp, flags);
1967 cm_IoctlSkipQueryOptions(&ioctlp->ioctl, userp);
1970 code = cm_IoctlSetUnixMode(&ioctlp->ioctl, userp, scp, &req);
1972 cm_ReleaseSCache(scp);
1978 RDR_IoctlGetVerifyData(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1980 cm_SkipIoctlPath(&ioctlp->ioctl);
1982 return cm_IoctlGetVerifyData(&ioctlp->ioctl);
1986 RDR_IoctlSetVerifyData(struct RDR_ioctl *ioctlp, struct cm_user *userp, afs_uint32 pflags)
1988 cm_SkipIoctlPath(&ioctlp->ioctl);
1990 return cm_IoctlSetVerifyData(&ioctlp->ioctl);