From 5c563c121e853a06bb47d0b8932276982e676150 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 27 Jun 2006 23:18:29 +0000 Subject: [PATCH] windows-fs-uuid-20060627 fs uuid [-generate] --- src/WINNT/afsd/cm_ioctl.c | 18 +++++++++++++ src/WINNT/afsd/cm_ioctl.h | 3 +++ src/WINNT/afsd/fs.c | 53 +++++++++++++++++++++++++++++++++++++ src/WINNT/afsd/smb_iocons.h | 1 + src/WINNT/afsd/smb_ioctl.c | 1 + 5 files changed, 76 insertions(+) diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index f8ee369e5..2906bc00a 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -2647,6 +2647,24 @@ long cm_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp) return 0; } +long cm_IoctlUUIDControl(struct smb_ioctl * ioctlp, struct cm_user *userp) +{ + long cmd; + afsUUID uuid; + + memcpy(&cmd, ioctlp->inDatap, sizeof(long)); + + if (cmd) { /* generate a new UUID */ + UuidCreate((UUID *) &uuid); + cm_data.Uuid = uuid; + } + + memcpy(ioctlp->outDatap, &cm_data.Uuid, sizeof(cm_data.Uuid)); + ioctlp->outDatap += sizeof(cm_data.Uuid); + + return 0; +} + /* * functions to dump contents of various structures. * In debug build (linked with crt debug library) will dump allocated but not freed memory diff --git a/src/WINNT/afsd/cm_ioctl.h b/src/WINNT/afsd/cm_ioctl.h index 246a78834..6753cb334 100644 --- a/src/WINNT/afsd/cm_ioctl.h +++ b/src/WINNT/afsd/cm_ioctl.h @@ -161,6 +161,9 @@ extern long cm_IoctlMemoryDump(smb_ioctl_t *ioctlp, cm_user_t *userp); extern long cm_IoctlRxStatProcess(smb_ioctl_t *ioctlp, cm_user_t *userp); extern long cm_IoctlRxStatPeer(smb_ioctl_t *ioctlp, cm_user_t *userp); + +extern long cm_IoctlUUIDControl(struct smb_ioctl * ioctlp, struct cm_user *userp); + #endif /* __CM_IOCTL_INTERFACES_ONLY__ */ #endif /* __CM_IOCTL_H_ENV__ */ diff --git a/src/WINNT/afsd/fs.c b/src/WINNT/afsd/fs.c index 7b000bf24..ed5db81b3 100644 --- a/src/WINNT/afsd/fs.c +++ b/src/WINNT/afsd/fs.c @@ -3532,6 +3532,56 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock) } #endif /* WIN32 */ +static int +UuidCmd(struct cmd_syndesc *asp, char *arock) +{ + long code; + long inValue; + afsUUID outValue; + struct ViceIoctl blob; + char * uuidstring = NULL; + +#ifdef WIN32 + if ( !IsAdmin() ) { + fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n"); + return EACCES; + } +#else + if (geteuid()) { + fprintf (stderr, "Permission denied: requires root access.\n"); + return EACCES; + } +#endif + + if (asp->parms[0].items) { + inValue = 1; /* generate new UUID */ + } else { + inValue = 0; /* just show the current UUID */ + } + + blob.in_size = sizeof(inValue); + blob.in = (char *) &inValue; + blob.out_size = sizeof(outValue); + blob.out = (char *) &outValue; + + code = pioctl(NULL, VIOC_UUIDCTL, &blob, 1); + if (code) { + Die(errno, NULL); + return code; + } + + UuidToString((UUID *) &outValue, &uuidstring); + + printf("%sUUID: %s", + ((inValue == 1)?"New ":""), + uuidstring); + + if (uuidstring) + RpcStringFree(&uuidstring); + + return 0; +} + static int TraceCmd(struct cmd_syndesc *asp, char *arock) { @@ -4543,6 +4593,9 @@ main(int argc, char **argv) cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL, "dump log contents"); cmd_CreateAlias(ts, "tr"); + ts = cmd_CreateSyntax("uuid", UuidCmd, 0, "manage the UUID for the cache manager"); + cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_OPTIONAL, "generate a new UUID"); + ts = cmd_CreateSyntax("memdump", MemDumpCmd, 0, "dump memory allocs in debug builds"); cmd_AddParm(ts, "-begin", CMD_FLAG, CMD_OPTIONAL, "set a memory checkpoint"); cmd_AddParm(ts, "-end", CMD_FLAG, CMD_OPTIONAL, "dump memory allocs"); diff --git a/src/WINNT/afsd/smb_iocons.h b/src/WINNT/afsd/smb_iocons.h index 585bdc862..be34f81d7 100644 --- a/src/WINNT/afsd/smb_iocons.h +++ b/src/WINNT/afsd/smb_iocons.h @@ -96,4 +96,5 @@ typedef struct cm_cacheParms { #define VIOCGETOWNER 0x2d #define VIOC_RXSTAT_PROC 0x2e #define VIOC_RXSTAT_PEER 0x2f +#define VIOC_UUIDCTL 0x30 #endif /* __SMB_IOCONS_H_ENV_ */ diff --git a/src/WINNT/afsd/smb_ioctl.c b/src/WINNT/afsd/smb_ioctl.c index 70f4b284f..3961dc0ac 100644 --- a/src/WINNT/afsd/smb_ioctl.c +++ b/src/WINNT/afsd/smb_ioctl.c @@ -83,6 +83,7 @@ void smb_InitIoctl(void) smb_ioctlProcsp[VIOCGETOWNER] = cm_IoctlGetOwner; smb_ioctlProcsp[VIOC_RXSTAT_PROC] = cm_IoctlRxStatProcess; smb_ioctlProcsp[VIOC_RXSTAT_PEER] = cm_IoctlRxStatPeer; + smb_ioctlProcsp[VIOC_UUIDCTL] = cm_IoctlUUIDControl; } /* called to make a fid structure into an IOCTL fid structure */ -- 2.39.5