ndmpd.h revision a23888a301b4822208e58d55cccf1b42c8e46cc7
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * BSD 3 Clause License
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar *
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Copyright (c) 2007, The Storage Networking Industry Association.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar *
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Redistribution and use in source and binary forms, with or without
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * modification, are permitted provided that the following conditions
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * are met:
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * - Redistributions of source code must retain the above copyright
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * notice, this list of conditions and the following disclaimer.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar *
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * - Redistributions in binary form must reproduce the above copyright
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * notice, this list of conditions and the following disclaimer in
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * the documentation and/or other materials provided with the
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * distribution.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar *
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * - Neither the name of The Storage Networking Industry Association (SNIA)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * nor the names of its contributors may be used to endorse or promote
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * products derived from this software without specific prior written
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * permission.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar *
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * POSSIBILITY OF SUCH DAMAGE.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Copyright (c) 2007, The Storage Networking Industry Association. */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
9ee94b97c8654689d6a034daec08757fda75d21aJan Kryl/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#ifndef _NDMPD_H
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define _NDMPD_H
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <sys/types.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <libzfs.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <ndmpd_door.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <libndmp.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include "ndmpd_common.h"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include "tlm_buffers.h"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <dirent.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include "ndmpd_prop.h"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include "traverse.h"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <pthread.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <libndmp.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#include <atomic.h>
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define MAX_RECORD_SIZE (126*512)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define REMOTE_RECORD_SIZE (60*KILOBYTE)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define SCSI_MAX_NAME 32
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define MD5_CHALLENGE_SIZE 64
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define MD5_PASS_LIMIT 32
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Test unit ready */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define TUR_WAIT 3000000
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define TUR_MAX_TRY 3
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* File handler classes */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define HC_CLIENT 1
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define HC_MOVER 2
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define HC_MODULE 4
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define HC_ALL 0xffffffff
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define IN_ADDR(x) \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar (*(struct in_addr *)&x)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define FS_READONLY(fs) (hasmntopt(fs, "ro") ? 1 : 0)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef void *(*funct_t)(void *); /* function pointer */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define HOSTNAMELEN 256
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define VENDOR_NAME "Sun Microsystems"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define PRODUCT_NAME "Solaris 5.11"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Calculate array length based on its size and size of
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * its elements.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define ARRAY_LEN(a, t) (sizeof (a) / sizeof (t))
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Default maximum permitted sequence number for the token-based backup.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_MAX_TOKSEQ 9
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Hard-limit for the sequence number in the token-based backup.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * It's one less than the ASCII value of 'A'. The 'A' letter
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * can be used as level in the lbr-type backups.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TOKSEQ_HLIMIT ('A' - 1)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Soft-limit for the sequence number in the token-based backup.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TOKSEQ_SLIMIT (NDMP_TOKSEQ_HLIMIT - 5)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Root inode number of dump format in V2.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define ROOT_INODE 2
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang * NDMP backup image signature
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMPUTF8MAGIC "NDMPUTF8MAGIC"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Supported BU types
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TAR_TYPE "tar"
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMP_DUMP_TYPE "dump"
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMP_ZFS_TYPE "zfs"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* All 1's binary maximum mover window */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define MAX_WINDOW_SIZE 0xffffffffffffffffULL
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_FREE(cp) { free((char *)(cp)); (cp) = NULL; }
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_YORN(f) ((f) ? 'Y' : 'N')
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TORF(f) ((f) ? "TRUE" : "FALSE")
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_SVAL(cp) ((cp) ? (cp) : "NULL")
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_SETENV(env, nm, val) \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar { \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar env->name = nm; \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar env->value = val; \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar env++; \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar }
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_CL_ADDR_LEN 24
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TCP_ADDR_SIZE 32
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NDMP_TAPE_DEV_NAME 256
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *bk_path;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int bk_llevel; /* last backup level */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar time_t bk_ldate; /* last backup date */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int bk_clevel; /* current backup level */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar time_t bk_cdate; /* current backup date */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int bk_map;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int bk_dirino;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *bk_dmpnm;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char **bk_exl; /* exlude list */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char **bk_inc; /* include list */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmp_backup_params_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t rs_nf; /* number of files to restore */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *rs_path;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *rs_bkpath;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int *rs_restored;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int rs_bm;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int rs_lastidx;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmp_restore_params_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Tar format archiving ops table
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern tm_ops_t tm_tar_ops;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * IS_LBR_BKTYPE shows if the backup type is one of these
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * 'F' of 'f': 'Full' backup type.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * 'A' of 'a': 'Archive' backup type.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * 'I' of 'i': 'Incremental' backup type.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * 'D' of 'd': 'Differntial' backup type.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define IS_LBR_BKTYPE(t) (((t) && strchr("FAID", toupper(t))) ? 1 : 0)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NLP flags.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_CHKPNTED_PATH (1 << 0)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_FH (1 << 1)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_DIRECT (1 << 2)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_UPDATE (1 << 3)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_DUMP (1 << 4)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_TAR (1 << 5)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_ABORTED (1 << 6)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_TOKENBK (1 << 8)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_LBRBK (1 << 9)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_LEVELBK (1 << 10)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_IGNCTIME (1 << 11)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_INCLMTIME (1 << 12)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLPF_RECURSIVE (1 << 13)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Macros on NLP flags.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_ISSET(n, f) (((n)->nlp_flags & (f)) != 0)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_SET(n, f) (n)->nlp_flags |= (f)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_UNSET(n, f) (n)->nlp_flags &= ~(f)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_ISCHKPNTED(n) NLP_ISSET(n, NLPF_CHKPNTED_PATH)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_SHOULD_UPDATE(n) NLP_ISSET(n, NLPF_UPDATE)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_ISDUMP(n) NLP_ISSET(n, NLPF_DUMP)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_ISTAR(n) NLP_ISSET(n, NLPF_TAR)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_IGNCTIME(n) NLP_ISSET(n, NLPF_IGNCTIME)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_INCLMTIME(n) NLP_ISSET(n, NLPF_INCLMTIME)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP statistics
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NS_INC(s) (atomic_inc_32((volatile uint32_t *)&ndstat.ns_##s))
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NS_DEC(s) (atomic_dec_32((volatile uint32_t *)&ndstat.ns_##s))
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NS_ADD(s, d) (atomic_add_64((volatile uint64_t *)&ndstat.ns_##s, \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar (uint64_t)d))
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NS_UPD(s, t) { \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar atomic_inc_32((volatile uint32_t *)&ndstat.ns_##s); \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar atomic_dec_32((volatile uint32_t *)&ndstat.ns_##t); \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar }
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define NLP_READY 1
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmp_lbr_params {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct ndmpd_session *nlp_session;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int nlp_flags;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_backup_params_t bk_params;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_restore_params_t rs_params;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_backup_path bk_params.bk_path
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_llevel bk_params.bk_llevel
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_ldate bk_params.bk_ldate
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_clevel bk_params.bk_clevel
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_tokseq nlp_clevel
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_tokdate nlp_ldate
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_cdate bk_params.bk_cdate
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_bkmap bk_params.bk_map
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_bkdirino bk_params.bk_dirino
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_dmpnm bk_params.bk_dmpnm
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_exl bk_params.bk_exl
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_inc bk_params.bk_inc
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_nfiles rs_params.rs_nf
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_restore_path rs_params.rs_path
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_restore_bk_path rs_params.rs_bkpath
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_restored rs_params.rs_restored
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_rsbm rs_params.rs_bm
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#define nlp_lastidx rs_params.rs_lastidx
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *nlp_params;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar tlm_job_stats_t *nlp_jstat;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar lbr_fhlog_call_backs_t *nlp_logcallbacks;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar tlm_commands_t nlp_cmds;
a23888a301b4822208e58d55cccf1b42c8e46cc7Jan Kryl
a23888a301b4822208e58d55cccf1b42c8e46cc7Jan Kryl cond_t nlp_cv; /* for signaling a processed request */
a23888a301b4822208e58d55cccf1b42c8e46cc7Jan Kryl mutex_t nlp_mtx; /* mutex to synchronize access to nlp_cv */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t nlp_bytes_total;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmp_lbr_params_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct mem_ndmp_name_v3 {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *nm3_opath;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *nm3_dpath;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *nm3_newnm;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t nm3_node;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t nm3_fh_info;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_error nm3_err;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} mem_ndmp_name_v3_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_file_handler {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int fh_fd;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_mode;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_class;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar void *fh_cookie;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_file_handler_func_t *fh_func;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct ndmpd_file_handler *fh_next;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_file_handler_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_scsi_desc {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int sd_is_open;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int sd_devid;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t sd_valid_target_set;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int sd_sid;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int sd_lun;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char sd_adapter_name[SCSI_MAX_NAME];
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_scsi_desc_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_tape_desc {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int td_fd; /* tape device file descriptor */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t td_record_count; /* number of records written */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_tape_open_mode td_mode; /* tape device open mode */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t td_pos; /* current position on the current tape */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int td_sid;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int td_lun;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char td_adapter_name[SCSI_MAX_NAME];
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_tape_desc_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_mover_desc {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_state md_state; /* current state */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_mode md_mode; /* current mode */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_pause_reason md_pause_reason; /* current reason */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_halt_reason md_halt_reason; /* current reason */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_data_written; /* total written to tape */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_seek_position; /* current seek position */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_bytes_left_to_read; /* #bytes to end of seek window */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_window_offset; /* valid data window begin */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_window_length; /* valid data window length */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t md_position; /* current data stream pos */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t md_pre_cond; /* used for precondition checks */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t md_record_size; /* tape I/O record size */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t md_record_num; /* current record num */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int md_listen_sock; /* data conn listen socket */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int md_sock; /* data conn socket */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t md_r_index; /* buffer read index */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t md_w_index; /* buffer write index */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *md_buf; /* data buffer */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V2 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t md_discard_length; /* bytes to discard */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V3 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_addr_v3 md_data_addr;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V4 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_addr_v4 md_data_addr_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_mover_desc_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_data_module {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar void *dm_module_cookie; /* sent as abort_func param */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar module_start_func_t *dm_start_func; /* start function */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar module_abort_func_t *dm_abort_func; /* abort function */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_stats dm_stats; /* statistics buffer */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_data_module_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_data_desc {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Common fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_data_operation dd_operation; /* current operation */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t dd_abort; /* abort operation flag */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t dd_io_ready; /* mover sock read for I/O */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_pval *dd_env; /* environment from backup or recover request */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t dd_env_len; /* environment length */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t dd_nlist_len; /* recover file list length */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int dd_sock; /* listen and data socket */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_read_offset; /* data read seek offset */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_read_length; /* data read length */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_data_size; /* data size to be backed up */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_data_module_t dd_module;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_data_state dd_state; /* current state */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_data_halt_reason dd_halt_reason; /* current reason */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V2 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_name *dd_nlist; /* recover file list */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_addr dd_mover; /* mover address */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V3 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar mem_ndmp_name_v3_t *dd_nlist_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_addr_v3 dd_data_addr;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int dd_listen_sock; /* socket for listening for remote */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /* mover connections */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_bytes_left_to_read;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_position;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t dd_discard_length;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * V4 fields.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_addr_v4 dd_data_addr_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_data_desc_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_file_history {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_fh_unix_path *fh_path_entries;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_fh_unix_dir *fh_dir_entries;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_fh_unix_node *fh_node_entries;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *fh_path_name_buf;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *fh_dir_name_buf;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_path_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_dir_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_node_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_path_name_buf_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_dir_name_buf_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_file_history_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session_file_history_v3 {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_file_v3 *fh_files;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_dir_v3 *fh_dirs;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_node_v3 *fh_nodes;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_file_name_v3 *fh_file_names;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_file_name_v3 *fh_dir_names;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_file_stat_v3 *fh_file_stats;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_file_stat_v3 *fh_node_stats;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *fh_file_name_buf;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *fh_dir_name_buf;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_file_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_dir_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_node_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_file_name_buf_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t fh_dir_name_buf_index;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_file_history_v3_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang/*
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang * zfs-based backup (zfs send/recv)
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef enum {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang NDMPD_ZFS_MAJOR_0,
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_major_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef enum {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang NDMPD_ZFS_MINOR_0,
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_minor_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef enum {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang NDMPD_ZFS_PROP_MAJOR_0,
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_prop_major_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef enum {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang NDMPD_ZFS_PROP_MINOR_0,
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_prop_minor_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMPD_ZFS_MAJOR_VERSION NDMPD_ZFS_MAJOR_0
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMPD_ZFS_MINOR_VERSION NDMPD_ZFS_MINOR_0
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMPD_ZFS_PROP_MAJOR_VERSION NDMPD_ZFS_PROP_MAJOR_0
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMPD_ZFS_PROP_MINOR_VERSION NDMPD_ZFS_PROP_MINOR_0
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#pragma pack(1)
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef struct {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nzh_magic[14]; /* NDMPUTF8MAGIC\0 */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang uint32_t nzh_major; /* major version */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang uint32_t nzh_minor; /* minor version */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang uint32_t nzh_hdrlen; /* length of hdr in bytes including magic */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang /* future extensions */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_header_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#pragma pack()
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define PIPE_TAPE 0
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define PIPE_ZFS 1
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMPD_ZFS_DMP_NAME_MAX 32
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changtypedef struct ndmpd_zfs_args {
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang zfs_type_t nz_type; /* type of ZFS dataset */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_dataset[ZFS_MAXNAMELEN]; /* dataset name */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_snapname[ZFS_MAXNAMELEN]; /* snapname (following '@') */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_fromsnap[ZFS_MAXNAMELEN]; /* snap of L-1 bkup */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_snapprop[ZFS_MAXPROPLEN]; /* contents of snap incr prop */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang boolean_t nz_ndmpd_snap; /* ndmpd-generated snap? */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang pthread_t nz_sendrecv_thread; /* thread for send/recv */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang pthread_t nz_tape_thread; /* thread for tape r/w */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang int32_t nz_pipe_fd[2]; /* pipe for above 2 threads */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang int32_t nz_bufsize; /* tape r/w buf size */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang int64_t nz_window_len; /* DMA window length */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang int nz_level; /* val of LEVEL env var */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_zfs_mode; /* val of ZFS_MODE env var */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang boolean_t nz_zfs_force; /* val of ZFS_FORCE env var */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang boolean_t nz_update; /* val of UPDATE env var */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang char nz_dmp_name[NDMPD_ZFS_DMP_NAME_MAX]; /* val of DMP_NAME env var */
c1a2c7311cbde5c239d7679fc280103ef7b36bf1Janice Chang u_longlong_t nz_zfs_backup_size; /* used for restore only */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang ndmpd_module_params_t nz_params;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang ndmp_lbr_params_t *nz_nlp;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang libzfs_handle_t *nz_zlibh; /* session-specific lzfs hdl */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang ndmp_context_t nz_nctx; /* used by plugin */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang ndmpd_zfs_header_t nz_tape_header; /* tape hdr for "zfs" backup */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang} ndmpd_zfs_args_t;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define ndmpd_zfs_params (&(ndmpd_zfs_args)->nz_params)
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct ndmpd_session {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_connection_t *ns_connection; /* NDMP connection to client */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t ns_eof; /* connection EOF flag */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ushort_t ns_protocol_version; /* connection protocol version */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_scsi_desc_t ns_scsi;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_tape_desc_t ns_tape;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_mover_desc_t ns_mover;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_data_desc_t ns_data;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_file_history_t ns_fh;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_file_handler_t *ns_file_handler_list; /* for I/O multiplexing */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int ns_nref;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_lbr_params_t *ns_ndmp_lbr_params;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang struct ndmpd_zfs_args ns_ndmpd_zfs_args;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang ndmpd_backup_type_t ns_butype;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar mutex_t ns_lock;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP V3
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Tape, SCSI, mover, data and file handlers will
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * be shared between V2 and V3.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_file_history_v3_t ns_fh_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar unsigned char ns_challenge[MD5_CHALLENGE_SIZE]; /* For MD5 */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP V4 related data
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t ns_set_ext_list;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar /* handling of hardlink, hardlink queue head */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct hardlink_q *hardlink_q;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_session_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP request handler functions.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Config */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_host_info_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_butype_attr_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_mover_type_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_auth_attr_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_host_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_butype_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_connection_type_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_auth_attr_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_fs_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_tape_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_scsi_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_server_info_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_butype_info_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_get_ext_list_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_config_set_ext_list_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Scsi */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_open_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_close_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_get_state_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_set_target_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_reset_device_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_reset_bus_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_execute_cdb_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_open_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_scsi_set_target_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Tape */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_open_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_close_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_get_state_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_mtio_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_write_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_read_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_execute_cdb_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_open_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_get_state_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_write_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_read_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_tape_close_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Data */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_get_state_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_start_backup_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_start_recover_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_get_env_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_stop_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_abort_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_get_state_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_connect_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_listen_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_stop_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_abort_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_start_recover_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_start_backup_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_get_env_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_get_state_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_connect_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_listen_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_data_start_recover_filehist_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Connect */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_open_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_client_auth_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_server_auth_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_close_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_client_auth_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_connect_close_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Mover */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_get_state_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_listen_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_continue_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_abort_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_stop_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_set_window_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_read_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_close_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_set_record_size_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_get_state_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_listen_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_continue_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_abort_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_set_window_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_read_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_set_record_size_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_connect_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_get_state_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_listen_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmp_msg_handler_func_t ndmpd_mover_connect_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Backup/recover module API functions.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_get_env_func_t ndmpd_api_get_env;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_add_env_func_t ndmpd_api_add_env;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_add_env_func_t ndmpd_api_set_env;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_get_name_func_t ndmpd_api_get_name;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_dispatch_func_t ndmpd_api_dispatch;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_done_func_t ndmpd_api_done_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_write_func_t ndmpd_api_write_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_path_func_t ndmpd_api_file_history_path_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_dir_func_t ndmpd_api_file_history_dir_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_node_func_t ndmpd_api_file_history_node_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_read_func_t ndmpd_api_read_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_seek_func_t ndmpd_api_seek_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_recovered_func_t ndmpd_api_file_recovered_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_add_file_handler_func_t ndmpd_api_add_file_handler;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_remove_file_handler_func_t ndmpd_api_remove_file_handler;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP V3
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_done_func_t ndmpd_api_done_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_write_func_t ndmpd_api_write_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_read_func_t ndmpd_api_read_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_seek_func_t ndmpd_api_seek_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_recovered_func_t ndmpd_api_file_recovered_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_get_name_func_t ndmpd_api_get_name_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_path_func_t ndmpd_api_file_history_file_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_dir_func_t ndmpd_api_file_history_dir_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_history_node_func_t ndmpd_api_file_history_node_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * NDMP V4
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_log_func_v3_t ndmpd_api_log_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_file_recovered_func_t ndmpd_api_file_recovered_v4;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#ifndef NO_NDMP_API_LOG_PROTOTYPES
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_log_func_t ndmpd_api_log_v2;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_log_func_v3_t ndmpd_api_log_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#endif /* NO_NDMP_API_LOG_PROTOTYPES */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef void ndmpd_func_t(ndmp_connection_t *, void *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * pthread call arg parameters
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int nw_sock;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar long nw_ipaddr;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_con_handler_func_t nw_con_handler_func;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmpd_worker_arg_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *br_jname;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_lbr_params_t *br_nlp;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar tlm_commands_t *br_cmds;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar pthread_barrier_t br_barrier;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} backup_reader_arg_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdartypedef struct {
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_session_t *tr_session;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *tr_mod_params;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar tlm_commands_t *tr_cmds;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar} ndmp_tar_reader_arg_t;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdartypedef struct {
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdar ndmpd_session_t *bs_session;
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdar char *bs_jname;
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdar char *bs_path;
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdar} ndmp_bkup_size_arg_t;
416eec611c764c2e9dc8dc28133302a7fc551facReza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Variables from ndmpd_comm.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_ver;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_full_restore_path;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_dar_support;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_port;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_stat_t ndstat;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_main(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void connection_handler(ndmp_connection_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_audit_backup(ndmp_connection_t *conn, char *path,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int dest, char *local_path, int result);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_audit_restore(ndmp_connection_t *conn,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *path, int dest, char *local_path, int result);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_audit_connect(ndmp_connection_t *conn,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int result);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_audit_disconnect(ndmp_connection_t *conn);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/* Variables from ndmpd_main.c */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern libzfs_handle_t *zlibh;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern mutex_t zlib_mtx;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility from ndmpd_connect.c.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_connect_list_add(ndmp_connection_t *, int *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_connect_list_del(ndmp_connection_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_connect_kill_id(int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_connect_list_get(ndmp_door_ctx_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_get_devs(ndmp_door_ctx_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions form ndmpd_data.c.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_data_cleanup(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_data_init(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmp_data_get_mover_mode(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_data_error(ndmpd_session_t *, ndmp_data_halt_reason);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions from ndmpd_mover.c.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_mover_init(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_mover_cleanup(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmpd_mover_connect(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_mode);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_mover_error(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_halt_reason);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_mover_seek(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_local_write(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_remote_write(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_local_read(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_remote_read(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_mover_shut_down(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_mover_error(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_mover_halt_reason);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_local_write_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_local_read_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_remote_read_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions from ndmpd_file_history.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_file_history_init(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_file_history_cleanup(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_file_history_path(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_file_history_dir(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_file_history_node(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarndmpd_path_restored(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_fhpath_v3_cb(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_fhdir_v3_cb(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_fhnode_v3_cb(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_path_restored_v3(lbr_fhlog_call_backs_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar struct stat64 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_send_recovery_stat_v3(ndmpd_module_params_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_lbr_params_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions from ndmpd_dtime.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_put_dumptime(char *, int, time_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_get_dumptime(char *, int *, time_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_append_dumptime(char *, char *, int, time_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Global variables from ndmpd_tar3.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char **ndmp_excl_list;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Global variables from ndmpd_util.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_force_bk_dirs;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_rbs;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_sbs;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_dump_path_node;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_tar_path_node;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_ignore_ctime;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_include_lmtime;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions from ndmpd_util.c.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_select(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar boolean_t,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmpd_save_env(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_pval *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_free_env(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmpd_save_nlist_v2(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_name *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_free_nlist(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_add_file_handler(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar void *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_file_handler_func_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_remove_file_handler(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_send_reply(ndmp_connection_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar void *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_mtioctl(int, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern u_longlong_t quad_to_long_long(ndmp_u_quad);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_u_quad long_long_to_quad(u_longlong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_set_socket_nodelay(int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_set_socket_snd_buf(int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_set_socket_rcv_buf(int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern long ndmp_buffer_get_size(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_lbr_init(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_lbr_cleanup(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
a23888a301b4822208e58d55cccf1b42c8e46cc7Jan Krylextern int ndmp_wait_for_mover(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t is_buffer_erroneous(tlm_buffer_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_execute_cdb(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_execute_cdb_request *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern scsi_adapter_t *scsi_get_adapter(int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t is_tape_unit_ready(char *, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_open_list_add(ndmp_connection_t *, char *, int, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_open_list_del(char *, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_open_list_release(ndmp_connection_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_stop_buffer_worker(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_stop_reader_thread(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_stop_writer_thread(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_free_reader_writer_ipc(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_waitfor_op(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *cctime(time_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmp_new_job_name(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmpd_mk_temp(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmpd_make_bk_dir_path(char *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_is_chkpnt_root(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char **ndmpd_make_exc_list(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_sort_nlist_v3(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_get_bk_dir_ino(ndmp_lbr_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_write_utf8magic(tlm_cmd_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_tar_writer(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar tlm_commands_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_wait_for_reader(tlm_commands_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmpd_save_nlist_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmp_name_v3 *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ulong_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_free_nlist_v3(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_create_socket(ulong_t *, ushort_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_connect_sock_v3(ulong_t, ushort_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_copy_addr_v3(ndmp_addr_v3 *, ndmp_addr_v3 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_copy_addr_v4(ndmp_addr_v4 *, ndmp_addr_v4 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmp_addr2str_v3(ndmp_addr_type);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_valid_v3addr_type(ndmp_addr_type);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_check_utf8magic(tlm_cmd_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_get_cur_bk_time(ndmp_lbr_params_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar time_t *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *ndmp_get_relative_path(char *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_fhinode;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_load_params(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void randomize(unsigned char *, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * Utility functions from ndmpd_tar3.c.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmp_restore_get_params_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_error ndmp_backup_get_params_v3(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar/*
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar * door init and fini function from ndmpd_door_serv.c
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar */
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_door_init(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_door_fini(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t ndmp_door_check(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_get_max_tok_seq(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t set_debug_level(boolean_t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t get_debug_level(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int get_zfsvolname(char *, int, char *);
876b86efac620aaabc70ad2ed4bfb715ce714875Reza Sabdarextern int ndmp_create_snapshot(char *, char *);
876b86efac620aaabc70ad2ed4bfb715ce714875Reza Sabdarextern int ndmp_remove_snapshot(char *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_mark_inodes_v2(ndmpd_session_t *, ndmp_lbr_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmpd_abort_marking_v2(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmpd_mark_inodes_v3(ndmpd_session_t *, ndmp_lbr_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_lbr_params_t *ndmp_get_nlp(void *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_start_func_t ndmpd_tar_backup_starter;
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_abort_func_t ndmpd_tar_backup_abort;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_start_func_t ndmpd_tar_restore_starter;
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_abort_func_t ndmpd_tar_restore_abort;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarmodule_start_func_t ndmpd_tar_backup_starter_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarmodule_abort_func_t ndmpd_tar_backup_abort_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarmodule_start_func_t ndmpd_tar_restore_starter_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarmodule_abort_func_t ndmpd_tar_restore_abort_v3;
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_backup_extract_params(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_restore_extract_params(ndmpd_session_t *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar ndmpd_module_params_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int ndmp_tar_reader(ndmp_tar_reader_arg_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int tape_open(char *, int);
9ee94b97c8654689d6a034daec08757fda75d21aJan Krylextern int tape_is_at_bot(ndmpd_session_t *);
9ee94b97c8654689d6a034daec08757fda75d21aJan Krylextern int tape_is_at_bof(ndmpd_session_t *);
9ee94b97c8654689d6a034daec08757fda75d21aJan Krylextern void fm_dance(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_session_ref(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_session_unref(ndmpd_session_t *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarvoid ndmpd_get_file_entry_type(int, ndmp_file_type *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int tcp_accept(int, unsigned int *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int tcp_get_peer(int, unsigned int *, int *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *gethostaddr(void);
588541fbf64fffe619698198cef04af1900f1f86Reza Sabdarextern char *get_default_nic_addr(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int tlm_init(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
876b86efac620aaabc70ad2ed4bfb715ce714875Reza Sabdarextern int snapshot_create(char *, char *, boolean_t, boolean_t);
876b86efac620aaabc70ad2ed4bfb715ce714875Reza Sabdarextern int snapshot_destroy(char *, char *, boolean_t, boolean_t, int *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t fs_is_chkpntvol(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t fs_is_chkpnt_enabled(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t fs_is_rdonly(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t fs_volexist(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t fs_is_valid_logvol(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t rootfs_dot_or_dotdot(char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int dp_readdir(DIR *, unsigned long *, char *,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar int *, unsigned long *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void scsi_find_sid_lun();
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *sasd_slink_name();
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int scsi_dev_exists(char *, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int scsi_get_devtype(char *, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern struct open_list *ndmp_open_list_find(char *, int, int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int filecopy(char *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_stop_local_reader();
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void ndmp_stop_remote_reader();
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern boolean_t match(char *, char *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern char *trim_whitespace(char *);
84bf06e9e5fd6d61897cc8c298a0f3e807b27094Reza Sabdarextern int fs_getstat(char *, struct fs_fhandle *, struct stat64 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int fs_readdir(struct fs_fhandle *, char *, long *,
84bf06e9e5fd6d61897cc8c298a0f3e807b27094Reza Sabdar char *, int *, struct fs_fhandle *, struct stat64 *);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int iscreated(ndmp_lbr_params_t *nlp, char *name, tlm_acls_t *tacl,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar time_t t);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern int sasd_dev_count(void);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern struct scsi_link *sasd_dev_slink(int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern struct sasd_drive *sasd_drive(int);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern void *ndmp_malloc(size_t size);
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdarextern ndmp_plugin_t *ndmp_pl;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang#define NDMP_APILOG(s, t, m, ...) \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang{ \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang if (((ndmpd_session_t *)(s))->ns_protocol_version == NDMPV4) \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang (void) ndmpd_api_log_v4(s, t, m, __VA_ARGS__); \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang else if (((ndmpd_session_t *)(s))->ns_protocol_version == NDMPV3) \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang (void) ndmpd_api_log_v3(s, t, m, __VA_ARGS__); \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang else \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang (void) ndmpd_api_log_v2(s, __VA_ARGS__); \
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang}
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang/*
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang * Backup path utility functions
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang */
8c4f9701439555b41fbfe7848508f53b52166007Janice Changextern char *get_backup_path_v3(ndmpd_module_params_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changextern char *get_backup_path_v2(ndmpd_module_params_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang/*
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang * Functions for zfs-based backup
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang */
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_start_func_t ndmpd_zfs_backup_starter;
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_start_func_t ndmpd_zfs_restore_starter;
8c4f9701439555b41fbfe7848508f53b52166007Janice Changmodule_abort_func_t ndmpd_zfs_abort;
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changint ndmpd_zfs_init(ndmpd_session_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changvoid ndmpd_zfs_fini(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changboolean_t ndmpd_zfs_backup_parms_valid(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changboolean_t ndmpd_zfs_restore_parms_valid(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changint ndmpd_zfs_pre_backup(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changint ndmpd_zfs_pre_restore(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changint ndmpd_zfs_post_backup(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Changint ndmpd_zfs_post_restore(ndmpd_zfs_args_t *);
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
8c4f9701439555b41fbfe7848508f53b52166007Janice Changvoid ndmpd_zfs_dma_log(ndmpd_zfs_args_t *, ndmp_log_type, char *, ...);
8c4f9701439555b41fbfe7848508f53b52166007Janice Chang
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar#endif /* _NDMPD_H */