umount.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/*
* -----------------------------------------------------------------
*
* umount.c
*
* CFS specific umount command.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <wait.h>
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <fslib.h>
#include "../common/cachefsd.h"
/* forward references */
int daemon_unmount(char *mntptp, int);
/*
*
* main
*
* Description:
* Main routine for the cfs umount program.
* Arguments:
* argc number of command line arguments
* argv list of command line arguments
* Returns:
* Returns 0 for success or 1 if an error occurs.
* Preconditions:
*/
int
{
char *strp;
int xx;
int ret;
char *p, mnt_frontns[PATH_MAX];
int stat_loc;
char *cachedirp, *s;
int ufd, c;
int flag = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
/*
* Set options
*/
switch (c) {
case 'f':
break;
default:
usage("Incorrect number of arguments specified");
return (1);
}
}
else
mnt_back[0] = '\0';
return (1);
}
/*
* An unmount from autofs may have a
* space appended to the path.
* Trim it off before attempting to
* match the mountpoint in mnttab
*/
if (*p == ' ')
*p = '\0';
/* get the mount point and the back file system mount point */
if (finp) {
/*
* AutoClient mounts do not have .cfs_mnt_points string in
* them, so strstr would return NULL. So .cfs_unmnt file
* is not updated.
*/
xx = -1;
0600)) > 0) {
}
if (xx < 0)
}
if (ret != -1) {
if (mget.mnt_special)
} else {
if (ret != -1) {
if (mget.mnt_special)
} else {
}
}
}
/* try to get the daemon to unmount this file system for us */
return (1);
return (1);
}
/* try to unmount the file system directly */
return (1);
}
}
/* if we do not know the name of the back file system mount point */
if (mnt_back[0] == '\0') {
/* all done */
return (0);
}
/*
* If the back file system was mounted on a directory with a
* parent name of BACKMNT_NAME then we assume that we
* mounted it and that it is okay to try to umount it.
*/
return (0);
/* if no back file system mounted */
return (0);
/* fork */
return (1);
}
/* if the child */
if (pid == 0) {
/* invoke the umount command on the back file system */
}
/* else if the parent */
else {
/* wait for the child to exit */
return (1);
}
return (1);
}
if (xx) {
return (xx);
}
}
/* delete the back file system mount point since we created it */
return (xx);
}
/*
*
* pr_err
*
* Description:
* Prints an error message to stderr.
* Arguments:
* fmt printf style format
* ... arguments for fmt
* Returns:
* Preconditions:
* precond(fmt)
*/
void
{
}
/*
*
* usage
*
* Description:
* Prints a usage message.
* Arguments:
* An optional additional message to be displayed.
* Returns:
* Preconditions:
*/
void
{
if (msgp)
}
/*
*
* daemon_unmount
*
* Description:
* Notifies the cachefsd of an unmount request.
* Arguments:
* Mount point to unmount.
* Returns:
* Returns 0 if the cachefsd unmounted the file system
* EIO if should try unmount directly
* EBUSY if did not unmount because busy
* EAGAIN if umounted but should not unmount nfs mount
*
* Preconditions:
* precond(mntptp)
*/
int
{
int xx;
int result;
char *hostp;
struct cachefsd_fs_unmounted uargs;
/* get the host name */
if (xx == -1) {
return (EIO);
}
/* creat the connection to the daemon */
return (EIO);
}
if (retval != RPC_SUCCESS) {
return (EIO);
}
return (result);
}