Deleted Added
full compact
umount.c (113220) umount.c (117132)
1/*-
2 * Copyright (c) 1980, 1989, 1993
3 * The Regents of the University of California. 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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95";
43#endif
44static const char rcsid[] =
1/*-
2 * Copyright (c) 1980, 1989, 1993
3 * The Regents of the University of California. 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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/sbin/umount/umount.c 113220 2003-04-07 12:56:01Z mdodd $";
45 "$FreeBSD: head/sbin/umount/umount.c 117132 2003-07-01 17:40:23Z iedowse $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/mount.h>
50#include <sys/socket.h>
51
52#include <netdb.h>
53#include <rpc/rpc.h>
54#include <nfs/rpcv2.h>
55
56#include <err.h>
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/mount.h>
50#include <sys/socket.h>
51
52#include <netdb.h>
53#include <rpc/rpc.h>
54#include <nfs/rpcv2.h>
55
56#include <err.h>
57#include <errno.h>
57#include <fstab.h>
58#include <stdio.h>
59#include <stdlib.h>
60#include <string.h>
61#include <unistd.h>
62
63#include "mounttab.h"
64
65#define ISDOT(x) ((x)[0] == '.' && (x)[1] == '\0')
66#define ISDOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
67
68typedef enum { MNTON, MNTFROM, NOTHING } mntwhat;
69typedef enum { MARK, UNMARK, NAME, COUNT, FREE } dowhat;
70
71struct addrinfo *nfshost_ai = NULL;
72int fflag, vflag;
73char *nfshost;
74
58#include <fstab.h>
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <unistd.h>
63
64#include "mounttab.h"
65
66#define ISDOT(x) ((x)[0] == '.' && (x)[1] == '\0')
67#define ISDOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
68
69typedef enum { MNTON, MNTFROM, NOTHING } mntwhat;
70typedef enum { MARK, UNMARK, NAME, COUNT, FREE } dowhat;
71
72struct addrinfo *nfshost_ai = NULL;
73int fflag, vflag;
74char *nfshost;
75
75void checkmntlist (char *, char **, char **, char **);
76struct statfs *checkmntlist (char *, char **);
76int checkvfsname (const char *, char **);
77int checkvfsname (const char *, char **);
77char *getmntname (const char *, const char *,
78 mntwhat, char **, dowhat);
78struct statfs *getmntentry (const char *, const char *, mntwhat, char **,
79 dowhat);
79char *getrealname(char *, char *resolved_path);
80char **makevfslist (const char *);
81size_t mntinfo (struct statfs **);
82int namematch (struct addrinfo *);
83int sacmp (struct sockaddr *, struct sockaddr *);
84int umountall (char **);
85int checkname (char *, char **);
80char *getrealname(char *, char *resolved_path);
81char **makevfslist (const char *);
82size_t mntinfo (struct statfs **);
83int namematch (struct addrinfo *);
84int sacmp (struct sockaddr *, struct sockaddr *);
85int umountall (char **);
86int checkname (char *, char **);
86int umountfs (char *, char *, char *);
87int umountfs (char *, char *, fsid_t *, char *);
87void usage (void);
88int xdr_dir (XDR *, char *);
89
90int
91main(int argc, char *argv[])
92{
93 int all, errs, ch, mntsize, error;
94 char **typelist = NULL, *mntonname, *mntfromname;
88void usage (void);
89int xdr_dir (XDR *, char *);
90
91int
92main(int argc, char *argv[])
93{
94 int all, errs, ch, mntsize, error;
95 char **typelist = NULL, *mntonname, *mntfromname;
95 char *type, *mntfromnamerev, *mntonnamerev;
96 struct statfs *mntbuf;
96 char *type;
97 struct statfs *mntbuf, *sfsrev;
97 struct addrinfo hints;
98
99 /* Start disks transferring immediately. */
100 sync();
101
102 all = errs = 0;
103 while ((ch = getopt(argc, argv, "AaF:fh:t:v")) != -1)
104 switch (ch) {

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

161 continue;
162 /*
163 * Check if a mountpoint is laid over by another mount.
164 * A warning will be printed to stderr if this is
165 * the case. The laid over mount remains unmounted.
166 */
167 mntonname = mntbuf[mntsize].f_mntonname;
168 mntfromname = mntbuf[mntsize].f_mntfromname;
98 struct addrinfo hints;
99
100 /* Start disks transferring immediately. */
101 sync();
102
103 all = errs = 0;
104 while ((ch = getopt(argc, argv, "AaF:fh:t:v")) != -1)
105 switch (ch) {

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

162 continue;
163 /*
164 * Check if a mountpoint is laid over by another mount.
165 * A warning will be printed to stderr if this is
166 * the case. The laid over mount remains unmounted.
167 */
168 mntonname = mntbuf[mntsize].f_mntonname;
169 mntfromname = mntbuf[mntsize].f_mntfromname;
169 mntonnamerev = getmntname(getmntname(mntonname,
170 NULL, MNTFROM, &type, NAME), NULL,
171 MNTON, &type, NAME);
172
170
173 mntfromnamerev = getmntname(mntonnamerev,
174 NULL, MNTFROM, &type, NAME);
171 sfsrev = getmntentry(mntonname, NULL, MNTON, &type,
172 NAME);
175
173
176 if (strcmp(mntonnamerev, mntonname) == 0 &&
177 strcmp(mntfromnamerev, mntfromname ) != 0)
174 if (!fflag && bcmp(&sfsrev->f_fsid,
175 &mntbuf[mntsize].f_fsid, sizeof(fsid_t)) != 0) {
178 warnx("cannot umount %s, %s\n "
179 "is mounted there, umount it first",
176 warnx("cannot umount %s, %s\n "
177 "is mounted there, umount it first",
180 mntonname, mntfromnamerev);
178 mntonname, sfsrev->f_mntfromname);
179 }
181
182 if (checkname(mntbuf[mntsize].f_mntonname,
183 typelist) != 0)
184 errs = 1;
185 }
186 free(mntbuf);
187 break;
188 case 1:
189 if (setfsent() == 0)
190 err(1, "%s", getfstab());
191 errs = umountall(typelist);
192 break;
193 case 0:
194 for (errs = 0; *argv != NULL; ++argv)
195 if (checkname(*argv, typelist) != 0)
196 errs = 1;
197 break;
198 }
180
181 if (checkname(mntbuf[mntsize].f_mntonname,
182 typelist) != 0)
183 errs = 1;
184 }
185 free(mntbuf);
186 break;
187 case 1:
188 if (setfsent() == 0)
189 err(1, "%s", getfstab());
190 errs = umountall(typelist);
191 break;
192 case 0:
193 for (errs = 0; *argv != NULL; ++argv)
194 if (checkname(*argv, typelist) != 0)
195 errs = 1;
196 break;
197 }
199 (void)getmntname(NULL, NULL, NOTHING, NULL, FREE);
198 (void)getmntentry(NULL, NULL, NOTHING, NULL, FREE);
200 exit(errs);
201}
202
203int
204umountall(char **typelist)
205{
206 struct xvfsconf vfc;
207 struct fstab *fs;

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

253 * Do magic checks on mountpoint and device or hand over
254 * it to unmount(2) if everything fails.
255 */
256int
257checkname(char *name, char **typelist)
258{
259 size_t len;
260 int speclen;
199 exit(errs);
200}
201
202int
203umountall(char **typelist)
204{
205 struct xvfsconf vfc;
206 struct fstab *fs;

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

252 * Do magic checks on mountpoint and device or hand over
253 * it to unmount(2) if everything fails.
254 */
255int
256checkname(char *name, char **typelist)
257{
258 size_t len;
259 int speclen;
261 char *mntonname, *mntfromname;
262 char *mntfromnamerev;
263 char *resolved, realname[MAXPATHLEN];
264 char *type, *hostp, *delimp, *origname;
260 char *resolved, realname[MAXPATHLEN];
261 char *type, *hostp, *delimp, *origname;
262 struct statfs *sfs, *sfsrev;
265
266 len = 0;
263
264 len = 0;
267 mntfromname = mntonname = delimp = hostp = NULL;
265 delimp = hostp = NULL;
266 sfs = NULL;
268
269 /*
270 * 1. Check if the name exists in the mounttable.
271 */
267
268 /*
269 * 1. Check if the name exists in the mounttable.
270 */
272 (void)checkmntlist(name, &mntfromname, &mntonname, &type);
271 sfs = checkmntlist(name, &type);
273 /*
274 * 2. Remove trailing slashes if there are any. After that
275 * we look up the name in the mounttable again.
276 */
272 /*
273 * 2. Remove trailing slashes if there are any. After that
274 * we look up the name in the mounttable again.
275 */
277 if (mntfromname == NULL && mntonname == NULL) {
276 if (sfs == NULL) {
278 speclen = strlen(name);
279 for (speclen = strlen(name);
280 speclen > 1 && name[speclen - 1] == '/';
281 speclen--)
282 name[speclen - 1] = '\0';
277 speclen = strlen(name);
278 for (speclen = strlen(name);
279 speclen > 1 && name[speclen - 1] == '/';
280 speclen--)
281 name[speclen - 1] = '\0';
283 (void)checkmntlist(name, &mntfromname, &mntonname, &type);
282 sfs = checkmntlist(name, &type);
284 resolved = name;
285 /* Save off original name in origname */
286 if ((origname = strdup(name)) == NULL)
287 err(1, "strdup");
288 /*
289 * 3. Check if the deprecated nfs-syntax with an '@'
290 * has been used and translate it to the ':' syntax.
291 * Look up the name in the mounttable again.
292 */
283 resolved = name;
284 /* Save off original name in origname */
285 if ((origname = strdup(name)) == NULL)
286 err(1, "strdup");
287 /*
288 * 3. Check if the deprecated nfs-syntax with an '@'
289 * has been used and translate it to the ':' syntax.
290 * Look up the name in the mounttable again.
291 */
293 if (mntfromname == NULL && mntonname == NULL) {
292 if (sfs == NULL) {
294 if ((delimp = strrchr(name, '@')) != NULL) {
295 hostp = delimp + 1;
296 if (*hostp != '\0') {
297 /*
298 * Make both '@' and ':'
299 * notations equal
300 */
301 char *host = strdup(hostp);

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

308 memmove(name, host, len);
309 free(host);
310 }
311 for (speclen = strlen(name);
312 speclen > 1 && name[speclen - 1] == '/';
313 speclen--)
314 name[speclen - 1] = '\0';
315 name[len + speclen + 1] = '\0';
293 if ((delimp = strrchr(name, '@')) != NULL) {
294 hostp = delimp + 1;
295 if (*hostp != '\0') {
296 /*
297 * Make both '@' and ':'
298 * notations equal
299 */
300 char *host = strdup(hostp);

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

307 memmove(name, host, len);
308 free(host);
309 }
310 for (speclen = strlen(name);
311 speclen > 1 && name[speclen - 1] == '/';
312 speclen--)
313 name[speclen - 1] = '\0';
314 name[len + speclen + 1] = '\0';
316 (void)checkmntlist(name, &mntfromname,
317 &mntonname, &type);
315 sfs = checkmntlist(name, &type);
318 resolved = name;
319 }
320 /*
321 * 4. Check if a relative mountpoint has been
322 * specified. This should happen as last check,
323 * the order is important. To prevent possible
324 * nfs-hangs, we just call realpath(3) on the
325 * basedir of mountpoint and add the dirname again.
326 * Check the name in mounttable one last time.
327 */
316 resolved = name;
317 }
318 /*
319 * 4. Check if a relative mountpoint has been
320 * specified. This should happen as last check,
321 * the order is important. To prevent possible
322 * nfs-hangs, we just call realpath(3) on the
323 * basedir of mountpoint and add the dirname again.
324 * Check the name in mounttable one last time.
325 */
328 if (mntfromname == NULL && mntonname == NULL) {
326 if (sfs == NULL) {
329 (void)strcpy(name, origname);
330 if ((getrealname(name, realname)) != NULL) {
327 (void)strcpy(name, origname);
328 if ((getrealname(name, realname)) != NULL) {
331 (void)checkmntlist(realname,
332 &mntfromname, &mntonname, &type);
329 sfs = checkmntlist(realname, &type);
333 resolved = realname;
334 }
335 /*
336 * 5. All tests failed, just hand over the
337 * mountpoint to the kernel, maybe the statfs
338 * structure has been truncated or is not
339 * useful anymore because of a chroot(2).
340 * Please note that nfs will not be able to
341 * notify the nfs-server about unmounting.
342 * These things can change in future when the
343 * fstat structure get's more reliable,
344 * but at the moment we cannot thrust it.
345 */
330 resolved = realname;
331 }
332 /*
333 * 5. All tests failed, just hand over the
334 * mountpoint to the kernel, maybe the statfs
335 * structure has been truncated or is not
336 * useful anymore because of a chroot(2).
337 * Please note that nfs will not be able to
338 * notify the nfs-server about unmounting.
339 * These things can change in future when the
340 * fstat structure get's more reliable,
341 * but at the moment we cannot thrust it.
342 */
346 if (mntfromname == NULL && mntonname == NULL) {
343 if (sfs == NULL) {
347 (void)strcpy(name, origname);
344 (void)strcpy(name, origname);
348 if (umountfs(NULL, origname,
345 if (umountfs(NULL, origname, NULL,
349 "none") == 0) {;
350 warnx("%s not found in "
351 "mount table, "
352 "unmounted it anyway",
353 origname);
354 free(origname);
355 return (0);
356 } else

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

365
366 if (checkvfsname(type, typelist))
367 return (1);
368
369 /*
370 * Check if the reverse entrys of the mounttable are really the
371 * same as the normal ones.
372 */
346 "none") == 0) {;
347 warnx("%s not found in "
348 "mount table, "
349 "unmounted it anyway",
350 origname);
351 free(origname);
352 return (0);
353 } else

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

362
363 if (checkvfsname(type, typelist))
364 return (1);
365
366 /*
367 * Check if the reverse entrys of the mounttable are really the
368 * same as the normal ones.
369 */
373 if ((mntfromnamerev = strdup(getmntname(getmntname(mntfromname,
374 NULL, MNTON, &type, NAME), NULL, MNTFROM, &type, NAME))) == NULL)
375 err(1, "strdup");
370 sfsrev = getmntentry(sfs->f_mntonname, NULL, MNTON, &type, NAME);
376 /*
377 * Mark the uppermost mount as unmounted.
378 */
371 /*
372 * Mark the uppermost mount as unmounted.
373 */
379 (void)getmntname(mntfromname, mntonname, NOTHING, &type, MARK);
374 (void)getmntentry(sfs->f_mntfromname, sfs->f_mntonname, NOTHING, &type,
375 MARK);
380 /*
381 * If several equal mounts are in the mounttable, check the order
382 * and warn the user if necessary.
383 */
376 /*
377 * If several equal mounts are in the mounttable, check the order
378 * and warn the user if necessary.
379 */
384 if (strcmp(mntfromnamerev, mntfromname ) != 0 &&
385 strcmp(resolved, mntonname) != 0) {
380 if (fflag != MNT_FORCE && sfsrev != sfs) {
386 warnx("cannot umount %s, %s\n "
387 "is mounted there, umount it first",
381 warnx("cannot umount %s, %s\n "
382 "is mounted there, umount it first",
388 mntonname, mntfromnamerev);
383 sfs->f_mntonname, sfsrev->f_mntfromname);
389
384
390 /* call getmntname again to set mntcheck[i] to 0 */
391 (void)getmntname(mntfromname, mntonname,
385 /* call getmntentry again to set mntcheck[i] to 0 */
386 (void)getmntentry(sfs->f_mntfromname, sfs->f_mntonname,
392 NOTHING, &type, UNMARK);
393 return (1);
394 }
387 NOTHING, &type, UNMARK);
388 return (1);
389 }
395 free(mntfromnamerev);
396 return (umountfs(mntfromname, mntonname, type));
390 return (umountfs(sfs->f_mntfromname, sfs->f_mntonname, &sfs->f_fsid,
391 type));
397}
398
399/*
400 * NFS stuff and unmount(2) call
401 */
402int
392}
393
394/*
395 * NFS stuff and unmount(2) call
396 */
397int
403umountfs(char *mntfromname, char *mntonname, char *type)
398umountfs(char *mntfromname, char *mntonname, fsid_t *fsid, char *type)
404{
399{
400 char fsidbuf[64];
405 enum clnt_stat clnt_stat;
406 struct timeval try;
407 struct addrinfo *ai, hints;
408 int do_rpc;
409 CLIENT *clp;
410 char *nfsdirname, *orignfsdirname;
411 char *hostp, *delimp;
412

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

434 * Check if we have to start the rpc-call later.
435 * If there are still identical nfs-names mounted,
436 * we skip the rpc-call. Obviously this has to
437 * happen before unmount(2), but it should happen
438 * after the previous namecheck.
439 * A non-NULL return means that this is the last
440 * mount from mntfromname that is still mounted.
441 */
401 enum clnt_stat clnt_stat;
402 struct timeval try;
403 struct addrinfo *ai, hints;
404 int do_rpc;
405 CLIENT *clp;
406 char *nfsdirname, *orignfsdirname;
407 char *hostp, *delimp;
408

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

430 * Check if we have to start the rpc-call later.
431 * If there are still identical nfs-names mounted,
432 * we skip the rpc-call. Obviously this has to
433 * happen before unmount(2), but it should happen
434 * after the previous namecheck.
435 * A non-NULL return means that this is the last
436 * mount from mntfromname that is still mounted.
437 */
442 if (getmntname(mntfromname, NULL, NOTHING, &type, COUNT)
443 != NULL)
438 if (getmntentry(mntfromname, NULL, NOTHING, &type, COUNT)
439 != NULL)
444 do_rpc = 1;
445 }
446
447 if (!namematch(ai))
448 return (1);
440 do_rpc = 1;
441 }
442
443 if (!namematch(ai))
444 return (1);
449 if (unmount(mntonname, fflag) != 0 ) {
445 /* First try to unmount using the specified file system ID. */
446 if (fsid != NULL) {
447 snprintf(fsidbuf, sizeof(fsidbuf), "FSID:%d:%d", fsid->val[0],
448 fsid->val[1]);
449 if (unmount(fsidbuf, fflag | MNT_BYFSID) != 0) {
450 warn("unmount of %s failed", mntonname);
451 if (errno != ENOENT)
452 return (1);
453 /* Compatability for old kernels. */
454 warnx("retrying using path instead of file system ID");
455 fsid = NULL;
456 }
457 }
458 if (fsid == NULL && unmount(mntonname, fflag) != 0) {
450 warn("unmount of %s failed", mntonname);
451 return (1);
452 }
453 if (vflag)
454 (void)printf("%s: unmount from %s\n", mntfromname, mntonname);
455 /*
456 * Report to mountd-server which nfsname
457 * has been unmounted.

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

485 }
486 free(orignfsdirname);
487 auth_destroy(clp->cl_auth);
488 clnt_destroy(clp);
489 }
490 return (0);
491}
492
459 warn("unmount of %s failed", mntonname);
460 return (1);
461 }
462 if (vflag)
463 (void)printf("%s: unmount from %s\n", mntfromname, mntonname);
464 /*
465 * Report to mountd-server which nfsname
466 * has been unmounted.

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

494 }
495 free(orignfsdirname);
496 auth_destroy(clp->cl_auth);
497 clnt_destroy(clp);
498 }
499 return (0);
500}
501
493char *
494getmntname(const char *fromname, const char *onname,
495 mntwhat what, char **type, dowhat mark)
502struct statfs *
503getmntentry(const char *fromname, const char *onname, mntwhat what,
504 char **type, dowhat mark)
496{
497 static struct statfs *mntbuf;
498 static size_t mntsize = 0;
499 static char *mntcheck = NULL;
500 static char *mntcount = NULL;
501 int i, count;
502
503 if (mntsize <= 0) {

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

518 * attention to the order, it can happen that an overlaying
519 * file system gets unmounted instead of the one the user
520 * has choosen.
521 */
522 switch (mark) {
523 case NAME:
524 /* Return only the specific name */
525 for (i = mntsize - 1; i >= 0; i--) {
505{
506 static struct statfs *mntbuf;
507 static size_t mntsize = 0;
508 static char *mntcheck = NULL;
509 static char *mntcount = NULL;
510 int i, count;
511
512 if (mntsize <= 0) {

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

527 * attention to the order, it can happen that an overlaying
528 * file system gets unmounted instead of the one the user
529 * has choosen.
530 */
531 switch (mark) {
532 case NAME:
533 /* Return only the specific name */
534 for (i = mntsize - 1; i >= 0; i--) {
526 if (fromname != NULL && what == MNTON &&
527 !strcmp(mntbuf[i].f_mntfromname, fromname) &&
528 mntcheck[i] != 1) {
535 if (fromname != NULL && !strcmp((what == MNTFROM) ?
536 mntbuf[i].f_mntfromname : mntbuf[i].f_mntonname,
537 fromname) && mntcheck[i] != 1) {
529 if (type)
530 *type = mntbuf[i].f_fstypename;
538 if (type)
539 *type = mntbuf[i].f_fstypename;
531 return (mntbuf[i].f_mntonname);
540 return (&mntbuf[i]);
532 }
541 }
533 if (fromname != NULL && what == MNTFROM &&
534 !strcmp(mntbuf[i].f_mntonname, fromname) &&
535 mntcheck[i] != 1) {
536 if (type)
537 *type = mntbuf[i].f_fstypename;
538 return (mntbuf[i].f_mntfromname);
539 }
540 }
542 }
543
541 return (NULL);
542 case MARK:
543 /* Mark current mount with '1' and return name */
544 for (i = mntsize - 1; i >= 0; i--) {
545 if (mntcheck[i] == 0 &&
546 (strcmp(mntbuf[i].f_mntonname, onname) == 0) &&
547 (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)) {
548 mntcheck[i] = 1;
544 return (NULL);
545 case MARK:
546 /* Mark current mount with '1' and return name */
547 for (i = mntsize - 1; i >= 0; i--) {
548 if (mntcheck[i] == 0 &&
549 (strcmp(mntbuf[i].f_mntonname, onname) == 0) &&
550 (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)) {
551 mntcheck[i] = 1;
549 return (mntbuf[i].f_mntonname);
552 return (&mntbuf[i]);
550 }
551 }
552 return (NULL);
553 case UNMARK:
554 /* Unmark current mount with '0' and return name */
555 for (i = 0; i < mntsize; i++) {
556 if (mntcheck[i] == 1 &&
557 (strcmp(mntbuf[i].f_mntonname, onname) == 0) &&
558 (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)) {
559 mntcheck[i] = 0;
553 }
554 }
555 return (NULL);
556 case UNMARK:
557 /* Unmark current mount with '0' and return name */
558 for (i = 0; i < mntsize; i++) {
559 if (mntcheck[i] == 1 &&
560 (strcmp(mntbuf[i].f_mntonname, onname) == 0) &&
561 (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)) {
562 mntcheck[i] = 0;
560 return (mntbuf[i].f_mntonname);
563 return (&mntbuf[i]);
561 }
562 }
563 return (NULL);
564 case COUNT:
565 /* Count the equal mntfromnames */
566 count = 0;
567 for (i = mntsize - 1; i >= 0; i--) {
568 if (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)

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

577 count--;
578 else {
579 mntcount[i] = 1;
580 break;
581 }
582 }
583 }
584 if (count <= 1)
564 }
565 }
566 return (NULL);
567 case COUNT:
568 /* Count the equal mntfromnames */
569 count = 0;
570 for (i = mntsize - 1; i >= 0; i--) {
571 if (strcmp(mntbuf[i].f_mntfromname, fromname) == 0)

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

580 count--;
581 else {
582 mntcount[i] = 1;
583 break;
584 }
585 }
586 }
587 if (count <= 1)
585 return (mntbuf[i].f_mntonname);
588 return (&mntbuf[i]);
586 else
587 return (NULL);
588 case FREE:
589 free(mntbuf);
590 free(mntcheck);
591 free(mntcount);
592 return (NULL);
593 default:

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

641 aip = aip->ai_next;
642 }
643 ai = ai->ai_next;
644 }
645
646 return (0);
647}
648
589 else
590 return (NULL);
591 case FREE:
592 free(mntbuf);
593 free(mntcheck);
594 free(mntcount);
595 return (NULL);
596 default:

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

644 aip = aip->ai_next;
645 }
646 ai = ai->ai_next;
647 }
648
649 return (0);
650}
651
649void
650checkmntlist(char *name, char **fromname, char **onname, char **type)
652struct statfs *
653checkmntlist(char *name, char **type)
651{
654{
655 struct statfs *sfs;
652
656
653 *fromname = getmntname(name, NULL, MNTFROM, type, NAME);
654 if (*fromname == NULL) {
655 *onname = getmntname(name, NULL, MNTON, type, NAME);
656 if (*onname != NULL)
657 *fromname = name;
658 } else
659 *onname = name;
657 sfs = getmntentry(name, NULL, MNTON, type, NAME);
658 if (sfs == NULL)
659 sfs = getmntentry(name, NULL, MNTFROM, type, NAME);
660 return (sfs);
660}
661
662size_t
663mntinfo(struct statfs **mntbuf)
664{
665 static struct statfs *origbuf;
666 size_t bufsize;
667 int mntsize;

--- 92 unchanged lines hidden ---
661}
662
663size_t
664mntinfo(struct statfs **mntbuf)
665{
666 static struct statfs *origbuf;
667 size_t bufsize;
668 int mntsize;

--- 92 unchanged lines hidden ---