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/afs_args.h>
17 #include <sys/ioctl.h>
18 #include <sys/socket.h>
22 #include <netinet/in.h>
26 #include <afs/venus.h>
41 #include "afs/prs_fs.h"
42 #include <afs/afsint.h>
44 #include <afs/cellconfig.h>
47 #include <rx/rx_globals.h>
48 #include <afs/vldbint.h>
49 #include <afs/volser.h>
50 #include <afs/vlserver.h>
53 #include <afs/afsutil.h>
56 #include <afs/ptclient.h>
61 #define MAXCELLHOSTS 8
64 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
65 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
67 static char space[MAXSIZE];
68 static char tspace[1024];
69 static struct ubik_client *uclient;
71 static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
72 static int RxStatProcCmd(), RxStatPeerCmd();
74 extern char *hostutil_GetNameByINet();
75 extern struct hostent *hostutil_GetHostByName();
78 extern struct cmd_syndesc *cmd_CreateSyntax();
79 static char pn[] = "fs";
80 static int rxInitDone = 0;
82 static void ZapList();
83 static int PruneList();
91 * Character to use between name and rights in printed representation for
94 #define DFS_SEPARATOR ' '
96 typedef char sec_rgy_name_t[1025]; /* A DCE definition */
99 int dfs; /* Originally true if a dfs acl; now also the type
100 of the acl (1, 2, or 3, corresponding to object,
101 initial dir, or initial object). */
102 sec_rgy_name_t cell; /* DFS cell name */
105 struct AclEntry *pluslist;
106 struct AclEntry *minuslist;
110 struct AclEntry *next;
115 static void ZapAcl(acl)
119 ZapList(acl->pluslist);
120 ZapList(acl->minuslist);
132 if (t >= 'A' && t <= 'Z') t += 0x20;
133 if (u >= 'A' && u <= 'Z') u += 0x20;
134 if (t != u) return 1;
135 if (t == 0) return 0;
140 * Mods for the AFS/DFS protocol translator.
142 * DFS rights. It's ugly to put these definitions here, but they
143 * *cannot* change, because they're part of the wire protocol.
144 * In any event, the protocol translator will guarantee these
145 * assignments for AFS cache managers.
147 #define DFS_READ 0x01
148 #define DFS_WRITE 0x02
149 #define DFS_EXECUTE 0x04
150 #define DFS_CONTROL 0x08
151 #define DFS_INSERT 0x10
152 #define DFS_DELETE 0x20
154 /* the application definable ones (backwards from AFS) */
155 #define DFS_USR0 0x80000000 /* "A" bit */
156 #define DFS_USR1 0x40000000 /* "B" bit */
157 #define DFS_USR2 0x20000000 /* "C" bit */
158 #define DFS_USR3 0x10000000 /* "D" bit */
159 #define DFS_USR4 0x08000000 /* "E" bit */
160 #define DFS_USR5 0x04000000 /* "F" bit */
161 #define DFS_USR6 0x02000000 /* "G" bit */
162 #define DFS_USR7 0x01000000 /* "H" bit */
163 #define DFS_USRALL (DFS_USR0 | DFS_USR1 | DFS_USR2 | DFS_USR3 |\
164 DFS_USR4 | DFS_USR5 | DFS_USR6 | DFS_USR7)
167 * Offset of -id switch in command structure for various commands.
168 * The -if switch is the next switch always.
170 static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
173 * Determine whether either the -id or -if switches are present, and
174 * return 0, 1 or 2, as appropriate. Abort if both switches are present.
176 static int getidf(as, id)
177 struct cmd_syndesc *as;
178 int id; /* Offset of -id switch; -if is next switch */
182 if (as->parms[id].items) {
185 if (as->parms[id + 1].items) {
191 "%s: you may specify either -id or -if, but not both switches\n",
198 static int PRights(arights, dfs)
203 if (arights & PRSFS_READ) printf("r");
204 if (arights & PRSFS_LOOKUP) printf("l");
205 if (arights & PRSFS_INSERT) printf("i");
206 if (arights & PRSFS_DELETE) printf("d");
207 if (arights & PRSFS_WRITE) printf("w");
208 if (arights & PRSFS_LOCK) printf("k");
209 if (arights & PRSFS_ADMINISTER) printf("a");
210 if (arights & PRSFS_USR0) printf("A");
211 if (arights & PRSFS_USR1) printf("B");
212 if (arights & PRSFS_USR2) printf("C");
213 if (arights & PRSFS_USR3) printf("D");
214 if (arights & PRSFS_USR4) printf("E");
215 if (arights & PRSFS_USR5) printf("F");
216 if (arights & PRSFS_USR6) printf("G");
217 if (arights & PRSFS_USR7) printf("H");
219 if (arights & DFS_READ) printf("r"); else printf("-");
220 if (arights & DFS_WRITE) printf("w"); else printf("-");
221 if (arights & DFS_EXECUTE) printf("x"); else printf("-");
222 if (arights & DFS_CONTROL) printf("c"); else printf("-");
223 if (arights & DFS_INSERT) printf("i"); else printf("-");
224 if (arights & DFS_DELETE) printf("d"); else printf("-");
225 if (arights & (DFS_USRALL)) printf("+");
226 if (arights & DFS_USR0) printf("A");
227 if (arights & DFS_USR1) printf("B");
228 if (arights & DFS_USR2) printf("C");
229 if (arights & DFS_USR3) printf("D");
230 if (arights & DFS_USR4) printf("E");
231 if (arights & DFS_USR5) printf("F");
232 if (arights & DFS_USR6) printf("G");
233 if (arights & DFS_USR7) printf("H");
237 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
238 static int InAFS(apath)
241 struct ViceIoctl blob;
245 blob.out_size = MAXSIZE;
248 code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
250 if ((errno == EINVAL) || (errno == ENOENT)) return 0;
255 /* return a static pointer to a buffer */
256 static char *Parent(apath)
260 strcpy(tspace, apath);
261 tp = strrchr(tspace, '/');
265 else strcpy(tspace, ".");
269 enum rtype {add, destroy, deny};
271 static afs_int32 Convert(arights, dfs, rtypep)
280 *rtypep = add; /* add rights, by default */
283 if (!strcmp(arights, "null")) {
287 if (!strcmp(arights,"read")) return DFS_READ | DFS_EXECUTE;
288 if (!strcmp(arights, "write")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE;
289 if (!strcmp(arights, "all")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE | DFS_CONTROL;
291 if (!strcmp(arights,"read")) return PRSFS_READ | PRSFS_LOOKUP;
292 if (!strcmp(arights, "write")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
293 if (!strcmp(arights, "mail")) return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
294 if (!strcmp(arights, "all")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
296 if (!strcmp(arights, "none")) {
297 *rtypep = destroy; /* Remove entire entry */
300 len = strlen(arights);
305 if (tc == '-') continue;
306 else if (tc == 'r') mode |= DFS_READ;
307 else if (tc == 'w') mode |= DFS_WRITE;
308 else if (tc == 'x') mode |= DFS_EXECUTE;
309 else if (tc == 'c') mode |= DFS_CONTROL;
310 else if (tc == 'i') mode |= DFS_INSERT;
311 else if (tc == 'd') mode |= DFS_DELETE;
312 else if (tc == 'A') mode |= DFS_USR0;
313 else if (tc == 'B') mode |= DFS_USR1;
314 else if (tc == 'C') mode |= DFS_USR2;
315 else if (tc == 'D') mode |= DFS_USR3;
316 else if (tc == 'E') mode |= DFS_USR4;
317 else if (tc == 'F') mode |= DFS_USR5;
318 else if (tc == 'G') mode |= DFS_USR6;
319 else if (tc == 'H') mode |= DFS_USR7;
321 fprintf(stderr, "%s: illegal DFS rights character '%c'.\n", pn, tc);
325 if (tc == 'r') mode |= PRSFS_READ;
326 else if (tc == 'l') mode |= PRSFS_LOOKUP;
327 else if (tc == 'i') mode |= PRSFS_INSERT;
328 else if (tc == 'd') mode |= PRSFS_DELETE;
329 else if (tc == 'w') mode |= PRSFS_WRITE;
330 else if (tc == 'k') mode |= PRSFS_LOCK;
331 else if (tc == 'a') mode |= PRSFS_ADMINISTER;
332 else if (tc == 'A') mode |= PRSFS_USR0;
333 else if (tc == 'B') mode |= PRSFS_USR1;
334 else if (tc == 'C') mode |= PRSFS_USR2;
335 else if (tc == 'D') mode |= PRSFS_USR3;
336 else if (tc == 'E') mode |= PRSFS_USR4;
337 else if (tc == 'F') mode |= PRSFS_USR5;
338 else if (tc == 'G') mode |= PRSFS_USR6;
339 else if (tc == 'H') mode |= PRSFS_USR7;
341 fprintf(stderr, "%s: illegal rights character '%c'.\n", pn, tc);
349 static struct AclEntry *FindList(alist, aname)
350 struct AclEntry *alist;
354 if (!foldcmp(alist->name, aname)) return alist;
360 /* if no parm specified in a particular slot, set parm to be "." instead */
361 static void SetDotDefault(aitemp)
362 struct cmd_item **aitemp;
365 if (*aitemp) return; /* already has value */
366 /* otherwise, allocate an item representing "." */
367 ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
369 ti->next = (struct cmd_item *) 0;
370 ti->data = (char *) malloc(2);
372 strcpy(ti->data, ".");
376 static void ChangeList(al, plus, aname, arights)
382 struct AclEntry *tlist;
383 tlist = (plus ? al->pluslist : al->minuslist);
384 tlist = FindList (tlist, aname);
386 /* Found the item already in the list. */
387 tlist->rights = arights;
389 al->nplus -= PruneList(&al->pluslist, al->dfs);
391 al->nminus -= PruneList(&al->minuslist, al->dfs);
394 /* Otherwise we make a new item and plug in the new data. */
395 tlist = (struct AclEntry *) malloc(sizeof (struct AclEntry));
397 strcpy(tlist->name, aname);
398 tlist->rights = arights;
400 tlist->next = al->pluslist;
401 al->pluslist = tlist;
403 if (arights == 0 || arights == -1)
404 al->nplus -= PruneList(&al->pluslist, al->dfs);
407 tlist->next = al->minuslist;
408 al->minuslist = tlist;
410 if (arights == 0) al->nminus -= PruneList(&al->minuslist, al->dfs);
414 static void ZapList(alist)
415 struct AclEntry *alist;
417 struct AclEntry *tp, *np;
418 for (tp = alist; tp; tp = np) {
424 static int PruneList(ae, dfs)
425 struct AclEntry **ae;
428 struct AclEntry **lp;
429 struct AclEntry *te, *ne;
433 for(te = *ae;te;te=ne) {
434 if ((!dfs && te->rights == 0) || te->rights == -1) {
448 static char *SkipLine(astr)
451 while (*astr !='\n') astr++;
457 * Create an empty acl, taking into account whether the acl pointed
458 * to by astr is an AFS or DFS acl. Only parse this minimally, so we
459 * can recover from problems caused by bogus ACL's (in that case, always
460 * assume that the acl is AFS: for DFS, the user can always resort to
461 * acl_edit, but for AFS there may be no other way out).
463 static struct Acl *EmptyAcl(astr)
469 tp = (struct Acl *)malloc(sizeof (struct Acl));
471 tp->nplus = tp->nminus = 0;
472 tp->pluslist = tp->minuslist = 0;
474 sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
478 static struct Acl *ParseAcl(astr)
481 int nplus, nminus, i, trights;
483 struct AclEntry *first, *last, *tl;
486 ta = (struct Acl *) malloc (sizeof (struct Acl));
489 sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
490 astr = SkipLine(astr);
491 sscanf(astr, "%d", &ta->nminus);
492 astr = SkipLine(astr);
499 for(i=0;i<nplus;i++) {
500 sscanf(astr, "%100s %d", tname, &trights);
501 astr = SkipLine(astr);
502 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
504 if (!first) first = tl;
505 strcpy(tl->name, tname);
506 tl->rights = trights;
508 if (last) last->next = tl;
511 ta->pluslist = first;
515 for(i=0;i<nminus;i++) {
516 sscanf(astr, "%100s %d", tname, &trights);
517 astr = SkipLine(astr);
518 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
520 if (!first) first = tl;
521 strcpy(tl->name, tname);
522 tl->rights = trights;
524 if (last) last->next = tl;
527 ta->minuslist = first;
532 static PrintStatus(status, name, offmsg)
533 VolumeStatus *status;
537 printf("Volume status for vid = %u named %s\n",status->Vid, name);
539 printf("Current offline message is %s\n",offmsg);
540 printf("Current disk quota is ");
541 if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota);
542 else printf("unlimited\n");
543 printf("Current blocks used are %d\n",status->BlocksInUse);
544 printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
547 static QuickPrintStatus(status, name)
548 VolumeStatus *status;
551 double QuotaUsed =0.0;
552 double PartUsed =0.0;
554 printf("%-25.25s",name);
556 if (status->MaxQuota != 0) {
557 printf("%10d%10d", status->MaxQuota, status->BlocksInUse);
558 QuotaUsed = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
560 printf(" no limit%10d", status->BlocksInUse);
562 if (QuotaUsed > 90.0) {
563 printf("%5.0f%%<<", QuotaUsed);
566 else printf("%5.0f%% ", QuotaUsed);
567 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
568 if (PartUsed > 97.0) {
569 printf("%9.0f%%<<", PartUsed);
572 else printf("%9.0f%% ", PartUsed);
574 printf(" <<WARNING\n");
579 static QuickPrintSpace(status, name)
580 VolumeStatus *status;
583 double PartUsed =0.0;
585 printf("%-25.25s",name);
587 printf("%10d%10d%10d", status->PartMaxBlocks, status->PartMaxBlocks - status->PartBlocksAvail, status->PartBlocksAvail);
589 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
590 if (PartUsed > 90.0){
591 printf(" %4.0f%%<<", PartUsed);
594 else printf(" %4.0f%% ", PartUsed);
596 printf(" <<WARNING\n");
601 static char *AclToString(acl)
604 static char mydata[MAXSIZE];
605 char tstring[MAXSIZE];
609 if (acl->dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
610 else dfsstring[0] = '\0';
611 sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
612 for(tp = acl->pluslist;tp;tp=tp->next) {
613 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
614 strcat(mydata, tstring);
616 for(tp = acl->minuslist;tp;tp=tp->next) {
617 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
618 strcat(mydata, tstring);
624 struct cmd_syndesc *as;
627 struct ViceIoctl blob;
629 struct cmd_item *ti, *ui;
633 int idf = getidf(as, parm_setacl_id);
636 if (as->parms[2].items) clear=1;
638 plusp = !(as->parms[3].items);
639 for(ti=as->parms[0].items; ti;ti=ti->next) {
640 blob.out_size = MAXSIZE;
642 blob.in = blob.out = space;
643 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
645 Die(errno, ti->data);
651 ta = ParseAcl(space);
652 if (!plusp && ta->dfs) {
654 "%s: %s: you may not use the -negative switch with DFS acl's.\n%s",
656 "(you may specify \"null\" to revoke all rights, however)\n");
662 if (clear) ta = EmptyAcl(space);
663 else ta = ParseAcl(space);
664 CleanAcl(ta, ti->data);
665 for(ui=as->parms[1].items; ui; ui=ui->next->next) {
668 fprintf(stderr, "%s: Missing second half of user/access pair.\n", pn);
672 rights = Convert(ui->next->data, ta->dfs, &rtype);
673 if (rtype == destroy && !ta->dfs) {
674 struct AclEntry *tlist;
676 tlist = (plusp ? ta->pluslist : ta->minuslist);
677 if (!FindList(tlist, ui->data))
680 if (rtype == deny && !ta->dfs) plusp = 0;
681 if (rtype == destroy && ta->dfs) rights = -1;
682 ChangeList(ta, plusp, ui->data, rights);
684 blob.in = AclToString(ta);
686 blob.in_size = 1+strlen(blob.in);
687 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
689 if (errno == EINVAL) {
691 static char *fsenv = 0;
693 fsenv = (char *)getenv("FS_EXPERT");
695 fprintf(stderr, "%s: \"Invalid argument\" was returned when you tried to store a DFS access list.\n", pn);
698 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
699 "\nPossible reasons for this include:\n\n",
700 " -You may have specified an inappropriate combination of rights.\n",
701 " For example, some DFS-supported filesystems may not allow you to\n",
702 " drop the \"c\" right from \"user_obj\".\n\n",
703 " -A mask_obj may be required (it is likely required by the underlying\n",
704 " filesystem if you try to set anything other than the basic \"user_obj\"\n",
705 " \"mask_obj\", or \"group_obj\" entries). Unlike acl_edit, the fs command\n",
706 " does not automatically create or update the mask_obj. Try setting\n",
707 " the rights \"mask_obj all\" with \"fs sa\" before adding any explicit\n",
708 " users or groups. You can do this with a single command, such as\n",
709 " \"fs sa mask_obj all user:somename read\"\n\n",
710 " -A specified user or group may not exist.\n\n",
711 " -You may have tried to delete \"user_obj\", \"group_obj\", or \"other_obj\".\n",
712 " This is probably not allowed by the underlying file system.\n\n",
713 " -If you add a user or group to a DFS ACL, remember that it must be\n",
714 " fully specified as \"user:username\" or \"group:groupname\". In addition, there\n",
715 " may be local requirements on the format of the user or group name.\n",
716 " Check with your cell administrator.\n\n",
717 " -Or numerous other possibilities. It would be great if we could be more\n",
718 " precise about the actual problem, but for various reasons, this is\n",
719 " impractical via this interface. If you can't figure it out, you\n",
720 " might try logging into a DCE-equipped machine and use acl_edit (or\n",
721 " whatever is provided). You may get better results. Good luck!\n\n",
722 " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
725 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
726 fprintf(stderr, "\t-File not in AFS\n");
727 fprintf(stderr, "\t-Too many users on access control list\n");
728 fprintf(stderr, "\t-Tried to add non-existent user to access control list\n");
732 Die(errno, ti->data);
742 static CopyACLCmd(as)
743 struct cmd_syndesc *as;
746 struct ViceIoctl blob;
747 struct Acl *fa, *ta = 0;
749 struct cmd_item *ti, *ui;
753 int idf = getidf(as, parm_copyacl_id);
756 if (as->parms[2].items) clear=1;
758 blob.out_size = MAXSIZE;
760 blob.in = blob.out = space;
761 code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
763 Die(errno, as->parms[0].items->data);
766 fa = ParseAcl(space);
767 CleanAcl(fa, as->parms[0].items->data);
768 for (ti=as->parms[1].items; ti;ti=ti->next) {
769 blob.out_size = MAXSIZE;
771 blob.in = blob.out = space;
772 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
774 Die(errno, ti->data);
780 if (clear) ta = EmptyAcl(space);
781 else ta = ParseAcl(space);
782 CleanAcl(ta, ti->data);
783 if (ta->dfs != fa->dfs) {
784 fprintf(stderr, "%s: incompatible file system types: acl not copied to %s; aborted\n", pn, ti->data);
789 if (! clear && strcmp(ta->cell, fa->cell) != 0) {
790 fprintf(stderr, "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", pn, ti->data);
794 strcpy(ta->cell, fa->cell);
796 for (tp = fa->pluslist;tp;tp=tp->next)
797 ChangeList(ta, 1, tp->name, tp->rights);
798 for (tp = fa->minuslist;tp;tp=tp->next)
799 ChangeList(ta, 0, tp->name, tp->rights);
800 blob.in = AclToString(ta);
802 blob.in_size = 1+strlen(blob.in);
803 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
805 if (errno == EINVAL) {
806 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
807 fprintf(stderr, "\t-File not in AFS\n");
810 Die(errno, ti->data);
820 /* pioctl() call to get the cellname of a pathname */
821 static afs_int32 GetCell(fname, cellname)
822 char *fname, *cellname;
825 struct ViceIoctl blob;
828 blob.out_size = MAXCELLCHARS;
831 code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
832 return code ? errno : 0;
835 /* Check if a username is valid: If it contains only digits (or a
836 * negative sign), then it might be bad. We then query the ptserver
839 static BadName(aname, fname)
842 afs_int32 tc, code, id;
844 char cell[MAXCELLCHARS];
846 for (nm=aname; tc=*nm; nm++) {
847 /* all must be '-' or digit to be bad */
848 if (tc != '-' && (tc < '0' || tc > '9')) return 0;
851 /* Go to the PRDB and see if this all number username is valid */
852 code = GetCell(fname, cell);
855 pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
856 code = pr_SNameToId(aname, &id);
859 /* 1=>Not-valid; 0=>Valid */
860 return ((!code && (id==ANONYMOUSID)) ? 1 : 0);
864 /* clean up an access control list of its bad entries; return 1 if we made
865 any changes to the list, and 0 otherwise */
866 static CleanAcl(aa, fname)
868 char *fname; /* The file name */
870 struct AclEntry *te, **le, *ne;
873 /* Don't correct DFS ACL's for now */
877 /* prune out bad entries */
878 changes = 0; /* count deleted entries */
880 for(te = aa->pluslist; te; te=ne) {
882 if (BadName(te->name,fname)) {
894 for(te = aa->minuslist; te; te=ne) {
896 if (BadName(te->name,fname)) {
911 /* clean up an acl to not have bogus entries */
912 static CleanACLCmd(as)
913 struct cmd_syndesc *as;
917 struct ViceIoctl blob;
923 SetDotDefault(&as->parms[0].items);
924 for(ti=as->parms[0].items; ti; ti=ti->next) {
925 blob.out_size = MAXSIZE;
928 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
930 Die(errno, ti->data);
936 ta = ParseAcl(space);
939 "%s: cleanacl is not supported for DFS access lists.\n",
945 changes = CleanAcl(ta, ti->data);
948 /* now set the acl */
949 blob.in=AclToString(ta);
950 blob.in_size = strlen(blob.in)+1;
952 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
954 if (errno == EINVAL) {
955 fprintf(stderr, "%s: Invalid argument, possible reasons include\n", pn);
956 fprintf(stderr, "%s: File not in vice or\n", pn);
957 fprintf(stderr, "%s: Too many users on access control list or\n", pn);
960 Die(errno, ti->data);
966 /* now list the updated acl */
967 printf("Access list for %s is now\n", ti->data);
969 if (!ta->dfs) printf("Normal rights:\n");
970 for(te = ta->pluslist;te;te=te->next) {
971 printf(" %s ", te->name);
972 PRights(te->rights, ta->dfs);
976 if (ta->nminus > 0) {
977 printf("Negative rights:\n");
978 for(te = ta->minuslist;te;te=te->next) {
979 printf(" %s ", te->name);
980 PRights(te->rights, ta->dfs);
984 if (ti->next) printf("\n");
987 printf("Access list for %s is fine.\n", ti->data);
993 static ListACLCmd(as)
994 struct cmd_syndesc *as;
998 struct ViceIoctl blob;
1000 struct cmd_item *ti;
1001 int idf = getidf(as, parm_listacl_id);
1004 SetDotDefault(&as->parms[0].items);
1005 for(ti=as->parms[0].items; ti; ti=ti->next) {
1006 blob.out_size = MAXSIZE;
1008 blob.in = blob.out = space;
1009 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
1011 Die(errno, ti->data);
1015 ta = ParseAcl(space);
1018 printf("Access list for %s is\n", ti->data);
1021 printf("DFS access list for %s is\n", ti->data);
1024 printf("DFS initial directory access list of %s is\n", ti->data);
1027 printf("DFS initial file access list of %s is\n", ti->data);
1031 printf(" Default cell = %s\n", ta->cell);
1033 if (ta->nplus > 0) {
1034 if (!ta->dfs) printf("Normal rights:\n");
1035 for(te = ta->pluslist;te;te=te->next) {
1036 printf(" %s ", te->name);
1037 PRights(te->rights, ta->dfs);
1041 if (ta->nminus > 0) {
1042 printf("Negative rights:\n");
1043 for(te = ta->minuslist;te;te=te->next) {
1044 printf(" %s ", te->name);
1045 PRights(te->rights, ta->dfs);
1049 if (ti->next) printf("\n");
1055 static FlushVolumeCmd(as)
1056 struct cmd_syndesc *as;
1059 struct ViceIoctl blob;
1060 struct cmd_item *ti;
1063 SetDotDefault(&as->parms[0].items);
1064 for(ti=as->parms[0].items; ti; ti=ti->next) {
1065 blob.in_size = blob.out_size = 0;
1066 code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
1068 fprintf(stderr, "Error flushing volume ");
1078 struct cmd_syndesc *as;
1081 struct ViceIoctl blob;
1082 struct cmd_item *ti;
1085 for(ti=as->parms[0].items; ti; ti=ti->next) {
1086 blob.in_size = blob.out_size = 0;
1087 code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
1089 if (errno == EMFILE) {
1090 fprintf(stderr, "%s: Can't flush active file %s\n", pn, ti->data);
1093 fprintf(stderr, "%s: Error flushing file ", pn);
1103 /* all this command does is repackage its args and call SetVolCmd */
1104 static SetQuotaCmd(as)
1105 struct cmd_syndesc *as;
1107 struct cmd_syndesc ts;
1109 /* copy useful stuff from our command slot; we may later have to reorder */
1110 memcpy(&ts, as, sizeof(ts)); /* copy whole thing */
1111 return SetVolCmd(&ts);
1114 static SetVolCmd(as)
1115 struct cmd_syndesc *as;
1118 struct ViceIoctl blob;
1119 struct cmd_item *ti;
1120 struct VolumeStatus *status;
1121 char *offmsg, *input;
1124 SetDotDefault(&as->parms[0].items);
1125 for(ti=as->parms[0].items; ti; ti=ti->next) {
1127 blob.out_size = MAXSIZE;
1128 blob.in_size = sizeof(*status) + 3; /* for the three terminating nulls */
1131 status = (VolumeStatus *)space;
1132 status->MinQuota = status->MaxQuota = -1;
1134 if (as->parms[1].items) {
1135 code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
1137 fprintf(stderr, "%s: bad integer specified for quota.\n", pn);
1142 if (as->parms[2].items) offmsg = as->parms[2].items->data;
1143 input = (char *)status + sizeof(*status);
1144 *(input++) = '\0'; /* never set name: this call doesn't change vldb */
1146 if (strlen(offmsg) >= VMSGSIZE) {
1147 fprintf(stderr, "%s: message must be shorter than %d characters\n",
1152 strcpy(input,offmsg);
1153 blob.in_size += strlen(offmsg);
1154 input += strlen(offmsg) + 1;
1156 else *(input++) = '\0';
1157 *(input++) = '\0'; /* Pad for old style volume "motd" */
1158 code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
1160 Die(errno, ti->data);
1167 static ExamineCmd(as)
1168 struct cmd_syndesc *as;
1171 struct ViceIoctl blob;
1172 struct cmd_item *ti;
1173 struct VolumeStatus *status;
1174 char *name, *offmsg;
1177 SetDotDefault(&as->parms[0].items);
1178 for(ti=as->parms[0].items; ti; ti=ti->next) {
1180 blob.out_size = MAXSIZE;
1183 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1185 Die(errno, ti->data);
1189 status = (VolumeStatus *)space;
1190 name = (char *)status + sizeof(*status);
1191 offmsg = name + strlen(name) + 1;
1192 PrintStatus(status, name, offmsg);
1197 static ListQuotaCmd(as)
1198 struct cmd_syndesc *as;
1201 struct ViceIoctl blob;
1202 struct cmd_item *ti;
1203 struct VolumeStatus *status;
1207 printf("%-25s%-10s%-10s%-7s%-11s\n",
1208 "Volume Name"," Quota", " Used", " %Used", " Partition");
1209 SetDotDefault(&as->parms[0].items);
1210 for(ti=as->parms[0].items; ti; ti=ti->next) {
1212 blob.out_size = MAXSIZE;
1215 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1217 Die(errno, ti->data);
1221 status = (VolumeStatus *)space;
1222 name = (char *)status + sizeof(*status);
1223 QuickPrintStatus(status, name);
1228 static WhereIsCmd(as)
1229 struct cmd_syndesc *as;
1232 struct ViceIoctl blob;
1233 struct cmd_item *ti;
1239 SetDotDefault(&as->parms[0].items);
1240 for(ti=as->parms[0].items; ti; ti=ti->next) {
1242 blob.out_size = MAXSIZE;
1245 memset(space, 0, sizeof(space));
1246 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
1248 Die(errno, ti->data);
1252 hosts = (afs_int32 *) space;
1253 printf("File %s is on host%s ", ti->data, (hosts[0] && !hosts[1]) ? "": "s");
1254 for(j=0; j<MAXHOSTS; j++) {
1255 if (hosts[j] == 0) break;
1256 tp = hostutil_GetNameByINet(hosts[j]);
1265 static DiskFreeCmd(as)
1266 struct cmd_syndesc *as;
1269 struct ViceIoctl blob;
1270 struct cmd_item *ti;
1272 struct VolumeStatus *status;
1275 printf("%-25s%-10s%-10s%-10s%-6s\n",
1276 "Volume Name"," kbytes", " used", " avail", " %used");
1277 SetDotDefault(&as->parms[0].items);
1278 for(ti=as->parms[0].items; ti; ti=ti->next) {
1280 blob.out_size = MAXSIZE;
1283 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1285 Die(errno, ti->data);
1289 status = (VolumeStatus *)space;
1290 name = (char *)status + sizeof(*status);
1291 QuickPrintSpace(status, name);
1297 struct cmd_syndesc *as;
1300 struct ViceIoctl blob;
1301 struct cmd_item *ti;
1303 struct VolumeStatus *status;
1306 SetDotDefault(&as->parms[0].items);
1307 for(ti=as->parms[0].items; ti; ti=ti->next) {
1309 blob.out_size = MAXSIZE;
1312 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1314 Die(errno, ti->data);
1318 status = (VolumeStatus *)space;
1319 if (status->MaxQuota) quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
1320 else quotaPct = 0.0;
1321 printf("%2.0f%% of quota used.\n", quotaPct);
1326 static ListMountCmd(as)
1327 struct cmd_syndesc *as;
1330 struct ViceIoctl blob;
1331 struct cmd_item *ti;
1332 char orig_name[1024]; /*Original name, may be modified*/
1333 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
1334 char parent_dir[1024]; /*Parent directory of true name*/
1335 char *last_component; /*Last component of true name*/
1336 struct stat statbuff; /*Buffer for status info*/
1337 int link_chars_read; /*Num chars read in readlink()*/
1338 int thru_symlink; /*Did we get to a mount point via a symlink?*/
1341 for(ti=as->parms[0].items; ti; ti=ti->next) {
1344 sprintf(orig_name, "%s%s",
1345 (ti->data[0] == '/') ? "" : "./",
1348 if (lstat(orig_name, &statbuff) < 0) {
1349 /* if lstat fails, we should still try the pioctl, since it
1350 may work (for example, lstat will fail, but pioctl will
1351 work if the volume of offline (returning ENODEV). */
1352 statbuff.st_mode = S_IFDIR; /* lie like pros */
1356 * The lstat succeeded. If the given file is a symlink, substitute
1357 * the file name with the link name.
1359 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
1362 * Read name of resolved file.
1364 link_chars_read = readlink(orig_name, true_name, 1024);
1365 if (link_chars_read <= 0) {
1366 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
1373 * Add a trailing null to what was read, bump the length.
1375 true_name[link_chars_read++] = 0;
1378 * If the symlink is an absolute pathname, we're fine. Otherwise, we
1379 * have to create a full pathname using the original name and the
1380 * relative symlink name. Find the rightmost slash in the original
1381 * name (we know there is one) and splice in the symlink value.
1383 if (true_name[0] != '/') {
1384 last_component = (char *) strrchr(orig_name, '/');
1385 strcpy(++last_component, true_name);
1386 strcpy(true_name, orig_name);
1390 strcpy(true_name, orig_name);
1393 * Find rightmost slash, if any.
1395 last_component = (char *) strrchr(true_name, '/');
1396 if (last_component) {
1398 * Found it. Designate everything before it as the parent directory,
1399 * everything after it as the final component.
1401 strncpy(parent_dir, true_name, last_component - true_name);
1402 parent_dir[last_component - true_name] = 0;
1403 last_component++; /*Skip the slash*/
1407 * No slash appears in the given file name. Set parent_dir to the current
1408 * directory, and the last component as the given name.
1410 strcpy(parent_dir, ".");
1411 last_component = true_name;
1414 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
1415 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
1416 fprintf(stderr, "%s: of a name in the 'fs lsmount' command.\n", pn);
1421 blob.in = last_component;
1422 blob.in_size = strlen(last_component)+1;
1423 blob.out_size = MAXSIZE;
1425 memset(space, 0, MAXSIZE);
1427 code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
1430 printf("'%s' is a %smount point for volume '%s'\n",
1432 (thru_symlink ? "symbolic link, leading to a " : ""),
1436 if (errno == EINVAL) {
1437 fprintf(stderr, "'%s' is not a mount point.\n",
1441 Die(errno, (ti->data ? ti->data : parent_dir));
1449 static MakeMountCmd(as)
1450 struct cmd_syndesc *as;
1453 char *cellName, *volName, *tmpName;
1454 struct afsconf_cell info;
1455 struct vldbentry vldbEntry;
1456 struct ViceIoctl blob;
1462 if (as->parms[5].items && !as->parms[2].items) {
1463 fprintf(stderr, "%s: must provide cell when creating cellular mount point.\n", pn);
1468 if (as->parms[2].items) /* cell name specified */
1469 cellName = as->parms[2].items->data;
1472 volName = as->parms[1].items->data;
1474 if (strlen(volName) >= 64) {
1475 fprintf(stderr, "%s: volume name too long (length must be < 64 characters)\n", pn);
1479 /* Check for a cellname in the volume specification, and complain
1480 * if it doesn't match what was specified with -cell */
1481 if (tmpName = strchr(volName, ':')) {
1484 if (strcasecmp(cellName,volName)) {
1485 fprintf(stderr, "%s: cellnames do not match.\n", pn);
1490 volName = ++tmpName;
1493 if (!InAFS(Parent(as->parms[0].items->data))) {
1494 fprintf(stderr, "%s: mount points must be created within the AFS file system\n", pn);
1500 blob.out_size = MAXSIZE;
1502 code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME, &blob, 1);
1505 code = GetCellName(cellName?cellName:space, &info);
1509 if (!(as->parms[4].items)) {
1510 /* not fast, check which cell the mountpoint is being created in */
1511 /* not fast, check name with VLDB */
1512 code = VLDBInit(1, &info);
1514 /* make the check. Don't complain if there are problems with init */
1515 code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
1516 if (code == VL_NOENT) {
1517 fprintf(stderr, "%s: warning, volume %s does not exist in cell %s.\n",
1518 pn, volName, cellName ? cellName : space);
1523 if (as->parms[3].items) /* if -rw specified */
1528 /* cellular mount point, prepend cell prefix */
1529 strcat(space, info.name);
1532 strcat(space, volName); /* append volume name */
1533 strcat(space, "."); /* stupid convention; these end with a period */
1534 code = symlink(space, as->parms[0].items->data);
1536 Die(errno, as->parms[0].items->data);
1543 * Delete AFS mount points. Variables are used as follows:
1544 * tbuffer: Set to point to the null-terminated directory name of the mount point
1545 * (or ``.'' if none is provided)
1546 * tp: Set to point to the actual name of the mount point to nuke.
1548 static RemoveMountCmd(as)
1549 struct cmd_syndesc *as;
1552 struct ViceIoctl blob;
1553 struct cmd_item *ti;
1555 char lsbuffer[1024];
1559 for(ti=as->parms[0].items; ti; ti=ti->next) {
1561 tp = (char *) strrchr(ti->data, '/');
1563 strncpy(tbuffer, ti->data, code=tp-ti->data); /* the dir name */
1565 tp++; /* skip the slash */
1568 strcpy(tbuffer, ".");
1572 blob.in_size = strlen(tp)+1;
1573 blob.out = lsbuffer;
1574 blob.out_size = sizeof(lsbuffer);
1575 code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
1577 if (errno == EINVAL) {
1578 fprintf(stderr, "%s: '%s' is not a mount point.\n", pn, ti->data);
1581 Die(errno, ti->data);
1584 continue; /* don't bother trying */
1588 blob.in_size = strlen(tp)+1;
1589 code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
1591 Die(errno, ti->data);
1601 static CheckServersCmd(as)
1602 struct cmd_syndesc *as;
1605 struct ViceIoctl blob;
1611 struct afsconf_cell info;
1612 struct chservinfo checkserv;
1614 memset(&checkserv, 0, sizeof(struct chservinfo));
1615 blob.in_size=sizeof(struct chservinfo);
1616 blob.in=(caddr_t)&checkserv;
1618 blob.out_size = MAXSIZE;
1620 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1622 /* prepare flags for checkservers command */
1623 temp = 2; /* default to checking local cell only */
1624 if (as->parms[2].items) temp |= 1; /* set fast flag */
1625 if (as->parms[1].items) temp &= ~2; /* turn off local cell check */
1627 checkserv.magic = 0x12345678; /* XXX */
1628 checkserv.tflags=temp;
1630 /* now copy in optional cell name, if specified */
1631 if (as->parms[0].items) {
1632 code = GetCellName(as->parms[0].items->data, &info);
1636 strcpy(checkserv.tbuffer,info.name);
1637 checkserv.tsize=strlen(info.name)+1;
1640 strcpy(checkserv.tbuffer,"\0");
1644 if(as->parms[3].items) {
1645 checkserv.tinterval=atol(as->parms[3].items->data);
1648 if(checkserv.tinterval<0) {
1649 printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
1650 checkserv.tinterval=0;
1652 else if(checkserv.tinterval> 600) {
1653 printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
1654 checkserv.tinterval=600; /* 10 min max interval */
1658 checkserv.tinterval = -1; /* don't change current interval */
1661 code = pioctl(0, VIOCCKSERV, &blob, 1);
1663 if ((errno == EACCES) && (checkserv.tinterval > 0)) {
1664 printf("Must be root to change -interval\n");
1670 memcpy(&temp, space, sizeof(afs_int32));
1671 if (checkserv.tinterval >= 0) {
1672 if (checkserv.tinterval > 0)
1673 printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
1674 checkserv.tinterval, temp);
1676 printf("The current down server probe interval is %d secs\n", temp);
1680 printf("All servers are running.\n");
1683 printf("These servers unavailable due to network or server problems: ");
1685 memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
1686 if (temp == 0) break;
1687 tp = hostutil_GetNameByINet(temp);
1696 static MessagesCmd(as)
1697 struct cmd_syndesc *as;
1700 struct ViceIoctl blob;
1703 struct gaginfo gagflags;
1704 struct cmd_item *show;
1706 memset(&gagflags, 0, sizeof(struct gaginfo));
1707 blob.in_size = sizeof(struct gaginfo);
1708 blob.in = (caddr_t) &gagflags;
1709 blob.out_size = MAXSIZE;
1711 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1713 if (show = as->parms[0].items) {
1714 if (!strcasecmp (show->data, "user"))
1715 gagflags.showflags |= GAGUSER;
1716 else if (!strcasecmp (show->data, "console"))
1717 gagflags.showflags |= GAGCONSOLE;
1718 else if (!strcasecmp (show->data, "all"))
1719 gagflags.showflags |= GAGCONSOLE | GAGUSER;
1720 else if (!strcasecmp (show->data, "none"))
1724 "unrecognized flag %s: must be in {user,console,all,none}\n",
1733 code = pioctl(0, VIOC_GAG, &blob, 1);
1742 static CheckVolumesCmd(as)
1743 struct cmd_syndesc *as;
1746 struct ViceIoctl blob;
1750 code = pioctl(0, VIOCCKBACK, &blob, 1);
1756 printf("All volumeID/name mappings checked.\n");
1760 static SetCacheSizeCmd(as)
1761 struct cmd_syndesc *as;
1764 struct ViceIoctl blob;
1767 if (!as->parms[0].items && !as->parms[1].items) {
1768 fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
1771 if (as->parms[0].items) {
1772 code = util_GetInt32(as->parms[0].items->data, &temp);
1774 fprintf(stderr, "%s: bad integer specified for cache size.\n", pn);
1780 blob.in = (char *) &temp;
1781 blob.in_size = sizeof(afs_int32);
1783 code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
1785 if (errno == EROFS) {
1786 printf("'fs setcache' not allowed on memory cache based cache managers.\n");
1794 printf("New cache size set.\n");
1798 #define MAXGCSIZE 16
1799 static GetCacheParmsCmd(as)
1800 struct cmd_syndesc *as;
1803 struct ViceIoctl blob;
1804 afs_int32 parms[MAXGCSIZE];
1806 memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
1809 blob.out_size = sizeof(parms);
1810 blob.out = (char *) parms;
1811 code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
1816 printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
1817 parms[1], parms[0]);
1818 if (parms[1] > parms[0])
1819 printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
1823 static ListCellsCmd(as)
1824 struct cmd_syndesc *as;
1830 struct ViceIoctl blob;
1833 resolve = !(as->parms[0].items); /* -numeric */
1837 memcpy(tp, &i, sizeof(afs_int32));
1838 blob.out_size = MAXSIZE;
1839 blob.in_size = sizeof(afs_int32);
1842 code = pioctl(0, VIOCGETCELL, &blob, 1);
1844 if (errno == EDOM) break; /* done with the list */
1849 printf("Cell %s on hosts", tp+MAXCELLHOSTS*sizeof(afs_int32));
1850 for(j=0; j < MAXCELLHOSTS; j++) {
1852 char *name, tbuffer[20];
1854 memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
1855 if (addr == 0) break;
1858 name = hostutil_GetNameByINet(addr);
1862 sprintf(tbuffer, "%d.%d.%d.%d",
1863 (addr>>24) & 0xff, (addr>>16) & 0xff,
1864 (addr>>8) & 0xff, addr & 0xff);
1867 printf(" %s", name);
1874 static ListAliasesCmd(as)
1875 struct cmd_syndesc *as;
1878 char *tp, *aliasName, *realName;
1879 struct ViceIoctl blob;
1883 memcpy(tp, &i, sizeof(afs_int32));
1884 blob.out_size = MAXSIZE;
1885 blob.in_size = sizeof(afs_int32);
1888 code = pioctl(0, VIOC_GETALIAS, &blob, 1);
1890 if (errno == EDOM) break; /* done with the list */
1896 tp += strlen(aliasName) + 1;
1898 printf("Alias %s for cell %s\n", aliasName, realName);
1903 static NewCellCmd(as)
1904 struct cmd_syndesc *as;
1906 afs_int32 code, linkedstate=0, size=0, *lp;
1907 struct ViceIoctl blob;
1908 struct cmd_item *ti;
1909 char *tp, *cellname=0;
1910 struct hostent *thp;
1911 afs_int32 fsport = 0, vlport = 0;
1912 afs_int32 magic, scount; /* Number of servers to pass in pioctl call */
1915 * With the NEWCELL pioctl call, 3.4 clients take an array of
1916 * MAXHOSTS (13) servers while 3.5 clients take an array of
1917 * MAXCELLHOSTS (8) servers. To determine which we are talking to,
1918 * do a GETCELL pioctl and pass it a magic number. If an array of
1919 * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
1920 * If we get back EDOM, there are no cells in the kernel yet,
1921 * and we'll assume a 3.5 client.
1924 lp = (afs_int32 *)tp;
1925 *lp++ = 0; /* first cell entry */
1926 *lp = 0x12345678; /* magic */
1927 blob.out_size = MAXSIZE;
1928 blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
1931 code = pioctl(0, VIOCGETCELL, &blob, 1);
1932 if (code < 0 && errno != EDOM) {
1936 if (code < 1 && errno == EDOM) {
1940 cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
1941 scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
1944 /* Now setup and do the NEWCELL pioctl call */
1945 memset(space, 0, (scount+1) * sizeof(afs_int32));
1947 lp = (afs_int32 *)tp;
1949 tp += sizeof(afs_int32);
1950 for(ti=as->parms[1].items; ti; ti=ti->next) {
1951 thp = hostutil_GetHostByName(ti->data);
1953 fprintf(stderr, "%s: Host %s not found in host table, skipping it.\n",
1957 memcpy(tp, thp->h_addr, sizeof(afs_int32));
1958 tp += sizeof(afs_int32);
1961 if (as->parms[2].items) {
1963 * Link the cell, for the purposes of volume location, to the specified
1966 cellname = as->parms[2].items->data;
1969 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
1970 if (as->parms[3].items) {
1971 code = util_GetInt32(as->parms[3].items->data, &vlport);
1973 fprintf(stderr, "%s: bad integer specified for the fileserver port.\n", pn);
1977 if (as->parms[4].items) {
1978 code = util_GetInt32(as->parms[4].items->data, &fsport);
1980 fprintf(stderr, "%s: bad integer specified for the vldb server port.\n", pn);
1985 tp = (char *)(space + (scount+1) *sizeof(afs_int32));
1986 lp = (afs_int32 *)tp;
1990 strcpy(space + ((scount+4) * sizeof(afs_int32)), as->parms[0].items->data);
1991 size = ((scount+4) * sizeof(afs_int32))
1992 + strlen(as->parms[0].items->data)
1994 tp = (char *)(space + size);
1996 strcpy(tp, cellname);
1997 size += strlen(cellname) + 1;
1999 blob.in_size = size;
2002 code = pioctl(0, VIOCNEWCELL, &blob, 1);
2010 static NewAliasCmd(as)
2011 struct cmd_syndesc *as;
2014 struct ViceIoctl blob;
2016 char *aliasName, *realName;
2018 /* Now setup and do the NEWCELL pioctl call */
2019 aliasName = as->parms[0].items->data;
2020 realName = as->parms[1].items->data;
2022 strcpy(tp, aliasName);
2023 tp += strlen(aliasName) + 1;
2024 strcpy(tp, realName);
2025 tp += strlen(realName) + 1;
2027 blob.in_size = tp - space;
2031 code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
2033 if (errno == EEXIST) {
2034 fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
2044 static WhichCellCmd(as)
2045 struct cmd_syndesc *as;
2048 struct cmd_item *ti;
2050 char cell[MAXCELLCHARS];
2052 SetDotDefault(&as->parms[0].items);
2053 for (ti=as->parms[0].items; ti; ti=ti->next) {
2054 code = GetCell(ti->data, cell);
2056 if (errno == ENOENT)
2057 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2059 Die(errno, ti->data);
2064 printf("File %s lives in cell '%s'\n", ti->data, cell);
2069 static WSCellCmd(as)
2070 struct cmd_syndesc *as;
2073 struct ViceIoctl blob;
2077 blob.out_size = MAXSIZE;
2080 code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
2086 printf("This workstation belongs to cell '%s'\n", space);
2091 static PrimaryCellCmd(as)
2092 struct cmd_syndesc *as;
2094 fprintf(stderr, "This command is obsolete, as is the concept of a primary token.\n");
2099 static MonitorCmd(as)
2100 struct cmd_syndesc *as;
2103 struct ViceIoctl blob;
2104 struct cmd_item *ti;
2106 struct hostent *thp;
2110 ti = as->parms[0].items;
2114 if (!strcmp(ti->data, "off"))
2115 hostAddr = 0xffffffff;
2117 thp = hostutil_GetHostByName(ti->data);
2119 if (!strcmp(ti->data, "localhost")) {
2120 fprintf(stderr, "localhost not in host table, assuming 127.0.0.1\n");
2121 hostAddr = htonl(0x7f000001);
2124 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2128 else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2132 hostAddr = 0; /* means don't set host */
2133 setp = 0; /* aren't setting host */
2136 /* now do operation */
2137 blob.in_size = sizeof(afs_int32);
2138 blob.out_size = sizeof(afs_int32);
2139 blob.in = (char *) &hostAddr;
2140 blob.out = (char *) &hostAddr;
2141 code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2147 printf("%s: new monitor host set.\n", pn);
2150 /* now decode old address */
2151 if (hostAddr == 0xffffffff) {
2152 printf("Cache monitoring is currently disabled.\n");
2155 tp = hostutil_GetNameByINet(hostAddr);
2156 printf("Using host %s for monitor services.\n", tp);
2162 static SysNameCmd(as)
2163 struct cmd_syndesc *as;
2166 struct ViceIoctl blob;
2167 struct cmd_item *ti;
2168 char *input = space;
2171 ti = as->parms[0].items;
2174 blob.out_size = MAXSIZE;
2175 blob.in_size = sizeof(afs_int32);
2176 input += sizeof(afs_int32);
2177 for(; ti; ti=ti->next) {
2179 blob.in_size += strlen(ti->data) + 1;
2180 if (blob.in_size > MAXSIZE) {
2181 fprintf(stderr, "%s: sysname%s too long.\n", pn, setp > 1 ? "s" : "");
2184 strcpy(input, ti->data);
2185 input += strlen(ti->data);
2188 memcpy(space, &setp, sizeof(afs_int32));
2189 code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
2195 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2199 memcpy(&setp, input, sizeof(afs_int32));
2200 input += sizeof(afs_int32);
2202 fprintf(stderr, "No sysname name value was found\n");
2205 printf("Current sysname%s is", setp>1 ? " list" : "");
2206 for(;setp>0;--setp) {
2207 printf(" \'%s\'", input);
2208 input += strlen(input) + 1;
2214 static char *exported_types[] = {"null", "nfs", ""};
2215 static ExportAfsCmd(as)
2216 struct cmd_syndesc *as;
2219 struct ViceIoctl blob;
2220 struct cmd_item *ti;
2221 int export=0, type=0, mode = 0, exp = 0, exportcall, pwsync=0, smounts=0;
2223 ti = as->parms[0].items;
2224 if (strcmp(ti->data, "nfs") == 0) type = 0x71; /* NFS */
2226 fprintf(stderr, "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2229 ti = as->parms[1].items;
2231 if (strcmp(ti->data, "on") == 0) export = 3;
2232 else if (strcmp(ti->data, "off") == 0) export = 2;
2234 fprintf(stderr, "Illegal argument %s\n", ti->data);
2239 if (ti = as->parms[2].items) { /* -noconvert */
2240 if (strcmp(ti->data, "on") == 0) mode = 2;
2241 else if (strcmp(ti->data, "off") == 0) mode = 3;
2243 fprintf(stderr, "Illegal argument %s\n", ti->data);
2247 if (ti = as->parms[3].items) { /* -uidcheck */
2248 if (strcmp(ti->data, "on") == 0) pwsync = 3;
2249 else if (strcmp(ti->data, "off") == 0) pwsync = 2;
2251 fprintf(stderr, "Illegal argument %s\n", ti->data);
2255 if (ti = as->parms[4].items) { /* -submounts */
2256 if (strcmp(ti->data, "on") == 0) smounts = 3;
2257 else if (strcmp(ti->data, "off") == 0) smounts = 2;
2259 fprintf(stderr, "Illegal argument %s\n", ti->data);
2263 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2266 blob.in = (char *) &exportcall;
2267 blob.in_size = sizeof(afs_int32);
2268 blob.out = (char *) &exportcall;
2269 blob.out_size = sizeof(afs_int32);
2270 code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
2272 if (errno == ENODEV) {
2273 fprintf(stderr, "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2281 if (exportcall & 1) {
2282 printf("'%s' translator is enabled with the following options:\n",
2283 exported_types[type]);
2284 printf("\tRunning in %s mode\n",
2285 (exportcall & 2 ? "strict unix"
2286 : "convert owner mode bits to world/other"));
2287 printf("\tRunning in %s mode\n",
2288 (exportcall & 4 ? "strict 'passwd sync'"
2289 : "no 'passwd sync'"));
2291 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs"
2292 : "Only mounts to /afs allowed"));
2295 printf("'%s' translator is disabled\n", exported_types[type]);
2301 static GetCellCmd(as)
2302 struct cmd_syndesc *as;
2305 struct ViceIoctl blob;
2306 struct afsconf_cell info;
2307 struct cmd_item *ti;
2314 memset(&args, '\0', sizeof args); /* avoid Purify UMR error */
2315 for(ti=as->parms[0].items; ti; ti=ti->next) {
2317 blob.out_size = sizeof(args);
2318 blob.out = (caddr_t) &args;
2319 code = GetCellName(ti->data, &info);
2324 blob.in_size = 1+strlen(info.name);
2325 blob.in = info.name;
2326 code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
2328 if (errno == ENOENT)
2329 fprintf(stderr, "%s: the cell named '%s' does not exist\n", pn, info.name);
2331 Die(errno, info.name);
2335 printf("Cell %s status: ", info.name);
2337 if (args.stat & 1) printf("primary ");
2339 if (args.stat & 2) printf("no setuid allowed");
2340 else printf("setuid allowed");
2341 if (args.stat & 4) printf(", using old VLDB");
2347 static SetCellCmd(as)
2348 struct cmd_syndesc *as;
2351 struct ViceIoctl blob;
2352 struct afsconf_cell info;
2353 struct cmd_item *ti;
2361 /* Check arguments. */
2362 if (as->parms[1].items && as->parms[2].items) {
2363 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
2367 /* figure stuff to set */
2371 if (! as->parms[1].items) args.stat |= 2; /* default to -nosuid */
2373 /* set stat for all listed cells */
2374 for(ti=as->parms[0].items; ti; ti=ti->next) {
2376 code = GetCellName(ti->data, &info);
2381 strcpy(args.cname, info.name);
2382 blob.in_size = sizeof(args);
2383 blob.in = (caddr_t) &args;
2385 blob.out = (caddr_t) 0;
2386 code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
2388 Die(errno, info.name); /* XXX added cell name to Die() call */
2395 static GetCellName(cellName, info)
2397 struct afsconf_cell *info;
2399 struct afsconf_dir *tdir;
2402 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
2404 fprintf(stderr, "Could not process files in configuration directory (%s).\n",
2405 AFSDIR_CLIENT_ETC_DIRPATH);
2409 code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
2411 fprintf(stderr, "%s: cell %s not in %s\n", pn, cellName,
2412 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
2420 static VLDBInit(noAuthFlag, info)
2422 struct afsconf_cell *info;
2425 struct ktc_principal sname;
2426 struct ktc_token ttoken;
2428 struct rx_securityClass *sc;
2429 struct rx_connection *serverconns[VLDB_MAXSERVERS];
2434 fprintf(stderr, "%s: could not initialize rx.\n", pn);
2438 rx_SetRxDeadTime(50);
2439 if (!noAuthFlag) { /* we don't need tickets for null */
2440 strcpy(sname.cell, info->name);
2441 sname.instance[0] = 0;
2442 strcpy(sname.name, "afs");
2443 code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), NULL);
2445 fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
2450 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
2452 fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
2458 else scIndex = 0; /* don't authenticate */
2461 sc = rxnull_NewClientSecurityObject();
2467 sc = (struct rx_securityClass *)
2468 rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
2469 ttoken.kvno, ttoken.ticketLen,
2473 if (info->numServers > VLDB_MAXSERVERS) {
2474 fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
2475 pn, info->numServers, VLDB_MAXSERVERS);
2478 memset(serverconns, 0, sizeof(serverconns));
2479 for (i = 0;i<info->numServers;i++)
2480 serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
2481 info->hostAddr[i].sin_port, USER_SERVICE_ID,
2484 code = ubik_ClientInit(serverconns, &uclient);
2487 fprintf(stderr, "%s: ubik client init failed.\n", pn);
2493 static struct ViceIoctl gblob;
2494 static int debug = 0;
2496 * here follow some routines in suport of the setserverprefs and
2497 * getserverprefs commands. They are:
2498 * SetPrefCmd "top-level" routine
2499 * addServer adds a server to the list of servers to be poked into the
2500 * kernel. Will poke the list into the kernel if it threatens
2502 * pokeServers pokes the existing list of servers and ranks into the kernel
2503 * GetPrefCmd reads the Cache Manager's current list of server ranks
2507 * returns -1 if error message printed,
2509 * errno value if error and no error message printed
2511 static pokeServers()
2515 code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
2516 if (code && (errno == EINVAL)) {
2517 struct setspref *ssp;
2518 ssp = (struct setspref *)gblob.in;
2519 if (!(ssp->flags & DBservers)) {
2520 gblob.in = (void *) &(ssp->servers[0]);
2521 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
2522 code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
2523 return code ? errno : 0;
2526 "This cache manager does not support VL server preferences.\n");
2530 return code ? errno : 0;
2534 * returns -1 if error message printed,
2536 * errno value if error and no error message printed
2538 static addServer(name, rank)
2543 struct setspref *ssp;
2545 struct hostent *thostent;
2551 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
2553 #define MAXUSHORT ((unsigned short) ~0)
2557 thostent = hostutil_GetHostByName(name);
2559 fprintf(stderr, "%s: couldn't resolve name.\n", name);
2563 ssp = (struct setspref *)(gblob.in);
2565 for (t = 0; thostent->h_addr_list[t]; t++) {
2566 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
2567 code = pokeServers();
2568 if (code) error = code;
2569 ssp->num_servers = 0;
2572 sp = (struct spref *) (gblob.in + gblob.in_size);
2573 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
2574 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
2575 gblob.in_size += sizeof(struct spref);
2579 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
2580 name,sp->rank,sp->server.s_addr);
2587 static SetPrefCmd(as)
2588 struct cmd_syndesc *as;
2592 struct cmd_item *ti;
2595 struct setspref *ssp;
2596 int error = 0; /* -1 means error message printed,
2597 * >0 means errno value for unprinted message */
2599 ssp = (struct setspref *)space;
2601 ssp->num_servers = 0;
2602 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2605 gblob.out_size = MAXSIZE;
2609 fprintf(stderr, "Permission denied: requires root access.\n");
2613 ti = as->parms[2].items; /* -file */
2615 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2616 if (!(infd = fopen(ti->data,"r"))) {
2621 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
2622 code = addServer(name, (unsigned short) rank);
2623 if (code) error = code;
2628 ti = as->parms[3].items; /* -stdin */
2630 while (scanf("%79s%ld", name, &rank) != EOF) {
2631 code = addServer(name, (unsigned short) rank);
2632 if (code) error = code;
2636 for (ti = as->parms[0].items;ti;ti=ti->next) { /* list of servers, ranks */
2641 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2642 if (code) error = code;
2644 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
2648 code = pokeServers();
2649 if (code) error = code;
2651 printf("now working on vlservers, code=%d\n",code);
2653 ssp = (struct setspref *)space;
2654 ssp->flags = DBservers;
2655 ssp->num_servers = 0;
2656 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2659 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
2664 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2665 if (code) error = code;
2667 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
2672 if (as->parms[1].items) {
2674 printf("now poking vlservers\n");
2675 code = pokeServers();
2676 if (code) error = code;
2682 return error ? 1 : 0;
2687 static GetPrefCmd(as)
2688 struct cmd_syndesc *as;
2691 struct cmd_item *ti;
2692 char *name, tbuffer[20];
2693 afs_int32 rank,addr;
2697 struct ViceIoctl blob;
2698 struct sprefrequest *in;
2699 struct sprefinfo *out;
2702 ti = as->parms[0].items; /* -file */
2704 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2705 if (!(outfd = freopen(ti->data,"w",stdout))) {
2711 ti = as->parms[1].items; /* -numeric */
2713 ti = as->parms[2].items; /* -vlservers */
2714 vlservers |= (ti ? DBservers : 0);
2715 /* ti = as->parms[3].items; -cell */
2717 in = (struct sprefrequest *)space;
2721 blob.in_size=sizeof(struct sprefrequest);
2722 blob.in = (char *)in;
2724 blob.out_size = MAXSIZE;
2726 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
2727 in->flags = vlservers;
2729 code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
2731 perror("getserverprefs pioctl");
2735 out = (struct sprefinfo *) blob.out;
2737 for (i=0;i<out->num_servers;i++) {
2739 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
2742 addr = ntohl(out->servers[i].server.s_addr);
2743 sprintf(tbuffer, "%d.%d.%d.%d",
2744 (addr>>24) & 0xff, (addr>>16) & 0xff,
2745 (addr>>8) & 0xff, addr & 0xff);
2748 printf("%-50s %5u\n",name,out->servers[i].rank);
2751 in->offset = out->next_offset;
2752 } while (out->next_offset > 0);
2757 static StoreBehindCmd(as)
2758 struct cmd_syndesc *as;
2761 struct ViceIoctl blob;
2762 struct cmd_item *ti;
2763 struct sbstruct tsb, tsb2;
2769 tsb.sb_thisfile = -1;
2770 ti=as->parms[0].items; /* -kbytes */
2772 if (!as->parms[1].items) {
2773 fprintf(stderr, "%s: you must specify -files with -kbytes.\n", pn);
2776 tsb.sb_thisfile = strtol(ti->data,&t,10) * 1024;
2777 if ((tsb.sb_thisfile < 0) || (t != ti->data+strlen(ti->data))) {
2778 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2784 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
2785 ti=as->parms[2].items; /* -allfiles */
2787 allfiles = strtol(ti->data,&t,10) * 1024;
2788 if ((allfiles < 0) || (t != ti->data+strlen(ti->data))) {
2789 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2795 /* -verbose or -file only or no options */
2796 if (as->parms[3].items ||
2797 (as->parms[1].items && !as->parms[0].items) ||
2798 (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items))
2801 blob.in = (char *)&tsb;
2802 blob.out = (char *)&tsb2;
2803 blob.in_size = blob.out_size = sizeof(struct sbstruct);
2804 memset(&tsb2, 0, sizeof(tsb2));
2806 /* once per -file */
2807 for (ti=as->parms[1].items; ti; ti=ti->next) {
2808 /* Do this solely to see if the file is there */
2809 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
2811 Die(errno, ti->data);
2816 code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
2818 Die(errno, ti->data);
2823 if (verbose && (blob.out_size == sizeof(tsb2))) {
2824 if (tsb2.sb_thisfile == -1) {
2825 fprintf(stdout, "Will store %s according to default.\n",
2830 "Will store up to %d kbytes of %s asynchronously.\n",
2831 (tsb2.sb_thisfile/1024), ti->data);
2836 /* If no files - make at least one pioctl call, or
2837 * set the allfiles default if we need to.
2839 if (!as->parms[1].items || (allfiles != -1)) {
2840 tsb.sb_default = allfiles;
2841 code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
2843 Die(errno, ((allfiles == -1)?0:"-allfiles"));
2848 /* Having no arguments also reports the default store asynchrony */
2849 if (verbose && (blob.out_size == sizeof(tsb2))) {
2850 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
2851 (tsb2.sb_default/1024));
2858 static afs_int32 SetCryptCmd(as)
2859 struct cmd_syndesc *as;
2861 afs_int32 code = 0, flag;
2862 struct ViceIoctl blob;
2865 tp = as->parms[0].items->data;
2866 if (strcmp(tp, "on") == 0)
2868 else if (strcmp(tp, "off") == 0)
2871 fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
2875 blob.in = (char *) &flag;
2876 blob.in_size = sizeof(flag);
2878 code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
2885 static afs_int32 GetCryptCmd(as)
2886 struct cmd_syndesc *as;
2888 afs_int32 code = 0, flag;
2889 struct ViceIoctl blob;
2894 blob.out_size = sizeof(flag);
2897 code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
2899 if (code) Die(errno, NULL);
2902 memcpy(&flag, tp, sizeof(afs_int32));
2903 printf("Security level is currently ");
2905 printf("crypt (data security).\n");
2912 #include "AFS_component_version_number.c"
2919 struct cmd_syndesc *ts;
2921 #ifdef AFS_AIX32_ENV
2923 * The following signal action for AIX is necessary so that in case of a
2924 * crash (i.e. core is generated) we can include the user's data section
2925 * in the core dump. Unfortunately, by default, only a partial core is
2926 * generated which, in many cases, isn't too useful.
2928 struct sigaction nsa;
2930 sigemptyset(&nsa.sa_mask);
2931 nsa.sa_handler = SIG_DFL;
2932 nsa.sa_flags = SA_FULLDUMP;
2933 sigaction(SIGSEGV, &nsa, NULL);
2936 /* try to find volume location information */
2937 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0, "get client network interface addresses");
2938 cmd_CreateAlias(ts, "gc");
2940 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0, "set client network interface addresses");
2941 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "client network interfaces");
2942 cmd_CreateAlias(ts, "sc");
2944 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
2945 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
2946 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
2947 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
2948 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
2949 cmd_CreateAlias(ts, "sp");
2951 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
2952 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
2953 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2954 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
2955 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
2956 cmd_CreateAlias(ts, "gp");
2958 ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
2959 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2960 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
2961 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
2962 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
2963 parm_setacl_id = ts->nParms;
2964 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
2965 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
2966 cmd_CreateAlias(ts, "sa");
2968 ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
2969 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2970 parm_listacl_id = ts->nParms;
2971 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2972 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2973 cmd_CreateAlias(ts, "la");
2975 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
2976 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2978 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
2979 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
2980 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
2981 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
2982 parm_copyacl_id = ts->nParms;
2983 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2984 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2986 cmd_CreateAlias(ts, "ca");
2988 ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
2989 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2990 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0, "flush mount symlink from cache");
2991 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2993 ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
2994 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2995 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
2997 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
2998 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
3000 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
3001 cmd_CreateAlias(ts, "sv");
3003 ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
3004 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
3006 ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
3007 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3008 cmd_CreateAlias(ts, "lv");
3009 cmd_CreateAlias(ts, "listvol");
3011 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
3012 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3013 cmd_CreateAlias(ts, "lq");
3015 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
3016 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3017 cmd_CreateAlias(ts, "df");
3019 ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
3020 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3022 ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
3023 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3025 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
3026 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
3027 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
3028 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
3029 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
3030 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
3036 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
3040 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
3041 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3043 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
3044 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
3045 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
3046 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
3047 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
3049 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
3050 cmd_CreateAlias(ts, "checkbackups");
3053 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
3054 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
3055 cmd_CreateAlias(ts, "cachesize");
3057 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
3059 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
3061 ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
3062 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
3064 ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
3066 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
3067 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
3068 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
3070 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
3072 cmd_CreateAlias(ts, "sq");
3074 ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
3075 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
3076 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
3077 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
3079 ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
3080 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
3081 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
3083 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
3085 * Turn this on only if you wish to be able to talk to a server which is listening
3086 * on alternative ports. This is not intended for general use and may not be
3087 * supported in the cache manager. It is not a way to run two servers at the
3088 * same host, since the cache manager cannot properly distinguish those two hosts.
3090 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
3091 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
3094 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
3095 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3097 ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
3098 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3100 ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
3103 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
3106 /* set cache monitor host address */
3107 ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *) CMD_HIDDEN);
3108 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
3109 cmd_CreateAlias(ts, "mariner");
3111 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
3112 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3114 ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
3115 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3116 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
3117 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
3119 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
3120 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3122 ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
3123 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
3125 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
3126 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
3127 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator (on | off)");
3128 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode (on | off)");
3129 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode (on | off)");
3130 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. (on | off)");
3133 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
3134 "store to server after file close");
3135 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
3136 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
3137 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
3138 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
3139 cmd_CreateAlias(ts, "sb");
3141 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
3142 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
3144 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "set cache manager encryption flag");
3146 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
3147 "Manage per process RX statistics");
3148 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3150 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3151 "Disable RX stats");
3152 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3155 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
3156 "Manage per peer RX statistics");
3157 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3159 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3160 "Disable RX stats");
3161 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3164 code = cmd_Dispatch(argc, argv);
3165 if (rxInitDone) rx_Finalize();
3170 static void Die(errnum, filename)
3177 fprintf(stderr, "%s: Invalid argument; it is possible that %s is not in AFS.\n",
3180 fprintf(stderr, "%s: Invalid argument.\n", pn);
3184 fprintf(stderr, "%s: File '%s' doesn't exist\n", pn, filename);
3186 fprintf(stderr, "%s: no such file returned\n", pn);
3189 fprintf(stderr, "%s: You can not change a backup or readonly volume\n", pn);
3194 fprintf(stderr, "%s: You don't have the required access rights on '%s'\n",
3197 fprintf(stderr, "%s: You do not have the required rights to do this operation\n",
3202 fprintf(stderr, "%s:'%s'", pn, filename);
3204 fprintf(stderr, "%s", pn);
3205 fprintf(stderr, ": %s\n", error_message(errnum));
3210 /* get clients interface addresses */
3212 GetClientAddrsCmd(as)
3213 struct cmd_syndesc *as;
3216 struct cmd_item *ti;
3218 struct ViceIoctl blob;
3219 struct sprefrequest *in;
3220 struct sprefinfo *out;
3222 in = (struct sprefrequest *)space;
3227 blob.in_size=sizeof(struct sprefrequest);
3228 blob.in = (char *)in;
3230 blob.out_size = MAXSIZE;
3232 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
3233 /* returns addr in network byte order */
3234 code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
3236 perror("getClientInterfaceAddr pioctl");
3242 out = (struct sprefinfo *) blob.out;
3243 for (i=0; i < out->num_servers; i++) {
3246 addr = ntohl(out->servers[i].server.s_addr);
3247 sprintf(tbuffer, "%d.%d.%d.%d",
3248 (addr>>24) & 0xff, (addr>>16) & 0xff,
3249 (addr>>8) & 0xff, addr & 0xff);
3250 printf ("%-50s\n", tbuffer);
3252 in->offset = out->next_offset;
3254 } while (out->next_offset > 0);
3260 SetClientAddrsCmd(as)
3261 struct cmd_syndesc *as;
3263 afs_int32 code, addr;
3264 struct cmd_item *ti;
3266 struct ViceIoctl blob;
3267 struct setspref *ssp;
3268 int sizeUsed = 0, i, flag;
3269 afs_int32 existingAddr[1024]; /* existing addresses on this host */
3273 ssp = (struct setspref *)space;
3274 ssp->num_servers = 0;
3277 blob.out_size = MAXSIZE;
3280 fprintf(stderr, "Permission denied: requires root access.\n");
3284 /* extract all existing interface addresses */
3285 existNu = rx_getAllAddr(existingAddr,1024);
3289 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
3290 for (ti = as->parms[0].items;ti;ti=ti->next) {
3291 if (sizeUsed >= sizeof(space)) {
3292 fprintf(stderr, "No more space\n");
3295 addr = extractAddr(ti->data, 20); /* network order */
3296 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
3297 fprintf(stderr, "Error in specifying address: %s..ignoring\n", ti->data);
3301 /* see if it is an address that really exists */
3302 for (flag = 0, i=0; i < existNu; i++)
3303 if (existingAddr[i] == addr) {
3307 if (!flag) { /* this is an nonexistent address */
3308 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
3312 /* copy all specified addr into ioctl buffer */
3313 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
3314 printf("Adding 0x%08x\n", addr);
3316 sizeUsed += sizeof(struct spref);
3318 if (ssp->num_servers < 1) {
3319 fprintf(stderr, "No addresses specified\n");
3322 blob.in_size = sizeUsed - sizeof(struct spref);
3324 code = pioctl(0, VIOC_SETCPREFS, &blob, 1); /* network order */
3335 struct cmd_syndesc *as;
3338 struct ViceIoctl blob;
3339 struct cmd_item *ti;
3340 char orig_name[1024]; /*Original name, may be modified*/
3341 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
3342 char parent_dir[1024]; /*Parent directory of true name*/
3343 char *last_component; /*Last component of true name*/
3344 struct stat statbuff; /*Buffer for status info*/
3345 int link_chars_read; /*Num chars read in readlink()*/
3346 int thru_symlink; /*Did we get to a mount point via a symlink?*/
3349 for(ti=as->parms[0].items; ti; ti=ti->next) {
3352 sprintf(orig_name, "%s%s",
3353 (ti->data[0] == '/') ? "" : "./",
3356 if (lstat(orig_name, &statbuff) < 0) {
3357 /* if lstat fails, we should still try the pioctl, since it
3358 may work (for example, lstat will fail, but pioctl will
3359 work if the volume of offline (returning ENODEV). */
3360 statbuff.st_mode = S_IFDIR; /* lie like pros */
3364 * The lstat succeeded. If the given file is a symlink, substitute
3365 * the file name with the link name.
3367 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
3370 * Read name of resolved file.
3372 link_chars_read = readlink(orig_name, true_name, 1024);
3373 if (link_chars_read <= 0) {
3374 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
3381 * Add a trailing null to what was read, bump the length.
3383 true_name[link_chars_read++] = 0;
3386 * If the symlink is an absolute pathname, we're fine. Otherwise, we
3387 * have to create a full pathname using the original name and the
3388 * relative symlink name. Find the rightmost slash in the original
3389 * name (we know there is one) and splice in the symlink value.
3391 if (true_name[0] != '/') {
3392 last_component = (char *) strrchr(orig_name, '/');
3393 strcpy(++last_component, true_name);
3394 strcpy(true_name, orig_name);
3398 strcpy(true_name, orig_name);
3401 * Find rightmost slash, if any.
3403 last_component = (char *) strrchr(true_name, '/');
3404 if (last_component) {
3406 * Found it. Designate everything before it as the parent directory,
3407 * everything after it as the final component.
3409 strncpy(parent_dir, true_name, last_component - true_name);
3410 parent_dir[last_component - true_name] = 0;
3411 last_component++; /*Skip the slash*/
3415 * No slash appears in the given file name. Set parent_dir to the current
3416 * directory, and the last component as the given name.
3418 strcpy(parent_dir, ".");
3419 last_component = true_name;
3422 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
3423 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
3424 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n", pn);
3429 blob.in = last_component;
3430 blob.in_size = strlen(last_component)+1;
3432 memset(space, 0, MAXSIZE);
3434 code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
3437 if (errno == EINVAL) {
3438 fprintf(stderr, "'%s' is not a mount point.\n",
3442 Die(errno, (ti->data ? ti->data : parent_dir));
3452 struct cmd_syndesc *as;
3455 afs_int32 flags = 0;
3456 struct ViceIoctl blob;
3457 struct cmd_item *ti;
3459 if (as->parms[0].items) { /* -enable*/
3460 flags |= AFSCALL_RXSTATS_ENABLE;
3462 if (as->parms[1].items) { /* -disable*/
3463 flags |= AFSCALL_RXSTATS_DISABLE;
3465 if (as->parms[2].items) { /* -clear*/
3466 flags |= AFSCALL_RXSTATS_CLEAR;
3469 fprintf(stderr, "You must specify at least one argument\n");
3473 blob.in = (char *)&flags;
3474 blob.in_size = sizeof(afs_int32);
3477 code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
3488 struct cmd_syndesc *as;
3491 afs_int32 flags = 0;
3492 struct ViceIoctl blob;
3493 struct cmd_item *ti;
3495 if (as->parms[0].items) { /* -enable*/
3496 flags |= AFSCALL_RXSTATS_ENABLE;
3498 if (as->parms[1].items) { /* -disable*/
3499 flags |= AFSCALL_RXSTATS_DISABLE;
3501 if (as->parms[2].items) { /* -clear*/
3502 flags |= AFSCALL_RXSTATS_CLEAR;
3505 fprintf(stderr, "You must specify at least one argument\n");
3509 blob.in = (char *)&flags;
3510 blob.in_size = sizeof(afs_int32);
3513 code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);