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>
52 #include <afs/afsutil.h>
55 #include <afs/ptclient.h>
60 #define MAXCELLHOSTS 8
63 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
64 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
66 static char space[MAXSIZE];
67 static char tspace[1024];
68 static struct ubik_client *uclient;
70 static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
71 static int RxStatProcCmd(), RxStatPeerCmd();
73 extern char *hostutil_GetNameByINet();
74 extern struct hostent *hostutil_GetHostByName();
77 extern struct cmd_syndesc *cmd_CreateSyntax();
78 static char pn[] = "fs";
79 static int rxInitDone = 0;
81 static void ZapList();
82 static int PruneList();
90 * Character to use between name and rights in printed representation for
93 #define DFS_SEPARATOR ' '
95 typedef char sec_rgy_name_t[1025]; /* A DCE definition */
98 int dfs; /* Originally true if a dfs acl; now also the type
99 of the acl (1, 2, or 3, corresponding to object,
100 initial dir, or initial object). */
101 sec_rgy_name_t cell; /* DFS cell name */
104 struct AclEntry *pluslist;
105 struct AclEntry *minuslist;
109 struct AclEntry *next;
114 static void ZapAcl(acl)
118 ZapList(acl->pluslist);
119 ZapList(acl->minuslist);
131 if (t >= 'A' && t <= 'Z') t += 0x20;
132 if (u >= 'A' && u <= 'Z') u += 0x20;
133 if (t != u) return 1;
134 if (t == 0) return 0;
139 * Mods for the AFS/DFS protocol translator.
141 * DFS rights. It's ugly to put these definitions here, but they
142 * *cannot* change, because they're part of the wire protocol.
143 * In any event, the protocol translator will guarantee these
144 * assignments for AFS cache managers.
146 #define DFS_READ 0x01
147 #define DFS_WRITE 0x02
148 #define DFS_EXECUTE 0x04
149 #define DFS_CONTROL 0x08
150 #define DFS_INSERT 0x10
151 #define DFS_DELETE 0x20
153 /* the application definable ones (backwards from AFS) */
154 #define DFS_USR0 0x80000000 /* "A" bit */
155 #define DFS_USR1 0x40000000 /* "B" bit */
156 #define DFS_USR2 0x20000000 /* "C" bit */
157 #define DFS_USR3 0x10000000 /* "D" bit */
158 #define DFS_USR4 0x08000000 /* "E" bit */
159 #define DFS_USR5 0x04000000 /* "F" bit */
160 #define DFS_USR6 0x02000000 /* "G" bit */
161 #define DFS_USR7 0x01000000 /* "H" bit */
162 #define DFS_USRALL (DFS_USR0 | DFS_USR1 | DFS_USR2 | DFS_USR3 |\
163 DFS_USR4 | DFS_USR5 | DFS_USR6 | DFS_USR7)
166 * Offset of -id switch in command structure for various commands.
167 * The -if switch is the next switch always.
169 static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
172 * Determine whether either the -id or -if switches are present, and
173 * return 0, 1 or 2, as appropriate. Abort if both switches are present.
175 /* int id; Offset of -id switch; -if is next switch */
176 static int getidf(struct cmd_syndesc *as, int id)
180 if (as->parms[id].items) {
183 if (as->parms[id + 1].items) {
189 "%s: you may specify either -id or -if, but not both switches\n",
196 static int PRights(afs_int32 arights, int dfs)
199 if (arights & PRSFS_READ) printf("r");
200 if (arights & PRSFS_LOOKUP) printf("l");
201 if (arights & PRSFS_INSERT) printf("i");
202 if (arights & PRSFS_DELETE) printf("d");
203 if (arights & PRSFS_WRITE) printf("w");
204 if (arights & PRSFS_LOCK) printf("k");
205 if (arights & PRSFS_ADMINISTER) printf("a");
206 if (arights & PRSFS_USR0) printf("A");
207 if (arights & PRSFS_USR1) printf("B");
208 if (arights & PRSFS_USR2) printf("C");
209 if (arights & PRSFS_USR3) printf("D");
210 if (arights & PRSFS_USR4) printf("E");
211 if (arights & PRSFS_USR5) printf("F");
212 if (arights & PRSFS_USR6) printf("G");
213 if (arights & PRSFS_USR7) printf("H");
215 if (arights & DFS_READ) printf("r"); else printf("-");
216 if (arights & DFS_WRITE) printf("w"); else printf("-");
217 if (arights & DFS_EXECUTE) printf("x"); else printf("-");
218 if (arights & DFS_CONTROL) printf("c"); else printf("-");
219 if (arights & DFS_INSERT) printf("i"); else printf("-");
220 if (arights & DFS_DELETE) printf("d"); else printf("-");
221 if (arights & (DFS_USRALL)) printf("+");
222 if (arights & DFS_USR0) printf("A");
223 if (arights & DFS_USR1) printf("B");
224 if (arights & DFS_USR2) printf("C");
225 if (arights & DFS_USR3) printf("D");
226 if (arights & DFS_USR4) printf("E");
227 if (arights & DFS_USR5) printf("F");
228 if (arights & DFS_USR6) printf("G");
229 if (arights & DFS_USR7) printf("H");
233 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
234 static int InAFS(char *apath)
236 struct ViceIoctl blob;
240 blob.out_size = MAXSIZE;
243 code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
245 if ((errno == EINVAL) || (errno == ENOENT)) return 0;
250 /* return a static pointer to a buffer */
251 static char *Parent(char *apath)
254 strcpy(tspace, apath);
255 tp = strrchr(tspace, '/');
259 else strcpy(tspace, ".");
263 enum rtype {add, destroy, deny};
265 static afs_int32 Convert(char *arights, int dfs, enum rtype *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(struct AclEntry *alist, char *aname)
343 if (!foldcmp(alist->name, aname)) return alist;
349 /* if no parm specified in a particular slot, set parm to be "." instead */
350 static void SetDotDefault(struct cmd_item **aitemp)
353 if (*aitemp) return; /* already has value */
354 /* otherwise, allocate an item representing "." */
355 ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
357 ti->next = (struct cmd_item *) 0;
358 ti->data = (char *) malloc(2);
360 strcpy(ti->data, ".");
364 static void ChangeList(struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights)
366 struct AclEntry *tlist;
367 tlist = (plus ? al->pluslist : al->minuslist);
368 tlist = FindList (tlist, aname);
370 /* Found the item already in the list. */
371 tlist->rights = arights;
373 al->nplus -= PruneList(&al->pluslist, al->dfs);
375 al->nminus -= PruneList(&al->minuslist, al->dfs);
378 /* Otherwise we make a new item and plug in the new data. */
379 tlist = (struct AclEntry *) malloc(sizeof (struct AclEntry));
381 strcpy(tlist->name, aname);
382 tlist->rights = arights;
384 tlist->next = al->pluslist;
385 al->pluslist = tlist;
387 if (arights == 0 || arights == -1)
388 al->nplus -= PruneList(&al->pluslist, al->dfs);
391 tlist->next = al->minuslist;
392 al->minuslist = tlist;
394 if (arights == 0) al->nminus -= PruneList(&al->minuslist, al->dfs);
398 static void ZapList(struct AclEntry *alist)
400 struct AclEntry *tp, *np;
401 for (tp = alist; tp; tp = np) {
407 static int PruneList(struct AclEntry **ae, int dfs)
409 struct AclEntry **lp;
410 struct AclEntry *te, *ne;
414 for(te = *ae;te;te=ne) {
415 if ((!dfs && te->rights == 0) || te->rights == -1) {
429 static char *SkipLine(char *astr)
431 while (*astr !='\n') astr++;
437 * Create an empty acl, taking into account whether the acl pointed
438 * to by astr is an AFS or DFS acl. Only parse this minimally, so we
439 * can recover from problems caused by bogus ACL's (in that case, always
440 * assume that the acl is AFS: for DFS, the user can always resort to
441 * acl_edit, but for AFS there may be no other way out).
443 static struct Acl *EmptyAcl(char *astr)
448 tp = (struct Acl *)malloc(sizeof (struct Acl));
450 tp->nplus = tp->nminus = 0;
451 tp->pluslist = tp->minuslist = 0;
453 sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
457 static struct Acl *ParseAcl(char *astr)
459 int nplus, nminus, i, trights;
461 struct AclEntry *first, *last, *tl;
464 ta = (struct Acl *) malloc (sizeof (struct Acl));
467 sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
468 astr = SkipLine(astr);
469 sscanf(astr, "%d", &ta->nminus);
470 astr = SkipLine(astr);
477 for(i=0;i<nplus;i++) {
478 sscanf(astr, "%100s %d", tname, &trights);
479 astr = SkipLine(astr);
480 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
482 if (!first) first = tl;
483 strcpy(tl->name, tname);
484 tl->rights = trights;
486 if (last) last->next = tl;
489 ta->pluslist = first;
493 for(i=0;i<nminus;i++) {
494 sscanf(astr, "%100s %d", tname, &trights);
495 astr = SkipLine(astr);
496 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
498 if (!first) first = tl;
499 strcpy(tl->name, tname);
500 tl->rights = trights;
502 if (last) last->next = tl;
505 ta->minuslist = first;
510 static int PrintStatus(VolumeStatus *status, char *name, char *offmsg)
512 printf("Volume status for vid = %u named %s\n",status->Vid, name);
514 printf("Current offline message is %s\n",offmsg);
515 printf("Current disk quota is ");
516 if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota);
517 else printf("unlimited\n");
518 printf("Current blocks used are %d\n",status->BlocksInUse);
519 printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
523 static int QuickPrintStatus(VolumeStatus *status, char *name)
525 double QuotaUsed =0.0;
526 double PartUsed =0.0;
528 printf("%-25.25s",name);
530 if (status->MaxQuota != 0) {
531 printf("%10d%10d", status->MaxQuota, status->BlocksInUse);
532 QuotaUsed = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
534 printf(" no limit%10d", status->BlocksInUse);
536 if (QuotaUsed > 90.0) {
537 printf("%5.0f%%<<", QuotaUsed);
540 else printf("%5.0f%% ", QuotaUsed);
541 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
542 if (PartUsed > 97.0) {
543 printf("%9.0f%%<<", PartUsed);
546 else printf("%9.0f%% ", PartUsed);
548 printf(" <<WARNING\n");
554 static int QuickPrintSpace(VolumeStatus *status, char *name)
556 double PartUsed =0.0;
558 printf("%-25.25s",name);
560 printf("%10d%10d%10d", status->PartMaxBlocks, status->PartMaxBlocks - status->PartBlocksAvail, status->PartBlocksAvail);
562 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
563 if (PartUsed > 90.0){
564 printf(" %4.0f%%<<", PartUsed);
567 else printf(" %4.0f%% ", PartUsed);
569 printf(" <<WARNING\n");
575 static char *AclToString(struct Acl *acl)
577 static char mydata[MAXSIZE];
578 char tstring[MAXSIZE];
582 if (acl->dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
583 else dfsstring[0] = '\0';
584 sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
585 for(tp = acl->pluslist;tp;tp=tp->next) {
586 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
587 strcat(mydata, tstring);
589 for(tp = acl->minuslist;tp;tp=tp->next) {
590 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
591 strcat(mydata, tstring);
596 static int SetACLCmd(struct cmd_syndesc *as)
599 struct ViceIoctl blob;
601 struct cmd_item *ti, *ui;
605 int idf = getidf(as, parm_setacl_id);
608 if (as->parms[2].items) clear=1;
610 plusp = !(as->parms[3].items);
611 for(ti=as->parms[0].items; ti;ti=ti->next) {
612 blob.out_size = MAXSIZE;
614 blob.in = blob.out = space;
615 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
617 Die(errno, ti->data);
623 ta = ParseAcl(space);
624 if (!plusp && ta->dfs) {
626 "%s: %s: you may not use the -negative switch with DFS acl's.\n%s",
628 "(you may specify \"null\" to revoke all rights, however)\n");
634 if (clear) ta = EmptyAcl(space);
635 else ta = ParseAcl(space);
636 CleanAcl(ta, ti->data);
637 for(ui=as->parms[1].items; ui; ui=ui->next->next) {
640 fprintf(stderr, "%s: Missing second half of user/access pair.\n", pn);
644 rights = Convert(ui->next->data, ta->dfs, &rtype);
645 if (rtype == destroy && !ta->dfs) {
646 struct AclEntry *tlist;
648 tlist = (plusp ? ta->pluslist : ta->minuslist);
649 if (!FindList(tlist, ui->data))
652 if (rtype == deny && !ta->dfs) plusp = 0;
653 if (rtype == destroy && ta->dfs) rights = -1;
654 ChangeList(ta, plusp, ui->data, rights);
656 blob.in = AclToString(ta);
658 blob.in_size = 1+strlen(blob.in);
659 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
661 if (errno == EINVAL) {
663 static char *fsenv = 0;
665 fsenv = (char *)getenv("FS_EXPERT");
667 fprintf(stderr, "%s: \"Invalid argument\" was returned when you tried to store a DFS access list.\n", pn);
670 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
671 "\nPossible reasons for this include:\n\n",
672 " -You may have specified an inappropriate combination of rights.\n",
673 " For example, some DFS-supported filesystems may not allow you to\n",
674 " drop the \"c\" right from \"user_obj\".\n\n",
675 " -A mask_obj may be required (it is likely required by the underlying\n",
676 " filesystem if you try to set anything other than the basic \"user_obj\"\n",
677 " \"mask_obj\", or \"group_obj\" entries). Unlike acl_edit, the fs command\n",
678 " does not automatically create or update the mask_obj. Try setting\n",
679 " the rights \"mask_obj all\" with \"fs sa\" before adding any explicit\n",
680 " users or groups. You can do this with a single command, such as\n",
681 " \"fs sa mask_obj all user:somename read\"\n\n",
682 " -A specified user or group may not exist.\n\n",
683 " -You may have tried to delete \"user_obj\", \"group_obj\", or \"other_obj\".\n",
684 " This is probably not allowed by the underlying file system.\n\n",
685 " -If you add a user or group to a DFS ACL, remember that it must be\n",
686 " fully specified as \"user:username\" or \"group:groupname\". In addition, there\n",
687 " may be local requirements on the format of the user or group name.\n",
688 " Check with your cell administrator.\n\n",
689 " -Or numerous other possibilities. It would be great if we could be more\n",
690 " precise about the actual problem, but for various reasons, this is\n",
691 " impractical via this interface. If you can't figure it out, you\n",
692 " might try logging into a DCE-equipped machine and use acl_edit (or\n",
693 " whatever is provided). You may get better results. Good luck!\n\n",
694 " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
697 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
698 fprintf(stderr, "\t-File not in AFS\n");
699 fprintf(stderr, "\t-Too many users on access control list\n");
700 fprintf(stderr, "\t-Tried to add non-existent user to access control list\n");
704 Die(errno, ti->data);
714 static int CopyACLCmd(struct cmd_syndesc *as)
717 struct ViceIoctl blob;
718 struct Acl *fa, *ta = 0;
720 struct cmd_item *ti, *ui;
724 int idf = getidf(as, parm_copyacl_id);
727 if (as->parms[2].items) clear=1;
729 blob.out_size = MAXSIZE;
731 blob.in = blob.out = space;
732 code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
734 Die(errno, as->parms[0].items->data);
737 fa = ParseAcl(space);
738 CleanAcl(fa, as->parms[0].items->data);
739 for (ti=as->parms[1].items; ti;ti=ti->next) {
740 blob.out_size = MAXSIZE;
742 blob.in = blob.out = space;
743 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
745 Die(errno, ti->data);
751 if (clear) ta = EmptyAcl(space);
752 else ta = ParseAcl(space);
753 CleanAcl(ta, ti->data);
754 if (ta->dfs != fa->dfs) {
755 fprintf(stderr, "%s: incompatible file system types: acl not copied to %s; aborted\n", pn, ti->data);
760 if (! clear && strcmp(ta->cell, fa->cell) != 0) {
761 fprintf(stderr, "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", pn, ti->data);
765 strcpy(ta->cell, fa->cell);
767 for (tp = fa->pluslist;tp;tp=tp->next)
768 ChangeList(ta, 1, tp->name, tp->rights);
769 for (tp = fa->minuslist;tp;tp=tp->next)
770 ChangeList(ta, 0, tp->name, tp->rights);
771 blob.in = AclToString(ta);
773 blob.in_size = 1+strlen(blob.in);
774 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
776 if (errno == EINVAL) {
777 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
778 fprintf(stderr, "\t-File not in AFS\n");
781 Die(errno, ti->data);
791 /* pioctl() call to get the cellname of a pathname */
792 static afs_int32 GetCell(char *fname, char *cellname)
795 struct ViceIoctl blob;
798 blob.out_size = MAXCELLCHARS;
801 code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
802 return code ? errno : 0;
805 /* Check if a username is valid: If it contains only digits (or a
806 * negative sign), then it might be bad. We then query the ptserver
809 static BadName(char *aname, char *fname)
811 afs_int32 tc, code, id;
813 char cell[MAXCELLCHARS];
815 for (nm=aname; tc=*nm; nm++) {
816 /* all must be '-' or digit to be bad */
817 if (tc != '-' && (tc < '0' || tc > '9')) return 0;
820 /* Go to the PRDB and see if this all number username is valid */
821 code = GetCell(fname, cell);
824 pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
825 code = pr_SNameToId(aname, &id);
828 /* 1=>Not-valid; 0=>Valid */
829 return ((!code && (id==ANONYMOUSID)) ? 1 : 0);
833 /* clean up an access control list of its bad entries; return 1 if we made
834 any changes to the list, and 0 otherwise */
835 static CleanAcl(struct Acl *aa, char *fname)
837 struct AclEntry *te, **le, *ne;
840 /* Don't correct DFS ACL's for now */
844 /* prune out bad entries */
845 changes = 0; /* count deleted entries */
847 for(te = aa->pluslist; te; te=ne) {
849 if (BadName(te->name,fname)) {
861 for(te = aa->minuslist; te; te=ne) {
863 if (BadName(te->name,fname)) {
878 /* clean up an acl to not have bogus entries */
879 static int CleanACLCmd(struct cmd_syndesc *as)
883 struct ViceIoctl blob;
889 SetDotDefault(&as->parms[0].items);
890 for(ti=as->parms[0].items; ti; ti=ti->next) {
891 blob.out_size = MAXSIZE;
894 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
896 Die(errno, ti->data);
902 ta = ParseAcl(space);
905 "%s: cleanacl is not supported for DFS access lists.\n",
911 changes = CleanAcl(ta, ti->data);
914 /* now set the acl */
915 blob.in=AclToString(ta);
916 blob.in_size = strlen(blob.in)+1;
918 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
920 if (errno == EINVAL) {
921 fprintf(stderr, "%s: Invalid argument, possible reasons include\n", pn);
922 fprintf(stderr, "%s: File not in vice or\n", pn);
923 fprintf(stderr, "%s: Too many users on access control list or\n", pn);
926 Die(errno, ti->data);
932 /* now list the updated acl */
933 printf("Access list for %s is now\n", ti->data);
935 if (!ta->dfs) printf("Normal rights:\n");
936 for(te = ta->pluslist;te;te=te->next) {
937 printf(" %s ", te->name);
938 PRights(te->rights, ta->dfs);
942 if (ta->nminus > 0) {
943 printf("Negative rights:\n");
944 for(te = ta->minuslist;te;te=te->next) {
945 printf(" %s ", te->name);
946 PRights(te->rights, ta->dfs);
950 if (ti->next) printf("\n");
953 printf("Access list for %s is fine.\n", ti->data);
959 static int ListACLCmd(struct cmd_syndesc *as)
963 struct ViceIoctl blob;
966 int idf = getidf(as, parm_listacl_id);
969 SetDotDefault(&as->parms[0].items);
970 for(ti=as->parms[0].items; ti; ti=ti->next) {
971 blob.out_size = MAXSIZE;
973 blob.in = blob.out = space;
974 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
976 Die(errno, ti->data);
980 ta = ParseAcl(space);
983 printf("Access list for %s is\n", ti->data);
986 printf("DFS access list for %s is\n", ti->data);
989 printf("DFS initial directory access list of %s is\n", ti->data);
992 printf("DFS initial file access list of %s is\n", ti->data);
996 printf(" Default cell = %s\n", ta->cell);
999 if (!ta->dfs) printf("Normal rights:\n");
1000 for(te = ta->pluslist;te;te=te->next) {
1001 printf(" %s ", te->name);
1002 PRights(te->rights, ta->dfs);
1006 if (ta->nminus > 0) {
1007 printf("Negative rights:\n");
1008 for(te = ta->minuslist;te;te=te->next) {
1009 printf(" %s ", te->name);
1010 PRights(te->rights, ta->dfs);
1014 if (ti->next) printf("\n");
1020 static int FlushVolumeCmd(struct cmd_syndesc *as)
1023 struct ViceIoctl blob;
1024 struct cmd_item *ti;
1027 SetDotDefault(&as->parms[0].items);
1028 for(ti=as->parms[0].items; ti; ti=ti->next) {
1029 blob.in_size = blob.out_size = 0;
1030 code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
1032 fprintf(stderr, "Error flushing volume ");
1041 static int FlushCmd(struct cmd_syndesc *as)
1044 struct ViceIoctl blob;
1045 struct cmd_item *ti;
1048 for(ti=as->parms[0].items; ti; ti=ti->next) {
1049 blob.in_size = blob.out_size = 0;
1050 code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
1052 if (errno == EMFILE) {
1053 fprintf(stderr, "%s: Can't flush active file %s\n", pn, ti->data);
1056 fprintf(stderr, "%s: Error flushing file ", pn);
1066 /* all this command does is repackage its args and call SetVolCmd */
1067 static int SetQuotaCmd(struct cmd_syndesc *as)
1069 struct cmd_syndesc ts;
1071 /* copy useful stuff from our command slot; we may later have to reorder */
1072 memcpy(&ts, as, sizeof(ts)); /* copy whole thing */
1073 return SetVolCmd(&ts);
1076 static int SetVolCmd(struct cmd_syndesc *as)
1079 struct ViceIoctl blob;
1080 struct cmd_item *ti;
1081 struct VolumeStatus *status;
1082 char *offmsg, *input;
1085 SetDotDefault(&as->parms[0].items);
1086 for(ti=as->parms[0].items; ti; ti=ti->next) {
1088 blob.out_size = MAXSIZE;
1089 blob.in_size = sizeof(*status) + 3; /* for the three terminating nulls */
1092 status = (VolumeStatus *)space;
1093 status->MinQuota = status->MaxQuota = -1;
1095 if (as->parms[1].items) {
1096 code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
1098 fprintf(stderr, "%s: bad integer specified for quota.\n", pn);
1103 if (as->parms[2].items) offmsg = as->parms[2].items->data;
1104 input = (char *)status + sizeof(*status);
1105 *(input++) = '\0'; /* never set name: this call doesn't change vldb */
1107 if (strlen(offmsg) >= VMSGSIZE) {
1108 fprintf(stderr, "%s: message must be shorter than %d characters\n",
1113 strcpy(input,offmsg);
1114 blob.in_size += strlen(offmsg);
1115 input += strlen(offmsg) + 1;
1117 else *(input++) = '\0';
1118 *(input++) = '\0'; /* Pad for old style volume "motd" */
1119 code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
1121 Die(errno, ti->data);
1128 static int ExamineCmd(struct cmd_syndesc *as)
1131 struct ViceIoctl blob;
1132 struct cmd_item *ti;
1133 struct VolumeStatus *status;
1134 char *name, *offmsg;
1137 SetDotDefault(&as->parms[0].items);
1138 for(ti=as->parms[0].items; ti; ti=ti->next) {
1140 blob.out_size = MAXSIZE;
1143 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1145 Die(errno, ti->data);
1149 status = (VolumeStatus *)space;
1150 name = (char *)status + sizeof(*status);
1151 offmsg = name + strlen(name) + 1;
1152 PrintStatus(status, name, offmsg);
1157 static int ListQuotaCmd(struct cmd_syndesc *as)
1160 struct ViceIoctl blob;
1161 struct cmd_item *ti;
1162 struct VolumeStatus *status;
1166 printf("%-25s%-10s%-10s%-7s%-11s\n",
1167 "Volume Name"," Quota", " Used", " %Used", " Partition");
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 QuickPrintStatus(status, name);
1187 static int WhereIsCmd(struct cmd_syndesc *as)
1190 struct ViceIoctl blob;
1191 struct cmd_item *ti;
1197 SetDotDefault(&as->parms[0].items);
1198 for(ti=as->parms[0].items; ti; ti=ti->next) {
1200 blob.out_size = MAXSIZE;
1203 memset(space, 0, sizeof(space));
1204 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
1206 Die(errno, ti->data);
1210 hosts = (afs_int32 *) space;
1211 printf("File %s is on host%s ", ti->data, (hosts[0] && !hosts[1]) ? "": "s");
1212 for(j=0; j<MAXHOSTS; j++) {
1213 if (hosts[j] == 0) break;
1214 tp = hostutil_GetNameByINet(hosts[j]);
1223 static int DiskFreeCmd(struct cmd_syndesc *as)
1226 struct ViceIoctl blob;
1227 struct cmd_item *ti;
1229 struct VolumeStatus *status;
1232 printf("%-25s%-10s%-10s%-10s%-6s\n",
1233 "Volume Name"," kbytes", " used", " avail", " %used");
1234 SetDotDefault(&as->parms[0].items);
1235 for(ti=as->parms[0].items; ti; ti=ti->next) {
1237 blob.out_size = MAXSIZE;
1240 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1242 Die(errno, ti->data);
1246 status = (VolumeStatus *)space;
1247 name = (char *)status + sizeof(*status);
1248 QuickPrintSpace(status, name);
1253 static int QuotaCmd(struct cmd_syndesc *as)
1256 struct ViceIoctl blob;
1257 struct cmd_item *ti;
1259 struct VolumeStatus *status;
1262 SetDotDefault(&as->parms[0].items);
1263 for(ti=as->parms[0].items; ti; ti=ti->next) {
1265 blob.out_size = MAXSIZE;
1268 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1270 Die(errno, ti->data);
1274 status = (VolumeStatus *)space;
1275 if (status->MaxQuota) quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
1276 else quotaPct = 0.0;
1277 printf("%2.0f%% of quota used.\n", quotaPct);
1282 static int ListMountCmd(struct cmd_syndesc *as)
1285 struct ViceIoctl blob;
1286 struct cmd_item *ti;
1287 char orig_name[1024]; /*Original name, may be modified*/
1288 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
1289 char parent_dir[1024]; /*Parent directory of true name*/
1290 char *last_component; /*Last component of true name*/
1291 struct stat statbuff; /*Buffer for status info*/
1292 int link_chars_read; /*Num chars read in readlink()*/
1293 int thru_symlink; /*Did we get to a mount point via a symlink?*/
1296 for(ti=as->parms[0].items; ti; ti=ti->next) {
1299 sprintf(orig_name, "%s%s",
1300 (ti->data[0] == '/') ? "" : "./",
1303 if (lstat(orig_name, &statbuff) < 0) {
1304 /* if lstat fails, we should still try the pioctl, since it
1305 may work (for example, lstat will fail, but pioctl will
1306 work if the volume of offline (returning ENODEV). */
1307 statbuff.st_mode = S_IFDIR; /* lie like pros */
1311 * The lstat succeeded. If the given file is a symlink, substitute
1312 * the file name with the link name.
1314 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
1317 * Read name of resolved file.
1319 link_chars_read = readlink(orig_name, true_name, 1024);
1320 if (link_chars_read <= 0) {
1321 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
1328 * Add a trailing null to what was read, bump the length.
1330 true_name[link_chars_read++] = 0;
1333 * If the symlink is an absolute pathname, we're fine. Otherwise, we
1334 * have to create a full pathname using the original name and the
1335 * relative symlink name. Find the rightmost slash in the original
1336 * name (we know there is one) and splice in the symlink value.
1338 if (true_name[0] != '/') {
1339 last_component = (char *) strrchr(orig_name, '/');
1340 strcpy(++last_component, true_name);
1341 strcpy(true_name, orig_name);
1345 strcpy(true_name, orig_name);
1348 * Find rightmost slash, if any.
1350 last_component = (char *) strrchr(true_name, '/');
1351 if (last_component) {
1353 * Found it. Designate everything before it as the parent directory,
1354 * everything after it as the final component.
1356 strncpy(parent_dir, true_name, last_component - true_name);
1357 parent_dir[last_component - true_name] = 0;
1358 last_component++; /*Skip the slash*/
1362 * No slash appears in the given file name. Set parent_dir to the current
1363 * directory, and the last component as the given name.
1365 strcpy(parent_dir, ".");
1366 last_component = true_name;
1369 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
1370 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
1371 fprintf(stderr, "%s: of a name in the 'fs lsmount' command.\n", pn);
1376 blob.in = last_component;
1377 blob.in_size = strlen(last_component)+1;
1378 blob.out_size = MAXSIZE;
1380 memset(space, 0, MAXSIZE);
1382 code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
1385 printf("'%s' is a %smount point for volume '%s'\n",
1387 (thru_symlink ? "symbolic link, leading to a " : ""),
1391 if (errno == EINVAL) {
1392 fprintf(stderr, "'%s' is not a mount point.\n",
1396 Die(errno, (ti->data ? ti->data : parent_dir));
1404 static MakeMountCmd(struct cmd_syndesc *as)
1407 char *cellName, *volName, *tmpName;
1408 struct afsconf_cell info;
1409 struct vldbentry vldbEntry;
1410 struct ViceIoctl blob;
1416 if (as->parms[5].items && !as->parms[2].items) {
1417 fprintf(stderr, "%s: must provide cell when creating cellular mount point.\n", pn);
1422 if (as->parms[2].items) /* cell name specified */
1423 cellName = as->parms[2].items->data;
1426 volName = as->parms[1].items->data;
1428 if (strlen(volName) >= 64) {
1429 fprintf(stderr, "%s: volume name too long (length must be < 64 characters)\n", pn);
1433 /* Check for a cellname in the volume specification, and complain
1434 * if it doesn't match what was specified with -cell */
1435 if (tmpName = strchr(volName, ':')) {
1438 if (strcasecmp(cellName,volName)) {
1439 fprintf(stderr, "%s: cellnames do not match.\n", pn);
1444 volName = ++tmpName;
1447 if (!InAFS(Parent(as->parms[0].items->data))) {
1448 fprintf(stderr, "%s: mount points must be created within the AFS file system\n", pn);
1454 blob.out_size = MAXSIZE;
1456 code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME, &blob, 1);
1459 code = GetCellName(cellName?cellName:space, &info);
1463 if (!(as->parms[4].items)) {
1464 /* not fast, check which cell the mountpoint is being created in */
1465 /* not fast, check name with VLDB */
1466 code = VLDBInit(1, &info);
1468 /* make the check. Don't complain if there are problems with init */
1469 code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
1470 if (code == VL_NOENT) {
1471 fprintf(stderr, "%s: warning, volume %s does not exist in cell %s.\n",
1472 pn, volName, cellName ? cellName : space);
1477 if (as->parms[3].items) /* if -rw specified */
1482 /* cellular mount point, prepend cell prefix */
1483 strcat(space, info.name);
1486 strcat(space, volName); /* append volume name */
1487 strcat(space, "."); /* stupid convention; these end with a period */
1488 code = symlink(space, as->parms[0].items->data);
1490 Die(errno, as->parms[0].items->data);
1497 * Delete AFS mount points. Variables are used as follows:
1498 * tbuffer: Set to point to the null-terminated directory name of the mount point
1499 * (or ``.'' if none is provided)
1500 * tp: Set to point to the actual name of the mount point to nuke.
1502 static int RemoveMountCmd(struct cmd_syndesc *as)
1505 struct ViceIoctl blob;
1506 struct cmd_item *ti;
1508 char lsbuffer[1024];
1512 for(ti=as->parms[0].items; ti; ti=ti->next) {
1514 tp = (char *) strrchr(ti->data, '/');
1516 strncpy(tbuffer, ti->data, code=tp-ti->data); /* the dir name */
1518 tp++; /* skip the slash */
1521 strcpy(tbuffer, ".");
1525 blob.in_size = strlen(tp)+1;
1526 blob.out = lsbuffer;
1527 blob.out_size = sizeof(lsbuffer);
1528 code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
1530 if (errno == EINVAL) {
1531 fprintf(stderr, "%s: '%s' is not a mount point.\n", pn, ti->data);
1534 Die(errno, ti->data);
1537 continue; /* don't bother trying */
1541 blob.in_size = strlen(tp)+1;
1542 code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
1544 Die(errno, ti->data);
1554 static int CheckServersCmd(struct cmd_syndesc *as)
1557 struct ViceIoctl blob;
1563 struct afsconf_cell info;
1564 struct chservinfo checkserv;
1566 memset(&checkserv, 0, sizeof(struct chservinfo));
1567 blob.in_size=sizeof(struct chservinfo);
1568 blob.in=(caddr_t)&checkserv;
1570 blob.out_size = MAXSIZE;
1572 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1574 /* prepare flags for checkservers command */
1575 temp = 2; /* default to checking local cell only */
1576 if (as->parms[2].items) temp |= 1; /* set fast flag */
1577 if (as->parms[1].items) temp &= ~2; /* turn off local cell check */
1579 checkserv.magic = 0x12345678; /* XXX */
1580 checkserv.tflags=temp;
1582 /* now copy in optional cell name, if specified */
1583 if (as->parms[0].items) {
1584 code = GetCellName(as->parms[0].items->data, &info);
1588 strcpy(checkserv.tbuffer,info.name);
1589 checkserv.tsize=strlen(info.name)+1;
1592 strcpy(checkserv.tbuffer,"\0");
1596 if(as->parms[3].items) {
1597 checkserv.tinterval=atol(as->parms[3].items->data);
1600 if(checkserv.tinterval<0) {
1601 printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
1602 checkserv.tinterval=0;
1604 else if(checkserv.tinterval> 600) {
1605 printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
1606 checkserv.tinterval=600; /* 10 min max interval */
1610 checkserv.tinterval = -1; /* don't change current interval */
1613 code = pioctl(0, VIOCCKSERV, &blob, 1);
1615 if ((errno == EACCES) && (checkserv.tinterval > 0)) {
1616 printf("Must be root to change -interval\n");
1622 memcpy(&temp, space, sizeof(afs_int32));
1623 if (checkserv.tinterval >= 0) {
1624 if (checkserv.tinterval > 0)
1625 printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
1626 checkserv.tinterval, temp);
1628 printf("The current down server probe interval is %d secs\n", temp);
1632 printf("All servers are running.\n");
1635 printf("These servers unavailable due to network or server problems: ");
1637 memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
1638 if (temp == 0) break;
1639 tp = hostutil_GetNameByINet(temp);
1648 static int MessagesCmd(struct cmd_syndesc *as)
1651 struct ViceIoctl blob;
1654 struct gaginfo gagflags;
1655 struct cmd_item *show;
1657 memset(&gagflags, 0, sizeof(struct gaginfo));
1658 blob.in_size = sizeof(struct gaginfo);
1659 blob.in = (caddr_t) &gagflags;
1660 blob.out_size = MAXSIZE;
1662 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1664 if (show = as->parms[0].items) {
1665 if (!strcasecmp (show->data, "user"))
1666 gagflags.showflags |= GAGUSER;
1667 else if (!strcasecmp (show->data, "console"))
1668 gagflags.showflags |= GAGCONSOLE;
1669 else if (!strcasecmp (show->data, "all"))
1670 gagflags.showflags |= GAGCONSOLE | GAGUSER;
1671 else if (!strcasecmp (show->data, "none"))
1675 "unrecognized flag %s: must be in {user,console,all,none}\n",
1684 code = pioctl(0, VIOC_GAG, &blob, 1);
1693 static int CheckVolumesCmd(struct cmd_syndesc *as)
1696 struct ViceIoctl blob;
1700 code = pioctl(0, VIOCCKBACK, &blob, 1);
1706 printf("All volumeID/name mappings checked.\n");
1710 static int SetCacheSizeCmd(struct cmd_syndesc *as)
1713 struct ViceIoctl blob;
1716 if (!as->parms[0].items && !as->parms[1].items) {
1717 fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
1720 if (as->parms[0].items) {
1721 code = util_GetInt32(as->parms[0].items->data, &temp);
1723 fprintf(stderr, "%s: bad integer specified for cache size.\n", pn);
1729 blob.in = (char *) &temp;
1730 blob.in_size = sizeof(afs_int32);
1732 code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
1734 if (errno == EROFS) {
1735 printf("'fs setcache' not allowed on memory cache based cache managers.\n");
1743 printf("New cache size set.\n");
1747 #define MAXGCSIZE 16
1748 static int GetCacheParmsCmd(struct cmd_syndesc *as)
1751 struct ViceIoctl blob;
1752 afs_int32 parms[MAXGCSIZE];
1754 memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
1757 blob.out_size = sizeof(parms);
1758 blob.out = (char *) parms;
1759 code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
1764 printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
1765 parms[1], parms[0]);
1766 if (parms[1] > parms[0])
1767 printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
1771 static int ListCellsCmd(struct cmd_syndesc *as)
1777 struct ViceIoctl blob;
1780 resolve = !(as->parms[0].items); /* -numeric */
1784 memcpy(tp, &i, sizeof(afs_int32));
1785 blob.out_size = MAXSIZE;
1786 blob.in_size = sizeof(afs_int32);
1789 code = pioctl(0, VIOCGETCELL, &blob, 1);
1791 if (errno == EDOM) break; /* done with the list */
1796 printf("Cell %s on hosts", tp+MAXCELLHOSTS*sizeof(afs_int32));
1797 for(j=0; j < MAXCELLHOSTS; j++) {
1799 char *name, tbuffer[20];
1801 memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
1802 if (addr == 0) break;
1805 name = hostutil_GetNameByINet(addr);
1809 sprintf(tbuffer, "%d.%d.%d.%d",
1810 (addr>>24) & 0xff, (addr>>16) & 0xff,
1811 (addr>>8) & 0xff, addr & 0xff);
1814 printf(" %s", name);
1821 static int ListAliasesCmd(struct cmd_syndesc *as)
1824 char *tp, *aliasName, *realName;
1825 struct ViceIoctl blob;
1829 memcpy(tp, &i, sizeof(afs_int32));
1830 blob.out_size = MAXSIZE;
1831 blob.in_size = sizeof(afs_int32);
1834 code = pioctl(0, VIOC_GETALIAS, &blob, 1);
1836 if (errno == EDOM) break; /* done with the list */
1842 tp += strlen(aliasName) + 1;
1844 printf("Alias %s for cell %s\n", aliasName, realName);
1849 static int NewCellCmd(struct cmd_syndesc *as)
1851 afs_int32 code, linkedstate=0, size=0, *lp;
1852 struct ViceIoctl blob;
1853 struct cmd_item *ti;
1854 char *tp, *cellname=0;
1855 struct hostent *thp;
1856 afs_int32 fsport = 0, vlport = 0;
1857 afs_int32 magic, scount; /* Number of servers to pass in pioctl call */
1860 * With the NEWCELL pioctl call, 3.4 clients take an array of
1861 * MAXHOSTS (13) servers while 3.5 clients take an array of
1862 * MAXCELLHOSTS (8) servers. To determine which we are talking to,
1863 * do a GETCELL pioctl and pass it a magic number. If an array of
1864 * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
1865 * If we get back EDOM, there are no cells in the kernel yet,
1866 * and we'll assume a 3.5 client.
1869 lp = (afs_int32 *)tp;
1870 *lp++ = 0; /* first cell entry */
1871 *lp = 0x12345678; /* magic */
1872 blob.out_size = MAXSIZE;
1873 blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
1876 code = pioctl(0, VIOCGETCELL, &blob, 1);
1877 if (code < 0 && errno != EDOM) {
1881 if (code < 1 && errno == EDOM) {
1885 cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
1886 scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
1889 /* Now setup and do the NEWCELL pioctl call */
1890 memset(space, 0, (scount+1) * sizeof(afs_int32));
1892 lp = (afs_int32 *)tp;
1894 tp += sizeof(afs_int32);
1895 for(ti=as->parms[1].items; ti; ti=ti->next) {
1896 thp = hostutil_GetHostByName(ti->data);
1898 fprintf(stderr, "%s: Host %s not found in host table, skipping it.\n",
1902 memcpy(tp, thp->h_addr, sizeof(afs_int32));
1903 tp += sizeof(afs_int32);
1906 if (as->parms[2].items) {
1908 * Link the cell, for the purposes of volume location, to the specified
1911 cellname = as->parms[2].items->data;
1914 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
1915 if (as->parms[3].items) {
1916 code = util_GetInt32(as->parms[3].items->data, &vlport);
1918 fprintf(stderr, "%s: bad integer specified for the fileserver port.\n", pn);
1922 if (as->parms[4].items) {
1923 code = util_GetInt32(as->parms[4].items->data, &fsport);
1925 fprintf(stderr, "%s: bad integer specified for the vldb server port.\n", pn);
1930 tp = (char *)(space + (scount+1) *sizeof(afs_int32));
1931 lp = (afs_int32 *)tp;
1935 strcpy(space + ((scount+4) * sizeof(afs_int32)), as->parms[0].items->data);
1936 size = ((scount+4) * sizeof(afs_int32))
1937 + strlen(as->parms[0].items->data)
1939 tp = (char *)(space + size);
1941 strcpy(tp, cellname);
1942 size += strlen(cellname) + 1;
1944 blob.in_size = size;
1947 code = pioctl(0, VIOCNEWCELL, &blob, 1);
1955 static int NewAliasCmd(struct cmd_syndesc *as)
1958 struct ViceIoctl blob;
1960 char *aliasName, *realName;
1962 /* Now setup and do the NEWCELL pioctl call */
1963 aliasName = as->parms[0].items->data;
1964 realName = as->parms[1].items->data;
1966 strcpy(tp, aliasName);
1967 tp += strlen(aliasName) + 1;
1968 strcpy(tp, realName);
1969 tp += strlen(realName) + 1;
1971 blob.in_size = tp - space;
1975 code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
1977 if (errno == EEXIST) {
1978 fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
1988 static int WhichCellCmd(struct cmd_syndesc *as)
1991 struct cmd_item *ti;
1993 char cell[MAXCELLCHARS];
1995 SetDotDefault(&as->parms[0].items);
1996 for (ti=as->parms[0].items; ti; ti=ti->next) {
1997 code = GetCell(ti->data, cell);
1999 if (errno == ENOENT)
2000 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2002 Die(errno, ti->data);
2007 printf("File %s lives in cell '%s'\n", ti->data, cell);
2012 static int WSCellCmd(struct cmd_syndesc *as)
2015 struct ViceIoctl blob;
2019 blob.out_size = MAXSIZE;
2022 code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
2028 printf("This workstation belongs to cell '%s'\n", space);
2033 static PrimaryCellCmd(as)
2034 struct cmd_syndesc *as;
2036 fprintf(stderr, "This command is obsolete, as is the concept of a primary token.\n");
2041 static int MonitorCmd(struct cmd_syndesc *as)
2044 struct ViceIoctl blob;
2045 struct cmd_item *ti;
2047 struct hostent *thp;
2051 ti = as->parms[0].items;
2055 if (!strcmp(ti->data, "off"))
2056 hostAddr = 0xffffffff;
2058 thp = hostutil_GetHostByName(ti->data);
2060 if (!strcmp(ti->data, "localhost")) {
2061 fprintf(stderr, "localhost not in host table, assuming 127.0.0.1\n");
2062 hostAddr = htonl(0x7f000001);
2065 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2069 else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2073 hostAddr = 0; /* means don't set host */
2074 setp = 0; /* aren't setting host */
2077 /* now do operation */
2078 blob.in_size = sizeof(afs_int32);
2079 blob.out_size = sizeof(afs_int32);
2080 blob.in = (char *) &hostAddr;
2081 blob.out = (char *) &hostAddr;
2082 code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2088 printf("%s: new monitor host set.\n", pn);
2091 /* now decode old address */
2092 if (hostAddr == 0xffffffff) {
2093 printf("Cache monitoring is currently disabled.\n");
2096 tp = hostutil_GetNameByINet(hostAddr);
2097 printf("Using host %s for monitor services.\n", tp);
2103 static int SysNameCmd(struct cmd_syndesc *as)
2106 struct ViceIoctl blob;
2107 struct cmd_item *ti;
2108 char *input = space;
2111 ti = as->parms[0].items;
2114 blob.out_size = MAXSIZE;
2115 blob.in_size = sizeof(afs_int32);
2116 input += sizeof(afs_int32);
2117 for(; ti; ti=ti->next) {
2119 blob.in_size += strlen(ti->data) + 1;
2120 if (blob.in_size > MAXSIZE) {
2121 fprintf(stderr, "%s: sysname%s too long.\n", pn, setp > 1 ? "s" : "");
2124 strcpy(input, ti->data);
2125 input += strlen(ti->data);
2128 memcpy(space, &setp, sizeof(afs_int32));
2129 code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
2135 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2139 memcpy(&setp, input, sizeof(afs_int32));
2140 input += sizeof(afs_int32);
2142 fprintf(stderr, "No sysname name value was found\n");
2145 printf("Current sysname%s is", setp>1 ? " list" : "");
2146 for(;setp>0;--setp) {
2147 printf(" \'%s\'", input);
2148 input += strlen(input) + 1;
2154 static char *exported_types[] = {"null", "nfs", ""};
2155 static int ExportAfsCmd(struct cmd_syndesc *as)
2158 struct ViceIoctl blob;
2159 struct cmd_item *ti;
2160 int export=0, type=0, mode = 0, exp = 0, exportcall, pwsync=0, smounts=0;
2162 ti = as->parms[0].items;
2163 if (strcmp(ti->data, "nfs") == 0) type = 0x71; /* NFS */
2165 fprintf(stderr, "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2168 ti = as->parms[1].items;
2170 if (strcmp(ti->data, "on") == 0) export = 3;
2171 else if (strcmp(ti->data, "off") == 0) export = 2;
2173 fprintf(stderr, "Illegal argument %s\n", ti->data);
2178 if (ti = as->parms[2].items) { /* -noconvert */
2179 if (strcmp(ti->data, "on") == 0) mode = 2;
2180 else if (strcmp(ti->data, "off") == 0) mode = 3;
2182 fprintf(stderr, "Illegal argument %s\n", ti->data);
2186 if (ti = as->parms[3].items) { /* -uidcheck */
2187 if (strcmp(ti->data, "on") == 0) pwsync = 3;
2188 else if (strcmp(ti->data, "off") == 0) pwsync = 2;
2190 fprintf(stderr, "Illegal argument %s\n", ti->data);
2194 if (ti = as->parms[4].items) { /* -submounts */
2195 if (strcmp(ti->data, "on") == 0) smounts = 3;
2196 else if (strcmp(ti->data, "off") == 0) smounts = 2;
2198 fprintf(stderr, "Illegal argument %s\n", ti->data);
2202 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2205 blob.in = (char *) &exportcall;
2206 blob.in_size = sizeof(afs_int32);
2207 blob.out = (char *) &exportcall;
2208 blob.out_size = sizeof(afs_int32);
2209 code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
2211 if (errno == ENODEV) {
2212 fprintf(stderr, "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2220 if (exportcall & 1) {
2221 printf("'%s' translator is enabled with the following options:\n",
2222 exported_types[type]);
2223 printf("\tRunning in %s mode\n",
2224 (exportcall & 2 ? "strict unix"
2225 : "convert owner mode bits to world/other"));
2226 printf("\tRunning in %s mode\n",
2227 (exportcall & 4 ? "strict 'passwd sync'"
2228 : "no 'passwd sync'"));
2230 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs"
2231 : "Only mounts to /afs allowed"));
2234 printf("'%s' translator is disabled\n", exported_types[type]);
2240 static int GetCellCmd(struct cmd_syndesc *as)
2243 struct ViceIoctl blob;
2244 struct afsconf_cell info;
2245 struct cmd_item *ti;
2252 memset(&args, '\0', sizeof args); /* avoid Purify UMR error */
2253 for(ti=as->parms[0].items; ti; ti=ti->next) {
2255 blob.out_size = sizeof(args);
2256 blob.out = (caddr_t) &args;
2257 code = GetCellName(ti->data, &info);
2262 blob.in_size = 1+strlen(info.name);
2263 blob.in = info.name;
2264 code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
2266 if (errno == ENOENT)
2267 fprintf(stderr, "%s: the cell named '%s' does not exist\n", pn, info.name);
2269 Die(errno, info.name);
2273 printf("Cell %s status: ", info.name);
2275 if (args.stat & 1) printf("primary ");
2277 if (args.stat & 2) printf("no setuid allowed");
2278 else printf("setuid allowed");
2279 if (args.stat & 4) printf(", using old VLDB");
2285 static int SetCellCmd(struct cmd_syndesc *as)
2288 struct ViceIoctl blob;
2289 struct afsconf_cell info;
2290 struct cmd_item *ti;
2298 /* Check arguments. */
2299 if (as->parms[1].items && as->parms[2].items) {
2300 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
2304 /* figure stuff to set */
2308 if (! as->parms[1].items) args.stat |= 2; /* default to -nosuid */
2310 /* set stat for all listed cells */
2311 for(ti=as->parms[0].items; ti; ti=ti->next) {
2313 code = GetCellName(ti->data, &info);
2318 strcpy(args.cname, info.name);
2319 blob.in_size = sizeof(args);
2320 blob.in = (caddr_t) &args;
2322 blob.out = (caddr_t) 0;
2323 code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
2325 Die(errno, info.name); /* XXX added cell name to Die() call */
2332 static int GetCellName(char *cellName, struct afsconf_cell *info)
2334 struct afsconf_dir *tdir;
2337 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
2339 fprintf(stderr, "Could not process files in configuration directory (%s).\n",
2340 AFSDIR_CLIENT_ETC_DIRPATH);
2344 code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
2346 fprintf(stderr, "%s: cell %s not in %s\n", pn, cellName,
2347 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
2355 static int VLDBInit(int noAuthFlag, struct afsconf_cell *info)
2358 struct ktc_principal sname;
2359 struct ktc_token ttoken;
2361 struct rx_securityClass *sc;
2362 struct rx_connection *serverconns[VLDB_MAXSERVERS];
2367 fprintf(stderr, "%s: could not initialize rx.\n", pn);
2371 rx_SetRxDeadTime(50);
2372 if (!noAuthFlag) { /* we don't need tickets for null */
2373 strcpy(sname.cell, info->name);
2374 sname.instance[0] = 0;
2375 strcpy(sname.name, "afs");
2376 code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), NULL);
2378 fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
2383 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
2385 fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
2391 else scIndex = 0; /* don't authenticate */
2394 sc = rxnull_NewClientSecurityObject();
2400 sc = (struct rx_securityClass *)
2401 rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
2402 ttoken.kvno, ttoken.ticketLen,
2406 if (info->numServers > VLDB_MAXSERVERS) {
2407 fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
2408 pn, info->numServers, VLDB_MAXSERVERS);
2411 memset(serverconns, 0, sizeof(serverconns));
2412 for (i = 0;i<info->numServers;i++)
2413 serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
2414 info->hostAddr[i].sin_port, USER_SERVICE_ID,
2417 code = ubik_ClientInit(serverconns, &uclient);
2420 fprintf(stderr, "%s: ubik client init failed.\n", pn);
2426 static struct ViceIoctl gblob;
2427 static int debug = 0;
2429 * here follow some routines in suport of the setserverprefs and
2430 * getserverprefs commands. They are:
2431 * SetPrefCmd "top-level" routine
2432 * addServer adds a server to the list of servers to be poked into the
2433 * kernel. Will poke the list into the kernel if it threatens
2435 * pokeServers pokes the existing list of servers and ranks into the kernel
2436 * GetPrefCmd reads the Cache Manager's current list of server ranks
2440 * returns -1 if error message printed,
2442 * errno value if error and no error message printed
2444 static int pokeServers(void)
2448 code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
2449 if (code && (errno == EINVAL)) {
2450 struct setspref *ssp;
2451 ssp = (struct setspref *)gblob.in;
2452 if (!(ssp->flags & DBservers)) {
2453 gblob.in = (void *) &(ssp->servers[0]);
2454 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
2455 code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
2456 return code ? errno : 0;
2459 "This cache manager does not support VL server preferences.\n");
2463 return code ? errno : 0;
2467 * returns -1 if error message printed,
2469 * errno value if error and no error message printed
2471 static int addServer(char *name, afs_int32 rank)
2474 struct setspref *ssp;
2476 struct hostent *thostent;
2482 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
2484 #define MAXUSHORT ((unsigned short) ~0)
2488 thostent = hostutil_GetHostByName(name);
2490 fprintf(stderr, "%s: couldn't resolve name.\n", name);
2494 ssp = (struct setspref *)(gblob.in);
2496 for (t = 0; thostent->h_addr_list[t]; t++) {
2497 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
2498 code = pokeServers();
2499 if (code) error = code;
2500 ssp->num_servers = 0;
2503 sp = (struct spref *) (gblob.in + gblob.in_size);
2504 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
2505 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
2506 gblob.in_size += sizeof(struct spref);
2510 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
2511 name,sp->rank,sp->server.s_addr);
2518 static int SetPrefCmd(struct cmd_syndesc *as)
2522 struct cmd_item *ti;
2525 struct setspref *ssp;
2526 int error = 0; /* -1 means error message printed,
2527 * >0 means errno value for unprinted message */
2529 ssp = (struct setspref *)space;
2531 ssp->num_servers = 0;
2532 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2535 gblob.out_size = MAXSIZE;
2539 fprintf(stderr, "Permission denied: requires root access.\n");
2543 ti = as->parms[2].items; /* -file */
2545 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2546 if (!(infd = fopen(ti->data,"r"))) {
2551 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
2552 code = addServer(name, (unsigned short) rank);
2553 if (code) error = code;
2558 ti = as->parms[3].items; /* -stdin */
2560 while (scanf("%79s%ld", name, &rank) != EOF) {
2561 code = addServer(name, (unsigned short) rank);
2562 if (code) error = code;
2566 for (ti = as->parms[0].items;ti;ti=ti->next) { /* list of servers, ranks */
2571 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2572 if (code) error = code;
2574 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
2578 code = pokeServers();
2579 if (code) error = code;
2581 printf("now working on vlservers, code=%d\n",code);
2583 ssp = (struct setspref *)space;
2584 ssp->flags = DBservers;
2585 ssp->num_servers = 0;
2586 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2589 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
2594 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2595 if (code) error = code;
2597 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
2602 if (as->parms[1].items) {
2604 printf("now poking vlservers\n");
2605 code = pokeServers();
2606 if (code) error = code;
2612 return error ? 1 : 0;
2617 static int GetPrefCmd(struct cmd_syndesc *as)
2620 struct cmd_item *ti;
2621 char *name, tbuffer[20];
2622 afs_int32 rank,addr;
2626 struct ViceIoctl blob;
2627 struct sprefrequest *in;
2628 struct sprefinfo *out;
2631 ti = as->parms[0].items; /* -file */
2633 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2634 if (!(outfd = freopen(ti->data,"w",stdout))) {
2640 ti = as->parms[1].items; /* -numeric */
2642 ti = as->parms[2].items; /* -vlservers */
2643 vlservers |= (ti ? DBservers : 0);
2644 /* ti = as->parms[3].items; -cell */
2646 in = (struct sprefrequest *)space;
2650 blob.in_size=sizeof(struct sprefrequest);
2651 blob.in = (char *)in;
2653 blob.out_size = MAXSIZE;
2655 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
2656 in->flags = vlservers;
2658 code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
2660 perror("getserverprefs pioctl");
2664 out = (struct sprefinfo *) blob.out;
2666 for (i=0;i<out->num_servers;i++) {
2668 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
2671 addr = ntohl(out->servers[i].server.s_addr);
2672 sprintf(tbuffer, "%d.%d.%d.%d",
2673 (addr>>24) & 0xff, (addr>>16) & 0xff,
2674 (addr>>8) & 0xff, addr & 0xff);
2677 printf("%-50s %5u\n",name,out->servers[i].rank);
2680 in->offset = out->next_offset;
2681 } while (out->next_offset > 0);
2686 static int StoreBehindCmd(struct cmd_syndesc *as)
2689 struct ViceIoctl blob;
2690 struct cmd_item *ti;
2691 struct sbstruct tsb, tsb2;
2697 tsb.sb_thisfile = -1;
2698 ti=as->parms[0].items; /* -kbytes */
2700 if (!as->parms[1].items) {
2701 fprintf(stderr, "%s: you must specify -files with -kbytes.\n", pn);
2704 tsb.sb_thisfile = strtol(ti->data,&t,10) * 1024;
2705 if ((tsb.sb_thisfile < 0) || (t != ti->data+strlen(ti->data))) {
2706 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2712 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
2713 ti=as->parms[2].items; /* -allfiles */
2715 allfiles = strtol(ti->data,&t,10) * 1024;
2716 if ((allfiles < 0) || (t != ti->data+strlen(ti->data))) {
2717 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2723 /* -verbose or -file only or no options */
2724 if (as->parms[3].items ||
2725 (as->parms[1].items && !as->parms[0].items) ||
2726 (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items))
2729 blob.in = (char *)&tsb;
2730 blob.out = (char *)&tsb2;
2731 blob.in_size = blob.out_size = sizeof(struct sbstruct);
2732 memset(&tsb2, 0, sizeof(tsb2));
2734 /* once per -file */
2735 for (ti=as->parms[1].items; ti; ti=ti->next) {
2736 /* Do this solely to see if the file is there */
2737 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
2739 Die(errno, ti->data);
2744 code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
2746 Die(errno, ti->data);
2751 if (verbose && (blob.out_size == sizeof(tsb2))) {
2752 if (tsb2.sb_thisfile == -1) {
2753 fprintf(stdout, "Will store %s according to default.\n",
2758 "Will store up to %d kbytes of %s asynchronously.\n",
2759 (tsb2.sb_thisfile/1024), ti->data);
2764 /* If no files - make at least one pioctl call, or
2765 * set the allfiles default if we need to.
2767 if (!as->parms[1].items || (allfiles != -1)) {
2768 tsb.sb_default = allfiles;
2769 code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
2771 Die(errno, ((allfiles == -1)?0:"-allfiles"));
2776 /* Having no arguments also reports the default store asynchrony */
2777 if (verbose && (blob.out_size == sizeof(tsb2))) {
2778 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
2779 (tsb2.sb_default/1024));
2786 static afs_int32 SetCryptCmd(struct cmd_syndesc *as)
2788 afs_int32 code = 0, flag;
2789 struct ViceIoctl blob;
2792 tp = as->parms[0].items->data;
2793 if (strcmp(tp, "on") == 0)
2795 else if (strcmp(tp, "off") == 0)
2798 fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
2802 blob.in = (char *) &flag;
2803 blob.in_size = sizeof(flag);
2805 code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
2812 static afs_int32 GetCryptCmd(struct cmd_syndesc *as)
2814 afs_int32 code = 0, flag;
2815 struct ViceIoctl blob;
2820 blob.out_size = sizeof(flag);
2823 code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
2825 if (code) Die(errno, NULL);
2828 memcpy(&flag, tp, sizeof(afs_int32));
2829 printf("Security level is currently ");
2831 printf("crypt (data security).\n");
2838 #include "AFS_component_version_number.c"
2840 int main(int argc, char **argv)
2843 struct cmd_syndesc *ts;
2845 #ifdef AFS_AIX32_ENV
2847 * The following signal action for AIX is necessary so that in case of a
2848 * crash (i.e. core is generated) we can include the user's data section
2849 * in the core dump. Unfortunately, by default, only a partial core is
2850 * generated which, in many cases, isn't too useful.
2852 struct sigaction nsa;
2854 sigemptyset(&nsa.sa_mask);
2855 nsa.sa_handler = SIG_DFL;
2856 nsa.sa_flags = SA_FULLDUMP;
2857 sigaction(SIGSEGV, &nsa, NULL);
2860 /* try to find volume location information */
2861 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0, "get client network interface addresses");
2862 cmd_CreateAlias(ts, "gc");
2864 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0, "set client network interface addresses");
2865 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "client network interfaces");
2866 cmd_CreateAlias(ts, "sc");
2868 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
2869 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
2870 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
2871 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
2872 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
2873 cmd_CreateAlias(ts, "sp");
2875 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
2876 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
2877 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2878 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
2879 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
2880 cmd_CreateAlias(ts, "gp");
2882 ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
2883 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2884 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
2885 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
2886 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
2887 parm_setacl_id = ts->nParms;
2888 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
2889 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
2890 cmd_CreateAlias(ts, "sa");
2892 ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
2893 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2894 parm_listacl_id = ts->nParms;
2895 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2896 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2897 cmd_CreateAlias(ts, "la");
2899 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
2900 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2902 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
2903 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
2904 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
2905 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
2906 parm_copyacl_id = ts->nParms;
2907 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2908 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2910 cmd_CreateAlias(ts, "ca");
2912 ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
2913 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2914 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0, "flush mount symlink from cache");
2915 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2917 ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
2918 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2919 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
2921 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
2922 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
2924 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
2925 cmd_CreateAlias(ts, "sv");
2927 ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
2928 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
2930 ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
2931 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2932 cmd_CreateAlias(ts, "lv");
2933 cmd_CreateAlias(ts, "listvol");
2935 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
2936 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2937 cmd_CreateAlias(ts, "lq");
2939 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
2940 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2941 cmd_CreateAlias(ts, "df");
2943 ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
2944 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2946 ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
2947 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2949 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
2950 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
2951 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
2952 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
2953 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
2954 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
2960 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
2964 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
2965 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2967 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
2968 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
2969 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
2970 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
2971 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
2973 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
2974 cmd_CreateAlias(ts, "checkbackups");
2977 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
2978 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
2979 cmd_CreateAlias(ts, "cachesize");
2981 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
2983 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
2985 ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
2986 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2988 ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
2990 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
2991 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
2992 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
2994 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
2996 cmd_CreateAlias(ts, "sq");
2998 ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
2999 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
3000 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
3001 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
3003 ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
3004 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
3005 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
3007 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
3009 * Turn this on only if you wish to be able to talk to a server which is listening
3010 * on alternative ports. This is not intended for general use and may not be
3011 * supported in the cache manager. It is not a way to run two servers at the
3012 * same host, since the cache manager cannot properly distinguish those two hosts.
3014 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
3015 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
3018 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
3019 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3021 ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
3022 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3024 ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
3027 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
3030 /* set cache monitor host address */
3031 ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *) CMD_HIDDEN);
3032 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
3033 cmd_CreateAlias(ts, "mariner");
3035 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
3036 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3038 ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
3039 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3040 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
3041 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
3043 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
3044 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3046 ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
3047 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
3049 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
3050 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
3051 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator (on | off)");
3052 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode (on | off)");
3053 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode (on | off)");
3054 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. (on | off)");
3057 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
3058 "store to server after file close");
3059 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
3060 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
3061 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
3062 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
3063 cmd_CreateAlias(ts, "sb");
3065 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
3066 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
3068 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "set cache manager encryption flag");
3070 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
3071 "Manage per process RX statistics");
3072 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3074 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3075 "Disable RX stats");
3076 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3079 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
3080 "Manage per peer RX statistics");
3081 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3083 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3084 "Disable RX stats");
3085 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3088 code = cmd_Dispatch(argc, argv);
3089 if (rxInitDone) rx_Finalize();
3094 static void Die(int errnum, char *filename)
3099 fprintf(stderr, "%s: Invalid argument; it is possible that %s is not in AFS.\n",
3102 fprintf(stderr, "%s: Invalid argument.\n", pn);
3106 fprintf(stderr, "%s: File '%s' doesn't exist\n", pn, filename);
3108 fprintf(stderr, "%s: no such file returned\n", pn);
3111 fprintf(stderr, "%s: You can not change a backup or readonly volume\n", pn);
3116 fprintf(stderr, "%s: You don't have the required access rights on '%s'\n",
3119 fprintf(stderr, "%s: You do not have the required rights to do this operation\n",
3124 fprintf(stderr, "%s:'%s'", pn, filename);
3126 fprintf(stderr, "%s", pn);
3127 fprintf(stderr, ": %s\n", error_message(errnum));
3132 /* get clients interface addresses */
3133 static int GetClientAddrsCmd(struct cmd_syndesc *as)
3136 struct cmd_item *ti;
3138 struct ViceIoctl blob;
3139 struct sprefrequest *in;
3140 struct sprefinfo *out;
3142 in = (struct sprefrequest *)space;
3147 blob.in_size=sizeof(struct sprefrequest);
3148 blob.in = (char *)in;
3150 blob.out_size = MAXSIZE;
3152 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
3153 /* returns addr in network byte order */
3154 code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
3156 perror("getClientInterfaceAddr pioctl");
3162 out = (struct sprefinfo *) blob.out;
3163 for (i=0; i < out->num_servers; i++) {
3166 addr = ntohl(out->servers[i].server.s_addr);
3167 sprintf(tbuffer, "%d.%d.%d.%d",
3168 (addr>>24) & 0xff, (addr>>16) & 0xff,
3169 (addr>>8) & 0xff, addr & 0xff);
3170 printf ("%-50s\n", tbuffer);
3172 in->offset = out->next_offset;
3174 } while (out->next_offset > 0);
3179 static int SetClientAddrsCmd(struct cmd_syndesc *as)
3181 afs_int32 code, addr;
3182 struct cmd_item *ti;
3184 struct ViceIoctl blob;
3185 struct setspref *ssp;
3186 int sizeUsed = 0, i, flag;
3187 afs_int32 existingAddr[1024]; /* existing addresses on this host */
3191 ssp = (struct setspref *)space;
3192 ssp->num_servers = 0;
3195 blob.out_size = MAXSIZE;
3198 fprintf(stderr, "Permission denied: requires root access.\n");
3202 /* extract all existing interface addresses */
3203 existNu = rx_getAllAddr(existingAddr,1024);
3207 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
3208 for (ti = as->parms[0].items;ti;ti=ti->next) {
3209 if (sizeUsed >= sizeof(space)) {
3210 fprintf(stderr, "No more space\n");
3213 addr = extractAddr(ti->data, 20); /* network order */
3214 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
3215 fprintf(stderr, "Error in specifying address: %s..ignoring\n", ti->data);
3219 /* see if it is an address that really exists */
3220 for (flag = 0, i=0; i < existNu; i++)
3221 if (existingAddr[i] == addr) {
3225 if (!flag) { /* this is an nonexistent address */
3226 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
3230 /* copy all specified addr into ioctl buffer */
3231 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
3232 printf("Adding 0x%08x\n", addr);
3234 sizeUsed += sizeof(struct spref);
3236 if (ssp->num_servers < 1) {
3237 fprintf(stderr, "No addresses specified\n");
3240 blob.in_size = sizeUsed - sizeof(struct spref);
3242 code = pioctl(0, VIOC_SETCPREFS, &blob, 1); /* network order */
3251 static int FlushMountCmd(struct cmd_syndesc *as)
3254 struct ViceIoctl blob;
3255 struct cmd_item *ti;
3256 char orig_name[1024]; /*Original name, may be modified*/
3257 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
3258 char parent_dir[1024]; /*Parent directory of true name*/
3259 char *last_component; /*Last component of true name*/
3260 struct stat statbuff; /*Buffer for status info*/
3261 int link_chars_read; /*Num chars read in readlink()*/
3262 int thru_symlink; /*Did we get to a mount point via a symlink?*/
3265 for(ti=as->parms[0].items; ti; ti=ti->next) {
3268 sprintf(orig_name, "%s%s",
3269 (ti->data[0] == '/') ? "" : "./",
3272 if (lstat(orig_name, &statbuff) < 0) {
3273 /* if lstat fails, we should still try the pioctl, since it
3274 may work (for example, lstat will fail, but pioctl will
3275 work if the volume of offline (returning ENODEV). */
3276 statbuff.st_mode = S_IFDIR; /* lie like pros */
3280 * The lstat succeeded. If the given file is a symlink, substitute
3281 * the file name with the link name.
3283 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
3286 * Read name of resolved file.
3288 link_chars_read = readlink(orig_name, true_name, 1024);
3289 if (link_chars_read <= 0) {
3290 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
3297 * Add a trailing null to what was read, bump the length.
3299 true_name[link_chars_read++] = 0;
3302 * If the symlink is an absolute pathname, we're fine. Otherwise, we
3303 * have to create a full pathname using the original name and the
3304 * relative symlink name. Find the rightmost slash in the original
3305 * name (we know there is one) and splice in the symlink value.
3307 if (true_name[0] != '/') {
3308 last_component = (char *) strrchr(orig_name, '/');
3309 strcpy(++last_component, true_name);
3310 strcpy(true_name, orig_name);
3314 strcpy(true_name, orig_name);
3317 * Find rightmost slash, if any.
3319 last_component = (char *) strrchr(true_name, '/');
3320 if (last_component) {
3322 * Found it. Designate everything before it as the parent directory,
3323 * everything after it as the final component.
3325 strncpy(parent_dir, true_name, last_component - true_name);
3326 parent_dir[last_component - true_name] = 0;
3327 last_component++; /*Skip the slash*/
3331 * No slash appears in the given file name. Set parent_dir to the current
3332 * directory, and the last component as the given name.
3334 strcpy(parent_dir, ".");
3335 last_component = true_name;
3338 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
3339 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
3340 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n", pn);
3345 blob.in = last_component;
3346 blob.in_size = strlen(last_component)+1;
3348 memset(space, 0, MAXSIZE);
3350 code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
3353 if (errno == EINVAL) {
3354 fprintf(stderr, "'%s' is not a mount point.\n",
3358 Die(errno, (ti->data ? ti->data : parent_dir));
3366 static int RxStatProcCmd(struct cmd_syndesc *as)
3369 afs_int32 flags = 0;
3370 struct ViceIoctl blob;
3371 struct cmd_item *ti;
3373 if (as->parms[0].items) { /* -enable*/
3374 flags |= AFSCALL_RXSTATS_ENABLE;
3376 if (as->parms[1].items) { /* -disable*/
3377 flags |= AFSCALL_RXSTATS_DISABLE;
3379 if (as->parms[2].items) { /* -clear*/
3380 flags |= AFSCALL_RXSTATS_CLEAR;
3383 fprintf(stderr, "You must specify at least one argument\n");
3387 blob.in = (char *)&flags;
3388 blob.in_size = sizeof(afs_int32);
3391 code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
3400 static int RxStatPeerCmd(struct cmd_syndesc *as)
3403 afs_int32 flags = 0;
3404 struct ViceIoctl blob;
3405 struct cmd_item *ti;
3407 if (as->parms[0].items) { /* -enable*/
3408 flags |= AFSCALL_RXSTATS_ENABLE;
3410 if (as->parms[1].items) { /* -disable*/
3411 flags |= AFSCALL_RXSTATS_DISABLE;
3413 if (as->parms[2].items) { /* -clear*/
3414 flags |= AFSCALL_RXSTATS_CLEAR;
3417 fprintf(stderr, "You must specify at least one argument\n");
3421 blob.in = (char *)&flags;
3422 blob.in_size = sizeof(afs_int32);
3425 code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);