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>
62 #include <afs/ptclient.h>
67 #define MAXCELLHOSTS 8
70 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
71 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
73 static char space[MAXSIZE];
74 static char tspace[1024];
75 static struct ubik_client *uclient;
77 static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
78 static int RxStatProcCmd(), RxStatPeerCmd();
80 extern char *hostutil_GetNameByINet();
81 extern struct hostent *hostutil_GetHostByName();
84 extern struct cmd_syndesc *cmd_CreateSyntax();
85 static char pn[] = "fs";
86 static int rxInitDone = 0;
88 static void ZapList();
89 static int PruneList();
97 * Character to use between name and rights in printed representation for
100 #define DFS_SEPARATOR ' '
102 typedef char sec_rgy_name_t[1025]; /* A DCE definition */
105 int dfs; /* Originally true if a dfs acl; now also the type
106 of the acl (1, 2, or 3, corresponding to object,
107 initial dir, or initial object). */
108 sec_rgy_name_t cell; /* DFS cell name */
111 struct AclEntry *pluslist;
112 struct AclEntry *minuslist;
116 struct AclEntry *next;
121 static void ZapAcl(acl)
125 ZapList(acl->pluslist);
126 ZapList(acl->minuslist);
138 if (t >= 'A' && t <= 'Z') t += 0x20;
139 if (u >= 'A' && u <= 'Z') u += 0x20;
140 if (t != u) return 1;
141 if (t == 0) return 0;
146 * Mods for the AFS/DFS protocol translator.
148 * DFS rights. It's ugly to put these definitions here, but they
149 * *cannot* change, because they're part of the wire protocol.
150 * In any event, the protocol translator will guarantee these
151 * assignments for AFS cache managers.
153 #define DFS_READ 0x01
154 #define DFS_WRITE 0x02
155 #define DFS_EXECUTE 0x04
156 #define DFS_CONTROL 0x08
157 #define DFS_INSERT 0x10
158 #define DFS_DELETE 0x20
160 /* the application definable ones (backwards from AFS) */
161 #define DFS_USR0 0x80000000 /* "A" bit */
162 #define DFS_USR1 0x40000000 /* "B" bit */
163 #define DFS_USR2 0x20000000 /* "C" bit */
164 #define DFS_USR3 0x10000000 /* "D" bit */
165 #define DFS_USR4 0x08000000 /* "E" bit */
166 #define DFS_USR5 0x04000000 /* "F" bit */
167 #define DFS_USR6 0x02000000 /* "G" bit */
168 #define DFS_USR7 0x01000000 /* "H" bit */
169 #define DFS_USRALL (DFS_USR0 | DFS_USR1 | DFS_USR2 | DFS_USR3 |\
170 DFS_USR4 | DFS_USR5 | DFS_USR6 | DFS_USR7)
173 * Offset of -id switch in command structure for various commands.
174 * The -if switch is the next switch always.
176 static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
179 * Determine whether either the -id or -if switches are present, and
180 * return 0, 1 or 2, as appropriate. Abort if both switches are present.
182 /* int id; Offset of -id switch; -if is next switch */
183 static int getidf(struct cmd_syndesc *as, int id)
187 if (as->parms[id].items) {
190 if (as->parms[id + 1].items) {
196 "%s: you may specify either -id or -if, but not both switches\n",
203 static int PRights(afs_int32 arights, int dfs)
206 if (arights & PRSFS_READ) printf("r");
207 if (arights & PRSFS_LOOKUP) printf("l");
208 if (arights & PRSFS_INSERT) printf("i");
209 if (arights & PRSFS_DELETE) printf("d");
210 if (arights & PRSFS_WRITE) printf("w");
211 if (arights & PRSFS_LOCK) printf("k");
212 if (arights & PRSFS_ADMINISTER) printf("a");
213 if (arights & PRSFS_USR0) printf("A");
214 if (arights & PRSFS_USR1) printf("B");
215 if (arights & PRSFS_USR2) printf("C");
216 if (arights & PRSFS_USR3) printf("D");
217 if (arights & PRSFS_USR4) printf("E");
218 if (arights & PRSFS_USR5) printf("F");
219 if (arights & PRSFS_USR6) printf("G");
220 if (arights & PRSFS_USR7) printf("H");
222 if (arights & DFS_READ) printf("r"); else printf("-");
223 if (arights & DFS_WRITE) printf("w"); else printf("-");
224 if (arights & DFS_EXECUTE) printf("x"); else printf("-");
225 if (arights & DFS_CONTROL) printf("c"); else printf("-");
226 if (arights & DFS_INSERT) printf("i"); else printf("-");
227 if (arights & DFS_DELETE) printf("d"); else printf("-");
228 if (arights & (DFS_USRALL)) printf("+");
229 if (arights & DFS_USR0) printf("A");
230 if (arights & DFS_USR1) printf("B");
231 if (arights & DFS_USR2) printf("C");
232 if (arights & DFS_USR3) printf("D");
233 if (arights & DFS_USR4) printf("E");
234 if (arights & DFS_USR5) printf("F");
235 if (arights & DFS_USR6) printf("G");
236 if (arights & DFS_USR7) printf("H");
240 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
241 static int InAFS(char *apath)
243 struct ViceIoctl blob;
247 blob.out_size = MAXSIZE;
250 code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
252 if ((errno == EINVAL) || (errno == ENOENT)) return 0;
257 /* return a static pointer to a buffer */
258 static char *Parent(char *apath)
261 strcpy(tspace, apath);
262 tp = strrchr(tspace, '/');
266 else strcpy(tspace, ".");
270 enum rtype {add, destroy, deny};
272 static afs_int32 Convert(char *arights, int dfs, enum rtype *rtypep)
278 *rtypep = add; /* add rights, by default */
281 if (!strcmp(arights, "null")) {
285 if (!strcmp(arights,"read")) return DFS_READ | DFS_EXECUTE;
286 if (!strcmp(arights, "write")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE;
287 if (!strcmp(arights, "all")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE | DFS_CONTROL;
289 if (!strcmp(arights,"read")) return PRSFS_READ | PRSFS_LOOKUP;
290 if (!strcmp(arights, "write")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
291 if (!strcmp(arights, "mail")) return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
292 if (!strcmp(arights, "all")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
294 if (!strcmp(arights, "none")) {
295 *rtypep = destroy; /* Remove entire entry */
298 len = strlen(arights);
303 if (tc == '-') continue;
304 else if (tc == 'r') mode |= DFS_READ;
305 else if (tc == 'w') mode |= DFS_WRITE;
306 else if (tc == 'x') mode |= DFS_EXECUTE;
307 else if (tc == 'c') mode |= DFS_CONTROL;
308 else if (tc == 'i') mode |= DFS_INSERT;
309 else if (tc == 'd') mode |= DFS_DELETE;
310 else if (tc == 'A') mode |= DFS_USR0;
311 else if (tc == 'B') mode |= DFS_USR1;
312 else if (tc == 'C') mode |= DFS_USR2;
313 else if (tc == 'D') mode |= DFS_USR3;
314 else if (tc == 'E') mode |= DFS_USR4;
315 else if (tc == 'F') mode |= DFS_USR5;
316 else if (tc == 'G') mode |= DFS_USR6;
317 else if (tc == 'H') mode |= DFS_USR7;
319 fprintf(stderr, "%s: illegal DFS rights character '%c'.\n", pn, tc);
323 if (tc == 'r') mode |= PRSFS_READ;
324 else if (tc == 'l') mode |= PRSFS_LOOKUP;
325 else if (tc == 'i') mode |= PRSFS_INSERT;
326 else if (tc == 'd') mode |= PRSFS_DELETE;
327 else if (tc == 'w') mode |= PRSFS_WRITE;
328 else if (tc == 'k') mode |= PRSFS_LOCK;
329 else if (tc == 'a') mode |= PRSFS_ADMINISTER;
330 else if (tc == 'A') mode |= PRSFS_USR0;
331 else if (tc == 'B') mode |= PRSFS_USR1;
332 else if (tc == 'C') mode |= PRSFS_USR2;
333 else if (tc == 'D') mode |= PRSFS_USR3;
334 else if (tc == 'E') mode |= PRSFS_USR4;
335 else if (tc == 'F') mode |= PRSFS_USR5;
336 else if (tc == 'G') mode |= PRSFS_USR6;
337 else if (tc == 'H') mode |= PRSFS_USR7;
339 fprintf(stderr, "%s: illegal rights character '%c'.\n", pn, tc);
347 static struct AclEntry *FindList(struct AclEntry *alist, char *aname)
350 if (!foldcmp(alist->name, aname)) return alist;
356 /* if no parm specified in a particular slot, set parm to be "." instead */
357 static void SetDotDefault(struct cmd_item **aitemp)
360 if (*aitemp) return; /* already has value */
361 /* otherwise, allocate an item representing "." */
362 ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
364 ti->next = (struct cmd_item *) 0;
365 ti->data = (char *) malloc(2);
367 strcpy(ti->data, ".");
371 static void ChangeList(struct Acl *al, afs_int32 plus, char *aname, afs_int32 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(struct AclEntry *alist)
407 struct AclEntry *tp, *np;
408 for (tp = alist; tp; tp = np) {
414 static int PruneList(struct AclEntry **ae, int dfs)
416 struct AclEntry **lp;
417 struct AclEntry *te, *ne;
421 for(te = *ae;te;te=ne) {
422 if ((!dfs && te->rights == 0) || te->rights == -1) {
436 static char *SkipLine(char *astr)
438 while (*astr !='\n') astr++;
444 * Create an empty acl, taking into account whether the acl pointed
445 * to by astr is an AFS or DFS acl. Only parse this minimally, so we
446 * can recover from problems caused by bogus ACL's (in that case, always
447 * assume that the acl is AFS: for DFS, the user can always resort to
448 * acl_edit, but for AFS there may be no other way out).
450 static struct Acl *EmptyAcl(char *astr)
455 tp = (struct Acl *)malloc(sizeof (struct Acl));
457 tp->nplus = tp->nminus = 0;
458 tp->pluslist = tp->minuslist = 0;
460 sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
464 static struct Acl *ParseAcl(char *astr)
466 int nplus, nminus, i, trights;
468 struct AclEntry *first, *last, *tl;
471 ta = (struct Acl *) malloc (sizeof (struct Acl));
474 sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
475 astr = SkipLine(astr);
476 sscanf(astr, "%d", &ta->nminus);
477 astr = SkipLine(astr);
484 for(i=0;i<nplus;i++) {
485 sscanf(astr, "%100s %d", tname, &trights);
486 astr = SkipLine(astr);
487 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
489 if (!first) first = tl;
490 strcpy(tl->name, tname);
491 tl->rights = trights;
493 if (last) last->next = tl;
496 ta->pluslist = first;
500 for(i=0;i<nminus;i++) {
501 sscanf(astr, "%100s %d", tname, &trights);
502 astr = SkipLine(astr);
503 tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
505 if (!first) first = tl;
506 strcpy(tl->name, tname);
507 tl->rights = trights;
509 if (last) last->next = tl;
512 ta->minuslist = first;
517 static int PrintStatus(VolumeStatus *status, char *name, char *offmsg)
519 printf("Volume status for vid = %u named %s\n",status->Vid, name);
521 printf("Current offline message is %s\n",offmsg);
522 printf("Current disk quota is ");
523 if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota);
524 else printf("unlimited\n");
525 printf("Current blocks used are %d\n",status->BlocksInUse);
526 printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
530 static int QuickPrintStatus(VolumeStatus *status, char *name)
532 double QuotaUsed =0.0;
533 double PartUsed =0.0;
535 printf("%-25.25s",name);
537 if (status->MaxQuota != 0) {
538 printf("%10d%10d", status->MaxQuota, status->BlocksInUse);
539 QuotaUsed = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
541 printf(" no limit%10d", status->BlocksInUse);
543 if (QuotaUsed > 90.0) {
544 printf("%5.0f%%<<", QuotaUsed);
547 else printf("%5.0f%% ", QuotaUsed);
548 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
549 if (PartUsed > 97.0) {
550 printf("%9.0f%%<<", PartUsed);
553 else printf("%9.0f%% ", PartUsed);
555 printf(" <<WARNING\n");
561 static int QuickPrintSpace(VolumeStatus *status, char *name)
563 double PartUsed =0.0;
565 printf("%-25.25s",name);
567 printf("%10d%10d%10d", status->PartMaxBlocks, status->PartMaxBlocks - status->PartBlocksAvail, status->PartBlocksAvail);
569 PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
570 if (PartUsed > 90.0){
571 printf(" %4.0f%%<<", PartUsed);
574 else printf(" %4.0f%% ", PartUsed);
576 printf(" <<WARNING\n");
582 static char *AclToString(struct Acl *acl)
584 static char mydata[MAXSIZE];
585 char tstring[MAXSIZE];
589 if (acl->dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
590 else dfsstring[0] = '\0';
591 sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
592 for(tp = acl->pluslist;tp;tp=tp->next) {
593 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
594 strcat(mydata, tstring);
596 for(tp = acl->minuslist;tp;tp=tp->next) {
597 sprintf(tstring, "%s %d\n", tp->name, tp->rights);
598 strcat(mydata, tstring);
603 static int SetACLCmd(struct cmd_syndesc *as)
606 struct ViceIoctl blob;
608 struct cmd_item *ti, *ui;
612 int idf = getidf(as, parm_setacl_id);
615 if (as->parms[2].items) clear=1;
617 plusp = !(as->parms[3].items);
618 for(ti=as->parms[0].items; ti;ti=ti->next) {
619 blob.out_size = MAXSIZE;
621 blob.in = blob.out = space;
622 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
624 Die(errno, ti->data);
630 ta = ParseAcl(space);
631 if (!plusp && ta->dfs) {
633 "%s: %s: you may not use the -negative switch with DFS acl's.\n%s",
635 "(you may specify \"null\" to revoke all rights, however)\n");
641 if (clear) ta = EmptyAcl(space);
642 else ta = ParseAcl(space);
643 CleanAcl(ta, ti->data);
644 for(ui=as->parms[1].items; ui; ui=ui->next->next) {
647 fprintf(stderr, "%s: Missing second half of user/access pair.\n", pn);
651 rights = Convert(ui->next->data, ta->dfs, &rtype);
652 if (rtype == destroy && !ta->dfs) {
653 struct AclEntry *tlist;
655 tlist = (plusp ? ta->pluslist : ta->minuslist);
656 if (!FindList(tlist, ui->data))
659 if (rtype == deny && !ta->dfs) plusp = 0;
660 if (rtype == destroy && ta->dfs) rights = -1;
661 ChangeList(ta, plusp, ui->data, rights);
663 blob.in = AclToString(ta);
665 blob.in_size = 1+strlen(blob.in);
666 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
668 if (errno == EINVAL) {
670 static char *fsenv = 0;
672 fsenv = (char *)getenv("FS_EXPERT");
674 fprintf(stderr, "%s: \"Invalid argument\" was returned when you tried to store a DFS access list.\n", pn);
677 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
678 "\nPossible reasons for this include:\n\n",
679 " -You may have specified an inappropriate combination of rights.\n",
680 " For example, some DFS-supported filesystems may not allow you to\n",
681 " drop the \"c\" right from \"user_obj\".\n\n",
682 " -A mask_obj may be required (it is likely required by the underlying\n",
683 " filesystem if you try to set anything other than the basic \"user_obj\"\n",
684 " \"mask_obj\", or \"group_obj\" entries). Unlike acl_edit, the fs command\n",
685 " does not automatically create or update the mask_obj. Try setting\n",
686 " the rights \"mask_obj all\" with \"fs sa\" before adding any explicit\n",
687 " users or groups. You can do this with a single command, such as\n",
688 " \"fs sa mask_obj all user:somename read\"\n\n",
689 " -A specified user or group may not exist.\n\n",
690 " -You may have tried to delete \"user_obj\", \"group_obj\", or \"other_obj\".\n",
691 " This is probably not allowed by the underlying file system.\n\n",
692 " -If you add a user or group to a DFS ACL, remember that it must be\n",
693 " fully specified as \"user:username\" or \"group:groupname\". In addition, there\n",
694 " may be local requirements on the format of the user or group name.\n",
695 " Check with your cell administrator.\n\n",
696 " -Or numerous other possibilities. It would be great if we could be more\n",
697 " precise about the actual problem, but for various reasons, this is\n",
698 " impractical via this interface. If you can't figure it out, you\n",
699 " might try logging into a DCE-equipped machine and use acl_edit (or\n",
700 " whatever is provided). You may get better results. Good luck!\n\n",
701 " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
704 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
705 fprintf(stderr, "\t-File not in AFS\n");
706 fprintf(stderr, "\t-Too many users on access control list\n");
707 fprintf(stderr, "\t-Tried to add non-existent user to access control list\n");
711 Die(errno, ti->data);
721 static int CopyACLCmd(struct cmd_syndesc *as)
724 struct ViceIoctl blob;
725 struct Acl *fa, *ta = 0;
727 struct cmd_item *ti, *ui;
731 int idf = getidf(as, parm_copyacl_id);
734 if (as->parms[2].items) clear=1;
736 blob.out_size = MAXSIZE;
738 blob.in = blob.out = space;
739 code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
741 Die(errno, as->parms[0].items->data);
744 fa = ParseAcl(space);
745 CleanAcl(fa, as->parms[0].items->data);
746 for (ti=as->parms[1].items; ti;ti=ti->next) {
747 blob.out_size = MAXSIZE;
749 blob.in = blob.out = space;
750 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
752 Die(errno, ti->data);
758 if (clear) ta = EmptyAcl(space);
759 else ta = ParseAcl(space);
760 CleanAcl(ta, ti->data);
761 if (ta->dfs != fa->dfs) {
762 fprintf(stderr, "%s: incompatible file system types: acl not copied to %s; aborted\n", pn, ti->data);
767 if (! clear && strcmp(ta->cell, fa->cell) != 0) {
768 fprintf(stderr, "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", pn, ti->data);
772 strcpy(ta->cell, fa->cell);
774 for (tp = fa->pluslist;tp;tp=tp->next)
775 ChangeList(ta, 1, tp->name, tp->rights);
776 for (tp = fa->minuslist;tp;tp=tp->next)
777 ChangeList(ta, 0, tp->name, tp->rights);
778 blob.in = AclToString(ta);
780 blob.in_size = 1+strlen(blob.in);
781 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
783 if (errno == EINVAL) {
784 fprintf(stderr, "%s: Invalid argument, possible reasons include:\n", pn);
785 fprintf(stderr, "\t-File not in AFS\n");
788 Die(errno, ti->data);
798 /* pioctl() call to get the cellname of a pathname */
799 static afs_int32 GetCell(char *fname, char *cellname)
802 struct ViceIoctl blob;
805 blob.out_size = MAXCELLCHARS;
808 code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
809 return code ? errno : 0;
812 /* Check if a username is valid: If it contains only digits (or a
813 * negative sign), then it might be bad. We then query the ptserver
816 static BadName(char *aname, char *fname)
818 afs_int32 tc, code, id;
820 char cell[MAXCELLCHARS];
822 for (nm=aname; tc=*nm; nm++) {
823 /* all must be '-' or digit to be bad */
824 if (tc != '-' && (tc < '0' || tc > '9')) return 0;
827 /* Go to the PRDB and see if this all number username is valid */
828 code = GetCell(fname, cell);
831 pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
832 code = pr_SNameToId(aname, &id);
835 /* 1=>Not-valid; 0=>Valid */
836 return ((!code && (id==ANONYMOUSID)) ? 1 : 0);
840 /* clean up an access control list of its bad entries; return 1 if we made
841 any changes to the list, and 0 otherwise */
842 static CleanAcl(struct Acl *aa, char *fname)
844 struct AclEntry *te, **le, *ne;
847 /* Don't correct DFS ACL's for now */
851 /* prune out bad entries */
852 changes = 0; /* count deleted entries */
854 for(te = aa->pluslist; te; te=ne) {
856 if (BadName(te->name,fname)) {
868 for(te = aa->minuslist; te; te=ne) {
870 if (BadName(te->name,fname)) {
885 /* clean up an acl to not have bogus entries */
886 static int CleanACLCmd(struct cmd_syndesc *as)
890 struct ViceIoctl blob;
896 SetDotDefault(&as->parms[0].items);
897 for(ti=as->parms[0].items; ti; ti=ti->next) {
898 blob.out_size = MAXSIZE;
901 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
903 Die(errno, ti->data);
909 ta = ParseAcl(space);
912 "%s: cleanacl is not supported for DFS access lists.\n",
918 changes = CleanAcl(ta, ti->data);
921 /* now set the acl */
922 blob.in=AclToString(ta);
923 blob.in_size = strlen(blob.in)+1;
925 code = pioctl(ti->data, VIOCSETAL, &blob, 1);
927 if (errno == EINVAL) {
928 fprintf(stderr, "%s: Invalid argument, possible reasons include\n", pn);
929 fprintf(stderr, "%s: File not in vice or\n", pn);
930 fprintf(stderr, "%s: Too many users on access control list or\n", pn);
933 Die(errno, ti->data);
939 /* now list the updated acl */
940 printf("Access list for %s is now\n", ti->data);
942 if (!ta->dfs) printf("Normal rights:\n");
943 for(te = ta->pluslist;te;te=te->next) {
944 printf(" %s ", te->name);
945 PRights(te->rights, ta->dfs);
949 if (ta->nminus > 0) {
950 printf("Negative rights:\n");
951 for(te = ta->minuslist;te;te=te->next) {
952 printf(" %s ", te->name);
953 PRights(te->rights, ta->dfs);
957 if (ti->next) printf("\n");
960 printf("Access list for %s is fine.\n", ti->data);
966 static int ListACLCmd(struct cmd_syndesc *as)
970 struct ViceIoctl blob;
973 int idf = getidf(as, parm_listacl_id);
976 SetDotDefault(&as->parms[0].items);
977 for(ti=as->parms[0].items; ti; ti=ti->next) {
978 blob.out_size = MAXSIZE;
980 blob.in = blob.out = space;
981 code = pioctl(ti->data, VIOCGETAL, &blob, 1);
983 Die(errno, ti->data);
987 ta = ParseAcl(space);
990 printf("Access list for %s is\n", ti->data);
993 printf("DFS access list for %s is\n", ti->data);
996 printf("DFS initial directory access list of %s is\n", ti->data);
999 printf("DFS initial file access list of %s is\n", ti->data);
1003 printf(" Default cell = %s\n", ta->cell);
1005 if (ta->nplus > 0) {
1006 if (!ta->dfs) printf("Normal rights:\n");
1007 for(te = ta->pluslist;te;te=te->next) {
1008 printf(" %s ", te->name);
1009 PRights(te->rights, ta->dfs);
1013 if (ta->nminus > 0) {
1014 printf("Negative rights:\n");
1015 for(te = ta->minuslist;te;te=te->next) {
1016 printf(" %s ", te->name);
1017 PRights(te->rights, ta->dfs);
1021 if (ti->next) printf("\n");
1027 static int FlushVolumeCmd(struct cmd_syndesc *as)
1030 struct ViceIoctl blob;
1031 struct cmd_item *ti;
1034 SetDotDefault(&as->parms[0].items);
1035 for(ti=as->parms[0].items; ti; ti=ti->next) {
1036 blob.in_size = blob.out_size = 0;
1037 code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
1039 fprintf(stderr, "Error flushing volume ");
1048 static int FlushCmd(struct cmd_syndesc *as)
1051 struct ViceIoctl blob;
1052 struct cmd_item *ti;
1055 for(ti=as->parms[0].items; ti; ti=ti->next) {
1056 blob.in_size = blob.out_size = 0;
1057 code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
1059 if (errno == EMFILE) {
1060 fprintf(stderr, "%s: Can't flush active file %s\n", pn, ti->data);
1063 fprintf(stderr, "%s: Error flushing file ", pn);
1073 /* all this command does is repackage its args and call SetVolCmd */
1074 static int SetQuotaCmd(struct cmd_syndesc *as)
1076 struct cmd_syndesc ts;
1078 /* copy useful stuff from our command slot; we may later have to reorder */
1079 memcpy(&ts, as, sizeof(ts)); /* copy whole thing */
1080 return SetVolCmd(&ts);
1083 static int SetVolCmd(struct cmd_syndesc *as)
1086 struct ViceIoctl blob;
1087 struct cmd_item *ti;
1088 struct VolumeStatus *status;
1089 char *offmsg, *input;
1092 SetDotDefault(&as->parms[0].items);
1093 for(ti=as->parms[0].items; ti; ti=ti->next) {
1095 blob.out_size = MAXSIZE;
1096 blob.in_size = sizeof(*status) + 3; /* for the three terminating nulls */
1099 status = (VolumeStatus *)space;
1100 status->MinQuota = status->MaxQuota = -1;
1102 if (as->parms[1].items) {
1103 code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
1105 fprintf(stderr, "%s: bad integer specified for quota.\n", pn);
1110 if (as->parms[2].items) offmsg = as->parms[2].items->data;
1111 input = (char *)status + sizeof(*status);
1112 *(input++) = '\0'; /* never set name: this call doesn't change vldb */
1114 if (strlen(offmsg) >= VMSGSIZE) {
1115 fprintf(stderr, "%s: message must be shorter than %d characters\n",
1120 strcpy(input,offmsg);
1121 blob.in_size += strlen(offmsg);
1122 input += strlen(offmsg) + 1;
1124 else *(input++) = '\0';
1125 *(input++) = '\0'; /* Pad for old style volume "motd" */
1126 code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
1128 Die(errno, ti->data);
1135 static int ExamineCmd(struct cmd_syndesc *as)
1138 struct ViceIoctl blob;
1139 struct cmd_item *ti;
1140 struct VolumeStatus *status;
1141 char *name, *offmsg;
1144 SetDotDefault(&as->parms[0].items);
1145 for(ti=as->parms[0].items; ti; ti=ti->next) {
1147 blob.out_size = MAXSIZE;
1150 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1152 Die(errno, ti->data);
1156 status = (VolumeStatus *)space;
1157 name = (char *)status + sizeof(*status);
1158 offmsg = name + strlen(name) + 1;
1159 PrintStatus(status, name, offmsg);
1164 static int ListQuotaCmd(struct cmd_syndesc *as)
1167 struct ViceIoctl blob;
1168 struct cmd_item *ti;
1169 struct VolumeStatus *status;
1173 printf("%-25s%-10s%-10s%-7s%-11s\n",
1174 "Volume Name"," Quota", " Used", " %Used", " Partition");
1175 SetDotDefault(&as->parms[0].items);
1176 for(ti=as->parms[0].items; ti; ti=ti->next) {
1178 blob.out_size = MAXSIZE;
1181 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1183 Die(errno, ti->data);
1187 status = (VolumeStatus *)space;
1188 name = (char *)status + sizeof(*status);
1189 QuickPrintStatus(status, name);
1194 static int WhereIsCmd(struct cmd_syndesc *as)
1197 struct ViceIoctl blob;
1198 struct cmd_item *ti;
1204 SetDotDefault(&as->parms[0].items);
1205 for(ti=as->parms[0].items; ti; ti=ti->next) {
1207 blob.out_size = MAXSIZE;
1210 memset(space, 0, sizeof(space));
1211 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
1213 Die(errno, ti->data);
1217 hosts = (afs_int32 *) space;
1218 printf("File %s is on host%s ", ti->data, (hosts[0] && !hosts[1]) ? "": "s");
1219 for(j=0; j<MAXHOSTS; j++) {
1220 if (hosts[j] == 0) break;
1221 tp = hostutil_GetNameByINet(hosts[j]);
1230 static int DiskFreeCmd(struct cmd_syndesc *as)
1233 struct ViceIoctl blob;
1234 struct cmd_item *ti;
1236 struct VolumeStatus *status;
1239 printf("%-25s%-10s%-10s%-10s%-6s\n",
1240 "Volume Name"," kbytes", " used", " avail", " %used");
1241 SetDotDefault(&as->parms[0].items);
1242 for(ti=as->parms[0].items; ti; ti=ti->next) {
1244 blob.out_size = MAXSIZE;
1247 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1249 Die(errno, ti->data);
1253 status = (VolumeStatus *)space;
1254 name = (char *)status + sizeof(*status);
1255 QuickPrintSpace(status, name);
1260 static int QuotaCmd(struct cmd_syndesc *as)
1263 struct ViceIoctl blob;
1264 struct cmd_item *ti;
1266 struct VolumeStatus *status;
1269 SetDotDefault(&as->parms[0].items);
1270 for(ti=as->parms[0].items; ti; ti=ti->next) {
1272 blob.out_size = MAXSIZE;
1275 code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
1277 Die(errno, ti->data);
1281 status = (VolumeStatus *)space;
1282 if (status->MaxQuota) quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
1283 else quotaPct = 0.0;
1284 printf("%2.0f%% of quota used.\n", quotaPct);
1289 static int ListMountCmd(struct cmd_syndesc *as)
1292 struct ViceIoctl blob;
1293 struct cmd_item *ti;
1294 char orig_name[1024]; /*Original name, may be modified*/
1295 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
1296 char parent_dir[1024]; /*Parent directory of true name*/
1297 char *last_component; /*Last component of true name*/
1298 struct stat statbuff; /*Buffer for status info*/
1299 int link_chars_read; /*Num chars read in readlink()*/
1300 int thru_symlink; /*Did we get to a mount point via a symlink?*/
1303 for(ti=as->parms[0].items; ti; ti=ti->next) {
1306 sprintf(orig_name, "%s%s",
1307 (ti->data[0] == '/') ? "" : "./",
1310 if (lstat(orig_name, &statbuff) < 0) {
1311 /* if lstat fails, we should still try the pioctl, since it
1312 may work (for example, lstat will fail, but pioctl will
1313 work if the volume of offline (returning ENODEV). */
1314 statbuff.st_mode = S_IFDIR; /* lie like pros */
1318 * The lstat succeeded. If the given file is a symlink, substitute
1319 * the file name with the link name.
1321 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
1324 * Read name of resolved file.
1326 link_chars_read = readlink(orig_name, true_name, 1024);
1327 if (link_chars_read <= 0) {
1328 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
1335 * Add a trailing null to what was read, bump the length.
1337 true_name[link_chars_read++] = 0;
1340 * If the symlink is an absolute pathname, we're fine. Otherwise, we
1341 * have to create a full pathname using the original name and the
1342 * relative symlink name. Find the rightmost slash in the original
1343 * name (we know there is one) and splice in the symlink value.
1345 if (true_name[0] != '/') {
1346 last_component = (char *) strrchr(orig_name, '/');
1347 strcpy(++last_component, true_name);
1348 strcpy(true_name, orig_name);
1352 strcpy(true_name, orig_name);
1355 * Find rightmost slash, if any.
1357 last_component = (char *) strrchr(true_name, '/');
1358 if (last_component) {
1360 * Found it. Designate everything before it as the parent directory,
1361 * everything after it as the final component.
1363 strncpy(parent_dir, true_name, last_component - true_name);
1364 parent_dir[last_component - true_name] = 0;
1365 last_component++; /*Skip the slash*/
1369 * No slash appears in the given file name. Set parent_dir to the current
1370 * directory, and the last component as the given name.
1372 strcpy(parent_dir, ".");
1373 last_component = true_name;
1376 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
1377 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
1378 fprintf(stderr, "%s: of a name in the 'fs lsmount' command.\n", pn);
1383 blob.in = last_component;
1384 blob.in_size = strlen(last_component)+1;
1385 blob.out_size = MAXSIZE;
1387 memset(space, 0, MAXSIZE);
1389 code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
1392 printf("'%s' is a %smount point for volume '%s'\n",
1394 (thru_symlink ? "symbolic link, leading to a " : ""),
1398 if (errno == EINVAL) {
1399 fprintf(stderr, "'%s' is not a mount point.\n",
1403 Die(errno, (ti->data ? ti->data : parent_dir));
1411 static MakeMountCmd(struct cmd_syndesc *as)
1414 char *cellName, *volName, *tmpName;
1415 struct afsconf_cell info;
1416 struct vldbentry vldbEntry;
1417 struct ViceIoctl blob;
1423 if (as->parms[5].items && !as->parms[2].items) {
1424 fprintf(stderr, "%s: must provide cell when creating cellular mount point.\n", pn);
1429 if (as->parms[2].items) /* cell name specified */
1430 cellName = as->parms[2].items->data;
1433 volName = as->parms[1].items->data;
1435 if (strlen(volName) >= 64) {
1436 fprintf(stderr, "%s: volume name too long (length must be < 64 characters)\n", pn);
1440 /* Check for a cellname in the volume specification, and complain
1441 * if it doesn't match what was specified with -cell */
1442 if (tmpName = strchr(volName, ':')) {
1445 if (strcasecmp(cellName,volName)) {
1446 fprintf(stderr, "%s: cellnames do not match.\n", pn);
1451 volName = ++tmpName;
1454 if (!InAFS(Parent(as->parms[0].items->data))) {
1455 fprintf(stderr, "%s: mount points must be created within the AFS file system\n", pn);
1461 blob.out_size = MAXSIZE;
1463 code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME, &blob, 1);
1466 code = GetCellName(cellName?cellName:space, &info);
1470 if (!(as->parms[4].items)) {
1471 /* not fast, check which cell the mountpoint is being created in */
1472 /* not fast, check name with VLDB */
1473 code = VLDBInit(1, &info);
1475 /* make the check. Don't complain if there are problems with init */
1476 code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
1477 if (code == VL_NOENT) {
1478 fprintf(stderr, "%s: warning, volume %s does not exist in cell %s.\n",
1479 pn, volName, cellName ? cellName : space);
1484 if (as->parms[3].items) /* if -rw specified */
1489 /* cellular mount point, prepend cell prefix */
1490 strcat(space, info.name);
1493 strcat(space, volName); /* append volume name */
1494 strcat(space, "."); /* stupid convention; these end with a period */
1495 code = symlink(space, as->parms[0].items->data);
1497 Die(errno, as->parms[0].items->data);
1504 * Delete AFS mount points. Variables are used as follows:
1505 * tbuffer: Set to point to the null-terminated directory name of the mount point
1506 * (or ``.'' if none is provided)
1507 * tp: Set to point to the actual name of the mount point to nuke.
1509 static int RemoveMountCmd(struct cmd_syndesc *as)
1512 struct ViceIoctl blob;
1513 struct cmd_item *ti;
1515 char lsbuffer[1024];
1519 for(ti=as->parms[0].items; ti; ti=ti->next) {
1521 tp = (char *) strrchr(ti->data, '/');
1523 strncpy(tbuffer, ti->data, code=tp-ti->data); /* the dir name */
1525 tp++; /* skip the slash */
1528 strcpy(tbuffer, ".");
1532 blob.in_size = strlen(tp)+1;
1533 blob.out = lsbuffer;
1534 blob.out_size = sizeof(lsbuffer);
1535 code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
1537 if (errno == EINVAL) {
1538 fprintf(stderr, "%s: '%s' is not a mount point.\n", pn, ti->data);
1541 Die(errno, ti->data);
1544 continue; /* don't bother trying */
1548 blob.in_size = strlen(tp)+1;
1549 code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
1551 Die(errno, ti->data);
1561 static int CheckServersCmd(struct cmd_syndesc *as)
1564 struct ViceIoctl blob;
1570 struct afsconf_cell info;
1571 struct chservinfo checkserv;
1573 memset(&checkserv, 0, sizeof(struct chservinfo));
1574 blob.in_size=sizeof(struct chservinfo);
1575 blob.in=(caddr_t)&checkserv;
1577 blob.out_size = MAXSIZE;
1579 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1581 /* prepare flags for checkservers command */
1582 temp = 2; /* default to checking local cell only */
1583 if (as->parms[2].items) temp |= 1; /* set fast flag */
1584 if (as->parms[1].items) temp &= ~2; /* turn off local cell check */
1586 checkserv.magic = 0x12345678; /* XXX */
1587 checkserv.tflags=temp;
1589 /* now copy in optional cell name, if specified */
1590 if (as->parms[0].items) {
1591 code = GetCellName(as->parms[0].items->data, &info);
1595 strcpy(checkserv.tbuffer,info.name);
1596 checkserv.tsize=strlen(info.name)+1;
1599 strcpy(checkserv.tbuffer,"\0");
1603 if(as->parms[3].items) {
1604 checkserv.tinterval=atol(as->parms[3].items->data);
1607 if(checkserv.tinterval<0) {
1608 printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
1609 checkserv.tinterval=0;
1611 else if(checkserv.tinterval> 600) {
1612 printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
1613 checkserv.tinterval=600; /* 10 min max interval */
1617 checkserv.tinterval = -1; /* don't change current interval */
1620 code = pioctl(0, VIOCCKSERV, &blob, 1);
1622 if ((errno == EACCES) && (checkserv.tinterval > 0)) {
1623 printf("Must be root to change -interval\n");
1629 memcpy(&temp, space, sizeof(afs_int32));
1630 if (checkserv.tinterval >= 0) {
1631 if (checkserv.tinterval > 0)
1632 printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
1633 checkserv.tinterval, temp);
1635 printf("The current down server probe interval is %d secs\n", temp);
1639 printf("All servers are running.\n");
1642 printf("These servers unavailable due to network or server problems: ");
1644 memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
1645 if (temp == 0) break;
1646 tp = hostutil_GetNameByINet(temp);
1655 static int MessagesCmd(struct cmd_syndesc *as)
1658 struct ViceIoctl blob;
1661 struct gaginfo gagflags;
1662 struct cmd_item *show;
1664 memset(&gagflags, 0, sizeof(struct gaginfo));
1665 blob.in_size = sizeof(struct gaginfo);
1666 blob.in = (caddr_t) &gagflags;
1667 blob.out_size = MAXSIZE;
1669 memset(space, 0, sizeof(afs_int32)); /* so we assure zero when nothing is copied back */
1671 if (show = as->parms[0].items) {
1672 if (!strcasecmp (show->data, "user"))
1673 gagflags.showflags |= GAGUSER;
1674 else if (!strcasecmp (show->data, "console"))
1675 gagflags.showflags |= GAGCONSOLE;
1676 else if (!strcasecmp (show->data, "all"))
1677 gagflags.showflags |= GAGCONSOLE | GAGUSER;
1678 else if (!strcasecmp (show->data, "none"))
1682 "unrecognized flag %s: must be in {user,console,all,none}\n",
1691 code = pioctl(0, VIOC_GAG, &blob, 1);
1700 static int CheckVolumesCmd(struct cmd_syndesc *as)
1703 struct ViceIoctl blob;
1707 code = pioctl(0, VIOCCKBACK, &blob, 1);
1713 printf("All volumeID/name mappings checked.\n");
1717 static int SetCacheSizeCmd(struct cmd_syndesc *as)
1720 struct ViceIoctl blob;
1723 if (!as->parms[0].items && !as->parms[1].items) {
1724 fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
1727 if (as->parms[0].items) {
1728 code = util_GetInt32(as->parms[0].items->data, &temp);
1730 fprintf(stderr, "%s: bad integer specified for cache size.\n", pn);
1736 blob.in = (char *) &temp;
1737 blob.in_size = sizeof(afs_int32);
1739 code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
1741 if (errno == EROFS) {
1742 printf("'fs setcache' not allowed on memory cache based cache managers.\n");
1750 printf("New cache size set.\n");
1754 #define MAXGCSIZE 16
1755 static int GetCacheParmsCmd(struct cmd_syndesc *as)
1758 struct ViceIoctl blob;
1759 afs_int32 parms[MAXGCSIZE];
1761 memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
1764 blob.out_size = sizeof(parms);
1765 blob.out = (char *) parms;
1766 code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
1771 printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
1772 parms[1], parms[0]);
1773 if (parms[1] > parms[0])
1774 printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
1778 static int ListCellsCmd(struct cmd_syndesc *as)
1784 struct ViceIoctl blob;
1787 resolve = !(as->parms[0].items); /* -numeric */
1791 memcpy(tp, &i, sizeof(afs_int32));
1792 blob.out_size = MAXSIZE;
1793 blob.in_size = sizeof(afs_int32);
1796 code = pioctl(0, VIOCGETCELL, &blob, 1);
1798 if (errno == EDOM) break; /* done with the list */
1803 printf("Cell %s on hosts", tp+MAXCELLHOSTS*sizeof(afs_int32));
1804 for(j=0; j < MAXCELLHOSTS; j++) {
1806 char *name, tbuffer[20];
1808 memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
1809 if (addr == 0) break;
1812 name = hostutil_GetNameByINet(addr);
1816 sprintf(tbuffer, "%d.%d.%d.%d",
1817 (addr>>24) & 0xff, (addr>>16) & 0xff,
1818 (addr>>8) & 0xff, addr & 0xff);
1821 printf(" %s", name);
1828 static int ListAliasesCmd(struct cmd_syndesc *as)
1831 char *tp, *aliasName, *realName;
1832 struct ViceIoctl blob;
1836 memcpy(tp, &i, sizeof(afs_int32));
1837 blob.out_size = MAXSIZE;
1838 blob.in_size = sizeof(afs_int32);
1841 code = pioctl(0, VIOC_GETALIAS, &blob, 1);
1843 if (errno == EDOM) break; /* done with the list */
1849 tp += strlen(aliasName) + 1;
1851 printf("Alias %s for cell %s\n", aliasName, realName);
1856 static int NewCellCmd(struct cmd_syndesc *as)
1858 afs_int32 code, linkedstate=0, size=0, *lp;
1859 struct ViceIoctl blob;
1860 struct cmd_item *ti;
1861 char *tp, *cellname=0;
1862 struct hostent *thp;
1863 afs_int32 fsport = 0, vlport = 0;
1864 afs_int32 magic, scount; /* Number of servers to pass in pioctl call */
1867 * With the NEWCELL pioctl call, 3.4 clients take an array of
1868 * MAXHOSTS (13) servers while 3.5 clients take an array of
1869 * MAXCELLHOSTS (8) servers. To determine which we are talking to,
1870 * do a GETCELL pioctl and pass it a magic number. If an array of
1871 * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
1872 * If we get back EDOM, there are no cells in the kernel yet,
1873 * and we'll assume a 3.5 client.
1876 lp = (afs_int32 *)tp;
1877 *lp++ = 0; /* first cell entry */
1878 *lp = 0x12345678; /* magic */
1879 blob.out_size = MAXSIZE;
1880 blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
1883 code = pioctl(0, VIOCGETCELL, &blob, 1);
1884 if (code < 0 && errno != EDOM) {
1888 if (code < 1 && errno == EDOM) {
1892 cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
1893 scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
1896 /* Now setup and do the NEWCELL pioctl call */
1897 memset(space, 0, (scount+1) * sizeof(afs_int32));
1899 lp = (afs_int32 *)tp;
1901 tp += sizeof(afs_int32);
1902 for(ti=as->parms[1].items; ti; ti=ti->next) {
1903 thp = hostutil_GetHostByName(ti->data);
1905 fprintf(stderr, "%s: Host %s not found in host table, skipping it.\n",
1909 memcpy(tp, thp->h_addr, sizeof(afs_int32));
1910 tp += sizeof(afs_int32);
1913 if (as->parms[2].items) {
1915 * Link the cell, for the purposes of volume location, to the specified
1918 cellname = as->parms[2].items->data;
1921 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
1922 if (as->parms[3].items) {
1923 code = util_GetInt32(as->parms[3].items->data, &vlport);
1925 fprintf(stderr, "%s: bad integer specified for the fileserver port.\n", pn);
1929 if (as->parms[4].items) {
1930 code = util_GetInt32(as->parms[4].items->data, &fsport);
1932 fprintf(stderr, "%s: bad integer specified for the vldb server port.\n", pn);
1937 tp = (char *)(space + (scount+1) *sizeof(afs_int32));
1938 lp = (afs_int32 *)tp;
1942 strcpy(space + ((scount+4) * sizeof(afs_int32)), as->parms[0].items->data);
1943 size = ((scount+4) * sizeof(afs_int32))
1944 + strlen(as->parms[0].items->data)
1946 tp = (char *)(space + size);
1948 strcpy(tp, cellname);
1949 size += strlen(cellname) + 1;
1951 blob.in_size = size;
1954 code = pioctl(0, VIOCNEWCELL, &blob, 1);
1962 static int NewAliasCmd(struct cmd_syndesc *as)
1965 struct ViceIoctl blob;
1967 char *aliasName, *realName;
1969 /* Now setup and do the NEWCELL pioctl call */
1970 aliasName = as->parms[0].items->data;
1971 realName = as->parms[1].items->data;
1973 strcpy(tp, aliasName);
1974 tp += strlen(aliasName) + 1;
1975 strcpy(tp, realName);
1976 tp += strlen(realName) + 1;
1978 blob.in_size = tp - space;
1982 code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
1984 if (errno == EEXIST) {
1985 fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
1995 static int WhichCellCmd(struct cmd_syndesc *as)
1998 struct cmd_item *ti;
2000 char cell[MAXCELLCHARS];
2002 SetDotDefault(&as->parms[0].items);
2003 for (ti=as->parms[0].items; ti; ti=ti->next) {
2004 code = GetCell(ti->data, cell);
2006 if (errno == ENOENT)
2007 fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
2009 Die(errno, ti->data);
2014 printf("File %s lives in cell '%s'\n", ti->data, cell);
2019 static int WSCellCmd(struct cmd_syndesc *as)
2022 struct ViceIoctl blob;
2026 blob.out_size = MAXSIZE;
2029 code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
2035 printf("This workstation belongs to cell '%s'\n", space);
2040 static PrimaryCellCmd(as)
2041 struct cmd_syndesc *as;
2043 fprintf(stderr, "This command is obsolete, as is the concept of a primary token.\n");
2048 static int MonitorCmd(struct cmd_syndesc *as)
2051 struct ViceIoctl blob;
2052 struct cmd_item *ti;
2054 struct hostent *thp;
2058 ti = as->parms[0].items;
2062 if (!strcmp(ti->data, "off"))
2063 hostAddr = 0xffffffff;
2065 thp = hostutil_GetHostByName(ti->data);
2067 if (!strcmp(ti->data, "localhost")) {
2068 fprintf(stderr, "localhost not in host table, assuming 127.0.0.1\n");
2069 hostAddr = htonl(0x7f000001);
2072 fprintf(stderr, "host %s not found in host table.\n", ti->data);
2076 else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
2080 hostAddr = 0; /* means don't set host */
2081 setp = 0; /* aren't setting host */
2084 /* now do operation */
2085 blob.in_size = sizeof(afs_int32);
2086 blob.out_size = sizeof(afs_int32);
2087 blob.in = (char *) &hostAddr;
2088 blob.out = (char *) &hostAddr;
2089 code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
2095 printf("%s: new monitor host set.\n", pn);
2098 /* now decode old address */
2099 if (hostAddr == 0xffffffff) {
2100 printf("Cache monitoring is currently disabled.\n");
2103 tp = hostutil_GetNameByINet(hostAddr);
2104 printf("Using host %s for monitor services.\n", tp);
2110 static int SysNameCmd(struct cmd_syndesc *as)
2113 struct ViceIoctl blob;
2114 struct cmd_item *ti;
2115 char *input = space;
2118 ti = as->parms[0].items;
2121 blob.out_size = MAXSIZE;
2122 blob.in_size = sizeof(afs_int32);
2123 input += sizeof(afs_int32);
2124 for(; ti; ti=ti->next) {
2126 blob.in_size += strlen(ti->data) + 1;
2127 if (blob.in_size > MAXSIZE) {
2128 fprintf(stderr, "%s: sysname%s too long.\n", pn, setp > 1 ? "s" : "");
2131 strcpy(input, ti->data);
2132 input += strlen(ti->data);
2135 memcpy(space, &setp, sizeof(afs_int32));
2136 code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
2142 printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
2146 memcpy(&setp, input, sizeof(afs_int32));
2147 input += sizeof(afs_int32);
2149 fprintf(stderr, "No sysname name value was found\n");
2152 printf("Current sysname%s is", setp>1 ? " list" : "");
2153 for(;setp>0;--setp) {
2154 printf(" \'%s\'", input);
2155 input += strlen(input) + 1;
2161 static char *exported_types[] = {"null", "nfs", ""};
2162 static int ExportAfsCmd(struct cmd_syndesc *as)
2165 struct ViceIoctl blob;
2166 struct cmd_item *ti;
2167 int export=0, type=0, mode = 0, exp = 0, exportcall, pwsync=0, smounts=0;
2169 ti = as->parms[0].items;
2170 if (strcmp(ti->data, "nfs") == 0) type = 0x71; /* NFS */
2172 fprintf(stderr, "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
2175 ti = as->parms[1].items;
2177 if (strcmp(ti->data, "on") == 0) export = 3;
2178 else if (strcmp(ti->data, "off") == 0) export = 2;
2180 fprintf(stderr, "Illegal argument %s\n", ti->data);
2185 if (ti = as->parms[2].items) { /* -noconvert */
2186 if (strcmp(ti->data, "on") == 0) mode = 2;
2187 else if (strcmp(ti->data, "off") == 0) mode = 3;
2189 fprintf(stderr, "Illegal argument %s\n", ti->data);
2193 if (ti = as->parms[3].items) { /* -uidcheck */
2194 if (strcmp(ti->data, "on") == 0) pwsync = 3;
2195 else if (strcmp(ti->data, "off") == 0) pwsync = 2;
2197 fprintf(stderr, "Illegal argument %s\n", ti->data);
2201 if (ti = as->parms[4].items) { /* -submounts */
2202 if (strcmp(ti->data, "on") == 0) smounts = 3;
2203 else if (strcmp(ti->data, "off") == 0) smounts = 2;
2205 fprintf(stderr, "Illegal argument %s\n", ti->data);
2209 exportcall = (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
2212 blob.in = (char *) &exportcall;
2213 blob.in_size = sizeof(afs_int32);
2214 blob.out = (char *) &exportcall;
2215 blob.out_size = sizeof(afs_int32);
2216 code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
2218 if (errno == ENODEV) {
2219 fprintf(stderr, "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
2227 if (exportcall & 1) {
2228 printf("'%s' translator is enabled with the following options:\n",
2229 exported_types[type]);
2230 printf("\tRunning in %s mode\n",
2231 (exportcall & 2 ? "strict unix"
2232 : "convert owner mode bits to world/other"));
2233 printf("\tRunning in %s mode\n",
2234 (exportcall & 4 ? "strict 'passwd sync'"
2235 : "no 'passwd sync'"));
2237 (exportcall & 8 ? "Allow mounts of /afs/.. subdirs"
2238 : "Only mounts to /afs allowed"));
2241 printf("'%s' translator is disabled\n", exported_types[type]);
2247 static int GetCellCmd(struct cmd_syndesc *as)
2250 struct ViceIoctl blob;
2251 struct afsconf_cell info;
2252 struct cmd_item *ti;
2259 memset(&args, '\0', sizeof args); /* avoid Purify UMR error */
2260 for(ti=as->parms[0].items; ti; ti=ti->next) {
2262 blob.out_size = sizeof(args);
2263 blob.out = (caddr_t) &args;
2264 code = GetCellName(ti->data, &info);
2269 blob.in_size = 1+strlen(info.name);
2270 blob.in = info.name;
2271 code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
2273 if (errno == ENOENT)
2274 fprintf(stderr, "%s: the cell named '%s' does not exist\n", pn, info.name);
2276 Die(errno, info.name);
2280 printf("Cell %s status: ", info.name);
2282 if (args.stat & 1) printf("primary ");
2284 if (args.stat & 2) printf("no setuid allowed");
2285 else printf("setuid allowed");
2286 if (args.stat & 4) printf(", using old VLDB");
2292 static int SetCellCmd(struct cmd_syndesc *as)
2295 struct ViceIoctl blob;
2296 struct afsconf_cell info;
2297 struct cmd_item *ti;
2305 /* Check arguments. */
2306 if (as->parms[1].items && as->parms[2].items) {
2307 fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
2311 /* figure stuff to set */
2315 if (! as->parms[1].items) args.stat |= 2; /* default to -nosuid */
2317 /* set stat for all listed cells */
2318 for(ti=as->parms[0].items; ti; ti=ti->next) {
2320 code = GetCellName(ti->data, &info);
2325 strcpy(args.cname, info.name);
2326 blob.in_size = sizeof(args);
2327 blob.in = (caddr_t) &args;
2329 blob.out = (caddr_t) 0;
2330 code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
2332 Die(errno, info.name); /* XXX added cell name to Die() call */
2339 static int GetCellName(char *cellName, struct afsconf_cell *info)
2341 struct afsconf_dir *tdir;
2344 tdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
2346 fprintf(stderr, "Could not process files in configuration directory (%s).\n",
2347 AFSDIR_CLIENT_ETC_DIRPATH);
2351 code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
2353 fprintf(stderr, "%s: cell %s not in %s\n", pn, cellName,
2354 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
2362 static int VLDBInit(int noAuthFlag, struct afsconf_cell *info)
2365 struct ktc_principal sname;
2366 struct ktc_token ttoken;
2368 struct rx_securityClass *sc;
2369 struct rx_connection *serverconns[VLDB_MAXSERVERS];
2374 fprintf(stderr, "%s: could not initialize rx.\n", pn);
2378 rx_SetRxDeadTime(50);
2379 if (!noAuthFlag) { /* we don't need tickets for null */
2380 strcpy(sname.cell, info->name);
2381 sname.instance[0] = 0;
2382 strcpy(sname.name, "afs");
2383 code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), NULL);
2385 fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
2390 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
2392 fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
2398 else scIndex = 0; /* don't authenticate */
2401 sc = rxnull_NewClientSecurityObject();
2407 sc = (struct rx_securityClass *)
2408 rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
2409 ttoken.kvno, ttoken.ticketLen,
2413 if (info->numServers > VLDB_MAXSERVERS) {
2414 fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
2415 pn, info->numServers, VLDB_MAXSERVERS);
2418 memset(serverconns, 0, sizeof(serverconns));
2419 for (i = 0;i<info->numServers;i++)
2420 serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
2421 info->hostAddr[i].sin_port, USER_SERVICE_ID,
2424 code = ubik_ClientInit(serverconns, &uclient);
2427 fprintf(stderr, "%s: ubik client init failed.\n", pn);
2433 static struct ViceIoctl gblob;
2434 static int debug = 0;
2436 * here follow some routines in suport of the setserverprefs and
2437 * getserverprefs commands. They are:
2438 * SetPrefCmd "top-level" routine
2439 * addServer adds a server to the list of servers to be poked into the
2440 * kernel. Will poke the list into the kernel if it threatens
2442 * pokeServers pokes the existing list of servers and ranks into the kernel
2443 * GetPrefCmd reads the Cache Manager's current list of server ranks
2447 * returns -1 if error message printed,
2449 * errno value if error and no error message printed
2451 static int pokeServers(void)
2455 code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
2456 if (code && (errno == EINVAL)) {
2457 struct setspref *ssp;
2458 ssp = (struct setspref *)gblob.in;
2459 if (!(ssp->flags & DBservers)) {
2460 gblob.in = (void *) &(ssp->servers[0]);
2461 gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
2462 code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
2463 return code ? errno : 0;
2466 "This cache manager does not support VL server preferences.\n");
2470 return code ? errno : 0;
2474 * returns -1 if error message printed,
2476 * errno value if error and no error message printed
2478 static int addServer(char *name, afs_int32 rank)
2481 struct setspref *ssp;
2483 struct hostent *thostent;
2489 #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1) /* assumes two's complement binary system */
2491 #define MAXUSHORT ((unsigned short) ~0)
2495 thostent = hostutil_GetHostByName(name);
2497 fprintf(stderr, "%s: couldn't resolve name.\n", name);
2501 ssp = (struct setspref *)(gblob.in);
2503 for (t = 0; thostent->h_addr_list[t]; t++) {
2504 if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
2505 code = pokeServers();
2506 if (code) error = code;
2507 ssp->num_servers = 0;
2510 sp = (struct spref *) (gblob.in + gblob.in_size);
2511 memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
2512 sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
2513 gblob.in_size += sizeof(struct spref);
2517 fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
2518 name,sp->rank,sp->server.s_addr);
2525 static int SetPrefCmd(struct cmd_syndesc *as)
2529 struct cmd_item *ti;
2532 struct setspref *ssp;
2533 int error = 0; /* -1 means error message printed,
2534 * >0 means errno value for unprinted message */
2536 ssp = (struct setspref *)space;
2538 ssp->num_servers = 0;
2539 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2542 gblob.out_size = MAXSIZE;
2546 fprintf(stderr, "Permission denied: requires root access.\n");
2550 ti = as->parms[2].items; /* -file */
2552 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2553 if (!(infd = fopen(ti->data,"r"))) {
2558 while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
2559 code = addServer(name, (unsigned short) rank);
2560 if (code) error = code;
2565 ti = as->parms[3].items; /* -stdin */
2567 while (scanf("%79s%ld", name, &rank) != EOF) {
2568 code = addServer(name, (unsigned short) rank);
2569 if (code) error = code;
2573 for (ti = as->parms[0].items;ti;ti=ti->next) { /* list of servers, ranks */
2578 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2579 if (code) error = code;
2581 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
2585 code = pokeServers();
2586 if (code) error = code;
2588 printf("now working on vlservers, code=%d\n",code);
2590 ssp = (struct setspref *)space;
2591 ssp->flags = DBservers;
2592 ssp->num_servers = 0;
2593 gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
2596 for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
2601 code = addServer(ti->data, (unsigned short) atol(ti->next->data));
2602 if (code) error = code;
2604 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
2609 if (as->parms[1].items) {
2611 printf("now poking vlservers\n");
2612 code = pokeServers();
2613 if (code) error = code;
2619 return error ? 1 : 0;
2624 static int GetPrefCmd(struct cmd_syndesc *as)
2627 struct cmd_item *ti;
2628 char *name, tbuffer[20];
2629 afs_int32 rank,addr;
2633 struct ViceIoctl blob;
2634 struct sprefrequest *in;
2635 struct sprefinfo *out;
2638 ti = as->parms[0].items; /* -file */
2640 if (debug) fprintf(stderr, "opening file %s\n",ti->data);
2641 if (!(outfd = freopen(ti->data,"w",stdout))) {
2647 ti = as->parms[1].items; /* -numeric */
2649 ti = as->parms[2].items; /* -vlservers */
2650 vlservers |= (ti ? DBservers : 0);
2651 /* ti = as->parms[3].items; -cell */
2653 in = (struct sprefrequest *)space;
2657 blob.in_size=sizeof(struct sprefrequest);
2658 blob.in = (char *)in;
2660 blob.out_size = MAXSIZE;
2662 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
2663 in->flags = vlservers;
2665 code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
2667 perror("getserverprefs pioctl");
2671 out = (struct sprefinfo *) blob.out;
2673 for (i=0;i<out->num_servers;i++) {
2675 name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
2678 addr = ntohl(out->servers[i].server.s_addr);
2679 sprintf(tbuffer, "%d.%d.%d.%d",
2680 (addr>>24) & 0xff, (addr>>16) & 0xff,
2681 (addr>>8) & 0xff, addr & 0xff);
2684 printf("%-50s %5u\n",name,out->servers[i].rank);
2687 in->offset = out->next_offset;
2688 } while (out->next_offset > 0);
2693 static int StoreBehindCmd(struct cmd_syndesc *as)
2696 struct ViceIoctl blob;
2697 struct cmd_item *ti;
2698 struct sbstruct tsb, tsb2;
2704 tsb.sb_thisfile = -1;
2705 ti=as->parms[0].items; /* -kbytes */
2707 if (!as->parms[1].items) {
2708 fprintf(stderr, "%s: you must specify -files with -kbytes.\n", pn);
2711 tsb.sb_thisfile = strtol(ti->data,&t,10) * 1024;
2712 if ((tsb.sb_thisfile < 0) || (t != ti->data+strlen(ti->data))) {
2713 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2719 allfiles = tsb.sb_default = -1; /* Don't set allfiles yet */
2720 ti=as->parms[2].items; /* -allfiles */
2722 allfiles = strtol(ti->data,&t,10) * 1024;
2723 if ((allfiles < 0) || (t != ti->data+strlen(ti->data))) {
2724 fprintf(stderr, "%s: %s must be 0 or a positive number.\n",
2730 /* -verbose or -file only or no options */
2731 if (as->parms[3].items ||
2732 (as->parms[1].items && !as->parms[0].items) ||
2733 (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items))
2736 blob.in = (char *)&tsb;
2737 blob.out = (char *)&tsb2;
2738 blob.in_size = blob.out_size = sizeof(struct sbstruct);
2739 memset(&tsb2, 0, sizeof(tsb2));
2741 /* once per -file */
2742 for (ti=as->parms[1].items; ti; ti=ti->next) {
2743 /* Do this solely to see if the file is there */
2744 code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
2746 Die(errno, ti->data);
2751 code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
2753 Die(errno, ti->data);
2758 if (verbose && (blob.out_size == sizeof(tsb2))) {
2759 if (tsb2.sb_thisfile == -1) {
2760 fprintf(stdout, "Will store %s according to default.\n",
2765 "Will store up to %d kbytes of %s asynchronously.\n",
2766 (tsb2.sb_thisfile/1024), ti->data);
2771 /* If no files - make at least one pioctl call, or
2772 * set the allfiles default if we need to.
2774 if (!as->parms[1].items || (allfiles != -1)) {
2775 tsb.sb_default = allfiles;
2776 code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
2778 Die(errno, ((allfiles == -1)?0:"-allfiles"));
2783 /* Having no arguments also reports the default store asynchrony */
2784 if (verbose && (blob.out_size == sizeof(tsb2))) {
2785 fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
2786 (tsb2.sb_default/1024));
2793 static afs_int32 SetCryptCmd(struct cmd_syndesc *as)
2795 afs_int32 code = 0, flag;
2796 struct ViceIoctl blob;
2799 tp = as->parms[0].items->data;
2800 if (strcmp(tp, "on") == 0)
2802 else if (strcmp(tp, "off") == 0)
2805 fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
2809 blob.in = (char *) &flag;
2810 blob.in_size = sizeof(flag);
2812 code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
2819 static afs_int32 GetCryptCmd(struct cmd_syndesc *as)
2821 afs_int32 code = 0, flag;
2822 struct ViceIoctl blob;
2827 blob.out_size = sizeof(flag);
2830 code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
2832 if (code) Die(errno, NULL);
2835 memcpy(&flag, tp, sizeof(afs_int32));
2836 printf("Security level is currently ");
2838 printf("crypt (data security).\n");
2845 #include "AFS_component_version_number.c"
2847 int main(int argc, char **argv)
2850 struct cmd_syndesc *ts;
2852 #ifdef AFS_AIX32_ENV
2854 * The following signal action for AIX is necessary so that in case of a
2855 * crash (i.e. core is generated) we can include the user's data section
2856 * in the core dump. Unfortunately, by default, only a partial core is
2857 * generated which, in many cases, isn't too useful.
2859 struct sigaction nsa;
2861 sigemptyset(&nsa.sa_mask);
2862 nsa.sa_handler = SIG_DFL;
2863 nsa.sa_flags = SA_FULLDUMP;
2864 sigaction(SIGSEGV, &nsa, NULL);
2867 /* try to find volume location information */
2868 ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0, "get client network interface addresses");
2869 cmd_CreateAlias(ts, "gc");
2871 ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0, "set client network interface addresses");
2872 cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "client network interfaces");
2873 cmd_CreateAlias(ts, "sc");
2875 ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
2876 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
2877 cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
2878 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
2879 cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
2880 cmd_CreateAlias(ts, "sp");
2882 ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
2883 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
2884 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2885 cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
2886 /* cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
2887 cmd_CreateAlias(ts, "gp");
2889 ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
2890 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2891 cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
2892 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
2893 cmd_AddParm(ts, "-negative", CMD_FLAG, CMD_OPTIONAL, "apply to negative rights");
2894 parm_setacl_id = ts->nParms;
2895 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl (DFS only)");
2896 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
2897 cmd_CreateAlias(ts, "sa");
2899 ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
2900 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2901 parm_listacl_id = ts->nParms;
2902 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2903 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2904 cmd_CreateAlias(ts, "la");
2906 ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
2907 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2909 ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
2910 cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
2911 cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
2912 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
2913 parm_copyacl_id = ts->nParms;
2914 cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
2915 cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
2917 cmd_CreateAlias(ts, "ca");
2919 ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
2920 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2921 ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0, "flush mount symlink from cache");
2922 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2924 ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
2925 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2926 cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
2928 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
2929 cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
2931 cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
2932 cmd_CreateAlias(ts, "sv");
2934 ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
2935 cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
2937 ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
2938 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2939 cmd_CreateAlias(ts, "lv");
2940 cmd_CreateAlias(ts, "listvol");
2942 ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
2943 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2944 cmd_CreateAlias(ts, "lq");
2946 ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
2947 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2948 cmd_CreateAlias(ts, "df");
2950 ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
2951 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
2953 ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
2954 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2956 ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
2957 cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
2958 cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
2959 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
2960 cmd_AddParm(ts, "-rw", CMD_FLAG, CMD_OPTIONAL, "force r/w volume");
2961 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "don't check name with VLDB");
2967 cmd_AddParm(ts, "-root", CMD_FLAG, CMD_OPTIONAL, "create cellular mount point");
2971 ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
2972 cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
2974 ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
2975 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
2976 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
2977 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
2978 cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
2980 ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
2981 cmd_CreateAlias(ts, "checkbackups");
2984 ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
2985 cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
2986 cmd_CreateAlias(ts, "cachesize");
2988 cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
2990 ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
2992 ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
2993 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
2995 ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
2997 ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
2998 cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
2999 cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
3001 cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
3003 cmd_CreateAlias(ts, "sq");
3005 ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
3006 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
3007 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
3008 cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
3010 ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
3011 cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
3012 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
3014 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
3016 * Turn this on only if you wish to be able to talk to a server which is listening
3017 * on alternative ports. This is not intended for general use and may not be
3018 * supported in the cache manager. It is not a way to run two servers at the
3019 * same host, since the cache manager cannot properly distinguish those two hosts.
3021 cmd_AddParm(ts, "-fsport", CMD_SINGLE, CMD_OPTIONAL, "cell's fileserver port");
3022 cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
3025 ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
3026 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3028 ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
3029 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3031 ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
3034 ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
3037 /* set cache monitor host address */
3038 ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *) CMD_HIDDEN);
3039 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "host name or 'off'");
3040 cmd_CreateAlias(ts, "mariner");
3042 ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
3043 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3045 ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
3046 cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
3047 cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
3048 cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL, "disallow setuid programs");
3050 ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
3051 cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
3053 ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
3054 cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
3056 ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
3057 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
3058 cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator (on | off)");
3059 cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode (on | off)");
3060 cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode (on | off)");
3061 cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. (on | off)");
3064 ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
3065 "store to server after file close");
3066 cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
3067 cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
3068 cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
3069 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
3070 cmd_CreateAlias(ts, "sb");
3072 ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
3073 cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
3075 ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "set cache manager encryption flag");
3077 ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
3078 "Manage per process RX statistics");
3079 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3081 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3082 "Disable RX stats");
3083 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3086 ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
3087 "Manage per peer RX statistics");
3088 cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL,
3090 cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL,
3091 "Disable RX stats");
3092 cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL,
3095 code = cmd_Dispatch(argc, argv);
3096 if (rxInitDone) rx_Finalize();
3101 static void Die(int errnum, char *filename)
3106 fprintf(stderr, "%s: Invalid argument; it is possible that %s is not in AFS.\n",
3109 fprintf(stderr, "%s: Invalid argument.\n", pn);
3113 fprintf(stderr, "%s: File '%s' doesn't exist\n", pn, filename);
3115 fprintf(stderr, "%s: no such file returned\n", pn);
3118 fprintf(stderr, "%s: You can not change a backup or readonly volume\n", pn);
3123 fprintf(stderr, "%s: You don't have the required access rights on '%s'\n",
3126 fprintf(stderr, "%s: You do not have the required rights to do this operation\n",
3131 fprintf(stderr, "%s:'%s'", pn, filename);
3133 fprintf(stderr, "%s", pn);
3134 fprintf(stderr, ": %s\n", error_message(errnum));
3139 /* get clients interface addresses */
3140 static int GetClientAddrsCmd(struct cmd_syndesc *as)
3143 struct cmd_item *ti;
3145 struct ViceIoctl blob;
3146 struct sprefrequest *in;
3147 struct sprefinfo *out;
3149 in = (struct sprefrequest *)space;
3154 blob.in_size=sizeof(struct sprefrequest);
3155 blob.in = (char *)in;
3157 blob.out_size = MAXSIZE;
3159 in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct spref);
3160 /* returns addr in network byte order */
3161 code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
3163 perror("getClientInterfaceAddr pioctl");
3169 out = (struct sprefinfo *) blob.out;
3170 for (i=0; i < out->num_servers; i++) {
3173 addr = ntohl(out->servers[i].server.s_addr);
3174 sprintf(tbuffer, "%d.%d.%d.%d",
3175 (addr>>24) & 0xff, (addr>>16) & 0xff,
3176 (addr>>8) & 0xff, addr & 0xff);
3177 printf ("%-50s\n", tbuffer);
3179 in->offset = out->next_offset;
3181 } while (out->next_offset > 0);
3186 static int SetClientAddrsCmd(struct cmd_syndesc *as)
3188 afs_int32 code, addr;
3189 struct cmd_item *ti;
3191 struct ViceIoctl blob;
3192 struct setspref *ssp;
3193 int sizeUsed = 0, i, flag;
3194 afs_int32 existingAddr[1024]; /* existing addresses on this host */
3198 ssp = (struct setspref *)space;
3199 ssp->num_servers = 0;
3202 blob.out_size = MAXSIZE;
3205 fprintf(stderr, "Permission denied: requires root access.\n");
3209 /* extract all existing interface addresses */
3210 existNu = rx_getAllAddr(existingAddr,1024);
3214 sizeUsed = sizeof(struct setspref); /* space used in ioctl buffer */
3215 for (ti = as->parms[0].items;ti;ti=ti->next) {
3216 if (sizeUsed >= sizeof(space)) {
3217 fprintf(stderr, "No more space\n");
3220 addr = extractAddr(ti->data, 20); /* network order */
3221 if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
3222 fprintf(stderr, "Error in specifying address: %s..ignoring\n", ti->data);
3226 /* see if it is an address that really exists */
3227 for (flag = 0, i=0; i < existNu; i++)
3228 if (existingAddr[i] == addr) {
3232 if (!flag) { /* this is an nonexistent address */
3233 fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
3237 /* copy all specified addr into ioctl buffer */
3238 (ssp->servers[ssp->num_servers]).server.s_addr = addr;
3239 printf("Adding 0x%08x\n", addr);
3241 sizeUsed += sizeof(struct spref);
3243 if (ssp->num_servers < 1) {
3244 fprintf(stderr, "No addresses specified\n");
3247 blob.in_size = sizeUsed - sizeof(struct spref);
3249 code = pioctl(0, VIOC_SETCPREFS, &blob, 1); /* network order */
3258 static int FlushMountCmd(struct cmd_syndesc *as)
3261 struct ViceIoctl blob;
3262 struct cmd_item *ti;
3263 char orig_name[1024]; /*Original name, may be modified*/
3264 char true_name[1024]; /*``True'' dirname (e.g., symlink target)*/
3265 char parent_dir[1024]; /*Parent directory of true name*/
3266 char *last_component; /*Last component of true name*/
3267 struct stat statbuff; /*Buffer for status info*/
3268 int link_chars_read; /*Num chars read in readlink()*/
3269 int thru_symlink; /*Did we get to a mount point via a symlink?*/
3272 for(ti=as->parms[0].items; ti; ti=ti->next) {
3275 sprintf(orig_name, "%s%s",
3276 (ti->data[0] == '/') ? "" : "./",
3279 if (lstat(orig_name, &statbuff) < 0) {
3280 /* if lstat fails, we should still try the pioctl, since it
3281 may work (for example, lstat will fail, but pioctl will
3282 work if the volume of offline (returning ENODEV). */
3283 statbuff.st_mode = S_IFDIR; /* lie like pros */
3287 * The lstat succeeded. If the given file is a symlink, substitute
3288 * the file name with the link name.
3290 if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
3293 * Read name of resolved file.
3295 link_chars_read = readlink(orig_name, true_name, 1024);
3296 if (link_chars_read <= 0) {
3297 fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",
3304 * Add a trailing null to what was read, bump the length.
3306 true_name[link_chars_read++] = 0;
3309 * If the symlink is an absolute pathname, we're fine. Otherwise, we
3310 * have to create a full pathname using the original name and the
3311 * relative symlink name. Find the rightmost slash in the original
3312 * name (we know there is one) and splice in the symlink value.
3314 if (true_name[0] != '/') {
3315 last_component = (char *) strrchr(orig_name, '/');
3316 strcpy(++last_component, true_name);
3317 strcpy(true_name, orig_name);
3321 strcpy(true_name, orig_name);
3324 * Find rightmost slash, if any.
3326 last_component = (char *) strrchr(true_name, '/');
3327 if (last_component) {
3329 * Found it. Designate everything before it as the parent directory,
3330 * everything after it as the final component.
3332 strncpy(parent_dir, true_name, last_component - true_name);
3333 parent_dir[last_component - true_name] = 0;
3334 last_component++; /*Skip the slash*/
3338 * No slash appears in the given file name. Set parent_dir to the current
3339 * directory, and the last component as the given name.
3341 strcpy(parent_dir, ".");
3342 last_component = true_name;
3345 if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
3346 fprintf(stderr, "%s: you may not use '.' or '..' as the last component\n", pn);
3347 fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n", pn);
3352 blob.in = last_component;
3353 blob.in_size = strlen(last_component)+1;
3355 memset(space, 0, MAXSIZE);
3357 code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
3360 if (errno == EINVAL) {
3361 fprintf(stderr, "'%s' is not a mount point.\n",
3365 Die(errno, (ti->data ? ti->data : parent_dir));
3373 static int RxStatProcCmd(struct cmd_syndesc *as)
3376 afs_int32 flags = 0;
3377 struct ViceIoctl blob;
3378 struct cmd_item *ti;
3380 if (as->parms[0].items) { /* -enable*/
3381 flags |= AFSCALL_RXSTATS_ENABLE;
3383 if (as->parms[1].items) { /* -disable*/
3384 flags |= AFSCALL_RXSTATS_DISABLE;
3386 if (as->parms[2].items) { /* -clear*/
3387 flags |= AFSCALL_RXSTATS_CLEAR;
3390 fprintf(stderr, "You must specify at least one argument\n");
3394 blob.in = (char *)&flags;
3395 blob.in_size = sizeof(afs_int32);
3398 code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
3407 static int RxStatPeerCmd(struct cmd_syndesc *as)
3410 afs_int32 flags = 0;
3411 struct ViceIoctl blob;
3412 struct cmd_item *ti;
3414 if (as->parms[0].items) { /* -enable*/
3415 flags |= AFSCALL_RXSTATS_ENABLE;
3417 if (as->parms[1].items) { /* -disable*/
3418 flags |= AFSCALL_RXSTATS_DISABLE;
3420 if (as->parms[2].items) { /* -clear*/
3421 flags |= AFSCALL_RXSTATS_CLEAR;
3424 fprintf(stderr, "You must specify at least one argument\n");
3428 blob.in = (char *)&flags;
3429 blob.in_size = sizeof(afs_int32);
3432 code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);