/*
*      SCCS:   @(#)install/userintf/gen_nfsmnt	1.1 (01/21/97)  VSXgen release 1.4
*
*	UniSoft Ltd., London, England
*/
/***********************************************************************

NAME:		gen_nfsmnt - user-modifiable NFS mount/unmount routines
PROJECT:	VSX (X/OPEN Validation Suite)
AUTHOR:		Geoff Clare, UniSoft Ltd.
DATE CREATED:	December 1996
MODIFICATIONS:

************************************************************************/

/*
 *	Usr_mount() mounts the NFS file system specified by "fsys" from
 *	the system specified by "server" on the directory "dir" with
 *	options specified by "flags".
 *	It returns 0 for success, non-zero for failure.
 */

public int
usr_mount(server, fsys, dir, flags)
char *server, *fsys, *dir;
int flags;
{
	char cmd[512];
	char *p;
	int rc;

	/* construct a mount command */

	p = cmd;
	(void) sprintf(p, "mount");
	p += strlen(p);

	/* add read-only option if required */

	if (flags & XNFS_MOUNT_RO)
	{
		(void) sprintf(p, " -r");
		p += strlen(p);
	}

	/* add "-o" options required */

	/* keep mount in the foreground, turn off attribute caching */
	(void) sprintf(p, " -o fg,noac");
	p += strlen(p);

	/* SetUID= and RetrySemantics= attributes */
	(void) sprintf(p, ",%s,%s",
		flags & XNFS_MOUNT_SETUID ? "suid" : "nosuid",
		flags & XNFS_MOUNT_SOFT ? "soft" : "hard");
	p += strlen(p);

	/* GrpID= attribute */
	if (flags & XNFS_MOUNT_GRPID)
	{
		(void) sprintf(p, ",grpid");
		p += strlen(p);
	}

	/* Intr= attribute */
	if (flags & XNFS_MOUNT_INTR)
	{
		(void) sprintf(p, ",intr");
		p += strlen(p);
	}

	/* add the server name, file system and mount directory */

	(void) sprintf(p, " %s:%s %s", server, fsys, dir);

	rc = system(cmd);

	return rc;
}

/*
 *	Usr_unmount() unmounts the NFS file system specified by "fsys"
 *	currently mounted from the system specified by "server" on the
 *	directory "dir".
 *	It returns 0 for success, non-zero for failure.
 */

/* ARGSUSED */
public int
usr_unmount(server, fsys, dir)
char *server, *fsys, *dir;
{
	char cmd[512];
	int rc;

	/* construct a umount command */

	(void) sprintf(cmd, "umount %s:%s", server, fsys);

	rc = system(cmd);

	return rc;
}

