source: trunk/athena/bin/attach/zinit.c @ 12785

Revision 12785, 2.3 KB checked in by danw, 26 years ago (diff)
update for locker_do_zsubs (and a little other misc cleanup)
Line 
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
19static const char rcsid[] = "$Id: zinit.c,v 1.4 1999-03-29 17:35:40 danw Exp $";
20
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24
25#include <locker.h>
26#include "attach.h"
27#include "agetopt.h"
28
29static void usage(void);
30static int zinit_attachent(locker_context context, locker_attachent *at,
31                           void *opp);
32
33static struct agetopt_option zinit_options[] = {
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
42int zinit_main(int argc, char **argv)
43{
44  locker_context context;
45  int opt, all = 0;
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)
79    locker_iterate_attachtab(context, NULL, NULL, zinit_attachent, NULL);
80  else
81    {
82      locker_iterate_attachtab(context, locker_check_owner, &uid,
83                               zinit_attachent, NULL);
84    }
85
86  locker_do_zsubs(context, LOCKER_ZEPHYR_SUBSCRIBE);
87  locker_end(context);
88  return 0;
89}
90
91static int zinit_attachent(locker_context context, locker_attachent *at,
92                           void *arg)
93{
94  return at->fs->zsubs(context, at);
95}
96
97static void usage(void)
98{
99  fprintf(stderr, "Usage: zinit [-a | -m]\n");
100  exit(1);
101}
Note: See TracBrowser for help on using the repository browser.