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
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <afs/com_err.h>
28 #include <afs/afs_assert.h>
29 #include <rx/rx_globals.h>
33 #include <afs/afs_consts.h>
34 #include <afs/cellconfig.h>
35 #include <afs/ptserver.h>
36 #include <afs/ptuser.h>
37 #include <afs/volser.h>
38 #include <WINNT\afsreg.h>
46 #include "parsemode.h"
48 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
49 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
50 #define CELL_MAXNAMELEN 256
51 #define MAXHOSTCHARS 64
53 static char pn[] = "fs";
55 static char space[AFS_PIOCTL_MAXSIZE];
57 static struct ubik_client *uclient;
59 /* some forward references */
60 static int SetVolCmd(struct cmd_syndesc *as, void *arock);
62 static int GetCellName(char *cellNamep, struct afsconf_cell *infop);
63 static afs_int32 GetCell(char *fname, char *cellname, size_t cell_len);
65 static int VLDBInit(int noAuthFlag, struct afsconf_cell *infop);
66 static int GetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
67 static int SetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
68 static int FlushMountCmd(struct cmd_syndesc *asp, void *arock);
69 static int RxStatProcCmd(struct cmd_syndesc *asp, void *arock);
70 static int RxStatPeerCmd(struct cmd_syndesc *asp, void *arock);
72 static int MemDumpCmd(struct cmd_syndesc *asp, void *arock);
73 static int CSCPolicyCmd(struct cmd_syndesc *asp, void *arock);
74 static int MiniDumpCmd(struct cmd_syndesc *asp, void *arock);
76 static int rxInitDone = 0;
79 * Offset of -id switch in command structure for various commands.
80 * The -if switch is the next switch always.
82 static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
85 * Determine whether either the -id or -if switches are present, and
86 * return 0, 1 or 2, as appropriate. Abort if both switches are present.
88 /* int id; Offset of -id switch; -if is next switch */
90 getidf(struct cmd_syndesc *as, int id)
94 if (as->parms[id].items) {
97 if (as->parms[id + 1].items) {
102 "%s: you may specify either -id or -if, but not both switches\n",
110 PRights(afs_int32 arights, int dfs)
113 if (arights & PRSFS_READ)
115 if (arights & PRSFS_LOOKUP)
117 if (arights & PRSFS_INSERT)
119 if (arights & PRSFS_DELETE)
121 if (arights & PRSFS_WRITE)
123 if (arights & PRSFS_LOCK)
125 if (arights & PRSFS_ADMINISTER)
127 if (arights & PRSFS_USR0)
129 if (arights & PRSFS_USR1)
131 if (arights & PRSFS_USR2)
133 if (arights & PRSFS_USR3)
135 if (arights & PRSFS_USR4)
137 if (arights & PRSFS_USR5)
139 if (arights & PRSFS_USR6)
141 if (arights & PRSFS_USR7)
144 if (arights & DFS_READ)
148 if (arights & DFS_WRITE)
152 if (arights & DFS_EXECUTE)
156 if (arights & DFS_CONTROL)
160 if (arights & DFS_INSERT)
164 if (arights & DFS_DELETE)
168 if (arights & (DFS_USRALL))
170 if (arights & DFS_USR0)
172 if (arights & DFS_USR1)
174 if (arights & DFS_USR2)
176 if (arights & DFS_USR3)
178 if (arights & DFS_USR4)
180 if (arights & DFS_USR5)
182 if (arights & DFS_USR6)
184 if (arights & DFS_USR7)
191 Convert(char *arights, int dfs, enum rtype *rtypep)
197 *rtypep = add; /* add rights, by default */
199 /* analyze last character of string */
200 tcp = arights + strlen(arights);
201 if ( tcp-- > arights ) { /* assure non-empty string */
203 *rtypep = reladd; /* '+' indicates more rights */
204 else if ( *tcp == '-' )
205 *rtypep = reldel; /* '-' indicates less rights */
206 else if ( *tcp == '=' )
207 *rtypep = add; /* '=' also allows old behaviour */
209 tcp++; /* back to original null byte */
210 *tcp = '\0'; /* do not disturb old strcmp-s */
214 if (!strcmp(arights, "null")) {
218 if (!strcmp(arights,"read"))
219 return DFS_READ | DFS_EXECUTE;
220 if (!strcmp(arights, "write"))
221 return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE |
223 if (!strcmp(arights, "all"))
224 return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE |
225 DFS_WRITE | DFS_CONTROL;
227 if (!strcmp(arights,"read"))
228 return PRSFS_READ | PRSFS_LOOKUP;
229 if (!strcmp(arights, "write"))
230 return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
231 PRSFS_WRITE | PRSFS_LOCK;
232 if (!strcmp(arights, "mail"))
233 return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
234 if (!strcmp(arights, "all"))
235 return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
236 PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
238 if (!strcmp(arights, "none")) {
239 *rtypep = destroy; /* Remove entire entry */
244 while ((tc = *tcp++)) {
277 fprintf(stderr, "%s: illegal DFS rights character '%c'.\n",
285 mode |= PRSFS_LOOKUP;
287 mode |= PRSFS_INSERT;
289 mode |= PRSFS_DELETE;
295 mode |= PRSFS_ADMINISTER;
313 fprintf(stderr, "%s: illegal rights character '%c'.\n", pn,
322 /* if no parm specified in a particular slot, set parm to be "." instead */
324 SetDotDefault(struct cmd_item **aitemp)
330 return; /* already has value */
331 /* otherwise, allocate an item representing "." */
332 ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
334 ti->next = (struct cmd_item *) 0;
335 ti->data = (char *) malloc(len_data);
337 if( FAILED(StringCbCopy(ti->data, len_data, "."))) {
338 fprintf (stderr, "data - not enough space");
345 PrintStatus(VolumeStatus *status, char *name, char *motd, char *offmsg)
347 printf("Volume status for vid = %u named %s is\n",status->Vid, name);
349 printf("Current offline message is %s\n",offmsg);
351 printf("Current message of the day is %s\n",motd);
352 printf("Current disk quota is ");
353 if (status->MaxQuota != 0)
354 printf("%d\n", status->MaxQuota);
356 printf("unlimited\n");
357 printf("Current blocks used are %d\n",status->BlocksInUse);
358 printf("The partition has %d blocks available out of %d\n",
359 status->PartBlocksAvail, status->PartMaxBlocks);
364 QuickPrintStatus(VolumeStatus *status, char *name)
366 double QuotaUsed =0.0;
367 double PartUsed =0.0;
369 printf("%-25.25s",name);
371 if (status->MaxQuota != 0) {
372 printf(" %10d %10d", status->MaxQuota, status->BlocksInUse);
373 QuotaUsed = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
375 printf(" no limit %10d", status->BlocksInUse);
377 if (QuotaUsed > 90.0){
378 printf(" %5.0f%%<<", QuotaUsed);
381 printf(" %5.0f%% ", QuotaUsed);
382 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
383 if (PartUsed > 97.0){
384 printf(" %9.0f%%<<", PartUsed);
387 printf(" %9.0f%% ", PartUsed);
389 printf(" <<WARNING\n");
396 QuickPrintSpace(VolumeStatus *status, char *name)
398 double PartUsed =0.0;
400 printf("%-25.25s",name);
402 printf("%10d%10d%10d", status->PartMaxBlocks, status->PartMaxBlocks - status->PartBlocksAvail, status->PartBlocksAvail);
404 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
405 if (PartUsed > 90.0){
406 printf(" %4.0f%%<<", PartUsed);
409 printf(" %4.0f%% ", PartUsed);
411 printf(" <<WARNING\n");
417 static DWORD IsFreelance(void)
424 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
425 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey);
426 if (code == ERROR_SUCCESS) {
427 dummyLen = sizeof(cm_freelanceEnabled);
428 code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
429 (BYTE *) &enabled, &dummyLen);
430 RegCloseKey (parmKey);
436 SetACLCmd(struct cmd_syndesc *as, void *arock)
439 struct ViceIoctl blob;
441 struct cmd_item *ti, *ui;
445 int idf = getidf(as, parm_setacl_id);
448 char cell[CELL_MAXNAMELEN];
450 if (as->parms[2].items)
454 plusp = !(as->parms[3].items);
455 for(ti=as->parms[0].items; ti;ti=ti->next) {
456 code = GetCell(ti->data, cell, sizeof(cell));
458 fs_Die(errno, ti->data);
463 if ( fs_IsFreelanceRoot(ti->data) ) {
464 fprintf(stderr,"%s: ACLs cannot be set on the Freelance root.afs volume.\n", pn);
468 blob.out_size = AFS_PIOCTL_MAXSIZE;
470 blob.in = blob.out = space;
471 code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
473 fs_Die(errno, ti->data);
479 ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
482 "fs: %s: invalid acl data returned from VIOCGETAL\n",
487 if (!plusp && ta->dfs) {
489 "fs: %s: you may not use the -negative switch with DFS acl's.\n%s",
491 "(you may specify \"null\" to revoke all rights, however)\n");
498 ta = EmptyAcl(space);
500 ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
503 "fs: %s: invalid acl data returned from VIOCGETAL\n",
509 for(ui=as->parms[1].items; ui; ui=ui->next->next) {
513 "%s: Missing second half of user/access pair.\n", pn);
517 rights = Convert(ui->next->data, ta->dfs, &rtype);
518 if (rtype == destroy && !ta->dfs) {
519 struct AclEntry *tlist;
521 tlist = (plusp ? ta->pluslist : ta->minuslist);
522 if (!FindList(tlist, ui->data))
525 if (rtype == deny && !ta->dfs)
527 if (rtype == destroy && ta->dfs)
529 ChangeList(ta, plusp, ui->data, rights, &rtype);
531 blob.in = AclToString(ta);
533 if( FAILED(StringCbLength(blob.in, sizeof(space), &len))) {
534 fprintf (stderr, "StringCbLength failure on blob.in");
537 blob.in_size = 1+(long)len;
538 code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
540 if (errno == EINVAL) {
542 static char *fsenv = 0;
544 fsenv = (char *)getenv("FS_EXPERT");
546 fprintf(stderr, "fs: \"Invalid argument\" was returned when you tried to store a DFS access list.\n");
549 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
550 "\nPossible reasons for this include:\n\n",
551 " -You may have specified an inappropriate combination of rights.\n",
552 " For example, some DFS-supported filesystems may not allow you to\n",
553 " drop the \"c\" right from \"user_obj\".\n\n",
554 " -A mask_obj may be required (it is likely required by the underlying\n",
555 " filesystem if you try to set anything other than the basic \"user_obj\"\n",
556 " \"mask_obj\", or \"group_obj\" entries). Unlike acl_edit, the fs command\n",
557 " does not automatically create or update the mask_obj. Try setting\n",
558 " the rights \"mask_obj all\" with \"fs sa\" before adding any explicit\n",
559 " users or groups. You can do this with a single command, such as\n",
560 " \"fs sa mask_obj all user:somename read\"\n\n",
561 " -A specified user or group may not exist.\n\n",
562 " -You may have tried to delete \"user_obj\", \"group_obj\", or \"other_obj\".\n",
563 " This is probably not allowed by the underlying file system.\n\n",
564 " -If you add a user or group to a DFS ACL, remember that it must be\n",
565 " fully specified as \"user:username\" or \"group:groupname\". In addition, there\n",
566 " may be local requirements on the format of the user or group name.\n",
567 " Check with your cell administrator.\n\n",
568 " -Or numerous other possibilities. It would be great if we could be more\n",
569 " precise about the actual problem, but for various reasons, this is\n",
570 " impractical via this interface. If you can't figure it out, you\n",
571 " might try logging into a DCE-equipped machine and use acl_edit (or\n",
572 " whatever is provided). You may get better results. Good luck!\n\n",
573 " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
577 "%s: Invalid argument, possible reasons include:\n",
579 fprintf(stderr,"\t-File not in AFS\n");
581 "\t-Too many users on access control list\n");
583 "\t-Tried to add non-existent user to access control list\n");
586 fs_Die(errno, ti->data);
597 CopyACLCmd(struct cmd_syndesc *as, void *arock)
600 struct ViceIoctl blob;
601 struct Acl *fa, *ta = 0;
605 int idf = getidf(as, parm_copyacl_id);
608 char cell[CELL_MAXNAMELEN];
610 if (as->parms[2].items)
614 blob.out_size = AFS_PIOCTL_MAXSIZE;
616 blob.in = blob.out = space;
617 code = pioctl_utf8(as->parms[0].items->data, VIOCGETAL, &blob, 1);
619 fs_Die(errno, as->parms[0].items->data);
622 fa = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
625 "%s: %s: invalid acl data returned from VIOCGETAL\n",
626 pn, as->parms[0].items->data);
629 code = GetCell(as->parms[0].items->data, cell, sizeof(cell));
632 "%s: %s: unable to obtain cell name\n",
633 pn, as->parms[0].items->data);
637 for (ti=as->parms[1].items; ti;ti=ti->next) {
638 blob.out_size = AFS_PIOCTL_MAXSIZE;
640 blob.in = blob.out = space;
641 code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
643 fs_Die(errno, ti->data);
650 ta = EmptyAcl(space);
652 ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
655 "%s: %s: invalid acl data returned from VIOCGETAL\n",
660 code = GetCell(ti->data, cell, sizeof(cell));
663 "%s: %s: unable to obtain cell name\n",
669 if (ta->dfs != fa->dfs) {
671 "%s: incompatible file system types: acl not copied to %s; aborted\n",
677 if (! clear && strcmp(ta->cell, fa->cell) != 0) {
679 "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n",
684 if( FAILED(StringCbCopy(ta->cell, sizeof(ta->cell), fa->cell))) {
685 fprintf (stderr, "cell - not enough space");
689 for (tp = fa->pluslist;tp;tp=tp->next)
690 ChangeList(ta, 1, tp->name, tp->rights, NULL);
691 for (tp = fa->minuslist;tp;tp=tp->next)
692 ChangeList(ta, 0, tp->name, tp->rights, NULL);
693 blob.in = AclToString(ta);
695 if( FAILED(StringCbLength(blob.in, sizeof(space), &len))) {
696 fprintf (stderr, "StringCbLength failure on blob.in");
699 blob.in_size = 1+(long)len;
700 code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
702 if (errno == EINVAL) {
704 "%s: Invalid argument, possible reasons include:\n", pn);
705 fprintf(stderr,"\t-File not in AFS\n");
707 fs_Die(errno, ti->data);
718 /* pioctl_utf8() call to get the cellname of a pathname */
720 GetCell(char *fname, char *cellname, size_t cell_len)
723 struct ViceIoctl blob;
726 blob.out_size = cell_len;
729 code = pioctl_utf8(fname, VIOC_FILE_CELL_NAME, &blob, 1);
731 cellname[blob.out_size - 1] = '\0';
735 /* clean up an acl to not have bogus entries */
737 CleanACLCmd(struct cmd_syndesc *as, void *arock)
741 struct ViceIoctl blob;
747 char cell[CELL_MAXNAMELEN];
749 SetDotDefault(&as->parms[0].items);
750 for(ti=as->parms[0].items; ti; ti=ti->next) {
751 blob.out_size = AFS_PIOCTL_MAXSIZE;
754 code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
756 fs_Die(errno, ti->data);
762 ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
765 "fs: %s: invalid acl data returned from VIOCGETAL\n",
772 "%s: cleanacl is not supported for DFS access lists.\n",
778 changes = CleanAcl(ta, ti->data);
781 /* now set the acl */
782 blob.in=AclToString(ta);
783 if( FAILED(StringCbLength(blob.in, sizeof(space), &len))) {
784 fprintf (stderr, "StringCbLength failure on blob.in");
787 blob.in_size = (long)len+1;
789 code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
791 if (errno == EINVAL) {
793 "%s: Invalid argument, possible reasons include\n",
795 fprintf(stderr,"%s: File not in vice or\n", pn);
797 "%s: Too many users on access control list or\n",
800 fs_Die(errno, ti->data);
806 /* now list the updated acl */
807 printf("Access list for %s is now\n", ti->data);
810 printf("Normal rights:\n");
811 for(te = ta->pluslist;te;te=te->next) {
812 printf(" %s ", te->name);
813 PRights(te->rights, ta->dfs);
817 if (ta->nminus > 0) {
818 printf("Negative rights:\n");
819 for(te = ta->minuslist;te;te=te->next) {
820 printf(" %s ", te->name);
821 PRights(te->rights, ta->dfs);
828 printf("Access list for %s is fine.\n", ti->data);
836 ListACLCmd(struct cmd_syndesc *as, void *arock)
840 struct ViceIoctl blob;
843 int idf = getidf(as, parm_listacl_id);
846 SetDotDefault(&as->parms[0].items);
847 for(ti=as->parms[0].items; ti; ti=ti->next) {
850 if ( fs_IsFreelanceRoot(ti->data) ) {
851 fprintf(stderr,"%s: ACLs are not set on the Freelance root.afs volume.\n", pn);
856 blob.out_size = AFS_PIOCTL_MAXSIZE;
858 blob.in = blob.out = space;
859 code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
861 fs_Die(errno, ti->data);
865 ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
868 "fs: %s: invalid acl data returned from VIOCGETAL\n",
873 if (as->parms[3].items) { /* -cmd */
874 printf("fs setacl -dir %s -acl ", ti->data);
876 for (te = ta->pluslist; te; te = te->next) {
877 printf(" %s ", te->name);
878 PRights(te->rights, ta->dfs);
882 if (ta->nminus > 0) {
883 printf("fs setacl -dir %s -acl ", ti->data);
884 for (te = ta->minuslist; te; te = te->next) {
885 printf(" %s ", te->name);
886 PRights(te->rights, ta->dfs);
888 printf(" -negative\n");
893 printf("Access list for %s is\n", ti->data);
896 printf("DFS access list for %s is\n", ti->data);
899 printf("DFS initial directory access list of %s is\n", ti->data);
902 printf("DFS initial file access list of %s is\n", ti->data);
906 printf(" Default cell = %s\n", ta->cell);
908 separator = ta->dfs? DFS_SEPARATOR : ' ';
911 printf("Normal rights:\n");
912 for(te = ta->pluslist;te;te=te->next) {
913 printf(" %s%c", te->name, separator);
914 PRights(te->rights, ta->dfs);
918 if (ta->nminus > 0) {
919 printf("Negative rights:\n");
920 for(te = ta->minuslist;te;te=te->next) {
921 printf(" %s ", te->name);
922 PRights(te->rights, ta->dfs);
935 FlushAllCmd(struct cmd_syndesc *as, void *arock)
938 struct ViceIoctl blob;
940 blob.in_size = blob.out_size = 0;
941 code = pioctl_utf8(NULL, VIOC_FLUSHALL, &blob, 0);
943 fprintf(stderr, "Error flushing all ");
950 FlushVolumeCmd(struct cmd_syndesc *as, void *arock)
953 struct ViceIoctl blob;
957 SetDotDefault(&as->parms[0].items);
958 for(ti=as->parms[0].items; ti; ti=ti->next) {
959 blob.in_size = blob.out_size = 0;
960 code = pioctl_utf8(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
962 fprintf(stderr, "Error flushing volume ");
972 FlushCmd(struct cmd_syndesc *as, void *arock)
975 struct ViceIoctl blob;
979 cm_ioctlQueryOptions_t options;
981 if (as->parms[1].items)
984 for(ti=as->parms[0].items; ti; ti=ti->next) {
986 memset(&options, 0, sizeof(options));
987 options.size = sizeof(options);
988 options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
989 options.literal = literal;
990 blob.in_size = options.size; /* no variable length data */
994 code = pioctl_utf8(ti->data, VIOCFLUSH, &blob, 0);
996 if (errno == EMFILE) {
997 fprintf(stderr, "%s: Can't flush active file %s\n", pn,
1000 fprintf(stderr, "%s: Error flushing file ", pn);
1010 /* all this command does is repackage its args and call SetVolCmd */
1012 SetQuotaCmd(struct cmd_syndesc *as, void *arock) {
1013 struct cmd_syndesc ts;
1015 /* copy useful stuff from our command slot; we may later have to reorder */
1017 memcpy(&ts, as, sizeof(ts)); /* copy whole thing */
1019 err = memcpy_s(&ts, sizeof(ts), as, sizeof(ts)); /* copy whole thing */
1021 fprintf (stderr, "memcpy_s failure on ts");
1025 return SetVolCmd(&ts, arock);
1029 SetVolCmd(struct cmd_syndesc *as, void *arock) {
1031 struct ViceIoctl blob;
1032 struct cmd_item *ti;
1033 struct VolumeStatus *status;
1034 char *motd, *offmsg, *input, *destEnd;
1035 size_t destRemaining;
1039 SetDotDefault(&as->parms[0].items);
1040 for(ti=as->parms[0].items; ti; ti=ti->next) {
1042 destRemaining = sizeof(space);
1043 blob.out_size = AFS_PIOCTL_MAXSIZE;
1044 blob.in_size = sizeof(*status) + 3; /* for the three terminating nulls */
1047 status = (VolumeStatus *)space;
1048 status->MinQuota = status->MaxQuota = -1;
1049 motd = offmsg = NULL;
1050 if (as->parms[1].items) {
1051 code = util_GetHumanInt32(as->parms[1].items->data, &status->MaxQuota);
1053 fprintf(stderr,"%s: bad integer specified for quota.\n", pn);
1058 if (as->parms[2].items)
1059 motd = as->parms[2].items->data;
1060 if (as->parms[3].items)
1061 offmsg = as->parms[3].items->data;
1062 input = (char *)status + sizeof(*status);
1063 *(input++) = '\0'; /* never set name: this call doesn't change vldb */
1064 destRemaining -= sizeof(*status) + 1;
1066 if( FAILED(StringCbLength(offmsg, VMSGSIZE, &len))) {
1067 fprintf(stderr,"%s: message must be shorter than %d characters\n",
1072 if( FAILED(StringCbCopyEx(input, destRemaining, offmsg, &destEnd, &destRemaining, STRSAFE_FILL_ON_FAILURE))) {
1073 fprintf (stderr, "input - not enough space");
1076 blob.in_size += destEnd - input;
1077 input = destEnd + 1;
1078 destRemaining -= sizeof(char);
1081 destRemaining -= sizeof(char);
1084 if( FAILED(StringCbLength(motd, VMSGSIZE, &len))) {
1085 fprintf(stderr,"%s: message must be shorter than %d characters\n",
1089 if( FAILED(StringCbCopyEx(input, destRemaining, motd, &destEnd, &destRemaining, STRSAFE_FILL_ON_FAILURE))) {
1090 fprintf (stderr, "input - not enough space");
1093 blob.in_size += (long)(destEnd - input);
1094 input = destEnd + 1;
1095 destRemaining -= sizeof(char);
1098 destRemaining -= sizeof(char);
1100 code = pioctl_utf8(ti->data,VIOCSETVOLSTAT, &blob, 1);
1102 fs_Die(errno, ti->data);
1110 ExamineCmd(struct cmd_syndesc *as, void *arock)
1113 struct ViceIoctl blob;
1114 struct cmd_item *ti;
1115 struct VolumeStatus *status;
1116 char *name, *offmsg, *motd;
1119 cm_ioctlQueryOptions_t options;
1122 if (as->parms[1].items)
1125 SetDotDefault(&as->parms[0].items);
1126 for(ti=as->parms[0].items; ti; ti=ti->next) {
1128 afs_uint32 filetype;
1130 afs_uint32 unixModeBits;
1131 char cell[CELL_MAXNAMELEN];
1134 memset(&fid, 0, sizeof(fid));
1135 memset(&options, 0, sizeof(options));
1137 options.size = sizeof(options);
1138 options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
1139 options.literal = literal;
1140 blob.in_size = options.size; /* no variable length data */
1143 blob.out_size = sizeof(cm_fid_t);
1144 blob.out = (char *) &fid;
1145 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
1146 blob.out_size == sizeof(cm_fid_t)) {
1147 options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
1150 fs_Die(errno, ti->data);
1155 blob.out_size = sizeof(filetype);
1156 blob.out = &filetype;
1158 code = pioctl_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
1159 if (code || blob.out_size != sizeof(filetype)) {
1160 fs_Die(errno, ti->data);
1165 blob.out_size = CELL_MAXNAMELEN;
1168 code = pioctl_utf8(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
1170 cell[blob.out_size-1] = '\0';
1171 printf("%s %s (%u.%u.%u) contained in cell %s\n",
1172 fs_filetypestr(filetype),
1173 ti->data, fid.volume, fid.vnode, fid.unique,
1174 code ? "unknown-cell" : cell);
1176 blob.out_size = 2 * sizeof(afs_uint32);
1177 blob.out = (char *) &owner;
1178 if (0 == pioctl_utf8(ti->data, VIOCGETOWNER, &blob, 1) &&
1179 blob.out_size == 2 * sizeof(afs_uint32)) {
1180 char oname[PR_MAXNAMELEN] = "(unknown)";
1181 char gname[PR_MAXNAMELEN] = "(unknown)";
1184 /* Go to the PRDB and see if this all number username is valid */
1185 cm_GetConfigDir(confDir, sizeof(confDir));
1187 pr_Initialize(1, confDir, cell);
1188 pr_SIdToName(owner[0], oname);
1189 pr_SIdToName(owner[1], gname);
1190 printf("Owner %s (%d) Group %s (%d)\n", oname, owner[0], gname, owner[1]);
1193 blob.out_size = sizeof(afs_uint32);
1194 blob.out = (char *) &unixModeBits;
1195 if (0 == pioctl_utf8(ti->data, VIOC_GETUNIXMODE, &blob, 1) &&
1196 blob.out_size == sizeof(afs_uint32)) {
1197 printf("UNIX mode 0%o\n", unixModeBits);
1201 blob.out_size = AFS_PIOCTL_MAXSIZE;
1202 code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
1204 space[blob.out_size - 1] = '\0';
1205 status = (VolumeStatus *)space;
1206 name = (char *)status + sizeof(*status);
1207 if( FAILED(StringCbLength(name, sizeof(space) - (name - space), &len))) {
1208 fprintf (stderr, "StringCbLength failure on name");
1211 offmsg = name + len + 1;
1212 if( FAILED(StringCbLength(offmsg, sizeof(space) - (offmsg - space), &len))) {
1213 fprintf (stderr, "StringCbLength failure on offmsg");
1216 motd = offmsg + len + 1;
1217 PrintStatus(status, name, motd, offmsg);
1219 fs_Die(errno, ti->data);
1223 code = pioctl_utf8(ti->data, VIOC_PATH_AVAILABILITY, &blob, 1);
1226 printf("Volume is online\n");
1229 printf("Volume is offline\n");
1232 printf("All Volume servers are down\n");
1235 printf("All volume servers are busy\n");
1238 printf("Unknown volume state\n");
1239 fs_Die(errno, ti->data);
1247 ListQuotaCmd(struct cmd_syndesc *as, void *arock)
1250 struct ViceIoctl blob;
1251 struct cmd_item *ti;
1252 struct VolumeStatus *status;
1257 printf("%-25s%-11s%-11s%-7s%-13s\n", "Volume Name", " Quota",
1258 " Used", " %Used", " Partition");
1259 SetDotDefault(&as->parms[0].items);
1260 for(ti=as->parms[0].items; ti; ti=ti->next) {
1262 blob.out_size = AFS_PIOCTL_MAXSIZE;
1265 code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
1267 fs_Die(errno, ti->data);
1271 space[blob.out_size - 1] = '\0';
1272 status = (VolumeStatus *)space;
1273 name = (char *)status + sizeof(*status);
1274 QuickPrintStatus(status, name);
1280 WhereIsCmd(struct cmd_syndesc *as, void *arock)
1283 struct ViceIoctl blob;
1284 struct cmd_item *ti;
1290 cm_ioctlQueryOptions_t options;
1292 if (as->parms[1].items)
1295 SetDotDefault(&as->parms[0].items);
1296 for(ti=as->parms[0].items; ti; ti=ti->next) {
1298 afs_uint32 filetype;
1301 memset(&fid, 0, sizeof(fid));
1302 memset(&options, 0, sizeof(options));
1304 options.size = sizeof(options);
1305 options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
1306 options.literal = literal;
1307 blob.in_size = options.size; /* no variable length data */
1310 blob.out_size = sizeof(cm_fid_t);
1311 blob.out = (char *) &fid;
1312 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
1313 blob.out_size == sizeof(cm_fid_t)) {
1314 options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
1317 fs_Die(errno, ti->data);
1322 blob.out_size = sizeof(filetype);
1323 blob.out = &filetype;
1325 code = pioctl_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
1326 if (code || blob.out_size != sizeof(filetype)) {
1327 fs_Die(errno, ti->data);
1331 blob.out_size = AFS_PIOCTL_MAXSIZE;
1333 memset(space, 0, sizeof(space));
1334 code = pioctl_utf8(ti->data, VIOCWHEREIS, &blob, 1);
1336 fs_Die(errno, ti->data);
1340 hosts = (afs_int32 *) space;
1341 printf("%s %s is on host%s ",
1342 fs_filetypestr(filetype),
1344 (hosts[0] && !hosts[1]) ? "": "s");
1345 for(j=0; j<AFS_MAXHOSTS; j++) {
1348 tp = hostutil_GetNameByINet(hosts[j]);
1358 DiskFreeCmd(struct cmd_syndesc *as, void *arock)
1361 struct ViceIoctl blob;
1362 struct cmd_item *ti;
1364 struct VolumeStatus *status;
1367 printf("%-25s%-10s%-10s%-10s%-6s\n", "Volume Name", " kbytes",
1368 " used", " avail", " %used");
1369 SetDotDefault(&as->parms[0].items);
1370 for(ti=as->parms[0].items; ti; ti=ti->next) {
1372 blob.out_size = AFS_PIOCTL_MAXSIZE;
1375 code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
1377 fs_Die(errno, ti->data);
1381 space[blob.out_size - 1] = '\0';
1382 status = (VolumeStatus *)space;
1383 name = (char *)status + sizeof(*status);
1384 QuickPrintSpace(status, name);
1390 QuotaCmd(struct cmd_syndesc *as, void *arock)
1393 struct ViceIoctl blob;
1394 struct cmd_item *ti;
1396 struct VolumeStatus *status;
1399 SetDotDefault(&as->parms[0].items);
1400 for(ti=as->parms[0].items; ti; ti=ti->next) {
1402 blob.out_size = AFS_PIOCTL_MAXSIZE;
1405 code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
1407 * The response is VolumeStatus, volume name, offline message, and motd
1409 if (code || blob.out_size < sizeof(*status)) {
1410 fs_Die(errno, ti->data);
1415 status = (VolumeStatus *)space;
1416 if (status->MaxQuota)
1417 quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
1420 printf("%2.0f%% of quota used.\n", quotaPct);
1426 ListMountCmd(struct cmd_syndesc *as, void *arock)
1429 struct ViceIoctl blob;
1430 struct cmd_item *ti;
1431 char orig_name[1024]; /*Original name, may be modified*/
1432 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
1433 char parent_dir[1024]; /*Parent directory of true name*/
1434 char *last_component; /*Last component of true name*/
1438 struct stat statbuff; /*Buffer for status info*/
1439 #endif /* not WIN32 */
1441 int link_chars_read; /*Num chars read in readlink()*/
1442 #endif /* not WIN32 */
1443 int thru_symlink; /*Did we get to a mount point via a symlink?*/
1446 for(ti=as->parms[0].items; ti; ti=ti->next) {
1450 if( FAILED(StringCbCopy(orig_name, sizeof(orig_name), ti->data))) {
1451 fprintf (stderr, "orig_name - not enough space");
1454 #else /* not WIN32 */
1456 if( FAILED(StringCbPrintf(orig_name, sizeof(orig_name), "%s%s",
1457 (ti->data[0] == '/') ? "" : "./",
1459 fprintf (stderr, "orig_name - cannot be populated");
1462 #endif /* not WIN32 */
1465 if (lstat(orig_name, &statbuff) < 0) {
1466 /* if lstat fails, we should still try the pioctl, since it
1467 * may work (for example, lstat will fail, but pioctl will
1468 * work if the volume of offline (returning ENODEV). */
1469 statbuff.st_mode = S_IFDIR; /* lie like pros */
1473 * The lstat succeeded. If the given file is a symlink, substitute
1474 * the file name with the link name.
1476 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
1479 * Read name of resolved file.
1481 link_chars_read = readlink(orig_name, true_name, 1024);
1482 if (link_chars_read <= 0) {
1484 "%s: Can't read target name for '%s' symbolic link!\n",
1491 * Add a trailing null to what was read, bump the length.
1493 true_name[link_chars_read++] = 0;
1496 * If the symlink is an absolute pathname, we're fine. Otherwise, we
1497 * have to create a full pathname using the original name and the
1498 * relative symlink name. Find the rightmost slash in the original
1499 * name (we know there is one) and splice in the symlink value.
1501 if (true_name[0] != '\\') {
1502 last_component = (char *) strrchr(orig_name, '\\');
1503 if( FAILED(StringCbCopy(++last_component, sizeof(orig_name) - (last_component - orig_name) * sizeof(char), true_name))) {
1504 fprintf (stderr, "last_component - not enough space");
1507 if( FAILED(StringCbCopy(true_name, sizeof(true_name), orig_name))) {
1508 fprintf (stderr, "true_name - not enough space");
1513 if( FAILED(StringCbCopy(true_name, sizeof(true_name), orig_name))) {
1514 fprintf (stderr, "true_name - not enough space");
1519 if( FAILED(StringCbCopy(true_name, sizeof(true_name), orig_name))) {
1520 fprintf (stderr, "true_name - not enough space");
1526 * Find rightmost slash, if any.
1529 last_component = (char *) strrchr(true_name, '\\');
1530 if (!last_component)
1532 last_component = (char *) strrchr(true_name, '/');
1533 if (last_component) {
1535 * Found it. Designate everything before it as the parent directory,
1536 * everything after it as the final component.
1538 if( FAILED(StringCchCopyN(parent_dir, sizeof(parent_dir) / sizeof(char), true_name, last_component - true_name + 1))) {
1539 fprintf (stderr, "parent_dir - not enough space");
1542 parent_dir[last_component - true_name + 1] = 0;
1543 last_component++; /*Skip the slash*/
1545 if (!fs_InAFS(parent_dir)) {
1546 const char * nbname = fs_NetbiosName();
1547 if( FAILED(StringCbLength(nbname, NETBIOSNAMESZ, &len))) {
1548 fprintf (stderr, "StringCbLength failure on nbname");
1551 if (parent_dir[0] == '\\' && parent_dir[1] == '\\' &&
1552 parent_dir[len+2] == '\\' &&
1553 parent_dir[len+3] == '\0' &&
1554 !strnicmp(nbname,&parent_dir[2],len))
1556 if( FAILED(StringCbPrintf(parent_dir, sizeof(parent_dir),"\\\\%s\\all\\", nbname))) {
1557 fprintf (stderr, "parent_dir - cannot be populated");
1565 * No slash appears in the given file name. Set parent_dir to the current
1566 * directory, and the last component as the given name.
1568 fs_ExtractDriveLetter(true_name, parent_dir);
1569 if( FAILED(StringCbCat(parent_dir, sizeof(parent_dir), "."))) {
1570 fprintf (stderr, "parent_dir - not enough space");
1573 last_component = true_name;
1574 fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
1577 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
1578 fprintf(stderr,"%s: you may not use '.' or '..' as the last component\n",pn);
1579 fprintf(stderr,"%s: of a name in the 'fs lsmount' command.\n",pn);
1584 blob.in = last_component;
1585 if( FAILED(StringCchLength(last_component, sizeof(true_name) / sizeof(char) - (last_component - true_name), &len))) {
1586 fprintf (stderr, "StringCbLength failure on last_component");
1589 blob.in_size = (long)len+1;
1590 blob.out_size = AFS_PIOCTL_MAXSIZE;
1592 memset(space, 0, AFS_PIOCTL_MAXSIZE);
1594 code = pioctl_utf8(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
1597 printf("'%s' is a %smount point for volume '%.*s'\n",
1599 (thru_symlink ? "symbolic link, leading to a " : ""),
1604 if (errno == EINVAL) {
1605 fprintf(stderr,"'%s' is not a mount point.\n", ti->data);
1607 fs_Die(errno, (ti->data ? ti->data : parent_dir));
1616 MakeMountCmd(struct cmd_syndesc *as, void *arock)
1619 char *cellName, *volName, *tmpName;
1621 char localCellName[128];
1623 char path[1024] = "";
1624 struct afsconf_cell info;
1625 struct vldbentry vldbEntry;
1626 struct ViceIoctl blob;
1630 memset(&info, 0, sizeof(info));
1632 if (as->parms[2].items) /* cell name specified */
1633 cellName = as->parms[2].items->data;
1636 volName = as->parms[1].items->data;
1637 if( FAILED(StringCbLength(volName, VL_MAXNAMELEN, &len))) {
1638 fprintf(stderr,"%s: volume name too long (length must be <= 64 characters)\n", pn);
1642 /* Check for a cellname in the volume specification, and complain
1643 * if it doesn't match what was specified with -cell */
1644 if (tmpName = strchr(volName, ':')) {
1647 if (strcasecmp(cellName,volName)) {
1648 fprintf(stderr,"fs: cellnames do not match.\n");
1653 volName = ++tmpName;
1656 parent = fs_GetParent(as->parms[0].items->data);
1657 if (!fs_InAFS(parent)) {
1659 const char * nbname = fs_NetbiosName();
1660 if ( FAILED(StringCbLength(nbname, NETBIOSNAMESZ, &len))) {
1661 fprintf (stderr, "StringCbLength failure on nbname");
1664 if (parent[0] == '\\' && parent[1] == '\\' &&
1665 (parent[len+2] == '\\' && parent[len+3] == '\0' || parent[len+2] == '\0') &&
1666 !strnicmp(nbname,&parent[2],len))
1668 if( FAILED(StringCbPrintf(path, sizeof(path),"%s%sall%s", parent,
1669 parent[len+2]?"":"\\",
1670 &as->parms[0].items->data[len+2]))) {
1671 fprintf (stderr, "path - cannot be populated");
1674 parent = fs_GetParent(path);
1675 if (!fs_InAFS(parent)) {
1676 fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
1682 fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
1687 if( FAILED(StringCbLength(path, sizeof(path), &len))) {
1688 fprintf (stderr, "StringCbLength failure on path");
1692 if( FAILED(StringCbCopy(path, sizeof(path), as->parms[0].items->data))) {
1693 fprintf (stderr, "path - not enough space");
1697 if ( fs_IsFreelanceRoot(parent) ) {
1698 if ( !fs_IsAdmin() ) {
1699 fprintf(stderr,"%s: Only AFS Client Administrators may alter the Freelance root.afs volume\n", pn);
1705 blob.out_size = sizeof(localCellName);
1706 blob.out = localCellName;
1707 code = pioctl_utf8(parent, VIOC_GET_WS_CELL, &blob, 1);
1709 localCellName[sizeof(localCellName) - 1] = '\0';
1710 cellName = localCellName;
1715 code = GetCell(parent, space, sizeof(space));
1721 code = GetCellName(cellName?cellName:space, &info);
1725 if (!(as->parms[4].items)) {
1726 /* not fast, check which cell the mountpoint is being created in */
1728 /* not fast, check name with VLDB */
1730 code = VLDBInit(1, &info);
1732 /* make the check. Don't complain if there are problems with init */
1733 code = ubik_VL_GetEntryByNameO(uclient, 0, volName, &vldbEntry);
1734 if (code == VL_NOENT) {
1735 fprintf(stderr,"%s: warning, volume %s does not exist in cell %s.\n",
1736 pn, volName, cellName ? cellName : space);
1741 if (as->parms[3].items) { /* if -rw specified */
1742 if( FAILED(StringCbCopy(space, sizeof(space), "%"))) {
1743 fprintf (stderr, "space arr - not enough space");
1747 if( FAILED(StringCbCopy(space, sizeof(space), "#"))) {
1748 fprintf (stderr, "space arr - not enough space");
1753 /* cellular mount point, prepend cell prefix */
1754 if( FAILED(StringCbCat(space, sizeof(space), info.name))) {
1755 fprintf (stderr, "space arr - not enough space");
1758 if( FAILED(StringCbCat(space, sizeof(space), ":"))) {
1759 fprintf (stderr, "space arr - not enough space");
1763 if( FAILED(StringCbCat(space, sizeof(space), volName))) { /* append volume name */
1764 fprintf (stderr, "space arr - not enough space");
1767 if( FAILED(StringCbCat(space, sizeof(space), "."))) { /* stupid convention; these end with a period */
1768 fprintf (stderr, "space arr - not enough space");
1772 /* create symlink with a special pioctl for Windows NT, since it doesn't
1773 * have a symlink system call.
1776 if( FAILED(StringCbLength(space, sizeof(space), &len))) {
1777 fprintf (stderr, "StringCbLength failure on space");
1780 blob.in_size = 1 + (long)len;
1783 code = pioctl_utf8(path, VIOC_AFS_CREATE_MT_PT, &blob, 0);
1784 #else /* not WIN32 */
1785 code = symlink(space, path);
1786 #endif /* not WIN32 */
1788 if (info.linkedCell)
1789 free(info.linkedCell);
1792 fs_Die(errno, path);
1799 * Delete AFS mount points. Variables are used as follows:
1800 * tbuffer: Set to point to the null-terminated directory name of the mount point
1801 * (or ``.'' if none is provided)
1802 * tp: Set to point to the actual name of the mount point to nuke.
1805 RemoveMountCmd(struct cmd_syndesc *as, void *arock) {
1807 struct ViceIoctl blob;
1808 struct cmd_item *ti;
1810 char lsbuffer[1024];
1815 for(ti=as->parms[0].items; ti; ti=ti->next) {
1817 tp = (char *) strrchr(ti->data, '\\');
1819 tp = (char *) strrchr(ti->data, '/');
1821 if( FAILED(StringCchCopyN(tbuffer, sizeof(tbuffer) / sizeof(char), ti->data, code=(afs_int32)(tp-ti->data+1)))) { /* the dir name */
1822 fprintf (stderr, "tbuffer - not enough space");
1825 tp++; /* skip the slash */
1828 if (!fs_InAFS(tbuffer)) {
1829 const char * nbname = fs_NetbiosName();
1830 if( FAILED(StringCbLength(nbname, NETBIOSNAMESZ, &len))) {
1831 fprintf (stderr, "StringCbLength failure on nbname");
1835 if (tbuffer[0] == '\\' && tbuffer[1] == '\\' &&
1836 tbuffer[len+2] == '\\' &&
1837 tbuffer[len+3] == '\0' &&
1838 !strnicmp(nbname,&tbuffer[2],len))
1840 if( FAILED(StringCbPrintf(tbuffer, sizeof(tbuffer),"\\\\%s\\all\\", nbname))) {
1841 fprintf (stderr, "tbuffer - cannot be populated");
1848 fs_ExtractDriveLetter(ti->data, tbuffer);
1849 if( FAILED(StringCbCat(tbuffer, sizeof(tbuffer), "."))) {
1850 fprintf (stderr, "tbuffer - not enough space");
1854 fs_StripDriveLetter(tp, tp, strlen(tp) + 1);
1857 if( FAILED(StringCbLength(tp, AFS_PIOCTL_MAXSIZE, &len))) {
1858 fprintf (stderr, "StringCbLength failure on tp");
1861 blob.in_size = (long)len+1;
1862 blob.out = lsbuffer;
1863 blob.out_size = sizeof(lsbuffer);
1864 code = pioctl_utf8(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
1866 if (errno == EINVAL) {
1867 fprintf(stderr,"%s: '%s' is not a mount point.\n", pn, ti->data);
1869 fs_Die(errno, ti->data);
1872 continue; /* don't bother trying */
1875 if ( fs_IsFreelanceRoot(tbuffer) && !fs_IsAdmin() ) {
1876 fprintf(stderr,"%s: Only AFS Client Administrators may alter the Freelance root.afs volume\n", pn);
1878 continue; /* skip */
1883 if( FAILED(StringCbLength(tp, AFS_PIOCTL_MAXSIZE, &len))) {
1884 fprintf (stderr, "StringCbLength failure on tp");
1887 blob.in_size = (long)len+1;
1888 code = pioctl_utf8(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
1890 fs_Die(errno, ti->data);
1901 CheckServersCmd(struct cmd_syndesc *as, void *arock)
1904 struct ViceIoctl blob;
1908 struct afsconf_cell info;
1909 struct chservinfo checkserv;
1913 memset(&info, 0, sizeof(info));
1914 memset(&checkserv, 0, sizeof(struct chservinfo));
1915 blob.in_size=sizeof(struct chservinfo);
1916 blob.in=(caddr_t)&checkserv;
1918 blob.out_size = AFS_PIOCTL_MAXSIZE;
1920 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1922 /* prepare flags for checkservers command */
1923 temp = 2; /* default to checking local cell only */
1924 if (as->parms[2].items)
1925 temp |= 1; /* set fast flag */
1926 if (as->parms[1].items)
1927 temp &= ~2; /* turn off local cell check */
1929 checkserv.magic = 0x12345678; /* XXX */
1930 checkserv.tflags=temp;
1932 /* now copy in optional cell name, if specified */
1933 if (as->parms[0].items) {
1934 code = GetCellName(as->parms[0].items->data, &info);
1938 if( FAILED(StringCbCopy(checkserv.tbuffer, sizeof(checkserv.tbuffer), info.name))) {
1939 fprintf (stderr, "tbuffer - not enough space");
1942 if( FAILED(StringCbLength(info.name, sizeof(info.name), &len))) {
1943 fprintf (stderr, "StringCbLength failure on info.name");
1946 checkserv.tsize=(int)len+1;
1947 if (info.linkedCell)
1948 free(info.linkedCell);
1950 if( FAILED(StringCbCopy(checkserv.tbuffer, sizeof(checkserv.tbuffer),"\0"))) {
1951 fprintf (stderr, "tbuffer - not enough space");
1957 if(as->parms[3].items) {
1958 checkserv.tinterval=atol(as->parms[3].items->data);
1961 if(checkserv.tinterval<0) {
1962 printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
1963 checkserv.tinterval=-1;
1964 } else if(checkserv.tinterval> 600) {
1965 printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
1966 checkserv.tinterval=600; /* 10 min max interval */
1969 checkserv.tinterval = -1; /* don't change current interval */
1972 if ( checkserv.tinterval >= 0 ) {
1974 if ( !fs_IsAdmin() ) {
1975 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
1980 fprintf (stderr,"Permission denied: requires root access.\n");
1986 code = pioctl_utf8(0, VIOCCKSERV, &blob, 1);
1988 if ((errno == EACCES) && (checkserv.tinterval > 0)) {
1989 printf("Must be root to change -interval\n");
1996 memcpy(&temp, space, sizeof(afs_int32));
1998 err = memcpy_s(&temp, sizeof(temp), space, sizeof(afs_int32));
2000 fprintf (stderr, "memcpy_s failure on temp");
2005 if (checkserv.tinterval >= 0) {
2006 if (checkserv.tinterval > 0)
2007 printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
2008 checkserv.tinterval, temp);
2010 printf("The current down server probe interval is %d secs\n", temp);
2014 printf("All servers are running.\n");
2016 printf("These servers unavailable due to network or server problems: ");
2017 for(j=0; j < AFS_MAXHOSTS; j++) {
2019 memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
2021 err = memcpy_s(&temp, sizeof(temp), space + j*sizeof(afs_int32), sizeof(afs_int32));
2023 fprintf (stderr, "memcpy_s failure on temp");
2030 tp = hostutil_GetNameByINet(temp);
2040 MessagesCmd(struct cmd_syndesc *as, void *arock)
2043 struct ViceIoctl blob;
2044 struct gaginfo gagflags;
2045 struct cmd_item *show;
2047 memset(&gagflags, 0, sizeof(struct gaginfo));
2048 blob.in_size = sizeof(struct gaginfo);
2049 blob.in = (caddr_t ) &gagflags;
2050 blob.out_size = AFS_PIOCTL_MAXSIZE;
2052 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
2054 if (show = as->parms[0].items) {
2055 if (!strcasecmp (show->data, "user"))
2056 gagflags.showflags |= GAGUSER;
2057 else if (!strcasecmp (show->data, "console"))
2058 gagflags.showflags |= GAGCONSOLE;
2059 else if (!strcasecmp (show->data, "all"))
2060 gagflags.showflags |= GAGCONSOLE | GAGUSER;
2061 else if (!strcasecmp (show->data, "none"))
2065 "unrecognized flag %s: must be in {user,console,all,none}\n",
2074 code = pioctl_utf8(0, VIOC_GAG, &blob, 1);
2083 CheckVolumesCmd(struct cmd_syndesc *as, void *arock)
2086 struct ViceIoctl blob;
2090 code = pioctl_utf8(0, VIOCCKBACK, &blob, 1);
2095 printf("All volumeID/name mappings checked.\n");
2101 SetCacheSizeCmd(struct cmd_syndesc *as, void *arock)
2104 struct ViceIoctl blob;
2108 if ( !fs_IsAdmin() ) {
2109 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
2114 fprintf (stderr,"Permission denied: requires root access.\n");
2119 if (!as->parms[0].items && !as->parms[1].items) {
2120 fprintf(stderr,"%s: syntax error in set cache size cmd.\n", pn);
2123 if (as->parms[0].items) {
2124 code = util_GetHumanInt32(as->parms[0].items->data, &temp);
2126 fprintf(stderr,"%s: bad integer specified for cache size.\n", pn);
2131 blob.in = (char *) &temp;
2132 blob.in_size = sizeof(afs_int32);
2134 code = pioctl_utf8(0, VIOCSETCACHESIZE, &blob, 1);
2136 fs_Die(errno, (char *) 0);
2140 printf("New cache size set.\n");
2145 GetCacheParmsCmd(struct cmd_syndesc *as, void *arock)
2148 struct ViceIoctl blob;
2149 cm_cacheParms_t parms;
2151 memset(&parms, 0, sizeof(parms));
2154 blob.out_size = sizeof(parms);
2155 blob.out = (char *) &parms;
2156 code = pioctl_utf8(0, VIOCGETCACHEPARMS, &blob, 1);
2157 if (code || blob.out_size != sizeof(parms)) {
2158 fs_Die(errno, NULL);
2162 printf("AFS using %I64u of the cache's available %I64u 1K byte blocks.\n",
2163 parms.parms[1], parms.parms[0]);
2164 if (parms.parms[1] > parms.parms[0])
2165 printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
2170 ListCellsCmd(struct cmd_syndesc *as, void *arock)
2173 afs_int32 i, j, *lp, magic, size;
2175 afs_int32 addr, maxa = AFS_OMAXHOSTS;
2176 struct ViceIoctl blob;
2180 resolve = !(as->parms[0].items); /* -numeric */
2182 for(i=0;i<1000;i++) {
2185 memcpy(tp, &i, sizeof(afs_int32));
2187 err = memcpy_s(tp, sizeof(space), &i, sizeof(afs_int32));
2189 fprintf (stderr, "memcpy_s failure on tp");
2193 tp = (char *)(space + sizeof(afs_int32));
2194 lp = (afs_int32 *)tp;
2196 size = sizeof(afs_int32) + sizeof(afs_int32);
2197 blob.out_size = AFS_PIOCTL_MAXSIZE;
2198 blob.in_size = sizeof(afs_int32);
2201 code = pioctl_utf8(0, VIOCGETCELL, &blob, 1);
2204 break; /* done with the list */
2210 memcpy(&magic, tp, sizeof(afs_int32));
2212 err = memcpy_s(&magic, sizeof(magic), tp, sizeof(afs_int32));
2214 fprintf (stderr, "memcpy_s failure on magic");
2218 if (magic == 0x12345678) {
2219 maxa = AFS_MAXHOSTS;
2220 tp += sizeof(afs_int32);
2222 printf("Cell %s on hosts", tp+maxa*sizeof(afs_int32));
2223 for(j=0; j < maxa && j*sizeof(afs_int32) < AFS_PIOCTL_MAXSIZE; j++) {
2224 char *name, tbuffer[20];
2226 memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
2228 err = memcpy_s(&addr, sizeof(addr), tp + j*sizeof(afs_int32), sizeof(afs_int32));
2230 fprintf (stderr, "memcpy_s failure on addr");
2238 name = hostutil_GetNameByINet(addr);
2241 if( FAILED(StringCbPrintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
2242 (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff))) {
2243 fprintf (stderr, "tbuffer - cannot be populated");
2248 printf(" %s", name);
2257 ListAliasesCmd(struct cmd_syndesc *as, void *arock)
2260 char *tp, *aliasName, *realName;
2261 struct ViceIoctl blob;
2268 memcpy(tp, &i, sizeof(afs_int32));
2270 err = memcpy_s(tp, sizeof(space), &i, sizeof(afs_int32));
2272 fprintf (stderr, "memcpy_s failure on tp");
2276 blob.out_size = AFS_PIOCTL_MAXSIZE;
2277 blob.in_size = sizeof(afs_int32);
2280 code = pioctl_utf8(0, VIOC_GETALIAS, &blob, 1);
2283 break; /* done with the list */
2287 space[blob.out_size - 1] = '\0';
2290 if( FAILED(StringCbLength(aliasName, sizeof(space), &len))) {
2291 fprintf (stderr, "StringCbLength failure on aliasName");
2296 printf("Alias %s for cell %s\n", aliasName, realName);
2302 CallBackRxConnCmd(struct cmd_syndesc *as, void *arock)
2305 struct ViceIoctl blob;
2306 struct cmd_item *ti;
2308 struct hostent *thp;
2312 ti = as->parms[0].items;
2315 thp = hostutil_GetHostByName(ti->data);
2317 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2321 memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2323 err = memcpy_s(&hostAddr, sizeof(hostAddr), thp->h_addr, sizeof(afs_int32));
2325 fprintf (stderr, "memcpy_s failure on hostAddr");
2330 hostAddr = 0; /* means don't set host */
2331 setp = 0; /* aren't setting host */
2334 /* now do operation */
2335 blob.in_size = sizeof(afs_int32);
2336 blob.out_size = sizeof(afs_int32);
2337 blob.in = (char *) &hostAddr;
2338 blob.out = (char *) &hostAddr;
2340 code = pioctl_utf8(0, VIOC_CBADDR, &blob, 1);
2350 NewCellCmd(struct cmd_syndesc *as, void *arock)
2352 afs_uint32 code, linkedstate=0, size=0, count=0, *lp;
2353 afs_uint32 usedns=0, useregistry=0;
2354 struct ViceIoctl blob;
2355 struct cmd_item *ti;
2356 char *tp, *cellname=0, *linked_cellname=0;
2357 afs_uint32 fsport = 0, vlport = 0;
2358 size_t destRemaining;
2360 if ( !fs_IsAdmin() ) {
2361 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
2365 /* if there is no cell specified, use old Windows behavior */
2366 if (as->parms[0].items == NULL) {
2368 blob.in = (char *) 0;
2369 blob.out_size = AFS_PIOCTL_MAXSIZE;
2372 code = pioctl_utf8((char *) 0, VIOCNEWCELL, &blob, 1);
2375 fs_Die(errno, (char *) 0);
2379 printf("Cell servers information refreshed\n");
2382 cellname = as->parms[0].items->data;
2385 if (as->parms[2].items) {
2387 * Link the cell, for the purposes of volume location, to the specified
2390 linked_cellname = as->parms[2].items->data;
2394 if (as->parms[3].items) {
2395 code = util_GetInt32(as->parms[2].items->data, &vlport);
2397 fprintf(stderr,"fs: bad integer specified for the fileserver port.\n");
2401 if (as->parms[4].items) {
2402 code = util_GetInt32(as->parms[3].items->data, &fsport);
2404 fprintf(stderr,"fs: bad integer specified for the vldb server port.\n");
2409 if (as->parms[5].items) {
2413 if (as->parms[6].items) {
2417 /* Count the number of hostnames */
2418 for (ti=as->parms[1].items; ti && count < AFS_MAXHOSTS; ti=ti->next, count++);
2420 if (!usedns && count == 0) {
2421 fprintf( stderr, "fs: at least one vldb server must be specified.");
2425 if (count > AFS_MAXHOSTS) {
2426 fprintf( stderr, "fs: at most %u servers may be specified.", AFS_MAXHOSTS);
2431 * The pioctl data buffer consists of the following structure:
2434 * afs_uint32 alternative fs port
2435 * afs_uint32 alternative vl port
2436 * afs_uint32 count of vldb servers
2439 * n * char[] hostnames
2442 memset(space, 0, sizeof(space));
2444 lp = (afs_uint32 *)tp;
2448 *lp |= VIOC_NEWCELL2_FLAG_USEDNS;
2451 *lp |= VIOC_NEWCELL2_FLAG_USEREG;
2454 *lp |= VIOC_NEWCELL2_FLAG_LINKED;
2463 /* count of server names */
2466 /* Switch back to char pointer */
2469 /* Add nul-terminated cellname */
2470 destRemaining = sizeof(space) - (tp - space);
2471 if( FAILED(StringCbCopyEx( tp,
2473 as->parms[0].items->data,
2476 STRSAFE_FILL_ON_FAILURE))) {
2477 fprintf (stderr, " not enough space for cellname");
2480 /* Move beyond the terminating nul */
2482 destRemaining -= sizeof(char);
2484 /* Add nul-terminated linkname */
2485 if( FAILED(StringCbCopyEx( tp,
2487 linkedstate ? linked_cellname : "",
2490 STRSAFE_FILL_ON_FAILURE))) {
2491 fprintf (stderr, " not enough space for linked cellname");
2494 /* Move beyond the terminating nul */
2496 destRemaining -= sizeof(char);
2498 /* Add the servers */
2499 for (ti=as->parms[1].items; ti; ti=ti->next) {
2500 if( FAILED(StringCbCopyEx( tp,
2505 STRSAFE_FILL_ON_FAILURE))) {
2506 fprintf (stderr, " not enough space for server %s", ti->data);
2509 /* Move beyond the terminating nul */
2511 destRemaining -= sizeof(char);
2514 blob.in_size = (tp - space);
2518 code = pioctl_utf8(NULL, VIOCNEWCELL2, &blob, 1);
2521 fs_Die(errno, as->parms[0].items->data);
2525 printf("Cell servers information for %s added or updated.\n",
2526 as->parms[0].items->data);
2532 NewAliasCmd(struct cmd_syndesc *as, void *arock)
2535 struct ViceIoctl blob;
2537 char *aliasName, *realName;
2538 size_t destRemaining = sizeof(space);
2540 /* Setup and do the NEWALIAS pioctl call */
2541 aliasName = as->parms[0].items->data;
2542 realName = as->parms[1].items->data;
2544 if( FAILED(StringCbCopyEx(tp, destRemaining, aliasName, &tp, &destRemaining, STRSAFE_FILL_ON_FAILURE))) {
2545 fprintf (stderr, "tp - not enough space");
2549 destRemaining -= sizeof(char);
2550 if( FAILED(StringCbCopyEx(tp, destRemaining, realName, &tp, &destRemaining, STRSAFE_FILL_ON_FAILURE))) {
2551 fprintf (stderr, "tp - not enough space");
2555 destRemaining -= sizeof(char);
2557 blob.in_size = tp - space;
2561 code = pioctl_utf8(0, VIOC_NEWALIAS, &blob, 1);
2563 if (errno == EEXIST) {
2565 "%s: cell name `%s' in use by an existing cell.\n", pn,
2577 WhichCellCmd(struct cmd_syndesc *as, void *arock)
2580 struct cmd_item *ti;
2581 struct ViceIoctl blob;
2584 cm_ioctlQueryOptions_t options;
2586 if (as->parms[1].items)
2589 SetDotDefault(&as->parms[0].items);
2590 for(ti=as->parms[0].items; ti; ti=ti->next) {
2592 afs_uint32 filetype;
2593 char cell[CELL_MAXNAMELEN];
2596 memset(&fid, 0, sizeof(fid));
2597 memset(&options, 0, sizeof(options));
2599 options.size = sizeof(options);
2600 options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
2601 options.literal = literal;
2602 blob.in_size = options.size; /* no variable length data */
2605 blob.out_size = sizeof(cm_fid_t);
2606 blob.out = (char *) &fid;
2607 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
2608 blob.out_size == sizeof(cm_fid_t)) {
2609 options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
2612 fs_Die(errno, ti->data);
2617 blob.out_size = sizeof(filetype);
2618 blob.out = &filetype;
2620 code = pioctl_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
2621 if (code || blob.out_size != sizeof(filetype)) {
2622 fs_Die(errno, ti->data);
2626 blob.out_size = CELL_MAXNAMELEN;
2629 code = pioctl_utf8(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
2631 if (errno == ENOENT)
2632 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2634 fs_Die(errno, ti->data);
2638 cell[CELL_MAXNAMELEN - 1] = '\0';
2639 printf("%s %s lives in cell '%s'\n",
2640 fs_filetypestr(filetype),
2647 WSCellCmd(struct cmd_syndesc *as, void *arock)
2650 struct ViceIoctl blob;
2654 blob.out_size = AFS_PIOCTL_MAXSIZE;
2657 code = pioctl_utf8(NULL, VIOC_GET_WS_CELL, &blob, 1);
2660 fs_Die(errno, NULL);
2663 space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
2664 printf("This workstation belongs to cell '%s'\n", space);
2670 PrimaryCellCmd(struct cmd_syndesc *as, void *arock)
2672 fprintf(stderr,"This command is obsolete, as is the concept of a primary token.\n");
2677 #ifndef AFS_NT40_ENV
2679 MonitorCmd(struct cmd_syndesc *as, void *arock)
2682 struct ViceIoctl blob;
2683 struct cmd_item *ti;
2685 struct hostent *thp;
2690 ti = as->parms[0].items;
2694 if (!strcmp(ti->data, "off")) {
2695 hostAddr = 0xffffffff;
2697 thp = hostutil_GetHostByName(ti->data);
2699 if (!strcmp(ti->data, "localhost")) {
2700 fprintf(stderr,"localhost not in host table, assuming 127.0.0.1\n");
2701 hostAddr = htonl(0x7f000001);
2703 fprintf(stderr,"host %s not found in host table.\n", ti->data);
2708 memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2710 err = memcpy_s(&hostAddr, sizeof(hostAddr), thp->h_addr, sizeof(afs_int32));
2712 fprintf (stderr, "memcpy_s failure on hostAddr");
2719 hostAddr = 0; /* means don't set host */
2720 setp = 0; /* aren't setting host */
2723 /* now do operation */
2724 blob.in_size = sizeof(afs_int32);
2725 blob.out_size = sizeof(afs_int32);
2726 blob.in = (char *) &hostAddr;
2727 blob.out = (char *) &hostAddr;
2728 code = pioctl_utf8(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2729 if (code || blob.out_size != sizeof(afs_int32)) {
2734 printf("%s: new monitor host set.\n", pn);
2736 /* now decode old address */
2737 if (hostAddr == 0xffffffff) {
2738 printf("Cache monitoring is currently disabled.\n");
2740 tp = hostutil_GetNameByINet(hostAddr);
2741 printf("Using host %s for monitor services.\n", tp);
2746 #endif /* AFS_NT40_ENV */
2749 SysNameCmd(struct cmd_syndesc *as, void *arock)
2752 struct ViceIoctl blob;
2753 struct cmd_item *ti;
2754 char *input = space;
2757 size_t destRemaining = sizeof(space);
2760 ti = as->parms[0].items;
2763 if ( !fs_IsAdmin() ) {
2764 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
2769 fprintf (stderr,"Permission denied: requires root access.\n");
2777 blob.out_size = AFS_PIOCTL_MAXSIZE;
2778 blob.in_size = sizeof(afs_int32);
2780 memcpy(input, &setp, sizeof(afs_int32));
2782 err = memcpy_s(input, destRemaining, &setp, sizeof(afs_int32));
2784 fprintf (stderr, "memcpy_s failure on input");
2788 input += sizeof(afs_int32);
2789 destRemaining -= sizeof(afs_int32);
2790 for (; ti; ti = ti->next) {
2792 if( FAILED(StringCbCopyEx(input, destRemaining, ti->data, &input, &destRemaining, STRSAFE_FILL_ON_FAILURE))) {
2793 fprintf(stderr, "%s: sysname%s too long.\n", pn,
2794 setp > 1 ? "s" : "");
2798 destRemaining -= sizeof(char);
2800 blob.in_size = (input - space) * sizeof(char);
2802 memcpy(space, &setp, sizeof(afs_int32));
2804 err = memcpy_s(space, sizeof(space), &setp, sizeof(afs_int32));
2806 fprintf (stderr, "memcpy_s failure on space");
2811 code = pioctl_utf8(0, VIOC_AFS_SYSNAME, &blob, 1);
2817 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2823 memcpy(&setp, input, sizeof(afs_int32));
2825 err = memcpy_s(&setp, sizeof(setp), input, sizeof(afs_int32));
2827 fprintf (stderr, "memcpy_s failure on setp");
2831 input += sizeof(afs_int32);
2833 fprintf(stderr,"No sysname name value was found\n");
2836 space[blob.out_size - 1] = '\0';
2837 printf("Current sysname%s is", setp > 1 ? " list" : "");
2838 for (; setp > 0; --setp ) {
2839 printf(" \'%s\'", input);
2840 if( FAILED(StringCbLength(input, sizeof(space) - (input - space), &len))) {
2841 fprintf (stderr, "StringCbLength failure on input");
2850 #ifndef AFS_NT40_ENV
2851 static char *exported_types[] = {"null", "nfs", ""};
2852 static int ExportAfsCmd(struct cmd_syndesc *as, void *arock)
2855 struct ViceIoctl blob;
2856 struct cmd_item *ti;
2857 int export = 0, type = 0, mode = 0, exp = 0, gstat = 0;
2858 int exportcall, pwsync = 0, smounts = 0;
2861 if ( !fs_IsAdmin() ) {
2862 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
2867 fprintf (stderr,"Permission denied: requires root access.\n");
2872 ti = as->parms[0].items;
2873 if (strcmp(ti->data, "nfs") == 0)
2874 type = 0x71; /* NFS */
2877 "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2880 ti = as->parms[1].items;
2882 if (strcmp(ti->data, "on") == 0)
2884 else if (strcmp(ti->data, "off") == 0)
2887 fprintf(stderr, "Illegal argument %s\n", ti->data);
2892 if (ti = as->parms[2].items) { /* -noconvert */
2893 if (strcmp(ti->data, "on") == 0)
2895 else if (strcmp(ti->data, "off") == 0)
2898 fprintf(stderr, "Illegal argument %s\n", ti->data);
2902 if (ti = as->parms[3].items) { /* -uidcheck */
2903 if (strcmp(ti->data, "on") == 0)
2905 else if (strcmp(ti->data, "off") == 0)
2908 fprintf(stderr, "Illegal argument %s\n", ti->data);
2912 if (ti = as->parms[4].items) { /* -submounts */
2913 if (strcmp(ti->data, "on") == 0)
2915 else if (strcmp(ti->data, "off") == 0)
2918 fprintf(stderr, "Illegal argument %s\n", ti->data);
2922 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2925 blob.in = (char *) &exportcall;
2926 blob.in_size = sizeof(afs_int32);
2927 blob.out = (char *) &exportcall;
2928 blob.out_size = sizeof(afs_int32);
2929 code = pioctl_utf8(0, VIOC_EXPORTAFS, &blob, 1);
2931 if (errno == ENODEV) {
2933 "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2940 if (exportcall & 1) {
2941 printf("'%s' translator is enabled with the following options:\n\tRunning in %s mode\n\tRunning in %s mode\n\t%s\n",
2942 exported_types[type], (exportcall & 2 ? "strict unix" : "convert owner mode bits to world/other"),
2943 (exportcall & 4 ? "strict 'passwd sync'" : "no 'passwd sync'"),
2944 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs" : "Only mounts to /afs allowed"));
2946 printf("'%s' translator is disabled\n", exported_types[type]);
2955 GetCellCmd(struct cmd_syndesc *as, void *arock)
2958 struct ViceIoctl blob;
2959 struct afsconf_cell info;
2960 struct cmd_item *ti;
2968 memset(&info, 0, sizeof(info));
2969 memset(&args, 0, sizeof(args)); /* avoid Purify UMR error */
2970 for(ti=as->parms[0].items; ti; ti=ti->next) {
2972 blob.out_size = sizeof(args);
2973 blob.out = (caddr_t) &args;
2974 code = GetCellName(ti->data, &info);
2979 if (info.linkedCell)
2980 free(info.linkedCell);
2981 if( FAILED(StringCbLength(info.name, sizeof(info.name), &len))) {
2982 fprintf (stderr, "StringCbLength failure on info.name");
2985 blob.in_size = 1+(long)len;
2986 blob.in = info.name;
2987 code = pioctl_utf8(0, VIOC_GETCELLSTATUS, &blob, 1);
2989 if (errno == ENOENT)
2990 fprintf(stderr,"%s: the cell named '%s' does not exist\n", pn, info.name);
2992 fs_Die(errno, info.name);
2996 printf("Cell %s status: ", info.name);
3002 printf("no setuid allowed");
3004 printf("setuid allowed");
3006 printf(", using old VLDB");
3012 static int SetCellCmd(struct cmd_syndesc *as, void *arock)
3015 struct ViceIoctl blob;
3016 struct afsconf_cell info;
3017 struct cmd_item *ti;
3025 memset(&info, 0, sizeof(info));
3027 /* Check arguments. */
3028 if (as->parms[1].items && as->parms[2].items) {
3029 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
3033 /* figure stuff to set */
3038 if ( !fs_IsAdmin() ) {
3039 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
3044 fprintf (stderr,"Permission denied: requires root access.\n");
3049 if (! as->parms[1].items)
3050 args.stat |= CM_SETCELLFLAG_SUID; /* default to -nosuid */
3052 /* set stat for all listed cells */
3053 for(ti=as->parms[0].items; ti; ti=ti->next) {
3055 code = GetCellName(ti->data, &info);
3060 if (info.linkedCell)
3061 free(info.linkedCell);
3062 if( FAILED(StringCbCopy(args.cname, sizeof(args.cname), info.name))) {
3063 fprintf (stderr, "cname - not enough space");
3066 blob.in_size = sizeof(args);
3067 blob.in = (caddr_t) &args;
3069 blob.out = (caddr_t) 0;
3070 code = pioctl_utf8(0, VIOC_SETCELLSTATUS, &blob, 1);
3072 fs_Die(errno, info.name); /* XXX added cell name to fs_Die() call */
3080 GetCellName(char *cellNamep, struct afsconf_cell *infop)
3082 if( FAILED(StringCbCopy(infop->name, sizeof(infop->name), cellNamep))) {
3083 fprintf (stderr, "name - not enough space");
3090 VLDBInit(int noAuthFlag, struct afsconf_cell *info)
3095 cm_GetConfigDir(confDir, sizeof(confDir));
3097 code = ugen_ClientInit(noAuthFlag, confDir,
3098 info->name, 0, &uclient,
3099 NULL, pn, rxkad_clear,
3100 VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
3101 0, 0, USER_SERVICE_ID);
3106 static struct ViceIoctl gblob;
3107 static int debug = 0;
3109 * here follow some routines in suport of the setserverprefs and
3110 * getserverprefs commands. They are:
3111 * SetPrefCmd "top-level" routine
3112 * addServer adds a server to the list of servers to be poked into the
3113 * kernel. Will poke the list into the kernel if it threatens
3115 * pokeServers pokes the existing list of servers and ranks into the kernel
3116 * GetPrefCmd reads the Cache Manager's current list of server ranks
3125 code = pioctl_utf8(0, VIOC_SETSPREFS, &gblob, 1);
3127 ssp = (cm_SSetPref_t *)space;
3128 gblob.in_size = (long)(((char *)&(ssp->servers[0])) - (char *)ssp);
3134 * returns -1 if error message printed,
3136 * errno value if error and no error message printed
3143 code = pioctl_utf8(0, VIOC_SETSPREFS, &gblob, 1);
3144 if (code && (errno == EINVAL)) {
3145 struct setspref *ssp;
3146 ssp = (struct setspref *)gblob.in;
3147 if (!(ssp->flags & DBservers)) {
3148 gblob.in = (void *)&(ssp->servers[0]);
3149 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
3150 code = pioctl_utf8(0, VIOC_SETSPREFS33, &gblob, 1);
3151 return code ? errno : 0;
3154 "This cache manager does not support VL server preferences.\n");
3158 return code ? errno : 0;
3164 addServer(char *name, unsigned short rank)
3169 struct hostent *thostent;
3174 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
3176 #define MAXUSHORT ((unsigned short) ~0)
3181 thostent = hostutil_GetHostByName(name);
3183 fprintf (stderr, "%s: couldn't resolve name.\n", name);
3187 ssp = (cm_SSetPref_t *)(gblob.in);
3189 if (gblob.in_size > MAXINSIZE - sizeof(cm_SPref_t)) {
3190 code = pokeServers();
3191 ssp->num_servers = 0;
3194 sp = (cm_SPref_t *)((char*)gblob.in + gblob.in_size);
3196 memcpy (&(sp->host.s_addr), thostent->h_addr, sizeof(afs_uint32));
3198 err = memcpy_s (&(sp->host.s_addr), sizeof(afs_uint32), thostent->h_addr, sizeof(afs_uint32));
3200 fprintf (stderr, "memcpy_s failure on sp->host.s_addr");
3205 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
3206 gblob.in_size += sizeof(cm_SPref_t);
3209 if (debug) fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",name,sp->rank,sp->host.s_addr);
3215 * returns -1 if error message printed,
3217 * errno value if error and no error message printed
3220 addServer(char *name, afs_int32 rank)
3223 struct setspref *ssp;
3225 struct hostent *thostent;
3232 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
3234 #define MAXUSHORT ((unsigned short) ~0)
3238 thostent = hostutil_GetHostByName(name);
3240 fprintf(stderr, "%s: couldn't resolve name.\n", name);
3244 ssp = (struct setspref *)(gblob.in);
3246 for (t = 0; thostent->h_addr_list[t]; t++) {
3247 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
3248 code = pokeServers();
3251 ssp->num_servers = 0;
3254 sp = (struct spref *)(gblob.in + gblob.in_size);
3256 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t],
3257 sizeof(afs_uint32));
3259 err = memcpy_s(&(sp->server.s_addr), sizeof(afs_uint32), thostent->h_addr_list[t],
3260 sizeof(afs_uint32));
3262 fprintf (stderr, "memcpy_s failure on sp->server.s_addr");
3267 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
3268 gblob.in_size += sizeof(struct spref);
3272 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
3273 name, sp->rank, sp->server.s_addr);
3281 static BOOL IsWindowsNT (void)
3283 static BOOL fChecked = FALSE;
3284 static BOOL fIsWinNT = FALSE;
3288 OSVERSIONINFO Version;
3292 memset (&Version, 0x00, sizeof(Version));
3293 Version.dwOSVersionInfoSize = sizeof(Version);
3295 if (GetVersionEx (&Version))
3297 if (Version.dwPlatformId == VER_PLATFORM_WIN32_NT)
3307 SetPrefCmd(struct cmd_syndesc *as, void * arock)
3311 struct cmd_item *ti;
3316 ssp = (cm_SSetPref_t *)space;
3318 ssp->num_servers = 0;
3319 gblob.in_size = (long)(((char*)&(ssp->servers[0])) - (char *)ssp);
3322 gblob.out_size = AFS_PIOCTL_MAXSIZE;
3324 if ( !fs_IsAdmin() ) {
3325 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
3331 ti = as->parms[2].items; /* -file */
3333 if (debug) fprintf(stderr,"opening file %s\n",ti->data);
3334 if (!(infd = fopen(ti->data,"r" ))) {
3336 fs_Die(errno,ti->data);
3339 while ( fscanf(infd, "%79s%ld", name, &rank) != EOF) {
3340 code = addServer (name, (unsigned short) rank);
3343 while ( fscanf_s(infd, "%79s%ld", name, sizeof(name), &rank) != EOF) {
3344 code = addServer (name, (unsigned short) rank);
3351 ti = as->parms[3].items; /* -stdin */
3354 while ( scanf("%79s%ld", name, &rank) != EOF) {
3355 code = addServer (name, (unsigned short) rank);
3358 while ( scanf_s("%79s%ld", name, sizeof(name), &rank) != EOF) {
3359 code = addServer (name, (unsigned short) rank);
3364 for (ti = as->parms[0].items;ti;ti=ti->next) {/*list of servers, ranks */
3369 code = addServer (ti->data, (unsigned short) atol(ti->next->data));
3371 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
3375 code = pokeServers();
3377 printf("now working on vlservers, code=%d, errno=%d\n",code,errno);
3379 ssp = (cm_SSetPref_t *)space;
3380 gblob.in_size = (long)(((char*)&(ssp->servers[0])) - (char *)ssp);
3382 ssp->flags = CM_SPREF_VLONLY;
3383 ssp->num_servers = 0;
3385 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
3390 code = addServer (ti->data, (unsigned short) atol(ti->next->data));
3392 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
3397 if (as->parms[1].items) {
3399 printf("now poking vlservers\n");
3400 code = pokeServers();
3410 SetPrefCmd(struct cmd_syndesc *as, void *arock)
3414 struct cmd_item *ti;
3417 struct setspref *ssp;
3418 int error = 0; /* -1 means error message printed,
3419 * >0 means errno value for unprinted message */
3421 ssp = (struct setspref *)space;
3423 ssp->num_servers = 0;
3424 gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
3427 gblob.out_size = AFS_PIOCTL_MAXSIZE;
3431 fprintf(stderr, "Permission denied: requires root access.\n");
3435 ti = as->parms[2].items; /* -file */
3438 fprintf(stderr, "opening file %s\n", ti->data);
3439 if (!(infd = fopen(ti->data, "r"))) {
3444 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
3445 code = addServer(name, (unsigned short)rank);
3450 while (fscanf_s(infd, "%79s%ld", name, sizeof(name), &rank) != EOF) {
3451 code = addServer(name, (unsigned short)rank);
3460 ti = as->parms[3].items; /* -stdin */
3463 while (scanf("%79s%ld", name, &rank) != EOF) {
3464 code = addServer(name, (unsigned short)rank);
3469 while (scanf_s("%79s%ld", name, sizeof(name), &rank) != EOF) {
3470 code = addServer(name, (unsigned short)rank);
3477 for (ti = as->parms[0].items; ti; ti = ti->next) { /* list of servers, ranks */
3482 code = addServer(ti->data, (unsigned short)atol(ti->next->data));
3486 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
3490 code = pokeServers();
3494 printf("now working on vlservers, code=%d\n", code);
3496 ssp = (struct setspref *)space;
3497 ssp->flags = DBservers;
3498 ssp->num_servers = 0;
3499 gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
3502 for (ti = as->parms[1].items; ti; ti = ti->next) { /* list of dbservers, ranks */
3507 code = addServer(ti->data, (unsigned short)atol(ti->next->data));
3511 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
3516 if (as->parms[1].items) {
3518 printf("now poking vlservers\n");
3519 code = pokeServers();
3527 return error ? 1 : 0;
3533 GetPrefCmd(struct cmd_syndesc *as, void *arock)
3536 struct cmd_item *ti;
3537 char *name, tbuffer[20];
3542 struct ViceIoctl blob;
3543 struct cm_SPrefRequest *in;
3544 struct cm_SPrefInfo *out;
3548 ti = as->parms[0].items; /* -file */
3550 if (debug) fprintf(stderr,"opening file %s\n",ti->data);
3551 if (!(outfd = freopen(ti->data,"w",stdout))) {
3552 fs_Die(errno,ti->data);
3557 ti = as->parms[1].items; /* -numeric */
3559 ti = as->parms[2].items; /* -vlservers */
3560 vlservers = (ti ? CM_SPREF_VLONLY : 0);
3561 /* ti = as->parms[3].items; -cell */
3563 in = (struct cm_SPrefRequest *)space;
3567 blob.in_size=sizeof(struct cm_SPrefRequest);
3568 blob.in = (char *)in;
3570 blob.out_size = AFS_PIOCTL_MAXSIZE;
3572 in->num_servers = (AFS_PIOCTL_MAXSIZE - 2*sizeof(short))/sizeof(struct cm_SPref);
3573 in->flags = vlservers;
3575 code = pioctl_utf8(0, VIOC_GETSPREFS, &blob, 1);
3577 perror("getserverprefs pioctl");
3581 out = (struct cm_SPrefInfo *) blob.out;
3583 for (i=0;i<out->num_servers;i++) {
3585 name = hostutil_GetNameByINet(out->servers[i].host.s_addr);
3588 addr = ntohl(out->servers[i].host.s_addr);
3589 if( FAILED(StringCbPrintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr>>24) & 0xff, (addr>>16) & 0xff,
3590 (addr>>8) & 0xff, addr & 0xff))) {
3591 fprintf (stderr, "tbuffer - cannot be populated");
3596 printf ("%-50s %5u\n",name,out->servers[i].rank);
3599 in->offset = out->next_offset;
3601 } while (!code && out->next_offset > 0);
3607 GetPrefCmd(struct cmd_syndesc *as, void *arock)
3610 struct cmd_item *ti;
3611 char *name, tbuffer[20];
3612 afs_int32 rank, addr;
3616 struct ViceIoctl blob;
3617 struct sprefrequest *in;
3618 struct sprefinfo *out;
3621 ti = as->parms[0].items; /* -file */
3624 fprintf(stderr, "opening file %s\n", ti->data);
3625 if (!(outfd = freopen(ti->data, "w", stdout))) {
3631 ti = as->parms[1].items; /* -numeric */
3633 ti = as->parms[2].items; /* -vlservers */
3634 vlservers |= (ti ? DBservers : 0);
3635 /* ti = as->parms[3].items; -cell */
3637 in = (struct sprefrequest *)space;
3641 blob.in_size = sizeof(struct sprefrequest);
3642 blob.in = (char *)in;
3644 blob.out_size = AFS_PIOCTL_MAXSIZE;
3647 (AFS_PIOCTL_MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
3648 in->flags = vlservers;
3650 code = pioctl_utf8(0, VIOC_GETSPREFS, &blob, 1);
3652 perror("getserverprefs pioctl");
3656 out = (struct sprefinfo *)blob.out;
3658 for (i = 0; i < out->num_servers; i++) {
3660 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
3662 addr = ntohl(out->servers[i].server.s_addr);
3663 if( FAILED(StringCbPrintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
3664 (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff))) {
3665 fprintf (stderr, "tbuffer - cannot be populated");
3670 printf("%-50s %5u\n", name, out->servers[i].rank);
3673 in->offset = out->next_offset;
3674 } while (out->next_offset > 0);
3681 SmbUnicodeCmd(struct cmd_syndesc * asp, void * arock)
3687 struct ViceIoctl blob;
3689 if (asp->parms[0].items) {
3693 } else if (asp->parms[1].items) {
3699 if (inValue != 0 && !fs_IsAdmin()) {
3700 fprintf (stderr, "Permission denied: Requires AFS Client Administrator access.\n");
3704 blob.in_size = sizeof(inValue);
3705 blob.in = (char *) &inValue;
3706 blob.out_size = sizeof(outValue);
3707 blob.out = (char *) &outValue;
3709 code = pioctl_utf8(NULL, VIOC_UNICODECTL, &blob, 1);
3711 fs_Die(errno, NULL);
3715 if (outValue != 2) {
3716 printf("Unicode support is %s%s.\n",
3717 ((outValue != 0)? "enabled":"disabled"),
3718 ((inValue != 0)? " for new SMB connections":""));
3720 printf("Unicode support is absent in this installation of OpenAFS.\n");
3727 GetFidCmd(struct cmd_syndesc *as, void *arock)
3730 struct ViceIoctl blob;
3731 struct cmd_item *ti;
3734 cm_ioctlQueryOptions_t options;
3736 if (as->parms[1].items)
3739 SetDotDefault(&as->parms[0].items);
3740 for(ti=as->parms[0].items; ti; ti=ti->next) {
3742 afs_uint32 filetype;
3743 char cell[CELL_MAXNAMELEN];
3746 memset(&fid, 0, sizeof(fid));
3747 memset(&options, 0, sizeof(options));
3749 options.size = sizeof(options);
3750 options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
3751 options.literal = literal;
3752 blob.in_size = options.size; /* no variable length data */
3755 blob.out_size = sizeof(cm_fid_t);
3756 blob.out = (char *) &fid;
3757 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
3758 blob.out_size == sizeof(cm_fid_t)) {
3759 options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
3762 fs_Die(errno, ti->data);
3767 blob.out_size = sizeof(filetype);
3768 blob.out = &filetype;
3770 code = pioctl_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
3771 if (code || blob.out_size != sizeof(filetype)) {
3772 fs_Die(errno, ti->data);
3776 blob.out_size = CELL_MAXNAMELEN;
3779 code = pioctl_utf8(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
3781 cell[CELL_MAXNAMELEN - 1] = '\0';
3782 printf("%s %s (%u.%u.%u) contained in cell %s\n",
3783 fs_filetypestr(filetype),
3784 ti->data, fid.volume, fid.vnode, fid.unique,
3785 code ? "unknown-cell" : cell);
3791 UuidCmd(struct cmd_syndesc *asp, void *arock)
3796 struct ViceIoctl blob;
3797 char * uuidstring = NULL;
3799 if (asp->parms[0].items) {
3801 if ( !fs_IsAdmin() ) {
3802 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
3807 fprintf (stderr, "Permission denied: requires root access.\n");
3811 inValue = 1; /* generate new UUID */
3813 inValue = 0; /* just show the current UUID */
3816 blob.in_size = sizeof(inValue);
3817 blob.in = (char *) &inValue;
3818 blob.out_size = sizeof(outValue);
3819 blob.out = (char *) &outValue;
3821 code = pioctl_utf8(NULL, VIOC_UUIDCTL, &blob, 1);
3822 if (code || blob.out_size != sizeof(outValue)) {
3823 fs_Die(errno, NULL);
3827 UuidToString((UUID *) &outValue, &uuidstring);
3829 printf("%sUUID: %s",
3830 ((inValue == 1)?"New ":""),
3834 RpcStringFree(&uuidstring);
3840 TraceCmd(struct cmd_syndesc *asp, void *arock)
3843 struct ViceIoctl blob;
3848 if ( !fs_IsAdmin() ) {
3849 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
3854 fprintf (stderr,"Permission denied: requires root access.\n");
3859 if ((asp->parms[0].items && asp->parms[1].items)) {
3860 fprintf(stderr, "fs trace: must use at most one of '-off' or '-on'\n");
3864 /* determine if we're turning this tracing on or off */
3866 if (asp->parms[0].items)
3867 inValue = 3; /* enable */
3868 else if (asp->parms[1].items)
3869 inValue = 2; /* disable */
3870 if (asp->parms[2].items)
3871 inValue |= 4; /* do reset */
3872 if (asp->parms[3].items)
3873 inValue |= 8; /* dump */
3875 blob.in_size = sizeof(long);
3876 blob.in = (char *) &inValue;
3877 blob.out_size = sizeof(long);
3878 blob.out = (char *) &outValue;
3880 code = pioctl_utf8(NULL, VIOC_TRACECTL, &blob, 1);
3881 if (code || blob.out_size != sizeof(long)) {
3882 fs_Die(errno, NULL);
3887 printf("AFS tracing enabled.\n");
3889 printf("AFS tracing disabled.\n");
3894 static void sbusage(void)
3896 fprintf(stderr, "example usage: %s storebehind -files *.o -kb 99999 -default 0\n", pn);
3897 fprintf(stderr, " %s sb 50000 *.[ao] -default 10\n", pn);
3900 /* fs sb -kbytes 9999 -files *.o -default 64 */
3902 StoreBehindCmd(struct cmd_syndesc *as, void *arock)
3905 struct ViceIoctl blob;
3906 struct cmd_item *ti;
3907 struct sbstruct tsb, tsb2;
3914 if ( !fs_IsAdmin() ) {
3915 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
3920 tsb.sb_thisfile = -1;
3921 ti = as->parms[0].items; /* -kbytes */
3923 if (!as->parms[1].items) {
3924 fprintf(stderr, "%s: you must specify -files with -kbytes.\n",
3928 tsb.sb_thisfile = strtol(ti->data, &t, 10) * 1024;
3929 if (errno == ERANGE) {
3930 fprintf(stderr, "%s: ti->data must within long int range", pn);
3933 if ((tsb.sb_thisfile < 0) || (*t != '\0')) {
3934 fprintf(stderr, "%s: %s must be 0 or a positive number.\n", pn,
3940 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
3941 ti = as->parms[2].items; /* -allfiles */
3943 allfiles = strtol(ti->data, &t, 10) * 1024;
3944 if (errno == ERANGE) {
3945 fprintf(stderr, "%s: ti->data must within long int range", pn);
3948 if ((allfiles < 0) || (*t != '\0')) {
3949 fprintf(stderr, "%s: %s must be 0 or a positive number.\n", pn,
3955 /* -verbose or -file only or no options */
3956 if (as->parms[3].items || (as->parms[1].items && !as->parms[0].items)
3957 || (!as->parms[0].items && !as->parms[1].items
3958 && !as->parms[2].items))
3961 blob.in = (char *)&tsb;
3962 blob.out = (char *)&tsb2;
3963 blob.in_size = blob.out_size = sizeof(struct sbstruct);
3964 memset(&tsb2, 0, sizeof(tsb2));
3966 /* once per -file */
3967 for (ti = as->parms[1].items; ti; ti = ti->next) {
3968 /* Do this solely to see if the file is there */
3969 code = pioctl_utf8(ti->data, VIOCWHEREIS, &blob, 1);
3971 fs_Die(errno, ti->data);
3976 code = pioctl_utf8(ti->data, VIOC_STOREBEHIND, &blob, 1);
3978 fs_Die(errno, ti->data);
3983 if (verbose && (blob.out_size == sizeof(tsb2))) {
3984 if (tsb2.sb_thisfile == -1) {
3985 fprintf(stdout, "Will store %s according to default.\n",
3989 "Will store up to %d kbytes of %s asynchronously.\n",
3990 (tsb2.sb_thisfile / 1024), ti->data);
3995 /* If no files - make at least one pioctl call, or
3996 * set the allfiles default if we need to.
3998 if (!as->parms[1].items || (allfiles != -1)) {
3999 tsb.sb_default = allfiles;
4000 code = pioctl_utf8(0, VIOC_STOREBEHIND, &blob, 1);
4002 fs_Die(errno, ((allfiles == -1) ? 0 : "-allfiles"));
4007 /* Having no arguments also reports the default store asynchrony */
4008 if (verbose && (blob.out_size == sizeof(tsb2))) {
4009 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
4010 (tsb2.sb_default / 1024));
4017 SetCryptCmd(struct cmd_syndesc *as, void *arock)
4019 afs_int32 code = 0, flag;
4020 struct ViceIoctl blob;
4024 if ( !fs_IsAdmin() ) {
4025 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
4030 tp = as->parms[0].items->data;
4031 if (strcmp(tp, "on") == 0)
4033 else if (strcmp(tp, "off") == 0)
4035 else if (strcmp(tp, "auth") == 0)
4038 fprintf (stderr, "%s: %s must be \"on\", \"auth\", or \"off\".\n", pn, tp);
4042 blob.in = (char *) &flag;
4043 blob.in_size = sizeof(flag);
4045 code = pioctl_utf8(0, VIOC_SETRXKCRYPT, &blob, 1);
4052 GetCryptCmd(struct cmd_syndesc *as, void *arock)
4054 afs_int32 code = 0, flag;
4055 struct ViceIoctl blob;
4061 blob.out_size = sizeof(flag);
4064 code = pioctl_utf8(0, VIOC_GETRXKCRYPT, &blob, 1);
4066 if (code || blob.out_size != sizeof(flag))
4071 memcpy(&flag, tp, sizeof(afs_int32));
4073 err = memcpy_s(&flag, sizeof(flag), tp, sizeof(afs_int32));
4075 fprintf (stderr, "memcpy_s failure on flag");
4080 printf("Security level is currently ");
4082 printf("auth (data integrity).\n");
4084 printf("crypt (data security).\n");
4092 MemDumpCmd(struct cmd_syndesc *asp, void *arock)
4095 struct ViceIoctl blob;
4099 if ( !fs_IsAdmin() ) {
4100 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
4104 if ((asp->parms[0].items && asp->parms[1].items)) {
4105 fprintf(stderr, "%s trace: must use at most one of '-begin' or '-end'\n", pn);
4109 /* determine if we're turning this tracing on or off */
4110 if (asp->parms[0].items)
4111 inValue = 1; /* begin */
4112 else if (asp->parms[1].items)
4113 inValue = 0; /* end */
4116 blob.in_size = sizeof(long);
4117 blob.in = (char *) &inValue;
4118 blob.out_size = sizeof(long);
4119 blob.out = (char *) &outValue;
4121 code = pioctl_utf8(NULL, VIOC_TRACEMEMDUMP, &blob, 1);
4122 if (code || blob.out_size != sizeof(long)) {
4123 fs_Die(errno, NULL);
4128 printf("AFS memdump created.\n");
4131 printf("AFS memdump failed.\n");
4137 MiniDumpCmd(struct cmd_syndesc *asp, void *arock)
4140 SERVICE_STATUS status;
4141 SC_HANDLE hManager = NULL;
4142 SC_HANDLE hService = NULL;
4144 if ( !fs_IsAdmin() ) {
4145 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
4149 hManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
4153 hService = OpenService(hManager, "TransarcAFSDaemon", SERVICE_USER_DEFINED_CONTROL);
4157 success = ControlService(hService, SERVICE_CONTROL_CUSTOM_DUMP, &status);
4160 CloseServiceHandle(hService);
4161 CloseServiceHandle(hManager);
4163 printf("AFS minidump generated.\n");
4169 CloseServiceHandle(hService);
4171 CloseServiceHandle(hManager);
4173 printf("AFS minidump failed.\n");
4178 CSCPolicyCmd(struct cmd_syndesc *asp, void *arock)
4180 struct cmd_item *ti;
4185 if ( !fs_IsAdmin() ) {
4186 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
4190 for(ti=asp->parms[0].items; ti;ti=ti->next) {
4202 RegCreateKeyEx( HKEY_LOCAL_MACHINE,
4203 AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
4206 REG_OPTION_NON_VOLATILE,
4207 (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE,
4212 if ( hkCSCPolicy == NULL ) {
4213 fprintf (stderr,"Permission denied: requires Administrator access.\n");
4217 if ( !fs_IsAdmin() ) {
4218 fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
4219 RegCloseKey(hkCSCPolicy);
4226 if (asp->parms[1].items) {
4230 if (asp->parms[2].items) {
4231 policy = "programs";
4234 if (asp->parms[3].items) {
4235 policy = "documents";
4238 if (asp->parms[4].items) {
4242 RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, (DWORD)len+1);
4244 printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
4245 printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n");
4249 DWORD dwIndex, dwPolicies;
4250 char policyName[256];
4251 DWORD policyNameLen;
4256 /* list current csc policies */
4258 RegCreateKeyEx( HKEY_LOCAL_MACHINE,
4259 AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
4262 REG_OPTION_NON_VOLATILE,
4263 (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_QUERY_VALUE,
4268 RegQueryInfoKey( hkCSCPolicy,
4270 NULL, /* lpcClass */
4271 NULL, /* lpReserved */
4272 NULL, /* lpcSubKeys */
4273 NULL, /* lpcMaxSubKeyLen */
4274 NULL, /* lpcMaxClassLen */
4275 &dwPolicies, /* lpcValues */
4276 NULL, /* lpcMaxValueNameLen */
4277 NULL, /* lpcMaxValueLen */
4278 NULL, /* lpcbSecurityDescriptor */
4279 NULL /* lpftLastWriteTime */
4282 printf("Current CSC policies:\n");
4283 for ( dwIndex = 0; dwIndex < dwPolicies; dwIndex ++ ) {
4285 policyNameLen = sizeof(policyName);
4286 policyLen = sizeof(policy);
4287 RegEnumValue( hkCSCPolicy, dwIndex, policyName, &policyNameLen, NULL,
4288 &dwType, policy, &policyLen);
4290 printf(" %s = %s\n", policyName, policy);
4294 RegCloseKey(hkCSCPolicy);
4299 /* get clients interface addresses */
4301 GetClientAddrsCmd(struct cmd_syndesc *as, void *arock)
4304 struct cmd_item *ti;
4306 struct ViceIoctl blob;
4307 struct sprefrequest *in;
4308 struct sprefinfo *out;
4310 in = (struct sprefrequest *)space;
4314 blob.in_size = sizeof(struct sprefrequest);
4315 blob.in = (char *)in;
4317 blob.out_size = AFS_PIOCTL_MAXSIZE;
4320 (AFS_PIOCTL_MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
4321 /* returns addr in network byte order */
4322 code = pioctl_utf8(0, VIOC_GETCPREFS, &blob, 1);
4324 perror("getClientInterfaceAddr pioctl");
4330 out = (struct sprefinfo *)blob.out;
4331 for (i = 0; i < out->num_servers; i++) {
4334 addr = ntohl(out->servers[i].server.s_addr);
4335 if( FAILED(StringCbPrintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
4336 (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff))) {
4337 fprintf (stderr, "tbuffer - cannot be populated");
4340 printf("%-50s\n", tbuffer);
4342 in->offset = out->next_offset;
4344 } while (out->next_offset > 0);
4350 SetClientAddrsCmd(struct cmd_syndesc *as, void *arock)
4352 afs_int32 code, addr;
4353 struct cmd_item *ti;
4355 struct ViceIoctl blob;
4356 struct setspref *ssp;
4357 int sizeUsed = 0, i, flag;
4358 afs_int32 existingAddr[1024]; /* existing addresses on this host */
4362 ssp = (struct setspref *)space;
4363 ssp->num_servers = 0;
4366 blob.out_size = AFS_PIOCTL_MAXSIZE;
4369 fprintf(stderr, "Permission denied: requires root access.\n");
4373 /* extract all existing interface addresses */
4374 existNu = rx_getAllAddr(existingAddr, 1024);
4378 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
4379 for (ti = as->parms[0].items; ti; ti = ti->next) {
4380 if (sizeUsed >= sizeof(space)) {
4381 fprintf(stderr, "No more space\n");
4384 addr = extractAddr(ti->data, 20); /* network order */
4385 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
4386 fprintf(stderr, "Error in specifying address: %s..ignoring\n",
4391 /* see if it is an address that really exists */
4392 for (flag = 0, i = 0; i < existNu; i++)
4393 if (existingAddr[i] == addr) {
4397 if (!flag) { /* this is an nonexistent address */
4398 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
4402 /* copy all specified addr into ioctl buffer */
4403 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
4404 printf("Adding 0x%08x\n", addr);
4406 sizeUsed += sizeof(struct spref);
4408 if (ssp->num_servers < 1) {
4409 fprintf(stderr, "No addresses specified\n");
4412 blob.in_size = sizeUsed - sizeof(struct spref);
4414 code = pioctl_utf8(0, VIOC_SETCPREFS, &blob, 1); /* network order */
4424 FlushMountCmd(struct cmd_syndesc *as, void *arock)
4427 struct ViceIoctl blob;
4428 struct cmd_item *ti;
4429 char orig_name[1024]; /*Original name, may be modified */
4430 char true_name[1024]; /*``True'' dirname (e.g., symlink target) */
4431 char parent_dir[1024]; /*Parent directory of true name */
4432 char *last_component; /*Last component of true name */
4433 struct stat statbuff; /*Buffer for status info */
4434 int link_chars_read; /*Num chars read in readlink() */
4435 int thru_symlink; /*Did we get to a mount point via a symlink? */
4439 for (ti = as->parms[0].items; ti; ti = ti->next) {
4442 if( FAILED(StringCbPrintf(orig_name, sizeof(orig_name), "%s%s", (ti->data[0] == '/') ? "" : "./",
4444 fprintf (stderr, "orig_name - cannot be populated");
4448 if (lstat(orig_name, &statbuff) < 0) {
4449 /* if lstat fails, we should still try the pioctl, since it
4450 * may work (for example, lstat will fail, but pioctl will
4451 * work if the volume of offline (returning ENODEV). */
4452 statbuff.st_mode = S_IFDIR; /* lie like pros */
4456 * The lstat succeeded. If the given file is a symlink, substitute
4457 * the file name with the link name.
4459 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
4462 * Read name of resolved file.
4464 link_chars_read = readlink(orig_name, true_name, 1024);
4465 if (link_chars_read <= 0) {
4467 "%s: Can't read target name for '%s' symbolic link!\n",
4474 * Add a trailing null to what was read, bump the length.
4476 true_name[link_chars_read++] = 0;
4479 * If the symlink is an absolute pathname, we're fine. Otherwise, we
4480 * have to create a full pathname using the original name and the
4481 * relative symlink name. Find the rightmost slash in the original
4482 * name (we know there is one) and splice in the symlink value.
4484 if (true_name[0] != '/') {
4485 last_component = (char *)strrchr(orig_name, '/');
4486 if( FAILED(StringCbCopy(++last_component, sizeof(orig_name) - (last_component - orig_name) * sizeof(char), true_name))) {
4487 fprintf (stderr, "last_component - not enough space");
4490 if( FAILED(StringCbCopy(true_name, sizeof(true_name), orig_name))) {
4491 fprintf (stderr, "true_name - not enough space");
4496 if( FAILED(StringCbCopy(true_name, sizeof(true_name), orig_name))) {
4497 fprintf (stderr, "true_name - not enough space");
4502 * Find rightmost slash, if any.
4504 last_component = (char *)strrchr(true_name, '/');
4505 if (last_component) {
4507 * Found it. Designate everything before it as the parent directory,
4508 * everything after it as the final component.
4510 if( FAILED(StringCchCopyN(parent_dir, sizeof(parent_dir) / sizeof(char), true_name, last_component - true_name))) {
4511 fprintf (stderr, "parent_dir - not enough space");
4514 parent_dir[last_component - true_name] = 0;
4515 last_component++; /*Skip the slash */
4518 * No slash appears in the given file name. Set parent_dir to the current
4519 * directory, and the last component as the given name.
4521 if( FAILED(StringCbCopy(parent_dir, sizeof(parent_dir), "."))) {
4522 fprintf (stderr, "parent_dir - not enough space");
4525 last_component = true_name;
4528 if (strcmp(last_component, ".") == 0
4529 || strcmp(last_component, "..") == 0) {
4531 "%s: you may not use '.' or '..' as the last component\n",
4533 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n",
4539 blob.in = last_component;
4540 if( FAILED(StringCbLength(last_component, sizeof(true_name) - (last_component - true_name), &len))) {
4541 fprintf (stderr, "StringCbLength failure on last_component");
4544 blob.in_size = len + 1;
4546 memset(space, 0, AFS_PIOCTL_MAXSIZE);
4548 code = pioctl_utf8(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
4551 if (errno == EINVAL) {
4552 fprintf(stderr, "'%s' is not a mount point.\n", ti->data);
4554 fs_Die(errno, (ti->data ? ti->data : parent_dir));
4564 RxStatProcCmd(struct cmd_syndesc *as, void *arock)
4567 afs_int32 flags = 0;
4568 struct ViceIoctl blob;
4570 if (as->parms[0].items) { /* -enable */
4571 flags |= AFSCALL_RXSTATS_ENABLE;
4573 if (as->parms[1].items) { /* -disable */
4574 flags |= AFSCALL_RXSTATS_DISABLE;
4576 if (as->parms[2].items) { /* -clear */
4577 flags |= AFSCALL_RXSTATS_CLEAR;
4580 fprintf(stderr, "You must specify at least one argument\n");
4584 blob.in = (char *)&flags;
4585 blob.in_size = sizeof(afs_int32);
4588 code = pioctl_utf8(NULL, VIOC_RXSTAT_PROC, &blob, 1);
4590 fs_Die(errno, NULL);
4598 RxStatPeerCmd(struct cmd_syndesc *as, void *arock)
4601 afs_int32 flags = 0;
4602 struct ViceIoctl blob;
4604 if (as->parms[0].items) { /* -enable */
4605 flags |= AFSCALL_RXSTATS_ENABLE;
4607 if (as->parms[1].items) { /* -disable */
4608 flags |= AFSCALL_RXSTATS_DISABLE;
4610 if (as->parms[2].items) { /* -clear */
4611 flags |= AFSCALL_RXSTATS_CLEAR;
4614 fprintf(stderr, "You must specify at least one argument\n");
4618 blob.in = (char *)&flags;
4619 blob.in_size = sizeof(afs_int32);
4622 code = pioctl_utf8(NULL, VIOC_RXSTAT_PEER, &blob, 1);
4624 fs_Die(errno, NULL);
4632 TestVolStatCmd(struct cmd_syndesc *as, void *arock)
4635 struct VolStatTest test;
4636 struct ViceIoctl blob;
4640 memset(&test, 0, sizeof(test));
4642 if (as->parms[0].items) { /* -network */
4643 tp = as->parms[0].items->data;
4644 if (strcmp(tp, "up") == 0)
4645 test.flags |= VOLSTAT_TEST_NETWORK_UP;
4646 else if (strcmp(tp, "down") == 0)
4647 test.flags |= VOLSTAT_TEST_NETWORK_DOWN;
4649 fprintf (stderr, "%s: %s must be \"up\" or \"down\".\n", pn, tp);
4653 if (as->parms[1].items) { /* check */
4654 test.flags |= VOLSTAT_TEST_CHECK_VOLUME;
4656 if (as->parms[2].items) { /* cell */
4657 tp = as->parms[2].items->data;
4662 if( FAILED(StringCbCopy(test.cellname, sizeof(test.cellname), tp))) {
4663 fprintf (stderr, "cellname - not enough space");
4666 test.cellname[sizeof(test.cellname)-1] = '\0';
4669 if (as->parms[3].items) { /* volume */
4670 tp = as->parms[3].items->data;
4673 test.fid.volume = n;
4675 if( FAILED(StringCbCopy(test.volname, sizeof(test.volname), tp))) {
4676 fprintf (stderr, "volname - not enough space");
4679 test.volname[sizeof(test.volname)-1] = '\0';
4682 if (as->parms[4].items) { /* state */
4683 tp = as->parms[4].items->data;
4684 if (strcmp(tp, "online") == 0)
4685 test.state = vl_online;
4686 else if (strcmp(tp, "busy") == 0)
4687 test.state = vl_busy;
4688 else if (strcmp(tp, "offline") == 0)
4689 test.state = vl_offline;
4690 else if (strcmp(tp, "down") == 0)
4691 test.state = vl_alldown;
4693 fprintf (stderr, "%s: %s must be \"online\", \"busy\", \"offline\" or \"down\".\n", pn, tp);
4698 if ((test.fid.cell || test.cellname[0]) && !(test.fid.volume || test.volname[0]) ||
4699 !(test.fid.cell || test.cellname[0]) && (test.fid.volume || test.volname[0])) {
4700 fprintf (stderr, "%s: both a cell and a volume must be specified.\n", pn, tp);
4704 blob.in = (char *)&test;
4705 blob.in_size = sizeof(test);
4708 code = pioctl_utf8(NULL, VIOC_VOLSTAT_TEST, &blob, 1);
4710 fs_Die(errno, NULL);
4718 ChOwnCmd(struct cmd_syndesc *as, void *arock)
4721 struct ViceIoctl blob;
4722 struct cmd_item *ti;
4726 cm_ioctlQueryOptions_t options;
4733 cm_GetConfigDir(confDir, sizeof(confDir));
4735 if (as->parms[2].items)
4738 ownerStr = as->parms[0].items->data;
4739 ownerId = atoi(ownerStr);
4741 SetDotDefault(&as->parms[1].items);
4742 for(ti=as->parms[1].items; ti; ti=ti->next) {
4744 afs_uint32 filetype;
4745 char cell[CELL_MAXNAMELEN];
4748 memset(&fid, 0, sizeof(fid));
4749 memset(&inData, 0, sizeof(inData));
4751 inData.options.size = sizeof(inData.options);
4752 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
4753 inData.options.literal = literal;
4754 blob.in_size = inData.options.size; /* no variable length data */
4757 blob.out_size = sizeof(cm_fid_t);
4758 blob.out = (char *) &fid;
4759 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
4760 blob.out_size == sizeof(cm_fid_t)) {
4761 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
4762 inData.options.fid = fid;
4764 fs_Die(errno, ti->data);
4770 * if the owner was specified as a numeric value,
4771 * then we can just use it. Otherwise, we need
4772 * to know the cell of the path to determine which
4773 * ptserver to contact in order to convert the name
4774 * to a numeric value.
4777 blob.out_size = CELL_MAXNAMELEN;
4780 code = pioctl_utf8(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
4782 fs_Die(errno, ti->data);
4786 cell[CELL_MAXNAMELEN - 1] = '\0';
4788 * We now know the cell for the target and we need to
4789 * convert the ownerStr to the Id for this user
4791 pr_Initialize(1, confDir, cell);
4792 code = pr_SNameToId(ownerStr, &inData.owner);
4795 if (code || inData.owner == ANONYMOUSID ) {
4796 fs_Die(ECHILD, ti->data);
4801 inData.owner = ownerId;
4804 blob.in_size = sizeof(inData);
4807 code = pioctl_utf8(ti->data, VIOC_SETOWNER, &blob, 1);
4809 fs_Die(errno, ti->data);
4816 ChGrpCmd(struct cmd_syndesc *as, void *arock)
4819 struct ViceIoctl blob;
4820 struct cmd_item *ti;
4824 cm_ioctlQueryOptions_t options;
4831 cm_GetConfigDir(confDir, sizeof(confDir));
4833 if (as->parms[2].items)
4836 groupStr = as->parms[0].items->data;
4837 groupId = atoi(groupStr);
4839 SetDotDefault(&as->parms[1].items);
4840 for(ti=as->parms[1].items; ti; ti=ti->next) {
4842 afs_uint32 filetype;
4843 char cell[CELL_MAXNAMELEN];
4846 memset(&fid, 0, sizeof(fid));
4847 memset(&inData, 0, sizeof(inData));
4849 inData.options.size = sizeof(inData.options);
4850 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
4851 inData.options.literal = literal;
4852 blob.in_size = inData.options.size; /* no variable length data */
4855 blob.out_size = sizeof(cm_fid_t);
4856 blob.out = (char *) &fid;
4857 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
4858 blob.out_size == sizeof(cm_fid_t)) {
4859 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
4860 inData.options.fid = fid;
4862 fs_Die(errno, ti->data);
4868 * if the group was specified as a numeric value,
4869 * then we can just use it. Otherwise, we need
4870 * to know the cell of the path to determine which
4871 * ptserver to contact in order to convert the name
4872 * to a numeric value.
4875 blob.out_size = CELL_MAXNAMELEN;
4878 code = pioctl_utf8(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
4880 fs_Die(errno, ti->data);
4884 cell[CELL_MAXNAMELEN - 1] = '\0';
4886 * We now know the cell for the target and we need to
4887 * convert the groupStr to the Id for this user
4889 pr_Initialize(1, confDir, cell);
4890 code = pr_SNameToId(groupStr, &inData.group);
4893 if (code || inData.group == ANONYMOUSID ) {
4894 fs_Die(ECHILD, ti->data);
4899 inData.group = groupId;
4902 blob.in_size = sizeof(inData);
4905 code = pioctl_utf8(ti->data, VIOC_SETGROUP, &blob, 1);
4907 fs_Die(errno, ti->data);
4916 ChModCmd(struct cmd_syndesc *as, void *arock)
4919 struct ViceIoctl blob;
4920 struct cmd_item *ti;
4924 cm_ioctlQueryOptions_t options;
4925 afs_uint32 unixModeBits;
4927 afs_uint32 unixModeBits;
4928 afs_int32 absolute = 0;
4932 cm_GetConfigDir(confDir, sizeof(confDir));
4934 if (as->parms[2].items)
4937 unixModeStr = as->parms[0].items->data;
4938 if (*unixModeStr >= '0' && *unixModeStr <= '7') {
4941 while (*unixModeStr >= '0' && *unixModeStr <= '7')
4942 unixModeBits = (unixModeBits << 3) | (*unixModeStr++ & 07);
4944 fs_Die(EINVAL, "invalid mode");
4947 unixModeBits &= ALL_MODES;
4950 SetDotDefault(&as->parms[1].items);
4951 for(ti=as->parms[1].items; ti; ti=ti->next) {
4953 afs_uint32 filetype;
4954 char cell[CELL_MAXNAMELEN];
4957 memset(&fid, 0, sizeof(fid));
4958 memset(&inData, 0, sizeof(inData));
4960 inData.options.size = sizeof(inData.options);
4961 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
4962 inData.options.literal = literal;
4963 blob.in_size = inData.options.size; /* no variable length data */
4966 blob.out_size = sizeof(cm_fid_t);
4967 blob.out = (char *) &fid;
4968 if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1) &&
4969 blob.out_size == sizeof(cm_fid_t)) {
4970 inData.options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
4971 inData.options.fid = fid;
4973 fs_Die(errno, ti->data);
4979 * if the mode was specified as an absolute numeric,
4980 * value we can simply apply it to all of the listed
4981 * file paths. Otherwise, we must obtain the old mode
4982 * value in order to compute the new value from the
4983 * symbolic representation.
4987 blob.out_size = sizeof(afs_uint32);
4988 blob.out = (char *)&unixModeBits;
4989 if (pioctl_utf8(ti->data, VIOC_GETUNIXMODE, &blob, 1) != 0)
4991 fs_Die(errno, ti->data);
4995 inData.unixModeBits = parsemode(unixModeStr, unixModeBits);
4997 inData.unixModeBits = unixModeBits;
5000 blob.in_size = sizeof(inData);
5003 code = pioctl_utf8(ti->data, VIOC_SETUNIXMODE, &blob, 1);
5005 fs_Die(errno, ti->data);
5012 #include "AFS_component_version_number.c"
5015 int wmain(int argc, wchar_t **wargv)
5018 struct cmd_syndesc *ts;
5021 #ifdef AFS_AIX32_ENV
5023 * The following signal action for AIX is necessary so that in case of a
5024 * crash (i.e. core is generated) we can include the user's data section
5025 * in the core dump. Unfortunately, by default, only a partial core is
5026 * generated which, in many cases, isn't too useful.
5028 struct sigaction nsa;
5030 sigemptyset(&nsa.sa_mask);
5031 nsa.sa_handler = SIG_DFL;
5032 nsa.sa_flags = SA_FULLDUMP;
5033 sigaction(SIGSEGV, &nsa, NULL);
5038 WSAStartup(0x0101, &WSAjunk);
5041 fs_SetProcessName(pn);
5043 argv = fs_MakeUtf8Cmdline(argc, wargv);
5045 /* try to find volume location information */
5049 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, NULL,
5050 "get client network interface addresses");
5051 cmd_CreateAlias(ts, "gc");
5053 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, NULL,
5054 "set client network interface addresses");
5055 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
5056 "client network interfaces");
5057 cmd_CreateAlias(ts, "sc");
5060 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, NULL, "set server ranks");
5061 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
5062 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
5063 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
5064 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
5065 cmd_CreateAlias(ts, "sp");
5067 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, NULL, "get server ranks");
5068 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
5069 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
5070 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
5071 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
5072 cmd_CreateAlias(ts, "gp");
5074 ts = cmd_CreateSyntax("setacl", SetACLCmd, NULL, "set access control list");
5075 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
5076 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
5077 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
5078 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
5079 parm_setacl_id = ts->nParms;
5080 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
5081 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
5082 cmd_CreateAlias(ts, "sa");
5084 ts = cmd_CreateSyntax("listacl", ListACLCmd, NULL, "list access control list");
5085 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5086 parm_listacl_id = ts->nParms;
5087 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
5088 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
5089 cmd_AddParm(ts, "-cmd", CMD_FLAG, CMD_OPTIONAL, "output as 'fs setacl' command");
5090 cmd_CreateAlias(ts, "la");
5092 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, NULL, "clean up access control list");
5093 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5095 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, NULL, "copy access control list");
5096 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
5097 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
5098 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
5099 parm_copyacl_id = ts->nParms;
5100 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
5101 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
5103 cmd_CreateAlias(ts, "ca");
5105 ts = cmd_CreateSyntax("flush", FlushCmd, NULL, "flush file from cache");
5106 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5107 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5110 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, NULL,
5111 "flush mount symlink from cache");
5112 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5115 ts = cmd_CreateSyntax("setvol", SetVolCmd, NULL, "set volume status");
5116 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5117 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
5119 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
5121 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
5122 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
5123 cmd_CreateAlias(ts, "sv");
5125 ts = cmd_CreateSyntax("messages", MessagesCmd, NULL, "control Cache Manager messages");
5126 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
5128 ts = cmd_CreateSyntax("examine", ExamineCmd, NULL, "display file/volume status");
5129 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5130 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5131 cmd_CreateAlias(ts, "lv");
5132 cmd_CreateAlias(ts, "listvol");
5134 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, NULL, "list volume quota");
5135 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5136 cmd_CreateAlias(ts, "lq");
5138 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, NULL, "show server disk space usage");
5139 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5140 cmd_CreateAlias(ts, "df");
5142 ts = cmd_CreateSyntax("quota", QuotaCmd, NULL, "show volume quota usage");
5143 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5145 ts = cmd_CreateSyntax("lsmount", ListMountCmd, NULL, "list mount point");
5146 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
5148 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, NULL, "make mount point");
5149 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
5150 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
5151 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
5152 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
5153 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
5159 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
5163 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, NULL, "remove mount point");
5164 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
5166 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, NULL, "check local cell's servers");
5167 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
5168 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
5169 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
5170 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
5172 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd, NULL, "check volumeID/name mappings");
5173 cmd_CreateAlias(ts, "checkbackups");
5176 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, NULL, "set cache size");
5177 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
5178 cmd_CreateAlias(ts, "cachesize");
5180 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
5182 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, NULL, "get cache usage info");
5184 ts = cmd_CreateSyntax("listcells", ListCellsCmd, NULL, "list configured cells");
5185 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
5187 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, "set volume quota");
5188 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
5189 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
5191 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
5193 cmd_CreateAlias(ts, "sq");
5195 ts = cmd_CreateSyntax("newcell", NewCellCmd, NULL, "configure new cell");
5196 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "cell name");
5197 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "primary servers");
5198 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
5201 * Turn this on only if you wish to be able to talk to a server which is listening
5202 * on alternative ports. This is not intended for general use and may not be
5203 * supported in the cache manager. It is not a way to run two servers at the
5204 * same host, since the cache manager cannot properly distinguish those two hosts.
5206 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
5207 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
5208 cmd_AddParm(ts, "-registry", CMD_FLAG, CMD_OPTIONAL, "add cell info to registry cellservdb");
5209 cmd_AddParm(ts, "-dns", CMD_FLAG, CMD_OPTIONAL, "force use of dns");
5212 ts = cmd_CreateSyntax("newalias", NewAliasCmd, NULL,
5213 "configure new cell alias");
5214 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
5215 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
5218 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, NULL, "list file's cell");
5219 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5220 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5222 ts = cmd_CreateSyntax("whereis", WhereIsCmd, NULL, "list file's location");
5223 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5224 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5226 ts = cmd_CreateSyntax("wscell", WSCellCmd, NULL, "list workstation's cell");
5229 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
5232 #ifndef AFS_NT40_ENV
5233 ts = cmd_CreateSyntax("monitor", MonitorCmd, NULL, "set cache monitor host address");
5234 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
5235 cmd_CreateAlias(ts, "mariner");
5238 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, NULL, "get cell status");
5239 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
5241 ts = cmd_CreateSyntax("setcell", SetCellCmd, NULL, "set cell status");
5242 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
5243 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
5244 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
5246 ts = cmd_CreateSyntax("flushall", FlushAllCmd, NULL, "flush all data");
5248 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, NULL, "flush all data in volume");
5249 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5251 ts = cmd_CreateSyntax("sysname", SysNameCmd, NULL, "get/set sysname (i.e. @sys) value");
5252 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
5254 #ifndef AFS_NT40_ENV
5255 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, NULL, "enable/disable translators to AFS");
5256 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
5257 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator ('on' or 'off')");
5258 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode ('on or 'off')");
5259 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode ('on' or 'off')");
5260 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. ('on' or 'off')");
5263 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, NULL,
5264 "store to server after file close");
5265 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
5266 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
5267 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
5268 cmd_CreateAlias(ts, "sb");
5270 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, NULL, "set cache manager encryption flag");
5271 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
5273 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, NULL, "get cache manager encryption flag");
5275 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, NULL,
5276 "Manage per process RX statistics");
5277 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
5278 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
5279 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
5281 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, NULL,
5282 "Manage per peer RX statistics");
5283 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
5284 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
5285 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
5288 ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, NULL, "configure callback connection address");
5289 cmd_AddParm(ts, "-addr", CMD_SINGLE, CMD_OPTIONAL, "host name or address");
5292 ts = cmd_CreateSyntax("trace", TraceCmd, NULL, "enable or disable CM tracing");
5293 cmd_AddParm(ts, "-on", CMD_FLAG, CMD_OPTIONAL, "enable tracing");
5294 cmd_AddParm(ts, "-off", CMD_FLAG, CMD_OPTIONAL, "disable tracing");
5295 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset log contents");
5296 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL, "dump log contents");
5297 cmd_CreateAlias(ts, "tr");
5299 ts = cmd_CreateSyntax("uuid", UuidCmd, NULL, "manage the UUID for the cache manager");
5300 cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_OPTIONAL, "generate a new UUID");
5302 ts = cmd_CreateSyntax("memdump", MemDumpCmd, NULL, "dump memory allocs in debug builds");
5303 cmd_AddParm(ts, "-begin", CMD_FLAG, CMD_OPTIONAL, "set a memory checkpoint");
5304 cmd_AddParm(ts, "-end", CMD_FLAG, CMD_OPTIONAL, "dump memory allocs");
5306 ts = cmd_CreateSyntax("cscpolicy", CSCPolicyCmd, NULL, "change client side caching policy for AFS shares");
5307 cmd_AddParm(ts, "-share", CMD_SINGLE, CMD_OPTIONAL, "AFS share");
5308 cmd_AddParm(ts, "-manual", CMD_FLAG, CMD_OPTIONAL, "manual caching of documents");
5309 cmd_AddParm(ts, "-programs", CMD_FLAG, CMD_OPTIONAL, "automatic caching of programs and documents");
5310 cmd_AddParm(ts, "-documents", CMD_FLAG, CMD_OPTIONAL, "automatic caching of documents");
5311 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "disable caching");
5313 ts = cmd_CreateSyntax("minidump", MiniDumpCmd, NULL, "Generate MiniDump of current service state");
5315 ts = cmd_CreateSyntax("test_volstat", TestVolStatCmd, NULL, (char *)CMD_HIDDEN);
5316 cmd_AddParm(ts, "-network", CMD_SINGLE, CMD_OPTIONAL, "set network state up or down");
5317 cmd_AddParm(ts, "-check", CMD_FLAG, CMD_OPTIONAL, "check state of offline volumes");
5318 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name or number");
5319 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or number");
5320 cmd_AddParm(ts, "-state", CMD_SINGLE, CMD_OPTIONAL, "new volume state: online, busy, offline, down");
5322 ts = cmd_CreateSyntax("smbunicode", SmbUnicodeCmd, NULL, "enable or disable Unicode on new SMB connections");
5323 cmd_AddParm(ts, "-on", CMD_FLAG, CMD_OPTIONAL, "enable Unicode on new connections");
5324 cmd_AddParm(ts, "-off", CMD_FLAG, CMD_OPTIONAL, "disable Unicode on new connections");
5326 ts = cmd_CreateSyntax("getfid", GetFidCmd, NULL, "get file id for object(s) in afs");
5327 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5328 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5330 ts = cmd_CreateSyntax("chown", ChOwnCmd, NULL, "set owner for object(s) in afs");
5331 cmd_AddParm(ts, "-owner", CMD_SINGLE, 0, "user name or id");
5332 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5333 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5335 ts = cmd_CreateSyntax("chgrp", ChGrpCmd, NULL, "set owner for object(s) in afs");
5336 cmd_AddParm(ts, "-group", CMD_SINGLE, 0, "user/group name or id");
5337 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5338 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5340 ts = cmd_CreateSyntax("chmod", ChModCmd, NULL, "set UNIX mode for object(s) in afs");
5341 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "UNIX mode bits");
5342 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
5343 cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
5345 code = cmd_Dispatch(argc, argv);
5350 fs_FreeUtf8CmdLine(argc, argv);