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.
1922 lp = (afs_int32 *)tp;
1923 *lp++ = 0; /* first cell entry */
1924 *lp = 0x12345678; /* magic */
1925 blob.out_size = MAXSIZE;
1926 blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
1929 code = pioctl(0, VIOCGETCELL, &blob, 1);
1935 cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
1936 scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
1938 /* Now setup and do the NEWCELL pioctl call */
1939 memset(space, 0, (scount+1) * sizeof(afs_int32));
1941 lp = (afs_int32 *)tp;
1943 tp += sizeof(afs_int32);
1944 for(ti=as->parms[1].items; ti; ti=ti->next) {
1945 thp = hostutil_GetHostByName(ti->data);
1947 fprintf(stderr, "%s: Host %s not found in host table, skipping it.\n",
1951 memcpy(tp, thp->h_addr, sizeof(afs_int32));
1952 tp += sizeof(afs_int32);
1955 if (as->parms[2].items) {
1957 * Link the cell, for the purposes of volume location, to the specified
1960 cellname = as->parms[2].items->data;
1963 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
1964 if (as->parms[3].items) {
1965 code = util_GetInt32(as->parms[3].items->data, &vlport);
1967 fprintf(stderr, "%s: bad integer specified for the fileserver port.\n", pn);
1971 if (as->parms[4].items) {
1972 code = util_GetInt32(as->parms[4].items->data, &fsport);
1974 fprintf(stderr, "%s: bad integer specified for the vldb server port.\n", pn);
1979 tp = (char *)(space + (scount+1) *sizeof(afs_int32));
1980 lp = (afs_int32 *)tp;
1984 strcpy(space + ((scount+4) * sizeof(afs_int32)), as->parms[0].items->data);
1985 size = ((scount+4) * sizeof(afs_int32))
1986 + strlen(as->parms[0].items->data)
1988 tp = (char *)(space + size);
1990 strcpy(tp, cellname);
1991 size += strlen(cellname) + 1;
1993 blob.in_size = size;
1996 code = pioctl(0, VIOCNEWCELL, &blob, 1);
2004 static NewAliasCmd(as)
2005 struct cmd_syndesc *as;
2008 struct ViceIoctl blob;
2010 char *aliasName, *realName;
2012 /* Now setup and do the NEWCELL pioctl call */
2013 aliasName = as->parms[0].items->data;
2014 realName = as->parms[1].items->data;
2016 strcpy(tp, aliasName);
2017 tp += strlen(aliasName) + 1;
2018 strcpy(tp, realName);
2019 tp += strlen(realName) + 1;
2021 blob.in_size = tp - space;
2025 code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
2027 if (errno == EEXIST) {
2028 fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
2038 static WhichCellCmd(as)
2039 struct cmd_syndesc *as;
2042 struct cmd_item *ti;
2044 char cell[MAXCELLCHARS];
2046 SetDotDefault(&as->parms[0].items);
2047 for (ti=as->parms[0].items; ti; ti=ti->next) {
2048 code = GetCell(ti->data, cell);
2050 if (errno == ENOENT)
2051 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2053 Die(errno, ti->data);
2058 printf("File %s lives in cell '%s'\n", ti->data, cell);
2063 static WSCellCmd(as)
2064 struct cmd_syndesc *as;
2067 struct ViceIoctl blob;
2071 blob.out_size = MAXSIZE;
2074 code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
2080 printf("This workstation belongs to cell '%s'\n", space);
2085 static PrimaryCellCmd(as)
2086 struct cmd_syndesc *as;
2088 fprintf(stderr, "This command is obsolete, as is the concept of a primary token.\n");
2093 static MonitorCmd(as)
2094 struct cmd_syndesc *as;
2097 struct ViceIoctl blob;
2098 struct cmd_item *ti;
2100 struct hostent *thp;
2104 ti = as->parms[0].items;
2108 if (!strcmp(ti->data, "off"))
2109 hostAddr = 0xffffffff;
2111 thp = hostutil_GetHostByName(ti->data);
2113 if (!strcmp(ti->data, "localhost")) {
2114 fprintf(stderr, "localhost not in host table, assuming 127.0.0.1\n");
2115 hostAddr = htonl(0x7f000001);
2118 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2122 else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2126 hostAddr = 0; /* means don't set host */
2127 setp = 0; /* aren't setting host */
2130 /* now do operation */
2131 blob.in_size = sizeof(afs_int32);
2132 blob.out_size = sizeof(afs_int32);
2133 blob.in = (char *) &hostAddr;
2134 blob.out = (char *) &hostAddr;
2135 code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2141 printf("%s: new monitor host set.\n", pn);
2144 /* now decode old address */
2145 if (hostAddr == 0xffffffff) {
2146 printf("Cache monitoring is currently disabled.\n");
2149 tp = hostutil_GetNameByINet(hostAddr);
2150 printf("Using host %s for monitor services.\n", tp);
2156 static SysNameCmd(as)
2157 struct cmd_syndesc *as;
2160 struct ViceIoctl blob;
2161 struct cmd_item *ti;
2162 char *input = space;
2165 ti = as->parms[0].items;
2168 blob.out_size = MAXSIZE;
2169 blob.in_size = sizeof(afs_int32);
2170 input += sizeof(afs_int32);
2171 for(; ti; ti=ti->next) {
2173 blob.in_size += strlen(ti->data) + 1;
2174 if (blob.in_size > MAXSIZE) {
2175 fprintf(stderr, "%s: sysname%s too long.\n", pn, setp > 1 ? "s" : "");
2178 strcpy(input, ti->data);
2179 input += strlen(ti->data);
2182 memcpy(space, &setp, sizeof(afs_int32));
2183 code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
2189 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2193 memcpy(&setp, input, sizeof(afs_int32));
2194 input += sizeof(afs_int32);
2196 fprintf(stderr, "No sysname name value was found\n");
2199 printf("Current sysname%s is", setp>1 ? " list" : "");
2200 for(;setp>0;--setp) {
2201 printf(" \'%s\'", input);
2202 input += strlen(input) + 1;
2208 static char *exported_types[] = {"null", "nfs", ""};
2209 static ExportAfsCmd(as)
2210 struct cmd_syndesc *as;
2213 struct ViceIoctl blob;
2214 struct cmd_item *ti;
2215 int export=0, type=0, mode = 0, exp = 0, exportcall, pwsync=0, smounts=0;
2217 ti = as->parms[0].items;
2218 if (strcmp(ti->data, "nfs") == 0) type = 0x71; /* NFS */
2220 fprintf(stderr, "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2223 ti = as->parms[1].items;
2225 if (strcmp(ti->data, "on") == 0) export = 3;
2226 else if (strcmp(ti->data, "off") == 0) export = 2;
2228 fprintf(stderr, "Illegal argument %s\n", ti->data);
2233 if (ti = as->parms[2].items) { /* -noconvert */
2234 if (strcmp(ti->data, "on") == 0) mode = 2;
2235 else if (strcmp(ti->data, "off") == 0) mode = 3;
2237 fprintf(stderr, "Illegal argument %s\n", ti->data);
2241 if (ti = as->parms[3].items) { /* -uidcheck */
2242 if (strcmp(ti->data, "on") == 0) pwsync = 3;
2243 else if (strcmp(ti->data, "off") == 0) pwsync = 2;
2245 fprintf(stderr, "Illegal argument %s\n", ti->data);
2249 if (ti = as->parms[4].items) { /* -submounts */
2250 if (strcmp(ti->data, "on") == 0) smounts = 3;
2251 else if (strcmp(ti->data, "off") == 0) smounts = 2;
2253 fprintf(stderr, "Illegal argument %s\n", ti->data);
2257 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2260 blob.in = (char *) &exportcall;
2261 blob.in_size = sizeof(afs_int32);
2262 blob.out = (char *) &exportcall;
2263 blob.out_size = sizeof(afs_int32);
2264 code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
2266 if (errno == ENODEV) {
2267 fprintf(stderr, "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2275 if (exportcall & 1) {
2276 printf("'%s' translator is enabled with the following options:\n",
2277 exported_types[type]);
2278 printf("\tRunning in %s mode\n",
2279 (exportcall & 2 ? "strict unix"
2280 : "convert owner mode bits to world/other"));
2281 printf("\tRunning in %s mode\n",
2282 (exportcall & 4 ? "strict 'passwd sync'"
2283 : "no 'passwd sync'"));
2285 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs"
2286 : "Only mounts to /afs allowed"));
2289 printf("'%s' translator is disabled\n", exported_types[type]);
2295 static GetCellCmd(as)
2296 struct cmd_syndesc *as;
2299 struct ViceIoctl blob;
2300 struct afsconf_cell info;
2301 struct cmd_item *ti;
2308 memset(&args, '\0', sizeof args); /* avoid Purify UMR error */
2309 for(ti=as->parms[0].items; ti; ti=ti->next) {
2311 blob.out_size = sizeof(args);
2312 blob.out = (caddr_t) &args;
2313 code = GetCellName(ti->data, &info);
2318 blob.in_size = 1+strlen(info.name);
2319 blob.in = info.name;
2320 code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
2322 if (errno == ENOENT)
2323 fprintf(stderr, "%s: the cell named '%s' does not exist\n", pn, info.name);
2325 Die(errno, info.name);
2329 printf("Cell %s status: ", info.name);
2331 if (args.stat & 1) printf("primary ");
2333 if (args.stat & 2) printf("no setuid allowed");
2334 else printf("setuid allowed");
2335 if (args.stat & 4) printf(", using old VLDB");
2341 static SetCellCmd(as)
2342 struct cmd_syndesc *as;
2345 struct ViceIoctl blob;
2346 struct afsconf_cell info;
2347 struct cmd_item *ti;
2355 /* Check arguments. */
2356 if (as->parms[1].items && as->parms[2].items) {
2357 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
2361 /* figure stuff to set */
2365 if (! as->parms[1].items) args.stat |= 2; /* default to -nosuid */
2367 /* set stat for all listed cells */
2368 for(ti=as->parms[0].items; ti; ti=ti->next) {
2370 code = GetCellName(ti->data, &info);
2375 strcpy(args.cname, info.name);
2376 blob.in_size = sizeof(args);
2377 blob.in = (caddr_t) &args;
2379 blob.out = (caddr_t) 0;
2380 code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
2382 Die(errno, info.name); /* XXX added cell name to Die() call */
2389 static GetCellName(cellName, info)
2391 struct afsconf_cell *info;
2393 struct afsconf_dir *tdir;
2396 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
2398 fprintf(stderr, "Could not process files in configuration directory (%s).\n",
2399 AFSDIR_CLIENT_ETC_DIRPATH);
2403 code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
2405 fprintf(stderr, "%s: cell %s not in %s\n", pn, cellName,
2406 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
2414 static VLDBInit(noAuthFlag, info)
2416 struct afsconf_cell *info;
2419 struct ktc_principal sname;
2420 struct ktc_token ttoken;
2422 struct rx_securityClass *sc;
2423 struct rx_connection *serverconns[VLDB_MAXSERVERS];
2428 fprintf(stderr, "%s: could not initialize rx.\n", pn);
2432 rx_SetRxDeadTime(50);
2433 if (!noAuthFlag) { /* we don't need tickets for null */
2434 strcpy(sname.cell, info->name);
2435 sname.instance[0] = 0;
2436 strcpy(sname.name, "afs");
2437 code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), NULL);
2439 fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
2444 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
2446 fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
2452 else scIndex = 0; /* don't authenticate */
2455 sc = rxnull_NewClientSecurityObject();
2461 sc = (struct rx_securityClass *)
2462 rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
2463 ttoken.kvno, ttoken.ticketLen,
2467 if (info->numServers > VLDB_MAXSERVERS) {
2468 fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
2469 pn, info->numServers, VLDB_MAXSERVERS);
2472 memset(serverconns, 0, sizeof(serverconns));
2473 for (i = 0;i<info->numServers;i++)
2474 serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
2475 info->hostAddr[i].sin_port, USER_SERVICE_ID,
2478 code = ubik_ClientInit(serverconns, &uclient);
2481 fprintf(stderr, "%s: ubik client init failed.\n", pn);
2487 static struct ViceIoctl gblob;
2488 static int debug = 0;
2490 * here follow some routines in suport of the setserverprefs and
2491 * getserverprefs commands. They are:
2492 * SetPrefCmd "top-level" routine
2493 * addServer adds a server to the list of servers to be poked into the
2494 * kernel. Will poke the list into the kernel if it threatens
2496 * pokeServers pokes the existing list of servers and ranks into the kernel
2497 * GetPrefCmd reads the Cache Manager's current list of server ranks
2501 * returns -1 if error message printed,
2503 * errno value if error and no error message printed
2505 static pokeServers()
2509 code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
2510 if (code && (errno == EINVAL)) {
2511 struct setspref *ssp;
2512 ssp = (struct setspref *)gblob.in;
2513 if (!(ssp->flags & DBservers)) {
2514 gblob.in = (void *) &(ssp->servers[0]);
2515 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
2516 code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
2517 return code ? errno : 0;
2520 "This cache manager does not support VL server preferences.\n");
2524 return code ? errno : 0;
2528 * returns -1 if error message printed,
2530 * errno value if error and no error message printed
2532 static addServer(name, rank)
2537 struct setspref *ssp;
2539 struct hostent *thostent;
2545 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
2547 #define MAXUSHORT ((unsigned short) ~0)
2551 thostent = hostutil_GetHostByName(name);
2553 fprintf(stderr, "%s: couldn't resolve name.\n", name);
2557 ssp = (struct setspref *)(gblob.in);
2559 for (t = 0; thostent->h_addr_list[t]; t++) {
2560 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
2561 code = pokeServers();
2562 if (code) error = code;
2563 ssp->num_servers = 0;
2566 sp = (struct spref *) (gblob.in + gblob.in_size);
2567 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
2568 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
2569 gblob.in_size += sizeof(struct spref);
2573 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
2574 name,sp->rank,sp->server.s_addr);
2581 static SetPrefCmd(as)
2582 struct cmd_syndesc *as;
2586 struct cmd_item *ti;
2589 struct setspref *ssp;
2590 int error = 0; /* -1 means error message printed,
2591 * >0 means errno value for unprinted message */
2593 ssp = (struct setspref *)space;
2595 ssp->num_servers = 0;
2596 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2599 gblob.out_size = MAXSIZE;
2603 fprintf(stderr, "Permission denied: requires root access.\n");
2607 ti = as->parms[2].items; /* -file */
2609 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2610 if (!(infd = fopen(ti->data,"r"))) {
2615 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
2616 code = addServer(name, (unsigned short) rank);
2617 if (code) error = code;
2622 ti = as->parms[3].items; /* -stdin */
2624 while (scanf("%79s%ld", name, &rank) != EOF) {
2625 code = addServer(name, (unsigned short) rank);
2626 if (code) error = code;
2630 for (ti = as->parms[0].items;ti;ti=ti->next) { /* list of servers, ranks */
2635 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2636 if (code) error = code;
2638 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
2642 code = pokeServers();
2643 if (code) error = code;
2645 printf("now working on vlservers, code=%d\n",code);
2647 ssp = (struct setspref *)space;
2648 ssp->flags = DBservers;
2649 ssp->num_servers = 0;
2650 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2653 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
2658 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2659 if (code) error = code;
2661 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
2666 if (as->parms[1].items) {
2668 printf("now poking vlservers\n");
2669 code = pokeServers();
2670 if (code) error = code;
2676 return error ? 1 : 0;
2681 static GetPrefCmd(as)
2682 struct cmd_syndesc *as;
2685 struct cmd_item *ti;
2686 char *name, tbuffer[20];
2687 afs_int32 rank,addr;
2691 struct ViceIoctl blob;
2692 struct sprefrequest *in;
2693 struct sprefinfo *out;
2696 ti = as->parms[0].items; /* -file */
2698 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2699 if (!(outfd = freopen(ti->data,"w",stdout))) {
2705 ti = as->parms[1].items; /* -numeric */
2707 ti = as->parms[2].items; /* -vlservers */
2708 vlservers |= (ti ? DBservers : 0);
2709 /* ti = as->parms[3].items; -cell */
2711 in = (struct sprefrequest *)space;
2715 blob.in_size=sizeof(struct sprefrequest);
2716 blob.in = (char *)in;
2718 blob.out_size = MAXSIZE;
2720 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
2721 in->flags = vlservers;
2723 code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
2725 perror("getserverprefs pioctl");
2729 out = (struct sprefinfo *) blob.out;
2731 for (i=0;i<out->num_servers;i++) {
2733 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
2736 addr = ntohl(out->servers[i].server.s_addr);
2737 sprintf(tbuffer, "%d.%d.%d.%d",
2738 (addr>>24) & 0xff, (addr>>16) & 0xff,
2739 (addr>>8) & 0xff, addr & 0xff);
2742 printf("%-50s %5u\n",name,out->servers[i].rank);
2745 in->offset = out->next_offset;
2746 } while (out->next_offset > 0);
2751 static StoreBehindCmd(as)
2752 struct cmd_syndesc *as;
2755 struct ViceIoctl blob;
2756 struct cmd_item *ti;
2757 struct sbstruct tsb, tsb2;
2763 tsb.sb_thisfile = -1;
2764 ti=as->parms[0].items; /* -kbytes */
2766 if (!as->parms[1].items) {
2767 fprintf(stderr, "%s: you must specify -files with -kbytes.\n", pn);
2770 tsb.sb_thisfile = strtol(ti->data,&t,10) * 1024;
2771 if ((tsb.sb_thisfile < 0) || (t != ti->data+strlen(ti->data))) {
2772 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2778 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
2779 ti=as->parms[2].items; /* -allfiles */
2781 allfiles = strtol(ti->data,&t,10) * 1024;
2782 if ((allfiles < 0) || (t != ti->data+strlen(ti->data))) {
2783 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2789 /* -verbose or -file only or no options */
2790 if (as->parms[3].items ||
2791 (as->parms[1].items && !as->parms[0].items) ||
2792 (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items))
2795 blob.in = (char *)&tsb;
2796 blob.out = (char *)&tsb2;
2797 blob.in_size = blob.out_size = sizeof(struct sbstruct);
2798 memset(&tsb2, 0, sizeof(tsb2));
2800 /* once per -file */
2801 for (ti=as->parms[1].items; ti; ti=ti->next) {
2802 /* Do this solely to see if the file is there */
2803 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
2805 Die(errno, ti->data);
2810 code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
2812 Die(errno, ti->data);
2817 if (verbose && (blob.out_size == sizeof(tsb2))) {
2818 if (tsb2.sb_thisfile == -1) {
2819 fprintf(stdout, "Will store %s according to default.\n",
2824 "Will store up to %d kbytes of %s asynchronously.\n",
2825 (tsb2.sb_thisfile/1024), ti->data);
2830 /* If no files - make at least one pioctl call, or
2831 * set the allfiles default if we need to.
2833 if (!as->parms[1].items || (allfiles != -1)) {
2834 tsb.sb_default = allfiles;
2835 code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
2837 Die(errno, ((allfiles == -1)?0:"-allfiles"));
2842 /* Having no arguments also reports the default store asynchrony */
2843 if (verbose && (blob.out_size == sizeof(tsb2))) {
2844 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
2845 (tsb2.sb_default/1024));
2852 static afs_int32 SetCryptCmd(as)
2853 struct cmd_syndesc *as;
2855 afs_int32 code = 0, flag;
2856 struct ViceIoctl blob;
2859 tp = as->parms[0].items->data;
2860 if (strcmp(tp, "on") == 0)
2862 else if (strcmp(tp, "off") == 0)
2865 fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
2869 blob.in = (char *) &flag;
2870 blob.in_size = sizeof(flag);
2872 code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
2879 static afs_int32 GetCryptCmd(as)
2880 struct cmd_syndesc *as;
2882 afs_int32 code = 0, flag;
2883 struct ViceIoctl blob;
2888 blob.out_size = sizeof(flag);
2891 code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
2893 if (code) Die(errno, NULL);
2896 memcpy(&flag, tp, sizeof(afs_int32));
2897 printf("Security level is currently ");
2899 printf("crypt (data security).\n");
2906 #include "AFS_component_version_number.c"
2913 struct cmd_syndesc *ts;
2915 #ifdef AFS_AIX32_ENV
2917 * The following signal action for AIX is necessary so that in case of a
2918 * crash (i.e. core is generated) we can include the user's data section
2919 * in the core dump. Unfortunately, by default, only a partial core is
2920 * generated which, in many cases, isn't too useful.
2922 struct sigaction nsa;
2924 sigemptyset(&nsa.sa_mask);
2925 nsa.sa_handler = SIG_DFL;
2926 nsa.sa_flags = SA_FULLDUMP;
2927 sigaction(SIGSEGV, &nsa, NULL);
2930 /* try to find volume location information */
2931 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0, "get client network interface addresses");
2932 cmd_CreateAlias(ts, "gc");
2934 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0, "set client network interface addresses");
2935 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "client network interfaces");
2936 cmd_CreateAlias(ts, "sc");
2938 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
2939 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
2940 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
2941 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
2942 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
2943 cmd_CreateAlias(ts, "sp");
2945 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
2946 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
2947 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2948 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
2949 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
2950 cmd_CreateAlias(ts, "gp");
2952 ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
2953 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2954 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
2955 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
2956 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
2957 parm_setacl_id = ts->nParms;
2958 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
2959 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
2960 cmd_CreateAlias(ts, "sa");
2962 ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
2963 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2964 parm_listacl_id = ts->nParms;
2965 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2966 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2967 cmd_CreateAlias(ts, "la");
2969 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
2970 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2972 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
2973 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
2974 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
2975 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
2976 parm_copyacl_id = ts->nParms;
2977 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2978 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2980 cmd_CreateAlias(ts, "ca");
2982 ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
2983 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2984 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0, "flush mount symlink from cache");
2985 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2987 ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
2988 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2989 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
2991 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
2992 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
2994 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
2995 cmd_CreateAlias(ts, "sv");
2997 ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
2998 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
3000 ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
3001 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3002 cmd_CreateAlias(ts, "lv");
3003 cmd_CreateAlias(ts, "listvol");
3005 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
3006 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3007 cmd_CreateAlias(ts, "lq");
3009 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
3010 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3011 cmd_CreateAlias(ts, "df");
3013 ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
3014 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3016 ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
3017 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3019 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
3020 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
3021 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
3022 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
3023 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
3024 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
3030 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
3034 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
3035 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3037 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
3038 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
3039 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
3040 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
3041 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
3043 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
3044 cmd_CreateAlias(ts, "checkbackups");
3047 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
3048 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
3049 cmd_CreateAlias(ts, "cachesize");
3051 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
3053 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
3055 ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
3056 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
3058 ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
3060 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
3061 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
3062 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
3064 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
3066 cmd_CreateAlias(ts, "sq");
3068 ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
3069 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
3070 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
3071 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
3073 ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
3074 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
3075 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
3077 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
3079 * Turn this on only if you wish to be able to talk to a server which is listening
3080 * on alternative ports. This is not intended for general use and may not be
3081 * supported in the cache manager. It is not a way to run two servers at the
3082 * same host, since the cache manager cannot properly distinguish those two hosts.
3084 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
3085 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
3088 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
3089 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3091 ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
3092 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3094 ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
3097 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
3100 /* set cache monitor host address */
3101 ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *) CMD_HIDDEN);
3102 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
3103 cmd_CreateAlias(ts, "mariner");
3105 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
3106 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3108 ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
3109 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3110 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
3111 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
3113 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
3114 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3116 ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
3117 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
3119 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
3120 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
3121 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator (on | off)");
3122 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode (on | off)");
3123 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode (on | off)");
3124 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. (on | off)");
3127 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
3128 "store to server after file close");
3129 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
3130 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
3131 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
3132 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
3133 cmd_CreateAlias(ts, "sb");
3135 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
3136 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
3138 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "set cache manager encryption flag");
3140 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
3141 "Manage per process RX statistics");
3142 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3144 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3145 "Disable RX stats");
3146 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3149 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
3150 "Manage per peer RX statistics");
3151 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3153 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3154 "Disable RX stats");
3155 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3158 code = cmd_Dispatch(argc, argv);
3159 if (rxInitDone) rx_Finalize();
3164 static void Die(errnum, filename)
3171 fprintf(stderr, "%s: Invalid argument; it is possible that %s is not in AFS.\n",
3174 fprintf(stderr, "%s: Invalid argument.\n", pn);
3178 fprintf(stderr, "%s: File '%s' doesn't exist\n", pn, filename);
3180 fprintf(stderr, "%s: no such file returned\n", pn);
3183 fprintf(stderr, "%s: You can not change a backup or readonly volume\n", pn);
3188 fprintf(stderr, "%s: You don't have the required access rights on '%s'\n",
3191 fprintf(stderr, "%s: You do not have the required rights to do this operation\n",
3196 fprintf(stderr, "%s:'%s'", pn, filename);
3198 fprintf(stderr, "%s", pn);
3199 fprintf(stderr, ": %s\n", error_message(errnum));
3204 /* get clients interface addresses */
3206 GetClientAddrsCmd(as)
3207 struct cmd_syndesc *as;
3210 struct cmd_item *ti;
3212 struct ViceIoctl blob;
3213 struct sprefrequest *in;
3214 struct sprefinfo *out;
3216 in = (struct sprefrequest *)space;
3221 blob.in_size=sizeof(struct sprefrequest);
3222 blob.in = (char *)in;
3224 blob.out_size = MAXSIZE;
3226 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
3227 /* returns addr in network byte order */
3228 code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
3230 perror("getClientInterfaceAddr pioctl");
3236 out = (struct sprefinfo *) blob.out;
3237 for (i=0; i < out->num_servers; i++) {
3240 addr = ntohl(out->servers[i].server.s_addr);
3241 sprintf(tbuffer, "%d.%d.%d.%d",
3242 (addr>>24) & 0xff, (addr>>16) & 0xff,
3243 (addr>>8) & 0xff, addr & 0xff);
3244 printf ("%-50s\n", tbuffer);
3246 in->offset = out->next_offset;
3248 } while (out->next_offset > 0);
3254 SetClientAddrsCmd(as)
3255 struct cmd_syndesc *as;
3257 afs_int32 code, addr;
3258 struct cmd_item *ti;
3260 struct ViceIoctl blob;
3261 struct setspref *ssp;
3262 int sizeUsed = 0, i, flag;
3263 afs_int32 existingAddr[1024]; /* existing addresses on this host */
3267 ssp = (struct setspref *)space;
3268 ssp->num_servers = 0;
3271 blob.out_size = MAXSIZE;
3274 fprintf(stderr, "Permission denied: requires root access.\n");
3278 /* extract all existing interface addresses */
3279 existNu = rx_getAllAddr(existingAddr,1024);
3283 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
3284 for (ti = as->parms[0].items;ti;ti=ti->next) {
3285 if (sizeUsed >= sizeof(space)) {
3286 fprintf(stderr, "No more space\n");
3289 addr = extractAddr(ti->data, 20); /* network order */
3290 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
3291 fprintf(stderr, "Error in specifying address: %s..ignoring\n", ti->data);
3295 /* see if it is an address that really exists */
3296 for (flag = 0, i=0; i < existNu; i++)
3297 if (existingAddr[i] == addr) {
3301 if (!flag) { /* this is an nonexistent address */
3302 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
3306 /* copy all specified addr into ioctl buffer */
3307 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
3308 printf("Adding 0x%08x\n", addr);
3310 sizeUsed += sizeof(struct spref);
3312 if (ssp->num_servers < 1) {
3313 fprintf(stderr, "No addresses specified\n");
3316 blob.in_size = sizeUsed - sizeof(struct spref);
3318 code = pioctl(0, VIOC_SETCPREFS, &blob, 1); /* network order */
3329 struct cmd_syndesc *as;
3332 struct ViceIoctl blob;
3333 struct cmd_item *ti;
3334 char orig_name[1024]; /*Original name, may be modified*/
3335 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
3336 char parent_dir[1024]; /*Parent directory of true name*/
3337 char *last_component; /*Last component of true name*/
3338 struct stat statbuff; /*Buffer for status info*/
3339 int link_chars_read; /*Num chars read in readlink()*/
3340 int thru_symlink; /*Did we get to a mount point via a symlink?*/
3343 for(ti=as->parms[0].items; ti; ti=ti->next) {
3346 sprintf(orig_name, "%s%s",
3347 (ti->data[0] == '/') ? "" : "./",
3350 if (lstat(orig_name, &statbuff) < 0) {
3351 /* if lstat fails, we should still try the pioctl, since it
3352 may work (for example, lstat will fail, but pioctl will
3353 work if the volume of offline (returning ENODEV). */
3354 statbuff.st_mode = S_IFDIR; /* lie like pros */
3358 * The lstat succeeded. If the given file is a symlink, substitute
3359 * the file name with the link name.
3361 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
3364 * Read name of resolved file.
3366 link_chars_read = readlink(orig_name, true_name, 1024);
3367 if (link_chars_read <= 0) {
3368 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
3375 * Add a trailing null to what was read, bump the length.
3377 true_name[link_chars_read++] = 0;
3380 * If the symlink is an absolute pathname, we're fine. Otherwise, we
3381 * have to create a full pathname using the original name and the
3382 * relative symlink name. Find the rightmost slash in the original
3383 * name (we know there is one) and splice in the symlink value.
3385 if (true_name[0] != '/') {
3386 last_component = (char *) strrchr(orig_name, '/');
3387 strcpy(++last_component, true_name);
3388 strcpy(true_name, orig_name);
3392 strcpy(true_name, orig_name);
3395 * Find rightmost slash, if any.
3397 last_component = (char *) strrchr(true_name, '/');
3398 if (last_component) {
3400 * Found it. Designate everything before it as the parent directory,
3401 * everything after it as the final component.
3403 strncpy(parent_dir, true_name, last_component - true_name);
3404 parent_dir[last_component - true_name] = 0;
3405 last_component++; /*Skip the slash*/
3409 * No slash appears in the given file name. Set parent_dir to the current
3410 * directory, and the last component as the given name.
3412 strcpy(parent_dir, ".");
3413 last_component = true_name;
3416 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
3417 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
3418 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n", pn);
3423 blob.in = last_component;
3424 blob.in_size = strlen(last_component)+1;
3426 memset(space, 0, MAXSIZE);
3428 code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
3431 if (errno == EINVAL) {
3432 fprintf(stderr, "'%s' is not a mount point.\n",
3436 Die(errno, (ti->data ? ti->data : parent_dir));
3446 struct cmd_syndesc *as;
3449 afs_int32 flags = 0;
3450 struct ViceIoctl blob;
3451 struct cmd_item *ti;
3453 if (as->parms[0].items) { /* -enable*/
3454 flags |= AFSCALL_RXSTATS_ENABLE;
3456 if (as->parms[1].items) { /* -disable*/
3457 flags |= AFSCALL_RXSTATS_DISABLE;
3459 if (as->parms[2].items) { /* -clear*/
3460 flags |= AFSCALL_RXSTATS_CLEAR;
3463 fprintf(stderr, "You must specify at least one argument\n");
3467 blob.in = (char *)&flags;
3468 blob.in_size = sizeof(afs_int32);
3471 code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
3482 struct cmd_syndesc *as;
3485 afs_int32 flags = 0;
3486 struct ViceIoctl blob;
3487 struct cmd_item *ti;
3489 if (as->parms[0].items) { /* -enable*/
3490 flags |= AFSCALL_RXSTATS_ENABLE;
3492 if (as->parms[1].items) { /* -disable*/
3493 flags |= AFSCALL_RXSTATS_DISABLE;
3495 if (as->parms[2].items) { /* -clear*/
3496 flags |= AFSCALL_RXSTATS_CLEAR;
3499 fprintf(stderr, "You must specify at least one argument\n");
3503 blob.in = (char *)&flags;
3504 blob.in_size = sizeof(afs_int32);
3507 code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);