/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* BSD 3 Clause License
*
* Copyright (c) 2007, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* - Neither the name of The Storage Networking Industry Association (SNIA)
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <locale.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <fcntl.h>
#include <door.h>
#include <thread.h>
#include <ndmpd_door.h>
#include <libndmp.h>
static char *buf;
static int ndmp_door_setup(int opcode);
static int ndmp_door_call(void);
static int ndmp_door_fini(void);
/* ndmp library APIs */
int
{
int i;
(void) mutex_lock(&ndmp_lock);
if (ndmp_door_setup(opcode))
goto err;
if (ndmp_door_call())
goto err;
/* get the number of devices available */
if (!*dip) {
goto err;
}
}
if (ndmp_door_fini()) {
goto err;
}
(void) mutex_unlock(&ndmp_lock);
return (0);
err:
(void) mutex_unlock(&ndmp_lock);
return (-1);
}
void
{
int i;
}
}
int
{
int ret;
(void) mutex_lock(&ndmp_lock);
if (ndmp_door_setup(opcode))
goto err;
if (ndmp_door_call())
goto err;
if (ndmp_door_fini())
goto err;
(void) mutex_unlock(&ndmp_lock);
return (ret);
err:
(void) mutex_unlock(&ndmp_lock);
return (-1);
}
int
{
int status;
int i, j;
(void) mutex_lock(&ndmp_lock);
if (ndmp_door_setup(opcode))
goto err;
if (ndmp_door_call())
goto err;
/* number of sessions */
if (!*sinfo) {
goto err;
}
if (status == NDMP_SESSION_NODATA)
continue;
/* connection common info */
/*
* scsi and tape data are same for all version,
* so keep reading
*/
/* connection common scsi info. */
}
/* connection common tape info. */
}
}
/* connection common data info */
goto err;
}
}
/* Read V2 data info */
malloc(sizeof (ndmp_dt_name_t) *
goto err;
}
}
malloc(sizeof (ndmp_dt_name_v3_t) *
goto err;
}
j++, npv3++) {
npv3->nn3_fh_info =
}
}
}
if (ndmp_door_fini())
goto err;
(void) mutex_unlock(&ndmp_lock);
return (0);
err:
(void) mutex_unlock(&ndmp_lock);
return (-1);
}
void
{
int i, j;
}
}
}
j++, npv3++) {
}
}
}
}
/* ARGSUSED */
int
{
(void) mutex_lock(&ndmp_lock);
if (!statp) {
goto err;
}
if (ndmp_door_setup(opcode))
goto err;
if (ndmp_door_call())
goto err;
if (ndmp_door_fini())
goto err;
(void) mutex_unlock(&ndmp_lock);
return (0);
err:
(void) mutex_unlock(&ndmp_lock);
return (-1);
}
int
ndmp_door_status(void)
{
(void) mutex_lock(&ndmp_lock);
if (ndmp_door_setup(opcode))
goto err;
if (ndmp_door_call())
goto err;
if (ndmp_door_fini())
goto err;
(void) mutex_unlock(&ndmp_lock);
return (0);
err:
(void) mutex_unlock(&ndmp_lock);
return (-1);
}
static int
{
/* Open channel to NDMP service */
if ((ndmp_door_fildes == -1) &&
return (-1);
}
if (!buf) {
return (-1);
}
if (enc_ctx == 0) {
return (-1);
}
return (0);
}
static int
ndmp_door_call(void)
{
int rc;
return (-1);
}
(void) close(ndmp_door_fildes);
ndmp_door_fildes = -1;
return (-1);
}
if (rc != NDMP_DOOR_SRV_SUCCESS) {
return (-1);
}
return (0);
}
static int
ndmp_door_fini(void)
{
if ((ndmp_door_decode_finish(dec_ctx)) != 0) {
return (-1);
}
return (0);
}