本文整理汇总了C++中NDMP_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ NDMP_LOG函数的具体用法?C++ NDMP_LOG怎么用?C++ NDMP_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NDMP_LOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapshot_release
int
snapshot_release(char *volname, char *snapname, char *jname,
boolean_t recursive)
{
zfs_handle_t *zhp;
char *p;
int rv = 0;
if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
return (-1);
}
p = strchr(snapname, '@') + 1;
if (zfs_release(zhp, p, jname, recursive) != 0) {
NDMP_LOG(LOG_DEBUG, "Cannot release snapshot %s", p);
rv = -1;
}
if (cleanup_fd != -1) {
(void) close(cleanup_fd);
cleanup_fd = -1;
}
zfs_close(zhp);
return (rv);
}
示例2: tlm_get_chkpnt_time
/*
* Get the checkpoint (snapshot) creation time.
* This is necessary to check for checkpoints not being stale.
*/
int
tlm_get_chkpnt_time(char *path, int auto_checkpoint, time_t *tp, char *jname)
{
char volname[TLM_VOLNAME_MAX_LENGTH];
char chk_name[PATH_MAX];
char *cp_nm;
NDMP_LOG(LOG_DEBUG, "path [%s] auto_checkpoint: %d",
path, auto_checkpoint);
if (path == NULL || *path == '\0' || tp == NULL)
return (-1);
if (get_zfsvolname(volname, TLM_VOLNAME_MAX_LENGTH,
path) == -1)
return (-1);
if (auto_checkpoint) {
NDMP_LOG(LOG_DEBUG, "volname [%s]", volname);
(void) snprintf(chk_name, PATH_MAX, "%s", jname);
return (chkpnt_creationtime_bypattern(volname, chk_name, tp));
}
cp_nm = strchr(volname, '@');
NDMP_LOG(LOG_DEBUG, "volname [%s] cp_nm [%s]", volname, cp_nm);
return (chkpnt_creationtime_bypattern(volname, cp_nm, tp));
}
示例3: ndmpd_scsi_reset_device_v2
/*ARGSUSED*/
void
ndmpd_scsi_reset_device_v2(ndmp_connection_t *connection, void *body)
{
ndmp_scsi_reset_device_reply reply;
ndmpd_session_t *session = ndmp_get_client_data(connection);
struct uscsi_cmd cmd;
if (session->ns_scsi.sd_devid == -1) {
NDMP_LOG(LOG_ERR, "SCSI device is not open.");
reply.error = NDMP_DEV_NOT_OPEN_ERR;
} else {
reply.error = NDMP_NO_ERR;
(void) memset((void*)&cmd, 0, sizeof (cmd));
cmd.uscsi_flags |= USCSI_RESET;
if (ioctl(session->ns_scsi.sd_devid, USCSICMD, &cmd) < 0) {
NDMP_LOG(LOG_ERR, "USCSI reset failed: %m.");
NDMP_LOG(LOG_DEBUG,
"ioctl(USCSICMD) USCSI_RESET failed: %m.");
reply.error = NDMP_IO_ERR;
}
}
ndmp_send_reply(connection, (void *) &reply,
"sending scsi_reset_device reply");
}
示例4: snapshot_hold
/*
* Put a hold on snapshot
*/
int
snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
{
zfs_handle_t *zhp;
char *p;
if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
return (-1);
}
if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
O_RDWR|O_EXCL)) < 0) {
NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
zfs_close(zhp);
return (-1);
}
p = strchr(snapname, '@') + 1;
if (zfs_hold(zhp, p, jname, recursive, cleanup_fd) != 0) {
NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
zfs_close(zhp);
return (-1);
}
zfs_close(zhp);
return (0);
}
示例5: cstack_pop
/*
* cstack_pop
*
* Pop an element off the stack. Set up the data and len references for
* the caller, advance the stack head and free the popped stack node.
*
* Returns 0 on success. Otherwise returns -1 to indicate underflow.
*/
int
cstack_pop(cstack_t *stk, void **data, int *len)
{
cstack_t *stk_node;
if (stk == NULL) {
NDMP_LOG(LOG_DEBUG, "cstack_pop: invalid stack");
return (-1);
}
if ((stk_node = stk->next) == NULL) {
NDMP_LOG(LOG_DEBUG, "cstack_pop: underflow");
return (-1);
}
if (data)
*data = stk_node->data;
if (len)
*len = stk_node->len;
stk->next = stk_node->next;
NDMP_LOG(LOG_DEBUG, "cstack_pop(0x%p): 0x%p", stk, stk_node);
free(stk_node);
return (0);
}
示例6: tlm_log_list
/*
* Print the list of array of strings in the backup log
*/
void
tlm_log_list(char *title, char **lpp)
{
int i;
if (!lpp)
return;
NDMP_LOG(LOG_DEBUG, "%s:", title);
for (i = 0; *lpp; lpp++, i++)
NDMP_LOG(LOG_DEBUG, "%d: [%s]", i, *lpp);
}
示例7: ndmp_run
/*
* ndmp_run
*
* Creates a socket for listening and accepting connections
* from NDMP clients.
* Accepts connections and passes each connection to the connection
* handler.
*
* Parameters:
* port (input) - NDMP server port.
* If 0, the port number will be retrieved from
* the network service database. If not found there,
* the default NDMP port number (from ndmp.x)
* will be used.
* handler (input) - connection handler function.
*
* Returns:
* This function normally never returns unless there's error.
* -1 : error
*
* Notes:
* This function does not return unless encountering an error
* related to the listen socket.
*/
int
ndmp_run(ulong_t port, ndmp_con_handler_func_t con_handler_func)
{
int ns;
int on;
int server_socket;
unsigned int ipaddr;
struct sockaddr_in sin;
ndmpd_worker_arg_t *argp;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(port);
if ((server_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
NDMP_LOG(LOG_DEBUG, "Socket error: %m");
return (-1);
}
on = 1;
(void) setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR,
(char *)&on, sizeof (on));
if (bind(server_socket, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
NDMP_LOG(LOG_DEBUG, "bind error: %m");
(void) close(server_socket);
return (-1);
}
if (listen(server_socket, 5) < 0) {
NDMP_LOG(LOG_DEBUG, "listen error: %m");
(void) close(server_socket);
return (-1);
}
for (; ; ) {
if ((ns = tcp_accept(server_socket, &ipaddr)) < 0) {
NDMP_LOG(LOG_DEBUG, "tcp_accept error: %m");
continue;
}
NDMP_LOG(LOG_DEBUG, "connection fd: %d", ns);
set_socket_options(ns);
if ((argp = ndmp_malloc(sizeof (ndmpd_worker_arg_t))) != NULL) {
argp->nw_sock = ns;
argp->nw_ipaddr = ipaddr;
argp->nw_con_handler_func = con_handler_func;
(void) ndmp_start_worker(argp);
}
}
}
示例8: ndmpd_api_file_recovered_v3
/*
* ndmpd_api_file_recovered_v3
*
* Notify the NDMP client that the specified file was recovered.
*
* Parameters:
* cookie (input) - session pointer.
* name (input) - name of recovered file.
* ssid (input) - selection set id.
* error (input) - 0 if file successfully recovered.
* otherwise, error code indicating why recovery failed.
*
* Returns:
* 0 - success.
* -1 - error.
*/
int
ndmpd_api_file_recovered_v3(void *cookie, char *name, int error)
{
ndmpd_session_t *session = (ndmpd_session_t *)cookie;
ndmp_log_file_request_v3 request;
if (session == NULL)
return (-1);
request.name = name;
switch (error) {
case 0:
request.error = NDMP_NO_ERR;
break;
case ENOENT:
request.error = NDMP_FILE_NOT_FOUND_ERR;
break;
default:
request.error = NDMP_PERMISSION_ERR;
}
if (ndmp_send_request_lock(session->ns_connection, NDMP_LOG_FILE,
NDMP_NO_ERR, (void *)&request, 0) < 0) {
NDMP_LOG(LOG_DEBUG, "Error sending log file request");
return (-1);
}
return (0);
}
示例9: ndmp_create_connection
/*
* ndmp_create_connection
*
* Allocate and initialize a connection structure.
*
* Parameters:
* handler_tbl (input) - message handlers.
*
* Returns:
* NULL - error
* connection pointer
*
* Notes:
* The returned connection should be destroyed using
* ndmp_destroy_connection().
*/
ndmp_connection_t *
ndmp_create_connection(void)
{
ndmp_connection_t *connection;
connection = ndmp_malloc(sizeof (ndmp_connection_t));
if (connection == NULL)
return (NULL);
connection->conn_sock = -1;
connection->conn_my_sequence = 0;
connection->conn_authorized = FALSE;
connection->conn_eof = FALSE;
connection->conn_msginfo.mi_body = 0;
connection->conn_version = ndmp_ver;
connection->conn_client_data = 0;
(void) mutex_init(&connection->conn_lock, 0, NULL);
connection->conn_xdrs.x_ops = 0;
xdrrec_create(&connection->conn_xdrs, 0, 0, (caddr_t)connection,
ndmp_readit, ndmp_writeit);
if (connection->conn_xdrs.x_ops == 0) {
NDMP_LOG(LOG_DEBUG, "xdrrec_create failed");
(void) mutex_destroy(&connection->conn_lock);
(void) close(connection->conn_sock);
free(connection);
return (0);
}
return ((ndmp_connection_t *)connection);
}
示例10: ndmpd_scsi_close_v2
/*ARGSUSED*/
void
ndmpd_scsi_close_v2(ndmp_connection_t *connection, void *body)
{
ndmp_scsi_close_reply reply;
ndmpd_session_t *session = ndmp_get_client_data(connection);
if (session->ns_scsi.sd_is_open == -1) {
NDMP_LOG(LOG_ERR, "SCSI device is not open.");
reply.error = NDMP_DEV_NOT_OPEN_ERR;
ndmp_send_reply(connection, (void *) &reply,
"sending scsi_close reply");
return;
}
(void) ndmp_open_list_del(session->ns_scsi.sd_adapter_name,
session->ns_scsi.sd_sid,
session->ns_scsi.sd_lun);
(void) close(session->ns_scsi.sd_devid);
session->ns_scsi.sd_is_open = -1;
session->ns_scsi.sd_devid = -1;
session->ns_scsi.sd_sid = 0;
session->ns_scsi.sd_lun = 0;
session->ns_scsi.sd_valid_target_set = FALSE;
(void) memset(session->ns_scsi.sd_adapter_name, 0,
sizeof (session->ns_scsi.sd_adapter_name));
reply.error = NDMP_NO_ERR;
ndmp_send_reply(connection, (void *) &reply,
"sending scsi_close reply");
}
示例11: ndmpd_api_log_v2
/*ARGSUSED*/
int
ndmpd_api_log_v2(void *cookie, char *format, ...)
{
ndmpd_session_t *session = (ndmpd_session_t *)cookie;
ndmp_log_log_request request;
static char buf[1024];
va_list ap;
if (session == NULL)
return (-1);
va_start(ap, format);
/*LINTED variable format specifier */
(void) vsnprintf(buf, sizeof (buf), format, ap);
va_end(ap);
request.entry = buf;
if (ndmp_send_request(session->ns_connection, _NDMP_LOG_LOG,
NDMP_NO_ERR, (void *)&request, 0) < 0) {
NDMP_LOG(LOG_DEBUG, "Sending log request");
return (-1);
}
return (0);
}
示例12: ndmpd_api_log_v4
/*ARGSUSED*/
int
ndmpd_api_log_v4(void *cookie, ndmp_log_type type, ulong_t msg_id,
char *format, ...)
{
ndmpd_session_t *session = (ndmpd_session_t *)cookie;
ndmp_log_message_request_v4 request;
static char buf[1024];
va_list ap;
if (session == NULL)
return (-1);
va_start(ap, format);
/*LINTED variable format specifier */
(void) vsnprintf(buf, sizeof (buf), format, ap);
va_end(ap);
request.entry = buf;
request.log_type = type;
request.message_id = msg_id;
request.associated_message_valid = NDMP_NO_ASSOCIATED_MESSAGE;
request.associated_message_sequence = 0;
if (ndmp_send_request(session->ns_connection, NDMP_LOG_MESSAGE,
NDMP_NO_ERR, (void *)&request, 0) < 0) {
NDMP_LOG(LOG_DEBUG, "Error sending log message request.");
return (-1);
}
return (0);
}
示例13: chkpnt_creationtime_bypattern
/*
* Get the snapshot creation time
*/
int
chkpnt_creationtime_bypattern(char *volname, char *pattern, time_t *tp)
{
char chk_name[PATH_MAX];
zfs_handle_t *zhp;
char *p;
if (!volname || !*volname)
return (-1);
/* Should also return -1 if checkpoint not enabled */
/* Remove the leading slash */
p = volname;
while (*p == '/')
p++;
(void) strlcpy(chk_name, p, PATH_MAX);
(void) strlcat(chk_name, "@", PATH_MAX);
(void) strlcat(chk_name, pattern, PATH_MAX);
(void) mutex_lock(&zlib_mtx);
if ((zhp = zfs_open(zlibh, chk_name, ZFS_TYPE_DATASET)) == NULL) {
NDMP_LOG(LOG_DEBUG, "chkpnt_creationtime: open %s failed",
chk_name);
(void) mutex_unlock(&zlib_mtx);
return (-1);
}
*tp = zfs_prop_get_int(zhp, ZFS_PROP_CREATION);
zfs_close(zhp);
(void) mutex_unlock(&zlib_mtx);
return (0);
}
示例14: ndmpd_api_add_env
/*
* ndmpd_api_add_env
*
* Adds an environment variable name/value pair to the environment
* variable list.
*
* Parameters:
* session (input) - session pointer.
* name (input) - variable name.
* val (input) - value.
*
* Returns:
* 0 - success.
* -1 - error.
*/
int
ndmpd_api_add_env(void *cookie, char *name, char *value)
{
ndmpd_session_t *session = (ndmpd_session_t *)cookie;
char *namebuf;
char *valbuf;
if (session == NULL)
return (-1);
session->ns_data.dd_env = realloc((void *)session->ns_data.dd_env,
sizeof (ndmp_pval) * (session->ns_data.dd_env_len + 1));
if (session->ns_data.dd_env == NULL) {
NDMP_LOG(LOG_ERR, "Out of memory.");
return (-1);
}
namebuf = strdup(name);
if (namebuf == NULL)
return (-1);
valbuf = strdup(value);
if (valbuf == NULL) {
free(namebuf);
return (-1);
}
(void) mutex_lock(&session->ns_lock);
session->ns_data.dd_env[session->ns_data.dd_env_len].name = namebuf;
session->ns_data.dd_env[session->ns_data.dd_env_len].value = valbuf;
session->ns_data.dd_env_len++;
(void) mutex_unlock(&session->ns_lock);
return (0);
}
示例15: tlm_entry_restored
/*
* Log call back to report the entry recovery
*/
int
tlm_entry_restored(tlm_job_stats_t *job_stats, char *name, int pos)
{
lbr_fhlog_call_backs_t *cbp; /* callbacks pointer */
NDMP_LOG(LOG_DEBUG, "name: \"%s\", pos: %d", name, pos);
if (job_stats == NULL) {
NDMP_LOG(LOG_DEBUG, "entry_restored: jstat is NULL");
return (0);
}
cbp = (lbr_fhlog_call_backs_t *)job_stats->js_callbacks;
if (cbp == NULL) {
NDMP_LOG(LOG_DEBUG, "entry_restored is NULL");
return (0);
}
return (*cbp->fh_logpname)(cbp, name, 0, (longlong_t)pos);
}