/*
 *	sgethost.c -- library interfaces for shared FS operations
 * related to failover.
 *
 */

/*
 *    SAM-QFS_notice_begin
 *
 *      Solaris 2.x Sun Storage & Archiving Management File System
 *
 *		Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
 *
 *		U.S. Government Rights - Commercial software. Government users are
 *	subject to the Sun Microsystems, Inc. standard license agreement and applicable
 *	provisions of the FAR and its supplements.
 *
 *      	Use is subject to license terms. Sun, Sun Microsystems and the Sun logo
 *	are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S.
 *	and other countries.
 *
 *    SAM-QFS_notice_end
 */

/*
 *	LGPL NOTICE
 *
 *	This library is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU Lesser General Public
 *	License as published by the Free Software Foundation; either
 *	version 2.1 of the License, or (at your option) any later version.
 *
 *	This library is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *	Lesser General Public License for more details.
 *
 *	You should have received a copy of the GNU Lesser General Public
 *	License along with this library; if not, write to the Free Software
 *	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#pragma ident "$Revision$"

/* Feature test switches. */
	/* None. */

/* ANSI C headers. */
#include <string.h>

/* POSIX headers. */
#include <sys/types.h>

/* Solaris headers. */

/* SAM-FS headers. */
#include <sam/types.h>
#include <sam/syscall.h>
#include <sam/lib.h>

/* Local headers. */
	/* None. */

/* Macros. */
	/* None. */

/* Types. */
	/* None. */

/* Structures. */
	/* None. */

/* Private data. */
	/* None. */

/* Private functions. */
	/* None. */

/* Public data. */
	/* None. */

/* Function macros. */
	/* None. */

int
sam_gethost(const char *fs, int len, char *tab)
{
	int err;
	struct sam_sgethosts_arg arg;

	memset(&arg, 0, sizeof (arg));

	strncpy((char *)&arg.fsname, fs, sizeof (arg.fsname));
	arg.size = len;
	arg.hosts.ptr = tab;

	err = sam_syscall(SC_gethosts, &arg, sizeof (arg));
	return (err);
}


int
sam_sethost(const char *fs, int newserver, int len, const char *tab)
{
	int err;
	struct sam_sgethosts_arg arg;

	memset(&arg, 0, sizeof (arg));

	strncpy((char *)&arg.fsname, fs, sizeof (arg.fsname));
	arg.newserver = newserver;
	arg.size = len;
	arg.hosts.ptr = tab;

	err = sam_syscall(SC_sethosts, &arg, sizeof (arg));
	return (err);
}


int
sam_shareops(const char *fs, int op, int host)
{
	int err;
	struct sam_shareops_arg arg;

	memset(&arg, 0, sizeof (arg));

	strncpy((char *)&arg.fsname, fs, sizeof (arg.fsname));
	arg.op = op;
	arg.host = host;

	err = sam_syscall(SC_shareops, &arg, sizeof (arg));
	return (err);
}
