source: trunk/athena/lib/locker/mul.c @ 12582

Revision 12582, 3.9 KB checked in by danw, 26 years ago (diff)
liblocker, a library for attaching, detaching, and otherwise dealing with lockers
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 file is part of liblocker. It implements some of the code for
17 * MUL lockers. (Most of the code for MUL lockers is special-cased
18 * into attachtab.c, attach.c, and detach.c.)
19 */
20
21static const char rcsid[] = "$Id: mul.c,v 1.1 1999-02-26 19:04:53 danw Exp $";
22
23#include <sys/stat.h>
24#include <ctype.h>
25#include <errno.h>
26#include <stdlib.h>
27#include <string.h>
28#include <unistd.h>
29
30#include "locker.h"
31#include "locker_private.h"
32
33static int mul_parse(locker_context context, char *name, char *desc,
34                     char *mountpoint, locker_attachent **at);
35static int mul_attach(locker_context context, locker_attachent *at,
36                      char *mountoptions);
37static int mul_detach(locker_context context, locker_attachent *at);
38static int mul_auth(locker_context context, locker_attachent *at,
39                    int mode, int op);
40static int mul_zsubs(locker_context context, locker_attachent *at,
41                     int op);
42
43struct locker_ops locker__mul_ops = {
44  "MUL",
45  0,
46  mul_parse,
47  mul_attach,
48  mul_detach,
49  mul_auth,
50  mul_zsubs
51};
52
53static int mul_parse(locker_context context, char *name, char *desc,
54                     char *mountpoint, locker_attachent **atp)
55{
56  int status;
57  char *p, *q, *dup, *lasts = NULL;
58  locker_attachent *at, *attmp;
59
60  if (!name)
61    {
62      locker__error(context, "Cannot explicitly specify MUL locker.\n");
63      return LOCKER_EPARSE;
64    }
65
66  if (mountpoint)
67    {
68      locker__error(context, "%s: Explicit mountpoint is meaningless for "
69                    "MUL locker.\n", name);
70      return LOCKER_EPARSE;
71    }
72
73  at = locker__new_attachent(context, &locker__mul_ops);
74  if (!at)
75    return LOCKER_ENOMEM;
76
77  /* Skip "MUL". (But if this is called from read_attachent, the "MUL"
78   * won't be there.)
79   */
80  if (!strncmp(desc, "MUL ", 4))
81    {
82      p = desc + 4;
83      while (isspace(*p))
84        p++;
85    }
86  else
87    p = desc;
88
89  at->name = strdup(name);
90  at->mountpoint = strdup(p);
91  at->hostdir = strdup("");
92  at->mode = '-';
93  dup = strdup(p);
94  if (!at->name || !at->mountpoint || !at->hostdir || !dup)
95    {
96      locker_free_attachent(context, at);
97      locker__error(context, "Out of memory parsing locker description.\n");
98      return LOCKER_ENOMEM;
99    }
100
101  /* Read list of locker names. */
102  for (p = strtok_r(dup, " ", &lasts); p; p = strtok_r(NULL, " ", &lasts))
103    {
104      status = locker__lookup_attachent(context, p, NULL, 1, &attmp);
105      if (status)
106        break;
107
108      if (attmp->fs == at->fs)
109        {
110          locker__error(context, "%s: Cannot have MUL locker \"%s\" as a "
111                        "component of a MUL locker.\n", at->name,
112                        attmp->name);
113          locker_free_attachent(context, attmp);
114          status = LOCKER_EPARSE;
115          break;
116        }
117
118      attmp->next = at->next;
119      at->next = attmp;
120    }
121
122  free(dup);
123
124  if (status)
125    {
126      for (; at; at = attmp)
127        {
128          attmp = at->next;
129          locker_free_attachent(context, at);
130        }
131    }
132  else
133    *atp = at;
134
135  return status;
136}
137
138static int mul_attach(locker_context context, locker_attachent *at,
139                      char *mountoptions)
140{
141  return LOCKER_SUCCESS;
142}
143
144static int mul_detach(locker_context context, locker_attachent *at)
145{
146  return LOCKER_SUCCESS;
147}
148
149static int mul_auth(locker_context context, locker_attachent *at,
150                    int mode, int op)
151{
152  return LOCKER_SUCCESS;
153}
154
155static int mul_zsubs(locker_context context, locker_attachent *at,
156                     int op)
157{
158  return LOCKER_SUCCESS;
159}
Note: See TracBrowser for help on using the repository browser.