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>
32 #include "afs/prs_fs.h"
33 #include <afs/afsint.h>
35 #include <afs/cellconfig.h>
38 #include <rx/rx_globals.h>
39 #include <afs/vldbint.h>
40 #include <afs/volser.h>
41 #include <afs/vlserver.h>
44 #include <afs/afsutil.h>
47 #include <afs/ptclient.h>
52 #define MAXCELLHOSTS 8
55 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
56 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
58 static char space[MAXSIZE];
59 static char tspace[1024];
60 static struct ubik_client *uclient;
62 static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
63 static int RxStatProcCmd(), RxStatPeerCmd();
65 extern char *hostutil_GetNameByINet();
66 extern struct hostent *hostutil_GetHostByName();
69 extern struct cmd_syndesc *cmd_CreateSyntax();
70 static char pn[] = "fs";
71 static int rxInitDone = 0;
73 static void ZapList();
74 static int PruneList();
82 * Character to use between name and rights in printed representation for
85 #define DFS_SEPARATOR ' '
87 typedef char sec_rgy_name_t[1025]; /* A DCE definition */
90 int dfs; /* Originally true if a dfs acl; now also the type
91 of the acl (1, 2, or 3, corresponding to object,
92 initial dir, or initial object). */
93 sec_rgy_name_t cell; /* DFS cell name */
96 struct AclEntry *pluslist;
97 struct AclEntry *minuslist;
101 struct AclEntry *next;
106 static void ZapAcl(acl)
110 ZapList(acl->pluslist);
111 ZapList(acl->minuslist);
123 if (t >= 'A' && t <= 'Z') t += 0x20;
124 if (u >= 'A' && u <= 'Z') u += 0x20;
125 if (t != u) return 1;
126 if (t == 0) return 0;
131 * Mods for the AFS/DFS protocol translator.
133 * DFS rights. It's ugly to put these definitions here, but they
134 * *cannot* change, because they're part of the wire protocol.
135 * In any event, the protocol translator will guarantee these
136 * assignments for AFS cache managers.
138 #define DFS_READ 0x01
139 #define DFS_WRITE 0x02
140 #define DFS_EXECUTE 0x04
141 #define DFS_CONTROL 0x08
142 #define DFS_INSERT 0x10
143 #define DFS_DELETE 0x20
145 /* the application definable ones (backwards from AFS) */
146 #define DFS_USR0 0x80000000 /* "A" bit */
147 #define DFS_USR1 0x40000000 /* "B" bit */
148 #define DFS_USR2 0x20000000 /* "C" bit */
149 #define DFS_USR3 0x10000000 /* "D" bit */
150 #define DFS_USR4 0x08000000 /* "E" bit */
151 #define DFS_USR5 0x04000000 /* "F" bit */
152 #define DFS_USR6 0x02000000 /* "G" bit */
153 #define DFS_USR7 0x01000000 /* "H" bit */
154 #define DFS_USRALL (DFS_USR0 | DFS_USR1 | DFS_USR2 | DFS_USR3 |\
155 DFS_USR4 | DFS_USR5 | DFS_USR6 | DFS_USR7)
158 * Offset of -id switch in command structure for various commands.
159 * The -if switch is the next switch always.
161 static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
164 * Determine whether either the -id or -if switches are present, and
165 * return 0, 1 or 2, as appropriate. Abort if both switches are present.
167 static int getidf(as, id)
168 struct cmd_syndesc *as;
169 int id; /* Offset of -id switch; -if is next switch */
173 if (as->parms[id].items) {
176 if (as->parms[id + 1].items) {
182 "%s: you may specify either -id or -if, but not both switches\n",
189 static int PRights(arights, dfs)
194 if (arights & PRSFS_READ) printf("r");
195 if (arights & PRSFS_LOOKUP) printf("l");
196 if (arights & PRSFS_INSERT) printf("i");
197 if (arights & PRSFS_DELETE) printf("d");
198 if (arights & PRSFS_WRITE) printf("w");
199 if (arights & PRSFS_LOCK) printf("k");
200 if (arights & PRSFS_ADMINISTER) printf("a");
201 if (arights & PRSFS_USR0) printf("A");
202 if (arights & PRSFS_USR1) printf("B");
203 if (arights & PRSFS_USR2) printf("C");
204 if (arights & PRSFS_USR3) printf("D");
205 if (arights & PRSFS_USR4) printf("E");
206 if (arights & PRSFS_USR5) printf("F");
207 if (arights & PRSFS_USR6) printf("G");
208 if (arights & PRSFS_USR7) printf("H");
210 if (arights & DFS_READ) printf("r"); else printf("-");
211 if (arights & DFS_WRITE) printf("w"); else printf("-");
212 if (arights & DFS_EXECUTE) printf("x"); else printf("-");
213 if (arights & DFS_CONTROL) printf("c"); else printf("-");
214 if (arights & DFS_INSERT) printf("i"); else printf("-");
215 if (arights & DFS_DELETE) printf("d"); else printf("-");
216 if (arights & (DFS_USRALL)) printf("+");
217 if (arights & DFS_USR0) printf("A");
218 if (arights & DFS_USR1) printf("B");
219 if (arights & DFS_USR2) printf("C");
220 if (arights & DFS_USR3) printf("D");
221 if (arights & DFS_USR4) printf("E");
222 if (arights & DFS_USR5) printf("F");
223 if (arights & DFS_USR6) printf("G");
224 if (arights & DFS_USR7) printf("H");
228 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
229 static int InAFS(apath)
232 struct ViceIoctl blob;
236 blob.out_size = MAXSIZE;
239 code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
241 if ((errno == EINVAL) || (errno == ENOENT)) return 0;
246 /* return a static pointer to a buffer */
247 static char *Parent(apath)
251 strcpy(tspace, apath);
252 tp = strrchr(tspace, '/');
256 else strcpy(tspace, ".");
260 enum rtype {add, destroy, deny};
262 static afs_int32 Convert(arights, dfs, rtypep)
271 *rtypep = add; /* add rights, by default */
274 if (!strcmp(arights, "null")) {
278 if (!strcmp(arights,"read")) return DFS_READ | DFS_EXECUTE;
279 if (!strcmp(arights, "write")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE;
280 if (!strcmp(arights, "all")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE | DFS_CONTROL;
282 if (!strcmp(arights,"read")) return PRSFS_READ | PRSFS_LOOKUP;
283 if (!strcmp(arights, "write")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
284 if (!strcmp(arights, "mail")) return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
285 if (!strcmp(arights, "all")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
287 if (!strcmp(arights, "none")) {
288 *rtypep = destroy; /* Remove entire entry */
291 len = strlen(arights);
296 if (tc == '-') continue;
297 else if (tc == 'r') mode |= DFS_READ;
298 else if (tc == 'w') mode |= DFS_WRITE;
299 else if (tc == 'x') mode |= DFS_EXECUTE;
300 else if (tc == 'c') mode |= DFS_CONTROL;
301 else if (tc == 'i') mode |= DFS_INSERT;
302 else if (tc == 'd') mode |= DFS_DELETE;
303 else if (tc == 'A') mode |= DFS_USR0;
304 else if (tc == 'B') mode |= DFS_USR1;
305 else if (tc == 'C') mode |= DFS_USR2;
306 else if (tc == 'D') mode |= DFS_USR3;
307 else if (tc == 'E') mode |= DFS_USR4;
308 else if (tc == 'F') mode |= DFS_USR5;
309 else if (tc == 'G') mode |= DFS_USR6;
310 else if (tc == 'H') mode |= DFS_USR7;
312 fprintf(stderr, "%s: illegal DFS rights character '%c'.\n", pn, tc);
316 if (tc == 'r') mode |= PRSFS_READ;
317 else if (tc == 'l') mode |= PRSFS_LOOKUP;
318 else if (tc == 'i') mode |= PRSFS_INSERT;
319 else if (tc == 'd') mode |= PRSFS_DELETE;
320 else if (tc == 'w') mode |= PRSFS_WRITE;
321 else if (tc == 'k') mode |= PRSFS_LOCK;
322 else if (tc == 'a') mode |= PRSFS_ADMINISTER;
323 else if (tc == 'A') mode |= PRSFS_USR0;
324 else if (tc == 'B') mode |= PRSFS_USR1;
325 else if (tc == 'C') mode |= PRSFS_USR2;
326 else if (tc == 'D') mode |= PRSFS_USR3;
327 else if (tc == 'E') mode |= PRSFS_USR4;
328 else if (tc == 'F') mode |= PRSFS_USR5;
329 else if (tc == 'G') mode |= PRSFS_USR6;
330 else if (tc == 'H') mode |= PRSFS_USR7;
332 fprintf(stderr, "%s: illegal rights character '%c'.\n", pn, tc);
340 static struct AclEntry *FindList(alist, aname)
341 struct AclEntry *alist;
345 if (!foldcmp(alist->name, aname)) return alist;
351 /* if no parm specified in a particular slot, set parm to be "." instead */
352 static void SetDotDefault(aitemp)
353 struct cmd_item **aitemp;
356 if (*aitemp) return; /* already has value */
357 /* otherwise, allocate an item representing "." */
358 ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
360 ti->next = (struct cmd_item *) 0;
361 ti->data = (char *) malloc(2);
363 strcpy(ti->data, ".");
367 static void ChangeList(al, plus, aname, arights)
373 struct AclEntry *tlist;
374 tlist = (plus ? al->pluslist : al->minuslist);
375 tlist = FindList (tlist, aname);
377 /* Found the item already in the list. */
378 tlist->rights = arights;
380 al->nplus -= PruneList(&al->pluslist, al->dfs);
382 al->nminus -= PruneList(&al->minuslist, al->dfs);
385 /* Otherwise we make a new item and plug in the new data. */
386 tlist = (struct AclEntry *) malloc(sizeof (struct AclEntry));
388 strcpy(tlist->name, aname);
389 tlist->rights = arights;
391 tlist->next = al->pluslist;
392 al->pluslist = tlist;
394 if (arights == 0 || arights == -1)
395 al->nplus -= PruneList(&al->pluslist, al->dfs);
398 tlist->next = al->minuslist;
399 al->minuslist = tlist;
401 if (arights == 0) al->nminus -= PruneList(&al->minuslist, al->dfs);
405 static void ZapList(alist)
406 struct AclEntry *alist;
408 struct AclEntry *tp, *np;
409 for (tp = alist; tp; tp = np) {
415 static int PruneList(ae, dfs)
416 struct AclEntry **ae;
419 struct AclEntry **lp;
420 struct AclEntry *te, *ne;
424 for(te = *ae;te;te=ne) {
425 if ((!dfs && te->rights == 0) || te->rights == -1) {
439 static char *SkipLine(astr)
442 while (*astr !='\n') astr++;
448 * Create an empty acl, taking into account whether the acl pointed
449 * to by astr is an AFS or DFS acl. Only parse this minimally, so we
450 * can recover from problems caused by bogus ACL's (in that case, always
451 * assume that the acl is AFS: for DFS, the user can always resort to
452 * acl_edit, but for AFS there may be no other way out).
454 static struct Acl *EmptyAcl(astr)
460 tp = (struct Acl *)malloc(sizeof (struct Acl));
462 tp->nplus = tp->nminus = 0;
463 tp->pluslist = tp->minuslist = 0;
465 sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
469 static struct Acl *ParseAcl(astr)
472 int nplus, nminus, i, trights;
474 struct AclEntry *first, *last, *tl;
477 ta = (struct Acl *) malloc (sizeof (struct Acl));
480 sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
481 astr = SkipLine(astr);
482 sscanf(astr, "%d", &ta->nminus);
483 astr = SkipLine(astr);
490 for(i=0;i<nplus;i++) {
491 sscanf(astr, "%100s %d", tname, &trights);
492 astr = SkipLine(astr);
493 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
495 if (!first) first = tl;
496 strcpy(tl->name, tname);
497 tl->rights = trights;
499 if (last) last->next = tl;
502 ta->pluslist = first;
506 for(i=0;i<nminus;i++) {
507 sscanf(astr, "%100s %d", tname, &trights);
508 astr = SkipLine(astr);
509 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
511 if (!first) first = tl;
512 strcpy(tl->name, tname);
513 tl->rights = trights;
515 if (last) last->next = tl;
518 ta->minuslist = first;
523 static PrintStatus(status, name, offmsg)
524 VolumeStatus *status;
528 printf("Volume status for vid = %u named %s\n",status->Vid, name);
530 printf("Current offline message is %s\n",offmsg);
531 printf("Current disk quota is ");
532 if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota);
533 else printf("unlimited\n");
534 printf("Current blocks used are %d\n",status->BlocksInUse);
535 printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
538 static QuickPrintStatus(status, name)
539 VolumeStatus *status;
542 double QuotaUsed =0.0;
543 double PartUsed =0.0;
545 printf("%-25.25s",name);
547 if (status->MaxQuota != 0) {
548 printf("%10d%10d", status->MaxQuota, status->BlocksInUse);
549 QuotaUsed = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
551 printf(" no limit%10d", status->BlocksInUse);
553 if (QuotaUsed > 90.0) {
554 printf("%5.0f%%<<", QuotaUsed);
557 else printf("%5.0f%% ", QuotaUsed);
558 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
559 if (PartUsed > 97.0) {
560 printf("%9.0f%%<<", PartUsed);
563 else printf("%9.0f%% ", PartUsed);
565 printf(" <<WARNING\n");
570 static QuickPrintSpace(status, name)
571 VolumeStatus *status;
574 double PartUsed =0.0;
576 printf("%-25.25s",name);
578 printf("%10d%10d%10d", status->PartMaxBlocks, status->PartMaxBlocks - status->PartBlocksAvail, status->PartBlocksAvail);
580 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
581 if (PartUsed > 90.0){
582 printf(" %4.0f%%<<", PartUsed);
585 else printf(" %4.0f%% ", PartUsed);
587 printf(" <<WARNING\n");
592 static char *AclToString(acl)
595 static char mydata[MAXSIZE];
596 char tstring[MAXSIZE];
600 if (acl->dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
601 else dfsstring[0] = '\0';
602 sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
603 for(tp = acl->pluslist;tp;tp=tp->next) {
604 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
605 strcat(mydata, tstring);
607 for(tp = acl->minuslist;tp;tp=tp->next) {
608 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
609 strcat(mydata, tstring);
615 struct cmd_syndesc *as;
618 struct ViceIoctl blob;
620 struct cmd_item *ti, *ui;
624 int idf = getidf(as, parm_setacl_id);
627 if (as->parms[2].items) clear=1;
629 plusp = !(as->parms[3].items);
630 for(ti=as->parms[0].items; ti;ti=ti->next) {
631 blob.out_size = MAXSIZE;
633 blob.in = blob.out = space;
634 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
636 Die(errno, ti->data);
642 ta = ParseAcl(space);
643 if (!plusp && ta->dfs) {
645 "%s: %s: you may not use the -negative switch with DFS acl's.\n%s",
647 "(you may specify \"null\" to revoke all rights, however)\n");
653 if (clear) ta = EmptyAcl(space);
654 else ta = ParseAcl(space);
655 CleanAcl(ta, ti->data);
656 for(ui=as->parms[1].items; ui; ui=ui->next->next) {
659 fprintf(stderr, "%s: Missing second half of user/access pair.\n", pn);
663 rights = Convert(ui->next->data, ta->dfs, &rtype);
664 if (rtype == destroy && !ta->dfs) {
665 struct AclEntry *tlist;
667 tlist = (plusp ? ta->pluslist : ta->minuslist);
668 if (!FindList(tlist, ui->data))
671 if (rtype == deny && !ta->dfs) plusp = 0;
672 if (rtype == destroy && ta->dfs) rights = -1;
673 ChangeList(ta, plusp, ui->data, rights);
675 blob.in = AclToString(ta);
677 blob.in_size = 1+strlen(blob.in);
678 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
680 if (errno == EINVAL) {
682 static char *fsenv = 0;
684 fsenv = (char *)getenv("FS_EXPERT");
686 fprintf(stderr, "%s: \"Invalid argument\" was returned when you tried to store a DFS access list.\n", pn);
689 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
690 "\nPossible reasons for this include:\n\n",
691 " -You may have specified an inappropriate combination of rights.\n",
692 " For example, some DFS-supported filesystems may not allow you to\n",
693 " drop the \"c\" right from \"user_obj\".\n\n",
694 " -A mask_obj may be required (it is likely required by the underlying\n",
695 " filesystem if you try to set anything other than the basic \"user_obj\"\n",
696 " \"mask_obj\", or \"group_obj\" entries). Unlike acl_edit, the fs command\n",
697 " does not automatically create or update the mask_obj. Try setting\n",
698 " the rights \"mask_obj all\" with \"fs sa\" before adding any explicit\n",
699 " users or groups. You can do this with a single command, such as\n",
700 " \"fs sa mask_obj all user:somename read\"\n\n",
701 " -A specified user or group may not exist.\n\n",
702 " -You may have tried to delete \"user_obj\", \"group_obj\", or \"other_obj\".\n",
703 " This is probably not allowed by the underlying file system.\n\n",
704 " -If you add a user or group to a DFS ACL, remember that it must be\n",
705 " fully specified as \"user:username\" or \"group:groupname\". In addition, there\n",
706 " may be local requirements on the format of the user or group name.\n",
707 " Check with your cell administrator.\n\n",
708 " -Or numerous other possibilities. It would be great if we could be more\n",
709 " precise about the actual problem, but for various reasons, this is\n",
710 " impractical via this interface. If you can't figure it out, you\n",
711 " might try logging into a DCE-equipped machine and use acl_edit (or\n",
712 " whatever is provided). You may get better results. Good luck!\n\n",
713 " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
716 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
717 fprintf(stderr, "\t-File not in AFS\n");
718 fprintf(stderr, "\t-Too many users on access control list\n");
719 fprintf(stderr, "\t-Tried to add non-existent user to access control list\n");
723 Die(errno, ti->data);
733 static CopyACLCmd(as)
734 struct cmd_syndesc *as;
737 struct ViceIoctl blob;
738 struct Acl *fa, *ta = 0;
740 struct cmd_item *ti, *ui;
744 int idf = getidf(as, parm_copyacl_id);
747 if (as->parms[2].items) clear=1;
749 blob.out_size = MAXSIZE;
751 blob.in = blob.out = space;
752 code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
754 Die(errno, as->parms[0].items->data);
757 fa = ParseAcl(space);
758 CleanAcl(fa, as->parms[0].items->data);
759 for (ti=as->parms[1].items; ti;ti=ti->next) {
760 blob.out_size = MAXSIZE;
762 blob.in = blob.out = space;
763 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
765 Die(errno, ti->data);
771 if (clear) ta = EmptyAcl(space);
772 else ta = ParseAcl(space);
773 CleanAcl(ta, ti->data);
774 if (ta->dfs != fa->dfs) {
775 fprintf(stderr, "%s: incompatible file system types: acl not copied to %s; aborted\n", pn, ti->data);
780 if (! clear && strcmp(ta->cell, fa->cell) != 0) {
781 fprintf(stderr, "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", pn, ti->data);
785 strcpy(ta->cell, fa->cell);
787 for (tp = fa->pluslist;tp;tp=tp->next)
788 ChangeList(ta, 1, tp->name, tp->rights);
789 for (tp = fa->minuslist;tp;tp=tp->next)
790 ChangeList(ta, 0, tp->name, tp->rights);
791 blob.in = AclToString(ta);
793 blob.in_size = 1+strlen(blob.in);
794 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
796 if (errno == EINVAL) {
797 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
798 fprintf(stderr, "\t-File not in AFS\n");
801 Die(errno, ti->data);
811 /* pioctl() call to get the cellname of a pathname */
812 static afs_int32 GetCell(fname, cellname)
813 char *fname, *cellname;
816 struct ViceIoctl blob;
819 blob.out_size = MAXCELLCHARS;
822 code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
823 return code ? errno : 0;
826 /* Check if a username is valid: If it contains only digits (or a
827 * negative sign), then it might be bad. We then query the ptserver
830 static BadName(aname, fname)
833 afs_int32 tc, code, id;
835 char cell[MAXCELLCHARS];
837 for (nm=aname; tc=*nm; nm++) {
838 /* all must be '-' or digit to be bad */
839 if (tc != '-' && (tc < '0' || tc > '9')) return 0;
842 /* Go to the PRDB and see if this all number username is valid */
843 code = GetCell(fname, cell);
846 pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
847 code = pr_SNameToId(aname, &id);
850 /* 1=>Not-valid; 0=>Valid */
851 return ((!code && (id==ANONYMOUSID)) ? 1 : 0);
855 /* clean up an access control list of its bad entries; return 1 if we made
856 any changes to the list, and 0 otherwise */
857 static CleanAcl(aa, fname)
859 char *fname; /* The file name */
861 struct AclEntry *te, **le, *ne;
864 /* Don't correct DFS ACL's for now */
868 /* prune out bad entries */
869 changes = 0; /* count deleted entries */
871 for(te = aa->pluslist; te; te=ne) {
873 if (BadName(te->name,fname)) {
885 for(te = aa->minuslist; te; te=ne) {
887 if (BadName(te->name,fname)) {
902 /* clean up an acl to not have bogus entries */
903 static CleanACLCmd(as)
904 struct cmd_syndesc *as;
908 struct ViceIoctl blob;
914 SetDotDefault(&as->parms[0].items);
915 for(ti=as->parms[0].items; ti; ti=ti->next) {
916 blob.out_size = MAXSIZE;
919 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
921 Die(errno, ti->data);
927 ta = ParseAcl(space);
930 "%s: cleanacl is not supported for DFS access lists.\n",
936 changes = CleanAcl(ta, ti->data);
939 /* now set the acl */
940 blob.in=AclToString(ta);
941 blob.in_size = strlen(blob.in)+1;
943 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
945 if (errno == EINVAL) {
946 fprintf(stderr, "%s: Invalid argument, possible reasons include\n", pn);
947 fprintf(stderr, "%s: File not in vice or\n", pn);
948 fprintf(stderr, "%s: Too many users on access control list or\n", pn);
951 Die(errno, ti->data);
957 /* now list the updated acl */
958 printf("Access list for %s is now\n", ti->data);
960 if (!ta->dfs) printf("Normal rights:\n");
961 for(te = ta->pluslist;te;te=te->next) {
962 printf(" %s ", te->name);
963 PRights(te->rights, ta->dfs);
967 if (ta->nminus > 0) {
968 printf("Negative rights:\n");
969 for(te = ta->minuslist;te;te=te->next) {
970 printf(" %s ", te->name);
971 PRights(te->rights, ta->dfs);
975 if (ti->next) printf("\n");
978 printf("Access list for %s is fine.\n", ti->data);
984 static ListACLCmd(as)
985 struct cmd_syndesc *as;
989 struct ViceIoctl blob;
992 int idf = getidf(as, parm_listacl_id);
995 SetDotDefault(&as->parms[0].items);
996 for(ti=as->parms[0].items; ti; ti=ti->next) {
997 blob.out_size = MAXSIZE;
999 blob.in = blob.out = space;
1000 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
1002 Die(errno, ti->data);
1006 ta = ParseAcl(space);
1009 printf("Access list for %s is\n", ti->data);
1012 printf("DFS access list for %s is\n", ti->data);
1015 printf("DFS initial directory access list of %s is\n", ti->data);
1018 printf("DFS initial file access list of %s is\n", ti->data);
1022 printf(" Default cell = %s\n", ta->cell);
1024 if (ta->nplus > 0) {
1025 if (!ta->dfs) printf("Normal rights:\n");
1026 for(te = ta->pluslist;te;te=te->next) {
1027 printf(" %s ", te->name);
1028 PRights(te->rights, ta->dfs);
1032 if (ta->nminus > 0) {
1033 printf("Negative rights:\n");
1034 for(te = ta->minuslist;te;te=te->next) {
1035 printf(" %s ", te->name);
1036 PRights(te->rights, ta->dfs);
1040 if (ti->next) printf("\n");
1046 static FlushVolumeCmd(as)
1047 struct cmd_syndesc *as;
1050 struct ViceIoctl blob;
1051 struct cmd_item *ti;
1054 SetDotDefault(&as->parms[0].items);
1055 for(ti=as->parms[0].items; ti; ti=ti->next) {
1056 blob.in_size = blob.out_size = 0;
1057 code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
1059 fprintf(stderr, "Error flushing volume ");
1069 struct cmd_syndesc *as;
1072 struct ViceIoctl blob;
1073 struct cmd_item *ti;
1076 for(ti=as->parms[0].items; ti; ti=ti->next) {
1077 blob.in_size = blob.out_size = 0;
1078 code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
1080 if (errno == EMFILE) {
1081 fprintf(stderr, "%s: Can't flush active file %s\n", pn, ti->data);
1084 fprintf(stderr, "%s: Error flushing file ", pn);
1094 /* all this command does is repackage its args and call SetVolCmd */
1095 static SetQuotaCmd(as)
1096 struct cmd_syndesc *as;
1098 struct cmd_syndesc ts;
1100 /* copy useful stuff from our command slot; we may later have to reorder */
1101 memcpy(&ts, as, sizeof(ts)); /* copy whole thing */
1102 return SetVolCmd(&ts);
1105 static SetVolCmd(as)
1106 struct cmd_syndesc *as;
1109 struct ViceIoctl blob;
1110 struct cmd_item *ti;
1111 struct VolumeStatus *status;
1112 char *offmsg, *input;
1115 SetDotDefault(&as->parms[0].items);
1116 for(ti=as->parms[0].items; ti; ti=ti->next) {
1118 blob.out_size = MAXSIZE;
1119 blob.in_size = sizeof(*status) + 3; /* for the three terminating nulls */
1122 status = (VolumeStatus *)space;
1123 status->MinQuota = status->MaxQuota = -1;
1124 offmsg = (char *) 0;
1125 if (as->parms[1].items) {
1126 code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
1128 fprintf(stderr, "%s: bad integer specified for quota.\n", pn);
1133 if (as->parms[2].items) offmsg = as->parms[2].items->data;
1134 input = (char *)status + sizeof(*status);
1135 *(input++) = '\0'; /* never set name: this call doesn't change vldb */
1137 if (strlen(offmsg) >= VMSGSIZE) {
1138 fprintf(stderr, "%s: message must be shorter than %d characters\n",
1143 strcpy(input,offmsg);
1144 blob.in_size += strlen(offmsg);
1145 input += strlen(offmsg) + 1;
1147 else *(input++) = '\0';
1148 *(input++) = '\0'; /* Pad for old style volume "motd" */
1149 code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
1151 Die(errno, ti->data);
1158 static ExamineCmd(as)
1159 struct cmd_syndesc *as;
1162 struct ViceIoctl blob;
1163 struct cmd_item *ti;
1164 struct VolumeStatus *status;
1165 char *name, *offmsg;
1168 SetDotDefault(&as->parms[0].items);
1169 for(ti=as->parms[0].items; ti; ti=ti->next) {
1171 blob.out_size = MAXSIZE;
1174 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1176 Die(errno, ti->data);
1180 status = (VolumeStatus *)space;
1181 name = (char *)status + sizeof(*status);
1182 offmsg = name + strlen(name) + 1;
1183 PrintStatus(status, name, offmsg);
1188 static ListQuotaCmd(as)
1189 struct cmd_syndesc *as;
1192 struct ViceIoctl blob;
1193 struct cmd_item *ti;
1194 struct VolumeStatus *status;
1198 printf("%-25s%-10s%-10s%-7s%-11s\n",
1199 "Volume Name"," Quota", " Used", " %Used", " Partition");
1200 SetDotDefault(&as->parms[0].items);
1201 for(ti=as->parms[0].items; ti; ti=ti->next) {
1203 blob.out_size = MAXSIZE;
1206 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1208 Die(errno, ti->data);
1212 status = (VolumeStatus *)space;
1213 name = (char *)status + sizeof(*status);
1214 QuickPrintStatus(status, name);
1219 static WhereIsCmd(as)
1220 struct cmd_syndesc *as;
1223 struct ViceIoctl blob;
1224 struct cmd_item *ti;
1230 SetDotDefault(&as->parms[0].items);
1231 for(ti=as->parms[0].items; ti; ti=ti->next) {
1233 blob.out_size = MAXSIZE;
1236 memset(space, 0, sizeof(space));
1237 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
1239 Die(errno, ti->data);
1243 hosts = (afs_int32 *) space;
1244 printf("File %s is on host%s ", ti->data, (hosts[0] && !hosts[1]) ? "": "s");
1245 for(j=0; j<MAXHOSTS; j++) {
1246 if (hosts[j] == 0) break;
1247 tp = hostutil_GetNameByINet(hosts[j]);
1256 static DiskFreeCmd(as)
1257 struct cmd_syndesc *as;
1260 struct ViceIoctl blob;
1261 struct cmd_item *ti;
1263 struct VolumeStatus *status;
1266 printf("%-25s%-10s%-10s%-10s%-6s\n",
1267 "Volume Name"," kbytes", " used", " avail", " %used");
1268 SetDotDefault(&as->parms[0].items);
1269 for(ti=as->parms[0].items; ti; ti=ti->next) {
1271 blob.out_size = MAXSIZE;
1274 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1276 Die(errno, ti->data);
1280 status = (VolumeStatus *)space;
1281 name = (char *)status + sizeof(*status);
1282 QuickPrintSpace(status, name);
1288 struct cmd_syndesc *as;
1291 struct ViceIoctl blob;
1292 struct cmd_item *ti;
1294 struct VolumeStatus *status;
1297 SetDotDefault(&as->parms[0].items);
1298 for(ti=as->parms[0].items; ti; ti=ti->next) {
1300 blob.out_size = MAXSIZE;
1303 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1305 Die(errno, ti->data);
1309 status = (VolumeStatus *)space;
1310 if (status->MaxQuota) quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
1311 else quotaPct = 0.0;
1312 printf("%2.0f%% of quota used.\n", quotaPct);
1317 static ListMountCmd(as)
1318 struct cmd_syndesc *as;
1321 struct ViceIoctl blob;
1322 struct cmd_item *ti;
1323 char orig_name[1024]; /*Original name, may be modified*/
1324 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
1325 char parent_dir[1024]; /*Parent directory of true name*/
1326 char *last_component; /*Last component of true name*/
1327 struct stat statbuff; /*Buffer for status info*/
1328 int link_chars_read; /*Num chars read in readlink()*/
1329 int thru_symlink; /*Did we get to a mount point via a symlink?*/
1332 for(ti=as->parms[0].items; ti; ti=ti->next) {
1335 sprintf(orig_name, "%s%s",
1336 (ti->data[0] == '/') ? "" : "./",
1339 if (lstat(orig_name, &statbuff) < 0) {
1340 /* if lstat fails, we should still try the pioctl, since it
1341 may work (for example, lstat will fail, but pioctl will
1342 work if the volume of offline (returning ENODEV). */
1343 statbuff.st_mode = S_IFDIR; /* lie like pros */
1347 * The lstat succeeded. If the given file is a symlink, substitute
1348 * the file name with the link name.
1350 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
1353 * Read name of resolved file.
1355 link_chars_read = readlink(orig_name, true_name, 1024);
1356 if (link_chars_read <= 0) {
1357 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
1364 * Add a trailing null to what was read, bump the length.
1366 true_name[link_chars_read++] = 0;
1369 * If the symlink is an absolute pathname, we're fine. Otherwise, we
1370 * have to create a full pathname using the original name and the
1371 * relative symlink name. Find the rightmost slash in the original
1372 * name (we know there is one) and splice in the symlink value.
1374 if (true_name[0] != '/') {
1375 last_component = (char *) strrchr(orig_name, '/');
1376 strcpy(++last_component, true_name);
1377 strcpy(true_name, orig_name);
1381 strcpy(true_name, orig_name);
1384 * Find rightmost slash, if any.
1386 last_component = (char *) strrchr(true_name, '/');
1387 if (last_component) {
1389 * Found it. Designate everything before it as the parent directory,
1390 * everything after it as the final component.
1392 strncpy(parent_dir, true_name, last_component - true_name);
1393 parent_dir[last_component - true_name] = 0;
1394 last_component++; /*Skip the slash*/
1398 * No slash appears in the given file name. Set parent_dir to the current
1399 * directory, and the last component as the given name.
1401 strcpy(parent_dir, ".");
1402 last_component = true_name;
1405 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
1406 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
1407 fprintf(stderr, "%s: of a name in the 'fs lsmount' command.\n", pn);
1412 blob.in = last_component;
1413 blob.in_size = strlen(last_component)+1;
1414 blob.out_size = MAXSIZE;
1416 memset(space, 0, MAXSIZE);
1418 code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
1421 printf("'%s' is a %smount point for volume '%s'\n",
1423 (thru_symlink ? "symbolic link, leading to a " : ""),
1427 if (errno == EINVAL) {
1428 fprintf(stderr, "'%s' is not a mount point.\n",
1432 Die(errno, (ti->data ? ti->data : parent_dir));
1440 static MakeMountCmd(as)
1441 struct cmd_syndesc *as;
1444 char *cellName, *volName, *tmpName;
1445 struct afsconf_cell info;
1446 struct vldbentry vldbEntry;
1447 struct ViceIoctl blob;
1453 if (as->parms[5].items && !as->parms[2].items) {
1454 fprintf(stderr, "%s: must provide cell when creating cellular mount point.\n", pn);
1459 if (as->parms[2].items) /* cell name specified */
1460 cellName = as->parms[2].items->data;
1462 cellName = (char *) 0;
1463 volName = as->parms[1].items->data;
1465 if (strlen(volName) >= 64) {
1466 fprintf(stderr, "%s: volume name too long (length must be < 64 characters)\n", pn);
1470 /* Check for a cellname in the volume specification, and complain
1471 * if it doesn't match what was specified with -cell */
1472 if (tmpName = strchr(volName, ':')) {
1475 if (strcasecmp(cellName,volName)) {
1476 fprintf(stderr, "%s: cellnames do not match.\n", pn);
1481 volName = ++tmpName;
1484 if (!InAFS(Parent(as->parms[0].items->data))) {
1485 fprintf(stderr, "%s: mount points must be created within the AFS file system\n", pn);
1491 blob.out_size = MAXSIZE;
1493 code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME, &blob, 1);
1496 code = GetCellName(cellName?cellName:space, &info);
1500 if (!(as->parms[4].items)) {
1501 /* not fast, check which cell the mountpoint is being created in */
1502 /* not fast, check name with VLDB */
1503 code = VLDBInit(1, &info);
1505 /* make the check. Don't complain if there are problems with init */
1506 code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
1507 if (code == VL_NOENT) {
1508 fprintf(stderr, "%s: warning, volume %s does not exist in cell %s.\n",
1509 pn, volName, cellName ? cellName : space);
1514 if (as->parms[3].items) /* if -rw specified */
1519 /* cellular mount point, prepend cell prefix */
1520 strcat(space, info.name);
1523 strcat(space, volName); /* append volume name */
1524 strcat(space, "."); /* stupid convention; these end with a period */
1525 code = symlink(space, as->parms[0].items->data);
1527 Die(errno, as->parms[0].items->data);
1534 * Delete AFS mount points. Variables are used as follows:
1535 * tbuffer: Set to point to the null-terminated directory name of the mount point
1536 * (or ``.'' if none is provided)
1537 * tp: Set to point to the actual name of the mount point to nuke.
1539 static RemoveMountCmd(as)
1540 struct cmd_syndesc *as;
1543 struct ViceIoctl blob;
1544 struct cmd_item *ti;
1546 char lsbuffer[1024];
1550 for(ti=as->parms[0].items; ti; ti=ti->next) {
1552 tp = (char *) strrchr(ti->data, '/');
1554 strncpy(tbuffer, ti->data, code=tp-ti->data); /* the dir name */
1556 tp++; /* skip the slash */
1559 strcpy(tbuffer, ".");
1563 blob.in_size = strlen(tp)+1;
1564 blob.out = lsbuffer;
1565 blob.out_size = sizeof(lsbuffer);
1566 code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
1568 if (errno == EINVAL) {
1569 fprintf(stderr, "%s: '%s' is not a mount point.\n", pn, ti->data);
1572 Die(errno, ti->data);
1575 continue; /* don't bother trying */
1579 blob.in_size = strlen(tp)+1;
1580 code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
1582 Die(errno, ti->data);
1592 static CheckServersCmd(as)
1593 struct cmd_syndesc *as;
1596 struct ViceIoctl blob;
1602 struct afsconf_cell info;
1603 struct chservinfo checkserv;
1605 memset(&checkserv, 0, sizeof(struct chservinfo));
1606 blob.in_size=sizeof(struct chservinfo);
1607 blob.in=(caddr_t)&checkserv;
1609 blob.out_size = MAXSIZE;
1611 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1613 /* prepare flags for checkservers command */
1614 temp = 2; /* default to checking local cell only */
1615 if (as->parms[2].items) temp |= 1; /* set fast flag */
1616 if (as->parms[1].items) temp &= ~2; /* turn off local cell check */
1618 checkserv.magic = 0x12345678; /* XXX */
1619 checkserv.tflags=temp;
1621 /* now copy in optional cell name, if specified */
1622 if (as->parms[0].items) {
1623 code = GetCellName(as->parms[0].items->data, &info);
1627 strcpy(checkserv.tbuffer,info.name);
1628 checkserv.tsize=strlen(info.name)+1;
1631 strcpy(checkserv.tbuffer,"\0");
1635 if(as->parms[3].items) {
1636 checkserv.tinterval=atol(as->parms[3].items->data);
1639 if(checkserv.tinterval<0) {
1640 printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
1641 checkserv.tinterval=0;
1643 else if(checkserv.tinterval> 600) {
1644 printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
1645 checkserv.tinterval=600; /* 10 min max interval */
1649 checkserv.tinterval = -1; /* don't change current interval */
1652 code = pioctl(0, VIOCCKSERV, &blob, 1);
1654 if ((errno == EACCES) && (checkserv.tinterval > 0)) {
1655 printf("Must be root to change -interval\n");
1661 memcpy(&temp, space, sizeof(afs_int32));
1662 if (checkserv.tinterval >= 0) {
1663 if (checkserv.tinterval > 0)
1664 printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
1665 checkserv.tinterval, temp);
1667 printf("The current down server probe interval is %d secs\n", temp);
1671 printf("All servers are running.\n");
1674 printf("These servers unavailable due to network or server problems: ");
1676 memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
1677 if (temp == 0) break;
1678 tp = hostutil_GetNameByINet(temp);
1687 static MessagesCmd(as)
1688 struct cmd_syndesc *as;
1691 struct ViceIoctl blob;
1694 struct gaginfo gagflags;
1695 struct cmd_item *show;
1697 memset(&gagflags, 0, sizeof(struct gaginfo));
1698 blob.in_size = sizeof(struct gaginfo);
1699 blob.in = (caddr_t) &gagflags;
1700 blob.out_size = MAXSIZE;
1702 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1704 if (show = as->parms[0].items) {
1705 if (!strcasecmp (show->data, "user"))
1706 gagflags.showflags |= GAGUSER;
1707 else if (!strcasecmp (show->data, "console"))
1708 gagflags.showflags |= GAGCONSOLE;
1709 else if (!strcasecmp (show->data, "all"))
1710 gagflags.showflags |= GAGCONSOLE | GAGUSER;
1711 else if (!strcasecmp (show->data, "none"))
1715 "unrecognized flag %s: must be in {user,console,all,none}\n",
1724 code = pioctl(0, VIOC_GAG, &blob, 1);
1733 static CheckVolumesCmd(as)
1734 struct cmd_syndesc *as;
1737 struct ViceIoctl blob;
1741 code = pioctl(0, VIOCCKBACK, &blob, 1);
1747 printf("All volumeID/name mappings checked.\n");
1751 static SetCacheSizeCmd(as)
1752 struct cmd_syndesc *as;
1755 struct ViceIoctl blob;
1758 if (!as->parms[0].items && !as->parms[1].items) {
1759 fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
1762 if (as->parms[0].items) {
1763 code = util_GetInt32(as->parms[0].items->data, &temp);
1765 fprintf(stderr, "%s: bad integer specified for cache size.\n", pn);
1771 blob.in = (char *) &temp;
1772 blob.in_size = sizeof(afs_int32);
1774 code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
1776 if (errno == EROFS) {
1777 printf("'fs setcache' not allowed on memory cache based cache managers.\n");
1780 Die(errno, (char *) 0);
1785 printf("New cache size set.\n");
1789 #define MAXGCSIZE 16
1790 static GetCacheParmsCmd(as)
1791 struct cmd_syndesc *as;
1794 struct ViceIoctl blob;
1795 afs_int32 parms[MAXGCSIZE];
1797 memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
1798 blob.in = (char *) 0;
1800 blob.out_size = sizeof(parms);
1801 blob.out = (char *) parms;
1802 code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
1804 Die(errno, (char *) 0);
1807 printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
1808 parms[1], parms[0]);
1809 if (parms[1] > parms[0])
1810 printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
1814 static ListCellsCmd(as)
1815 struct cmd_syndesc *as;
1821 struct ViceIoctl blob;
1824 resolve = !(as->parms[0].items); /* -numeric */
1828 memcpy(tp, &i, sizeof(afs_int32));
1829 blob.out_size = MAXSIZE;
1830 blob.in_size = sizeof(afs_int32);
1833 code = pioctl(0, VIOCGETCELL, &blob, 1);
1835 if (errno == EDOM) break; /* done with the list */
1840 printf("Cell %s on hosts", tp+MAXCELLHOSTS*sizeof(afs_int32));
1841 for(j=0; j < MAXCELLHOSTS; j++) {
1843 char *name, tbuffer[20];
1845 memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
1846 if (addr == 0) break;
1849 name = hostutil_GetNameByINet(addr);
1853 sprintf(tbuffer, "%d.%d.%d.%d",
1854 (addr>>24) & 0xff, (addr>>16) & 0xff,
1855 (addr>>8) & 0xff, addr & 0xff);
1858 printf(" %s", name);
1865 static ListAliasesCmd(as)
1866 struct cmd_syndesc *as;
1869 char *tp, *aliasName, *realName;
1870 struct ViceIoctl blob;
1874 memcpy(tp, &i, sizeof(afs_int32));
1875 blob.out_size = MAXSIZE;
1876 blob.in_size = sizeof(afs_int32);
1879 code = pioctl(0, VIOC_GETALIAS, &blob, 1);
1881 if (errno == EDOM) break; /* done with the list */
1887 tp += strlen(aliasName) + 1;
1889 printf("Alias %s for cell %s\n", aliasName, realName);
1894 static NewCellCmd(as)
1895 struct cmd_syndesc *as;
1897 afs_int32 code, linkedstate=0, size=0, *lp;
1898 struct ViceIoctl blob;
1899 struct cmd_item *ti;
1900 char *tp, *cellname=0;
1901 struct hostent *thp;
1902 afs_int32 fsport = 0, vlport = 0;
1903 afs_int32 magic, scount; /* Number of servers to pass in pioctl call */
1906 * With the NEWCELL pioctl call, 3.4 clients take an array of
1907 * MAXHOSTS (13) servers while 3.5 clients take an array of
1908 * MAXCELLHOSTS (8) servers. To determine which we are talking to,
1909 * do a GETCELL pioctl and pass it a magic number. If an array of
1910 * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
1913 lp = (afs_int32 *)tp;
1914 *lp++ = 0; /* first cell entry */
1915 *lp = 0x12345678; /* magic */
1916 blob.out_size = MAXSIZE;
1917 blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
1920 code = pioctl(0, VIOCGETCELL, &blob, 1);
1926 cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
1927 scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
1929 /* Now setup and do the NEWCELL pioctl call */
1930 memset(space, 0, (scount+1) * sizeof(afs_int32));
1932 lp = (afs_int32 *)tp;
1934 tp += sizeof(afs_int32);
1935 for(ti=as->parms[1].items; ti; ti=ti->next) {
1936 thp = hostutil_GetHostByName(ti->data);
1938 fprintf(stderr, "%s: Host %s not found in host table, skipping it.\n",
1942 memcpy(tp, thp->h_addr, sizeof(afs_int32));
1943 tp += sizeof(afs_int32);
1946 if (as->parms[2].items) {
1948 * Link the cell, for the purposes of volume location, to the specified
1951 cellname = as->parms[2].items->data;
1954 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
1955 if (as->parms[3].items) {
1956 code = util_GetInt32(as->parms[3].items->data, &vlport);
1958 fprintf(stderr, "%s: bad integer specified for the fileserver port.\n", pn);
1962 if (as->parms[4].items) {
1963 code = util_GetInt32(as->parms[4].items->data, &fsport);
1965 fprintf(stderr, "%s: bad integer specified for the vldb server port.\n", pn);
1970 tp = (char *)(space + (scount+1) *sizeof(afs_int32));
1971 lp = (afs_int32 *)tp;
1975 strcpy(space + ((scount+4) * sizeof(afs_int32)), as->parms[0].items->data);
1976 size = ((scount+4) * sizeof(afs_int32))
1977 + strlen(as->parms[0].items->data)
1979 tp = (char *)(space + size);
1981 strcpy(tp, cellname);
1982 size += strlen(cellname) + 1;
1984 blob.in_size = size;
1987 code = pioctl(0, VIOCNEWCELL, &blob, 1);
1995 static NewAliasCmd(as)
1996 struct cmd_syndesc *as;
1999 struct ViceIoctl blob;
2001 char *aliasName, *realName;
2003 /* Now setup and do the NEWCELL pioctl call */
2004 aliasName = as->parms[0].items->data;
2005 realName = as->parms[1].items->data;
2007 strcpy(tp, aliasName);
2008 tp += strlen(aliasName) + 1;
2009 strcpy(tp, realName);
2010 tp += strlen(realName) + 1;
2012 blob.in_size = tp - space;
2016 code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
2018 if (errno == EEXIST) {
2019 fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
2029 static WhichCellCmd(as)
2030 struct cmd_syndesc *as;
2033 struct cmd_item *ti;
2035 char cell[MAXCELLCHARS];
2037 SetDotDefault(&as->parms[0].items);
2038 for (ti=as->parms[0].items; ti; ti=ti->next) {
2039 code = GetCell(ti->data, cell);
2041 if (errno == ENOENT)
2042 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2044 Die(errno, ti->data);
2049 printf("File %s lives in cell '%s'\n", ti->data, cell);
2054 static WSCellCmd(as)
2055 struct cmd_syndesc *as;
2058 struct ViceIoctl blob;
2061 blob.in = (char *) 0;
2062 blob.out_size = MAXSIZE;
2065 code = pioctl((char *) 0, VIOC_GET_WS_CELL, &blob, 1);
2067 Die(errno, (char *) 0);
2071 printf("This workstation belongs to cell '%s'\n", space);
2076 static PrimaryCellCmd(as)
2077 struct cmd_syndesc *as;
2079 fprintf(stderr, "This command is obsolete, as is the concept of a primary token.\n");
2084 static MonitorCmd(as)
2085 struct cmd_syndesc *as;
2088 struct ViceIoctl blob;
2089 struct cmd_item *ti;
2091 struct hostent *thp;
2095 ti = as->parms[0].items;
2099 if (!strcmp(ti->data, "off"))
2100 hostAddr = 0xffffffff;
2102 thp = hostutil_GetHostByName(ti->data);
2104 if (!strcmp(ti->data, "localhost")) {
2105 fprintf(stderr, "localhost not in host table, assuming 127.0.0.1\n");
2106 hostAddr = htonl(0x7f000001);
2109 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2113 else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2117 hostAddr = 0; /* means don't set host */
2118 setp = 0; /* aren't setting host */
2121 /* now do operation */
2122 blob.in_size = sizeof(afs_int32);
2123 blob.out_size = sizeof(afs_int32);
2124 blob.in = (char *) &hostAddr;
2125 blob.out = (char *) &hostAddr;
2126 code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2132 printf("%s: new monitor host set.\n", pn);
2135 /* now decode old address */
2136 if (hostAddr == 0xffffffff) {
2137 printf("Cache monitoring is currently disabled.\n");
2140 tp = hostutil_GetNameByINet(hostAddr);
2141 printf("Using host %s for monitor services.\n", tp);
2147 static SysNameCmd(as)
2148 struct cmd_syndesc *as;
2151 struct ViceIoctl blob;
2152 struct cmd_item *ti;
2153 char *input = space;
2156 ti = as->parms[0].items;
2159 blob.out_size = MAXSIZE;
2160 blob.in_size = sizeof(afs_int32);
2161 input += sizeof(afs_int32);
2162 for(; ti; ti=ti->next) {
2164 blob.in_size += strlen(ti->data) + 1;
2165 if (blob.in_size > MAXSIZE) {
2166 fprintf(stderr, "%s: sysname%s too long.\n", pn, setp > 1 ? "s" : "");
2169 strcpy(input, ti->data);
2170 input += strlen(ti->data);
2173 memcpy(space, &setp, sizeof(afs_int32));
2174 code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
2180 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2184 memcpy(&setp, input, sizeof(afs_int32));
2185 input += sizeof(afs_int32);
2187 fprintf(stderr, "No sysname name value was found\n");
2190 printf("Current sysname%s is", setp>1 ? " list" : "");
2191 for(;setp>0;--setp) {
2192 printf(" \'%s\'", input);
2193 input += strlen(input) + 1;
2199 static char *exported_types[] = {"null", "nfs", ""};
2200 static ExportAfsCmd(as)
2201 struct cmd_syndesc *as;
2204 struct ViceIoctl blob;
2205 struct cmd_item *ti;
2206 int export=0, type=0, mode = 0, exp = 0, exportcall, pwsync=0, smounts=0;
2208 ti = as->parms[0].items;
2209 if (strcmp(ti->data, "nfs") == 0) type = 0x71; /* NFS */
2211 fprintf(stderr, "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2214 ti = as->parms[1].items;
2216 if (strcmp(ti->data, "on") == 0) export = 3;
2217 else if (strcmp(ti->data, "off") == 0) export = 2;
2219 fprintf(stderr, "Illegal argument %s\n", ti->data);
2224 if (ti = as->parms[2].items) { /* -noconvert */
2225 if (strcmp(ti->data, "on") == 0) mode = 2;
2226 else if (strcmp(ti->data, "off") == 0) mode = 3;
2228 fprintf(stderr, "Illegal argument %s\n", ti->data);
2232 if (ti = as->parms[3].items) { /* -uidcheck */
2233 if (strcmp(ti->data, "on") == 0) pwsync = 3;
2234 else if (strcmp(ti->data, "off") == 0) pwsync = 2;
2236 fprintf(stderr, "Illegal argument %s\n", ti->data);
2240 if (ti = as->parms[4].items) { /* -submounts */
2241 if (strcmp(ti->data, "on") == 0) smounts = 3;
2242 else if (strcmp(ti->data, "off") == 0) smounts = 2;
2244 fprintf(stderr, "Illegal argument %s\n", ti->data);
2248 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2251 blob.in = (char *) &exportcall;
2252 blob.in_size = sizeof(afs_int32);
2253 blob.out = (char *) &exportcall;
2254 blob.out_size = sizeof(afs_int32);
2255 code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
2257 if (errno == ENODEV) {
2258 fprintf(stderr, "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2266 if (exportcall & 1) {
2267 printf("'%s' translator is enabled with the following options:\n",
2268 exported_types[type]);
2269 printf("\tRunning in %s mode\n",
2270 (exportcall & 2 ? "strict unix"
2271 : "convert owner mode bits to world/other"));
2272 printf("\tRunning in %s mode\n",
2273 (exportcall & 4 ? "strict 'passwd sync'"
2274 : "no 'passwd sync'"));
2276 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs"
2277 : "Only mounts to /afs allowed"));
2280 printf("'%s' translator is disabled\n", exported_types[type]);
2286 static GetCellCmd(as)
2287 struct cmd_syndesc *as;
2290 struct ViceIoctl blob;
2291 struct afsconf_cell info;
2292 struct cmd_item *ti;
2299 memset(&args, '\0', sizeof args); /* avoid Purify UMR error */
2300 for(ti=as->parms[0].items; ti; ti=ti->next) {
2302 blob.out_size = sizeof(args);
2303 blob.out = (caddr_t) &args;
2304 code = GetCellName(ti->data, &info);
2309 blob.in_size = 1+strlen(info.name);
2310 blob.in = info.name;
2311 code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
2313 if (errno == ENOENT)
2314 fprintf(stderr, "%s: the cell named '%s' does not exist\n", pn, info.name);
2316 Die(errno, info.name);
2320 printf("Cell %s status: ", info.name);
2322 if (args.stat & 1) printf("primary ");
2324 if (args.stat & 2) printf("no setuid allowed");
2325 else printf("setuid allowed");
2326 if (args.stat & 4) printf(", using old VLDB");
2332 static SetCellCmd(as)
2333 struct cmd_syndesc *as;
2336 struct ViceIoctl blob;
2337 struct afsconf_cell info;
2338 struct cmd_item *ti;
2346 /* Check arguments. */
2347 if (as->parms[1].items && as->parms[2].items) {
2348 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
2352 /* figure stuff to set */
2356 if (! as->parms[1].items) args.stat |= 2; /* default to -nosuid */
2358 /* set stat for all listed cells */
2359 for(ti=as->parms[0].items; ti; ti=ti->next) {
2361 code = GetCellName(ti->data, &info);
2366 strcpy(args.cname, info.name);
2367 blob.in_size = sizeof(args);
2368 blob.in = (caddr_t) &args;
2370 blob.out = (caddr_t) 0;
2371 code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
2373 Die(errno, info.name); /* XXX added cell name to Die() call */
2380 static GetCellName(cellName, info)
2382 struct afsconf_cell *info;
2384 struct afsconf_dir *tdir;
2387 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
2389 fprintf(stderr, "Could not process files in configuration directory (%s).\n",
2390 AFSDIR_CLIENT_ETC_DIRPATH);
2394 code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
2396 fprintf(stderr, "%s: cell %s not in %s\n", pn, cellName,
2397 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
2405 static VLDBInit(noAuthFlag, info)
2407 struct afsconf_cell *info;
2410 struct ktc_principal sname;
2411 struct ktc_token ttoken;
2413 struct rx_securityClass *sc;
2414 struct rx_connection *serverconns[VLDB_MAXSERVERS];
2419 fprintf(stderr, "%s: could not initialize rx.\n", pn);
2423 rx_SetRxDeadTime(50);
2424 if (!noAuthFlag) { /* we don't need tickets for null */
2425 strcpy(sname.cell, info->name);
2426 sname.instance[0] = 0;
2427 strcpy(sname.name, "afs");
2428 code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), (char *)0);
2430 fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
2435 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
2437 fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
2443 else scIndex = 0; /* don't authenticate */
2446 sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
2452 sc = (struct rx_securityClass *)
2453 rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
2454 ttoken.kvno, ttoken.ticketLen,
2458 if (info->numServers > VLDB_MAXSERVERS) {
2459 fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
2460 pn, info->numServers, VLDB_MAXSERVERS);
2463 memset(serverconns, 0, sizeof(serverconns));
2464 for (i = 0;i<info->numServers;i++)
2465 serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
2466 info->hostAddr[i].sin_port, USER_SERVICE_ID,
2469 code = ubik_ClientInit(serverconns, &uclient);
2472 fprintf(stderr, "%s: ubik client init failed.\n", pn);
2478 static struct ViceIoctl gblob;
2479 static int debug = 0;
2481 * here follow some routines in suport of the setserverprefs and
2482 * getserverprefs commands. They are:
2483 * SetPrefCmd "top-level" routine
2484 * addServer adds a server to the list of servers to be poked into the
2485 * kernel. Will poke the list into the kernel if it threatens
2487 * pokeServers pokes the existing list of servers and ranks into the kernel
2488 * GetPrefCmd reads the Cache Manager's current list of server ranks
2492 * returns -1 if error message printed,
2494 * errno value if error and no error message printed
2496 static pokeServers()
2500 code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
2501 if (code && (errno == EINVAL)) {
2502 struct setspref *ssp;
2503 ssp = (struct setspref *)gblob.in;
2504 if (!(ssp->flags & DBservers)) {
2505 gblob.in = (void *) &(ssp->servers[0]);
2506 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
2507 code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
2508 return code ? errno : 0;
2511 "This cache manager does not support VL server preferences.\n");
2515 return code ? errno : 0;
2519 * returns -1 if error message printed,
2521 * errno value if error and no error message printed
2523 static addServer(name, rank)
2528 struct setspref *ssp;
2530 struct hostent *thostent;
2536 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
2538 #define MAXUSHORT ((unsigned short) ~0)
2542 thostent = hostutil_GetHostByName(name);
2544 fprintf(stderr, "%s: couldn't resolve name.\n", name);
2548 ssp = (struct setspref *)(gblob.in);
2550 for (t = 0; thostent->h_addr_list[t]; t++) {
2551 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
2552 code = pokeServers();
2553 if (code) error = code;
2554 ssp->num_servers = 0;
2557 sp = (struct spref *) (gblob.in + gblob.in_size);
2558 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
2559 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
2560 gblob.in_size += sizeof(struct spref);
2564 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
2565 name,sp->rank,sp->server.s_addr);
2572 static SetPrefCmd(as)
2573 struct cmd_syndesc *as;
2577 struct cmd_item *ti;
2580 struct setspref *ssp;
2581 int error = 0; /* -1 means error message printed,
2582 * >0 means errno value for unprinted message */
2584 ssp = (struct setspref *)space;
2586 ssp->num_servers = 0;
2587 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2590 gblob.out_size = MAXSIZE;
2594 fprintf(stderr, "Permission denied: requires root access.\n");
2598 ti = as->parms[2].items; /* -file */
2600 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2601 if (!(infd = fopen(ti->data,"r"))) {
2606 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
2607 code = addServer(name, (unsigned short) rank);
2608 if (code) error = code;
2613 ti = as->parms[3].items; /* -stdin */
2615 while (scanf("%79s%ld", name, &rank) != EOF) {
2616 code = addServer(name, (unsigned short) rank);
2617 if (code) error = code;
2621 for (ti = as->parms[0].items;ti;ti=ti->next) { /* list of servers, ranks */
2626 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2627 if (code) error = code;
2629 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
2633 code = pokeServers();
2634 if (code) error = code;
2636 printf("now working on vlservers, code=%d\n",code);
2638 ssp = (struct setspref *)space;
2639 ssp->flags = DBservers;
2640 ssp->num_servers = 0;
2641 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2644 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
2649 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2650 if (code) error = code;
2652 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
2657 if (as->parms[1].items) {
2659 printf("now poking vlservers\n");
2660 code = pokeServers();
2661 if (code) error = code;
2667 return error ? 1 : 0;
2672 static GetPrefCmd(as)
2673 struct cmd_syndesc *as;
2676 struct cmd_item *ti;
2677 char *name, tbuffer[20];
2678 afs_int32 rank,addr;
2682 struct ViceIoctl blob;
2683 struct sprefrequest *in;
2684 struct sprefinfo *out;
2687 ti = as->parms[0].items; /* -file */
2689 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2690 if (!(outfd = freopen(ti->data,"w",stdout))) {
2696 ti = as->parms[1].items; /* -numeric */
2698 ti = as->parms[2].items; /* -vlservers */
2699 vlservers |= (ti ? DBservers : 0);
2700 /* ti = as->parms[3].items; -cell */
2702 in = (struct sprefrequest *)space;
2706 blob.in_size=sizeof(struct sprefrequest);
2707 blob.in = (char *)in;
2709 blob.out_size = MAXSIZE;
2711 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
2712 in->flags = vlservers;
2714 code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
2716 perror("getserverprefs pioctl");
2720 out = (struct sprefinfo *) blob.out;
2722 for (i=0;i<out->num_servers;i++) {
2724 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
2727 addr = ntohl(out->servers[i].server.s_addr);
2728 sprintf(tbuffer, "%d.%d.%d.%d",
2729 (addr>>24) & 0xff, (addr>>16) & 0xff,
2730 (addr>>8) & 0xff, addr & 0xff);
2733 printf("%-50s %5u\n",name,out->servers[i].rank);
2736 in->offset = out->next_offset;
2737 } while (out->next_offset > 0);
2742 static StoreBehindCmd(as)
2743 struct cmd_syndesc *as;
2746 struct ViceIoctl blob;
2747 struct cmd_item *ti;
2748 struct sbstruct tsb, tsb2;
2754 tsb.sb_thisfile = -1;
2755 ti=as->parms[0].items; /* -kbytes */
2757 if (!as->parms[1].items) {
2758 fprintf(stderr, "%s: you must specify -files with -kbytes.\n", pn);
2761 tsb.sb_thisfile = strtol(ti->data,&t,10) * 1024;
2762 if ((tsb.sb_thisfile < 0) || (t != ti->data+strlen(ti->data))) {
2763 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2769 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
2770 ti=as->parms[2].items; /* -allfiles */
2772 allfiles = strtol(ti->data,&t,10) * 1024;
2773 if ((allfiles < 0) || (t != ti->data+strlen(ti->data))) {
2774 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2780 /* -verbose or -file only or no options */
2781 if (as->parms[3].items ||
2782 (as->parms[1].items && !as->parms[0].items) ||
2783 (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items))
2786 blob.in = (char *)&tsb;
2787 blob.out = (char *)&tsb2;
2788 blob.in_size = blob.out_size = sizeof(struct sbstruct);
2789 memset(&tsb2, 0, sizeof(tsb2));
2791 /* once per -file */
2792 for (ti=as->parms[1].items; ti; ti=ti->next) {
2793 /* Do this solely to see if the file is there */
2794 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
2796 Die(errno, ti->data);
2801 code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
2803 Die(errno, ti->data);
2808 if (verbose && (blob.out_size == sizeof(tsb2))) {
2809 if (tsb2.sb_thisfile == -1) {
2810 fprintf(stdout, "Will store %s according to default.\n",
2815 "Will store up to %d kbytes of %s asynchronously.\n",
2816 (tsb2.sb_thisfile/1024), ti->data);
2821 /* If no files - make at least one pioctl call, or
2822 * set the allfiles default if we need to.
2824 if (!as->parms[1].items || (allfiles != -1)) {
2825 tsb.sb_default = allfiles;
2826 code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
2828 Die(errno, ((allfiles == -1)?0:"-allfiles"));
2833 /* Having no arguments also reports the default store asynchrony */
2834 if (verbose && (blob.out_size == sizeof(tsb2))) {
2835 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
2836 (tsb2.sb_default/1024));
2843 static afs_int32 SetCryptCmd(as)
2844 struct cmd_syndesc *as;
2846 afs_int32 code = 0, flag;
2847 struct ViceIoctl blob;
2850 tp = as->parms[0].items->data;
2851 if (strcmp(tp, "on") == 0)
2853 else if (strcmp(tp, "off") == 0)
2856 fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
2860 blob.in = (char *) &flag;
2861 blob.in_size = sizeof(flag);
2863 code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
2865 Die(errno, (char *) 0);
2870 static afs_int32 GetCryptCmd(as)
2871 struct cmd_syndesc *as;
2873 afs_int32 code = 0, flag;
2874 struct ViceIoctl blob;
2877 blob.in = (char *) 0;
2879 blob.out_size = sizeof(flag);
2882 code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
2884 if (code) Die(errno, (char *) 0);
2887 memcpy(&flag, tp, sizeof(afs_int32));
2888 printf("Security level is currently ");
2890 printf("crypt (data security).\n");
2897 #include "AFS_component_version_number.c"
2904 struct cmd_syndesc *ts;
2906 #ifdef AFS_AIX32_ENV
2908 * The following signal action for AIX is necessary so that in case of a
2909 * crash (i.e. core is generated) we can include the user's data section
2910 * in the core dump. Unfortunately, by default, only a partial core is
2911 * generated which, in many cases, isn't too useful.
2913 struct sigaction nsa;
2915 sigemptyset(&nsa.sa_mask);
2916 nsa.sa_handler = SIG_DFL;
2917 nsa.sa_flags = SA_FULLDUMP;
2918 sigaction(SIGSEGV, &nsa, NULL);
2921 /* try to find volume location information */
2922 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0, "get client network interface addresses");
2923 cmd_CreateAlias(ts, "gc");
2925 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0, "set client network interface addresses");
2926 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "client network interfaces");
2927 cmd_CreateAlias(ts, "sc");
2929 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
2930 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
2931 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
2932 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
2933 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
2934 cmd_CreateAlias(ts, "sp");
2936 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
2937 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
2938 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2939 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
2940 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
2941 cmd_CreateAlias(ts, "gp");
2943 ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
2944 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2945 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
2946 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
2947 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
2948 parm_setacl_id = ts->nParms;
2949 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
2950 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
2951 cmd_CreateAlias(ts, "sa");
2953 ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
2954 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2955 parm_listacl_id = ts->nParms;
2956 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2957 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2958 cmd_CreateAlias(ts, "la");
2960 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
2961 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2963 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
2964 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
2965 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
2966 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
2967 parm_copyacl_id = ts->nParms;
2968 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2969 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2971 cmd_CreateAlias(ts, "ca");
2973 ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
2974 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2975 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0, "flush mount symlink from cache");
2976 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2978 ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
2979 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2980 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
2982 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
2983 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
2985 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
2986 cmd_CreateAlias(ts, "sv");
2988 ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
2989 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
2991 ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
2992 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2993 cmd_CreateAlias(ts, "lv");
2994 cmd_CreateAlias(ts, "listvol");
2996 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
2997 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2998 cmd_CreateAlias(ts, "lq");
3000 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
3001 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3002 cmd_CreateAlias(ts, "df");
3004 ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
3005 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3007 ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
3008 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3010 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
3011 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
3012 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
3013 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
3014 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
3015 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
3021 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
3025 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
3026 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
3028 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
3029 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
3030 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
3031 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
3032 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
3034 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
3035 cmd_CreateAlias(ts, "checkbackups");
3038 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
3039 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
3040 cmd_CreateAlias(ts, "cachesize");
3042 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
3044 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
3046 ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
3047 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
3049 ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
3051 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
3052 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
3053 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
3055 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
3057 cmd_CreateAlias(ts, "sq");
3059 ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
3060 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
3061 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
3062 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
3064 ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
3065 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
3066 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
3068 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
3070 * Turn this on only if you wish to be able to talk to a server which is listening
3071 * on alternative ports. This is not intended for general use and may not be
3072 * supported in the cache manager. It is not a way to run two servers at the
3073 * same host, since the cache manager cannot properly distinguish those two hosts.
3075 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
3076 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
3079 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
3080 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3082 ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
3083 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3085 ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
3088 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
3091 /* set cache monitor host address */
3092 ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *) CMD_HIDDEN);
3093 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
3094 cmd_CreateAlias(ts, "mariner");
3096 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
3097 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3099 ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
3100 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3101 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
3102 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
3104 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
3105 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3107 ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
3108 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
3110 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
3111 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
3112 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator (on | off)");
3113 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode (on | off)");
3114 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode (on | off)");
3115 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. (on | off)");
3118 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
3119 "store to server after file close");
3120 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
3121 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
3122 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
3123 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
3124 cmd_CreateAlias(ts, "sb");
3126 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
3127 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
3129 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "set cache manager encryption flag");
3131 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
3132 "Manage per process RX statistics");
3133 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3135 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3136 "Disable RX stats");
3137 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3140 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
3141 "Manage per peer 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 code = cmd_Dispatch(argc, argv);
3150 if (rxInitDone) rx_Finalize();
3155 static void Die(errnum, filename)
3162 fprintf(stderr, "%s: Invalid argument; it is possible that %s is not in AFS.\n",
3165 fprintf(stderr, "%s: Invalid argument.\n", pn);
3169 fprintf(stderr, "%s: File '%s' doesn't exist\n", pn, filename);
3171 fprintf(stderr, "%s: no such file returned\n", pn);
3174 fprintf(stderr, "%s: You can not change a backup or readonly volume\n", pn);
3179 fprintf(stderr, "%s: You don't have the required access rights on '%s'\n",
3182 fprintf(stderr, "%s: You do not have the required rights to do this operation\n",
3187 fprintf(stderr, "%s:'%s'", pn, filename);
3189 fprintf(stderr, "%s", pn);
3190 fprintf(stderr, ": %s\n", error_message(errnum));
3195 /* get clients interface addresses */
3197 GetClientAddrsCmd(as)
3198 struct cmd_syndesc *as;
3201 struct cmd_item *ti;
3203 struct ViceIoctl blob;
3204 struct sprefrequest *in;
3205 struct sprefinfo *out;
3207 in = (struct sprefrequest *)space;
3212 blob.in_size=sizeof(struct sprefrequest);
3213 blob.in = (char *)in;
3215 blob.out_size = MAXSIZE;
3217 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
3218 /* returns addr in network byte order */
3219 code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
3221 perror("getClientInterfaceAddr pioctl");
3227 out = (struct sprefinfo *) blob.out;
3228 for (i=0; i < out->num_servers; i++) {
3231 addr = ntohl(out->servers[i].server.s_addr);
3232 sprintf(tbuffer, "%d.%d.%d.%d",
3233 (addr>>24) & 0xff, (addr>>16) & 0xff,
3234 (addr>>8) & 0xff, addr & 0xff);
3235 printf ("%-50s\n", tbuffer);
3237 in->offset = out->next_offset;
3239 } while (out->next_offset > 0);
3245 SetClientAddrsCmd(as)
3246 struct cmd_syndesc *as;
3248 afs_int32 code, addr;
3249 struct cmd_item *ti;
3251 struct ViceIoctl blob;
3252 struct setspref *ssp;
3253 int sizeUsed = 0, i, flag;
3254 afs_int32 existingAddr[1024]; /* existing addresses on this host */
3258 ssp = (struct setspref *)space;
3259 ssp->num_servers = 0;
3262 blob.out_size = MAXSIZE;
3265 fprintf(stderr, "Permission denied: requires root access.\n");
3269 /* extract all existing interface addresses */
3270 existNu = rx_getAllAddr(existingAddr,1024);
3274 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
3275 for (ti = as->parms[0].items;ti;ti=ti->next) {
3276 if (sizeUsed >= sizeof(space)) {
3277 fprintf(stderr, "No more space\n");
3280 addr = extractAddr(ti->data, 20); /* network order */
3281 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
3282 fprintf(stderr, "Error in specifying address: %s..ignoring\n", ti->data);
3286 /* see if it is an address that really exists */
3287 for (flag = 0, i=0; i < existNu; i++)
3288 if (existingAddr[i] == addr) {
3292 if (!flag) { /* this is an nonexistent address */
3293 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
3297 /* copy all specified addr into ioctl buffer */
3298 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
3299 printf("Adding 0x%08x\n", addr);
3301 sizeUsed += sizeof(struct spref);
3303 if (ssp->num_servers < 1) {
3304 fprintf(stderr, "No addresses specified\n");
3307 blob.in_size = sizeUsed - sizeof(struct spref);
3309 code = pioctl(0, VIOC_SETCPREFS, &blob, 1); /* network order */
3320 struct cmd_syndesc *as;
3323 struct ViceIoctl blob;
3324 struct cmd_item *ti;
3325 char orig_name[1024]; /*Original name, may be modified*/
3326 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
3327 char parent_dir[1024]; /*Parent directory of true name*/
3328 char *last_component; /*Last component of true name*/
3329 struct stat statbuff; /*Buffer for status info*/
3330 int link_chars_read; /*Num chars read in readlink()*/
3331 int thru_symlink; /*Did we get to a mount point via a symlink?*/
3334 for(ti=as->parms[0].items; ti; ti=ti->next) {
3337 sprintf(orig_name, "%s%s",
3338 (ti->data[0] == '/') ? "" : "./",
3341 if (lstat(orig_name, &statbuff) < 0) {
3342 /* if lstat fails, we should still try the pioctl, since it
3343 may work (for example, lstat will fail, but pioctl will
3344 work if the volume of offline (returning ENODEV). */
3345 statbuff.st_mode = S_IFDIR; /* lie like pros */
3349 * The lstat succeeded. If the given file is a symlink, substitute
3350 * the file name with the link name.
3352 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
3355 * Read name of resolved file.
3357 link_chars_read = readlink(orig_name, true_name, 1024);
3358 if (link_chars_read <= 0) {
3359 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
3366 * Add a trailing null to what was read, bump the length.
3368 true_name[link_chars_read++] = 0;
3371 * If the symlink is an absolute pathname, we're fine. Otherwise, we
3372 * have to create a full pathname using the original name and the
3373 * relative symlink name. Find the rightmost slash in the original
3374 * name (we know there is one) and splice in the symlink value.
3376 if (true_name[0] != '/') {
3377 last_component = (char *) strrchr(orig_name, '/');
3378 strcpy(++last_component, true_name);
3379 strcpy(true_name, orig_name);
3383 strcpy(true_name, orig_name);
3386 * Find rightmost slash, if any.
3388 last_component = (char *) strrchr(true_name, '/');
3389 if (last_component) {
3391 * Found it. Designate everything before it as the parent directory,
3392 * everything after it as the final component.
3394 strncpy(parent_dir, true_name, last_component - true_name);
3395 parent_dir[last_component - true_name] = 0;
3396 last_component++; /*Skip the slash*/
3400 * No slash appears in the given file name. Set parent_dir to the current
3401 * directory, and the last component as the given name.
3403 strcpy(parent_dir, ".");
3404 last_component = true_name;
3407 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
3408 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
3409 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n", pn);
3414 blob.in = last_component;
3415 blob.in_size = strlen(last_component)+1;
3417 memset(space, 0, MAXSIZE);
3419 code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
3422 if (errno == EINVAL) {
3423 fprintf(stderr, "'%s' is not a mount point.\n",
3427 Die(errno, (ti->data ? ti->data : parent_dir));
3437 struct cmd_syndesc *as;
3440 afs_int32 flags = 0;
3441 struct ViceIoctl blob;
3442 struct cmd_item *ti;
3444 if (as->parms[0].items) { /* -enable*/
3445 flags |= AFSCALL_RXSTATS_ENABLE;
3447 if (as->parms[1].items) { /* -disable*/
3448 flags |= AFSCALL_RXSTATS_DISABLE;
3450 if (as->parms[2].items) { /* -clear*/
3451 flags |= AFSCALL_RXSTATS_CLEAR;
3454 fprintf(stderr, "You must specify at least one argument\n");
3458 blob.in = (char *)&flags;
3459 blob.in_size = sizeof(afs_int32);
3462 code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
3473 struct cmd_syndesc *as;
3476 afs_int32 flags = 0;
3477 struct ViceIoctl blob;
3478 struct cmd_item *ti;
3480 if (as->parms[0].items) { /* -enable*/
3481 flags |= AFSCALL_RXSTATS_ENABLE;
3483 if (as->parms[1].items) { /* -disable*/
3484 flags |= AFSCALL_RXSTATS_DISABLE;
3486 if (as->parms[2].items) { /* -clear*/
3487 flags |= AFSCALL_RXSTATS_CLEAR;
3490 fprintf(stderr, "You must specify at least one argument\n");
3494 blob.in = (char *)&flags;
3495 blob.in_size = sizeof(afs_int32);
3498 code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);