[12589] | 1 | /* Copyright 1998 by the Massachusetts Institute of Technology. |
---|
| 2 | * |
---|
| 3 | * Permission to use, copy, modify, and distribute this |
---|
| 4 | * software and its documentation for any purpose and without |
---|
| 5 | * fee is hereby granted, provided that the above copyright |
---|
| 6 | * notice appear in all copies and that both that copyright |
---|
| 7 | * notice and this permission notice appear in supporting |
---|
| 8 | * documentation, and that the name of M.I.T. not be used in |
---|
| 9 | * advertising or publicity pertaining to distribution of the |
---|
| 10 | * software without specific, written prior permission. |
---|
| 11 | * M.I.T. makes no representations about the suitability of |
---|
| 12 | * this software for any purpose. It is provided "as is" |
---|
| 13 | * without express or implied warranty. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | /* This is zinit, which is run by zwgc to get subs for lockers that |
---|
| 17 | were attached before zwgc started. */ |
---|
| 18 | |
---|
[12785] | 19 | static const char rcsid[] = "$Id: zinit.c,v 1.4 1999-03-29 17:35:40 danw Exp $"; |
---|
[12589] | 20 | |
---|
| 21 | #include <stdlib.h> |
---|
[12678] | 22 | #include <string.h> |
---|
[12589] | 23 | #include <unistd.h> |
---|
| 24 | |
---|
| 25 | #include <locker.h> |
---|
[12748] | 26 | #include "attach.h" |
---|
[12589] | 27 | #include "agetopt.h" |
---|
| 28 | |
---|
[12748] | 29 | static void usage(void); |
---|
| 30 | static int zinit_attachent(locker_context context, locker_attachent *at, |
---|
| 31 | void *opp); |
---|
[12589] | 32 | |
---|
[12748] | 33 | static struct agetopt_option zinit_options[] = { |
---|
[12589] | 34 | { "all", 'a', 0 }, |
---|
| 35 | { "debug", 'd', 0 }, |
---|
| 36 | { "me", 'm', 0 }, |
---|
| 37 | { "quiet", 'q', 0 }, |
---|
| 38 | { "verbose", 'v', 0 }, |
---|
| 39 | { 0, 0, 0 } |
---|
| 40 | }; |
---|
| 41 | |
---|
[12748] | 42 | int zinit_main(int argc, char **argv) |
---|
[12589] | 43 | { |
---|
| 44 | locker_context context; |
---|
[12785] | 45 | int opt, all = 0; |
---|
[12589] | 46 | uid_t uid = getuid(); |
---|
| 47 | |
---|
| 48 | if (locker_init(&context, uid, NULL, NULL)) |
---|
| 49 | exit(1); |
---|
| 50 | |
---|
| 51 | while ((opt = attach_getopt(argc, argv, zinit_options)) != -1) |
---|
| 52 | { |
---|
| 53 | switch (opt) |
---|
| 54 | { |
---|
| 55 | case 'a': |
---|
| 56 | all = 1; |
---|
| 57 | break; |
---|
| 58 | |
---|
| 59 | case 'm': |
---|
| 60 | all = 0; |
---|
| 61 | break; |
---|
| 62 | |
---|
| 63 | case 'q': |
---|
| 64 | case 'v': |
---|
| 65 | case 'd': |
---|
| 66 | fprintf(stderr, "%s: The '%c' flag is no longer supported.\n", |
---|
| 67 | whoami, opt); |
---|
| 68 | break; |
---|
| 69 | |
---|
| 70 | default: |
---|
| 71 | usage(); |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | if (optind != argc) |
---|
| 76 | usage(); |
---|
| 77 | |
---|
| 78 | if (all) |
---|
[12785] | 79 | locker_iterate_attachtab(context, NULL, NULL, zinit_attachent, NULL); |
---|
[12589] | 80 | else |
---|
| 81 | { |
---|
| 82 | locker_iterate_attachtab(context, locker_check_owner, &uid, |
---|
[12785] | 83 | zinit_attachent, NULL); |
---|
[12589] | 84 | } |
---|
[12785] | 85 | |
---|
| 86 | locker_do_zsubs(context, LOCKER_ZEPHYR_SUBSCRIBE); |
---|
| 87 | locker_end(context); |
---|
[12589] | 88 | return 0; |
---|
| 89 | } |
---|
| 90 | |
---|
[12748] | 91 | static int zinit_attachent(locker_context context, locker_attachent *at, |
---|
[12785] | 92 | void *arg) |
---|
[12589] | 93 | { |
---|
[12785] | 94 | return at->fs->zsubs(context, at); |
---|
[12589] | 95 | } |
---|
| 96 | |
---|
[12748] | 97 | static void usage(void) |
---|
[12589] | 98 | { |
---|
| 99 | fprintf(stderr, "Usage: zinit [-a | -m]\n"); |
---|
| 100 | exit(1); |
---|
| 101 | } |
---|