/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* nfs umount
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <signal.h>
#include <unistd.h>
#include <kstat.h>
#include <nfs/nfs_clnt.h>
#include <errno.h>
#include <locale.h>
#include <fslib.h>
#include <priv.h>
#include "replica.h"
#define RET_OK 0
#ifdef __STDC__
#else
#endif
static void usage();
static int nfs_unmount(char *, int);
static void inform_server(char *, char *, bool_t);
static struct extmnttab *mnttab_find();
extern int __clnt_bindresvport(CLIENT *);
static int is_v4_mount(struct extmnttab *);
static char *myname;
int
{
extern int optind;
int c;
int umnt_flag = 0;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
/*
* Set options
*/
switch (c) {
case 'f':
break;
default:
usage();
}
}
usage();
}
if (!priv_ineffect(PRIV_SYS_MOUNT) ||
}
/*
* On a labeled system, a MAC flag may be needed if the mount is
* read-down, so attempt to assert it but ignore errors in any case.
*/
if (is_system_labeled())
/*
* exit, really
*/
}
static void
{
}
static void
usage()
{
gettext("Usage: nfs umount [-f] {server:path | dir}\n"));
}
static int
{
if (mntp) {
}
if (mntp)
/* Forced unmount will almost always be successful */
} else {
}
return (RET_ERR);
}
/* All done if it's v4 */
return (RET_OK);
/* Inform server quickly in case of forced unmount */
if (mntp) {
}
return (RET_OK);
}
/*
* Find the mnttab entry that corresponds to "name".
* We're not sure what the name represents: either
* a mountpoint name, or a special name (server:/path).
* Return the last entry in the file that matches.
*/
static struct extmnttab *
char *dirname;
{
return (NULL);
}
if (res)
}
}
return (res);
}
/*
* If quick is TRUE, it will try to inform server quickly
* as possible.
*/
static void
{
int i, n;
char *p = NULL;
if (n < 0)
string);
else
return;
}
/*
* If mounted with -o public, then no need to contact server
* because mount protocol was not used.
*/
if (p != NULL) {
i = strlen(MNTOPT_PUBLIC);
/*
* Now make sure the match of "public" isn't a substring
* of another option.
*/
((p[i] == ',') || (p[i] == '\0')))
return;
}
for (i = 0; i < n; i++) {
int vers;
/*
* Skip file systems mounted using WebNFS, because mount
* protocol was not used.
*/
"//", 2) == 0)
continue;
/*
* Use 5 sec. timeout if file system is forced unmounted,
* otherwise use default timeout to create a client handle.
* This would minimize the time to force unmount a file
* system reside on a server that is down.
*/
"datagram_n", timep);
/*
* Do not print any error messages in case of forced
* unmount.
*/
if (!quick)
"server not responding"));
continue;
}
/*
* Now it is most likely that the NFS client will be able
* to contact the server since rpcbind is running on
* the server. There is still a small window in which
* server can be unreachable.
*/
if (__clnt_bindresvport(cl) < 0) {
if (!quick)
"couldn't bind to reserved port\n"));
return;
}
if (!quick)
"couldn't create authsys structure\n"));
return;
}
timeout);
/*
* The rare case of a v3-only server
*/
vers = MOUNTVERS3;
goto retry;
}
if (rpc_stat != RPC_SUCCESS)
}
free_replica(list, n);
}
/*
* This function's behavior is taken from nfsstat.
* Trying to determine what NFS version was used for the mount.
*/
int
{
return (FALSE);
return (FALSE);
continue;
continue;
continue;
continue;
continue;
return (TRUE);
else
return (FALSE);
}
return (FALSE);
}