ndmpd_config.c revision 5bc1e22263da29a716575a856dd867c1f58f4a8b
/*
*/
/*
* 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.
*/
/* Copyright (c) 2007, The Storage Networking Industry Association. */
/* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/systeminfo.h>
#include "ndmpd_common.h"
#include "ndmpd.h"
/*
* Number of environment variable for the file system
* info in V3 net_fs_info.
*/
#define V3_N_FS_ENVS 4
/*
* Is the file system a valid one to be reported to the
* clients?
*/
#define MNTTYPE_LEN 10
extern struct fs_ops sfs2cpv_ops;
/*
* ************************************************************************
* NDMP V2 HANDLERS
* ************************************************************************
*/
/*
* ndmpd_config_get_host_info_v2
*
* This handler handles the ndmp_config_get_host_info request.
* Host specific information is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
char hostidstr[16];
}
/*
* Convert the hostid to hex. The returned string must match
* the string returned by hostid(1).
*/
auth_types[0] = NDMP_AUTH_TEXT;
"sending ndmp_config_get_host_info reply");
}
/*
* ndmpd_config_get_butype_attr_v2
*
* This handler handles the ndmp_config_get_butype_attr request.
* Information about the specified backup type is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
void
{
} else {
"Supported backup types are 'dump' and 'tar' only.");
}
"sending ndmp_config_get_butype_attr reply");
}
/*
* ndmpd_config_get_mover_type_v2
*
* This handler handles the ndmp_config_get_mover_type request.
* Information about the supported mover types is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
types[0] = NDMP_ADDR_LOCAL;
"sending ndmp_config_get_mover_type reply");
}
/*
* ndmpd_config_get_auth_attr_v2
*
* This handler handles the ndmp_config_get_auth_attr request.
* Authorization type specific information is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
void
{
case NDMP_AUTH_TEXT:
break;
case NDMP_AUTH_MD5:
/* Create a 64 byte random session challenge */
break;
case NDMP_AUTH_NONE:
/* FALL THROUGH */
default:
"Supported authentication types are md5 and cleartext.");
break;
}
"sending ndmp_config_get_auth_attr reply");
}
/*
* ************************************************************************
* NDMP V3 HANDLERS
* ************************************************************************
*/
/*
* ndmpd_config_get_host_info_v3
*
* This handler handles the ndmp_config_get_host_info request.
* Host specific information is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
char hostidstr[16];
}
/*
* Convert the hostid to hex. The returned string must match
* the string returned by hostid(1).
*/
"sending ndmp_config_get_host_info reply");
}
/*
* ndmpd_config_get_connection_type_v3
*
* This handler handles the ndmp_config_get_connection_type_request.
* A list of supported data connection types is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
void *body)
{
addr_types[0] = NDMP_ADDR_LOCAL;
"sending config_get_connection_type_v3 reply");
}
/*
* ndmpd_config_get_auth_attr_v3
*
* This handler handles the ndmp_config_get_auth_attr request.
* Authorization type specific information is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
void
{
case NDMP_AUTH_TEXT:
break;
case NDMP_AUTH_MD5:
/* Create a 64 bytes random session challenge */
break;
case NDMP_AUTH_NONE:
/* FALL THROUGH */
default:
"Supported authentication types are md5 and cleartext.");
break;
}
"sending ndmp_config_get_auth_attr_v3 reply");
}
/*
* ndmpd_config_get_butype_info_v3
*
* This handler handles the ndmp_config_get_butype_info_request.
* Information about all supported backup types are returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
/*
* Supported environment variables and their default values
* for dump and tar.
*
* The environment variables for dump and tar format are the
* same, because we use the same backup engine for both.
*/
/* If DAR supported */
if (ndmp_dar_support)
/* tar backup type */
/* dump backup type */
/*
* Supported environment variables and their default values
* for type "zfs."
*/
/* zfs backup type */
"sending ndmp_config_get_butype_info reply");
}
/*
* ndmpd_config_get_fs_info_v3
*
* This handler handles the ndmp_config_get_fs_info_request.
* Information about all mounted file systems is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
int log_dev_len;
goto send_reply;
}
/* nothing was found, send an empty reply */
goto send_reply;
}
if (!fp) {
goto send_reply;
}
if (!fsip) {
goto send_reply;
}
/*
* Re-read the directory and set up file system information.
*/
{
if (!IS_VALID_FS(fs))
continue;
break;
}
fs->mnt_fstype);
fs->mnt_mountp);
"statvfs error: unable to determine filesystem"
" attributes";
} else {
fsip->total_size =
fsip->avail_size =
fsip->total_inodes =
fsip->used_inodes =
}
if (!envp) {
break;
}
V3_N_FS_ENVS * sizeof (ndmp_pval));
if (FS_READONLY(fs) == 0) {
}
len++;
fsip++;
}
}
"error sending ndmp_config_get_fs_info reply");
fsip--;
}
}
/*
* ndmpd_config_get_tape_info_v3
*
* This handler handles the ndmp_config_get_tape_info_request.
* Information about all connected tape drives is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
int i, n, max;
max = sasd_dev_count();
"error sending ndmp_config_get_tape_info reply");
return;
}
for (i = n = 0; i < max; i++) {
continue;
continue;
/*
* Don't report dead links.
*/
continue;
tip++;
dcp++;
n++;
}
/*
* We should not receive the get_tape_info when three-way backup is
* running and we are acting as just data, but some clients try
* to get the Tape information anyway.
*/
if (n == 0 || max <= 0) {
"error sending ndmp_config_get_tape_info reply");
return;
}
"error sending ndmp_config_get_tape_info reply");
}
/*
* ndmpd_config_get_scsi_info_v3
*
* This handler handles the ndmp_config_get_tape_scsi_request.
* Information about all connected scsi tape stacker and jukeboxes
* is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
int i, n, max;
max = sasd_dev_count();
"error sending ndmp_config_get_scsi_info reply");
return;
}
for (i = n = 0; i < max; i++) {
continue;
continue;
/*
* Don't report dead links.
*/
continue;
sip++;
dcp++;
n++;
}
"error sending ndmp_config_get_scsi_info reply");
}
/*
* ndmpd_config_get_server_info_v3
*
* This handler handles the ndmp_config_get_server_info request.
* Host specific information is returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
char rev_number[10];
if (connection->conn_authorized ||
ndmp_ver);
} else {
}
"vendor \"%s\", product \"%s\" rev \"%s\"",
auth_types[0] = NDMP_AUTH_TEXT;
"error sending ndmp_config_get_server_info reply");
}
/*
* ************************************************************************
* NDMP V4 HANDLERS
* ************************************************************************
*/
/*
* ndmpd_config_get_butype_info_v4
*
* This handler handles the ndmp_config_get_butype_info_request.
* Information about all supported backup types are returned.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
/*
* Supported environment variables and their default values
* for dump and tar.
*
* The environment variables for dump and tar format are the
* same, because we use the same backup engine for both.
*/
/* If DAR supported */
if (ndmp_dar_support)
/* tar backup type */
/* dump backup type */
/*
* Supported environment variables and their default values
* for type "zfs."
*/
/* zfs backup type */
"sending ndmp_config_get_butype_info reply");
}
/*
* ndmpd_config_get_ext_list_v4
*
* This handler handles the ndmpd_config_get_ext_list_v4 request.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
/*ARGSUSED*/
void
{
if (session->ns_set_ext_list) {
/*
* Illegal request if extensions have already been selected.
*/
} else {
/*
* Reply with an empty set of extensions.
*/
}
"error sending ndmp_config_get_ext_list reply");
}
/*
* ndmpd_config_set_ext_list_v4
*
* This handler handles the ndmpd_config_get_ext_list_v4 request.
*
* Parameters:
* connection (input) - connection handle.
* body (input) - request message body.
*
* Returns:
* void
*/
void
{
if (!session->ns_get_ext_list) {
/*
* The DMA is required to issue a NDMP_GET_EXT_LIST request
* prior sending a NDMP_SET_EXT_LIST request.
*/
} else if (session->ns_set_ext_list) {
/*
* Illegal request if extensions have already been selected.
*/
} else {
/*
* We currently do not support any extensions, but the DMA
* may test NDMP_CONFIG_SET_EXT_LIST with an empty list.
*/
} else {
}
}
"error sending ndmp_config_set_ext_list reply");
}
/*
* ************************************************************************
* LOCALS
* ************************************************************************
*/
/*
* simple_get_attrs
*
* Set the default attrs for dump mode
*
* Parameters:
* attributes (output) - the attributes for dump mode
*
* Returns:
* void
*/
static void
{
}