Deleted Added
full compact
rpc.umntall.c (80123) rpc.umntall.c (80146)
1/*
2 * Copyright (c) 1999 Martin Blapp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
1/*
2 * Copyright (c) 1999 Martin Blapp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
30 "$FreeBSD: head/usr.sbin/rpc.umntall/rpc.umntall.c 80123 2001-07-22 01:25:25Z iedowse $";
30 "$FreeBSD: head/usr.sbin/rpc.umntall/rpc.umntall.c 80146 2001-07-22 12:17:51Z iedowse $";
31#endif /* not lint */
32
33#include <sys/param.h>
34#include <sys/ucred.h>
35#include <sys/mount.h>
36
37#include <rpc/rpc.h>
38#include <nfs/rpcv2.h>

--- 10 unchanged lines hidden (view full) ---

49int verbose;
50
51static int do_umount (char *, char *);
52static int do_umntall (char *);
53static int is_mounted (char *, char *);
54static void usage (void);
55int xdr_dir (XDR *, char *);
56
31#endif /* not lint */
32
33#include <sys/param.h>
34#include <sys/ucred.h>
35#include <sys/mount.h>
36
37#include <rpc/rpc.h>
38#include <nfs/rpcv2.h>

--- 10 unchanged lines hidden (view full) ---

49int verbose;
50
51static int do_umount (char *, char *);
52static int do_umntall (char *);
53static int is_mounted (char *, char *);
54static void usage (void);
55int xdr_dir (XDR *, char *);
56
57struct mtablist *mtabhead;
58
59int
60main(int argc, char **argv) {
61 int ch, keep, success, pathlen;
62 time_t expire, now;
63 char *host, *path;
64 struct mtablist *mtab;
65
66 expire = 0;

--- 28 unchanged lines hidden (view full) ---

95 signal(SIGQUIT, SIG_IGN);
96
97 /* Default expiretime is one day */
98 if (expire == 0)
99 expire = 86400;
100 time(&now);
101
102 /* Read PATH_MOUNTTAB. */
57int
58main(int argc, char **argv) {
59 int ch, keep, success, pathlen;
60 time_t expire, now;
61 char *host, *path;
62 struct mtablist *mtab;
63
64 expire = 0;

--- 28 unchanged lines hidden (view full) ---

93 signal(SIGQUIT, SIG_IGN);
94
95 /* Default expiretime is one day */
96 if (expire == 0)
97 expire = 86400;
98 time(&now);
99
100 /* Read PATH_MOUNTTAB. */
103 if (!read_mtab(NULL)) {
101 if (!read_mtab()) {
104 if (verbose)
105 warnx("no mounttab entries (%s does not exist)",
106 PATH_MOUNTTAB);
107 mtabhead = NULL;
108 }
109
110 if (host == NULL && path == NULL) {
111 /* Check each entry and do any necessary unmount RPCs. */

--- 16 unchanged lines hidden (view full) ---

128 mtab->mtab_host, mtab->mtab_dirp);
129 continue;
130 }
131 if (do_umount(mtab->mtab_host, mtab->mtab_dirp)) {
132 if (verbose)
133 warnx("umount RPC for %s:%s succeeded",
134 mtab->mtab_host, mtab->mtab_dirp);
135 /* Remove all entries for this host + path. */
102 if (verbose)
103 warnx("no mounttab entries (%s does not exist)",
104 PATH_MOUNTTAB);
105 mtabhead = NULL;
106 }
107
108 if (host == NULL && path == NULL) {
109 /* Check each entry and do any necessary unmount RPCs. */

--- 16 unchanged lines hidden (view full) ---

126 mtab->mtab_host, mtab->mtab_dirp);
127 continue;
128 }
129 if (do_umount(mtab->mtab_host, mtab->mtab_dirp)) {
130 if (verbose)
131 warnx("umount RPC for %s:%s succeeded",
132 mtab->mtab_host, mtab->mtab_dirp);
133 /* Remove all entries for this host + path. */
136 clean_mtab(mtab->mtab_host, mtab->mtab_dirp);
134 clean_mtab(mtab->mtab_host, mtab->mtab_dirp,
135 verbose);
137 }
138 }
139 success = 1;
140 } else {
141 if (host == NULL && path != NULL)
142 /* Missing hostname. */
143 usage();
144 if (path == NULL) {

--- 8 unchanged lines hidden (view full) ---

153 path[pathlen - 1] = '\0';
154 success = do_umount(host, path);
155 if (verbose && success)
156 warnx("umount RPC for %s:%s succeeded", host,
157 path);
158 }
159 /* If successful, remove any corresponding mounttab entries. */
160 if (success)
136 }
137 }
138 success = 1;
139 } else {
140 if (host == NULL && path != NULL)
141 /* Missing hostname. */
142 usage();
143 if (path == NULL) {

--- 8 unchanged lines hidden (view full) ---

152 path[pathlen - 1] = '\0';
153 success = do_umount(host, path);
154 if (verbose && success)
155 warnx("umount RPC for %s:%s succeeded", host,
156 path);
157 }
158 /* If successful, remove any corresponding mounttab entries. */
159 if (success)
161 clean_mtab(host, path);
160 clean_mtab(host, path, verbose);
162 }
163 /* Write and unlink PATH_MOUNTTAB if necessary */
164 if (success)
161 }
162 /* Write and unlink PATH_MOUNTTAB if necessary */
163 if (success)
165 success = write_mtab();
164 success = write_mtab(verbose);
166 free_mtab();
167 exit (success ? 0 : 1);
168}
169
170/*
171 * Send a RPC_MNT UMNTALL request to hostname.
172 * XXX This works for all mountd implementations,
173 * but produces a RPC IOERR on non FreeBSD systems.

--- 96 unchanged lines hidden ---
165 free_mtab();
166 exit (success ? 0 : 1);
167}
168
169/*
170 * Send a RPC_MNT UMNTALL request to hostname.
171 * XXX This works for all mountd implementations,
172 * but produces a RPC IOERR on non FreeBSD systems.

--- 96 unchanged lines hidden ---