Print this page
NEX-9532 NDMP: readdir errors when file/directory has special characters
Reviewed by: Peer Dampmann <peer.dampmann@nexenta.com>
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
NEX-799 past last file mark returned NDMP_IO_ERR, should be NDMP_EOM_ERR (V4+)
NEX-812 NDMP backup terminate after hit the EOM in Netbackup backup
NEX-355 NDMP backup, EOF position remains on BOT side of filemark
NEX-249 NS ndmp can't write to a brand new tape with IO error (fix cstyle)
SUP-484 NDMP backup jobs error out when reaching the end of media (EOM)
NEX-249 NS ndmp can't write to a brand new tape with IO error

*** 35,47 **** * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* Copyright (c) 2007, The Storage Networking Industry Association. */ /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */ ! /* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ #include <sys/param.h> #include <fcntl.h> #include <sys/mtio.h> #include <errno.h> #include <stdio.h> #include <string.h> --- 35,48 ---- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* Copyright (c) 2007, The Storage Networking Industry Association. */ /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */ ! /* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */ #include <sys/param.h> + #include <syslog.h> #include <fcntl.h> #include <sys/mtio.h> #include <errno.h> #include <stdio.h> #include <string.h>
*** 113,139 **** char adptnm[SCSI_MAX_NAME]; int mode; int sid, lun; int err; scsi_adapter_t *sa; ! int devid; err = NDMP_NO_ERR; if (session->ns_tape.td_fd != -1 || session->ns_scsi.sd_is_open != -1) { ! NDMP_LOG(LOG_INFO, "Connection already has a tape or scsi device open"); err = NDMP_DEVICE_OPENED_ERR; } else if (request->mode != NDMP_TAPE_READ_MODE && request->mode != NDMP_TAPE_WRITE_MODE && request->mode != NDMP_TAPE_RAW1_MODE) { err = NDMP_ILLEGAL_ARGS_ERR; } if ((sa = scsi_get_adapter(0)) != NULL) { - NDMP_LOG(LOG_DEBUG, - "Adapter device opened: %s", request->device.name); (void) strlcpy(adptnm, request->device.name, SCSI_MAX_NAME-2); adptnm[SCSI_MAX_NAME-1] = '\0'; sid = lun = -1; } /* try to get the scsi id etc.... */ --- 114,138 ---- char adptnm[SCSI_MAX_NAME]; int mode; int sid, lun; int err; scsi_adapter_t *sa; ! int devid = -1; err = NDMP_NO_ERR; if (session->ns_tape.td_fd != -1 || session->ns_scsi.sd_is_open != -1) { ! syslog(LOG_INFO, "Connection already has a tape or scsi device open"); err = NDMP_DEVICE_OPENED_ERR; } else if (request->mode != NDMP_TAPE_READ_MODE && request->mode != NDMP_TAPE_WRITE_MODE && request->mode != NDMP_TAPE_RAW1_MODE) { err = NDMP_ILLEGAL_ARGS_ERR; } if ((sa = scsi_get_adapter(0)) != NULL) { (void) strlcpy(adptnm, request->device.name, SCSI_MAX_NAME-2); adptnm[SCSI_MAX_NAME-1] = '\0'; sid = lun = -1; } /* try to get the scsi id etc.... */
*** 140,157 **** if (sa) { scsi_find_sid_lun(sa, request->device.name, &sid, &lun); if (ndmp_open_list_find(request->device.name, sid, lun) == 0 && (devid = tape_open(request->device.name, O_RDWR | O_NDELAY)) < 0) { ! NDMP_LOG(LOG_ERR, "Failed to open device %s: %m.", request->device.name); err = NDMP_NO_DEVICE_ERR; } else (void) close(devid); } else { ! NDMP_LOG(LOG_ERR, "%s: No such tape device.", request->device.name); err = NDMP_NO_DEVICE_ERR; } if (err != NDMP_NO_ERR) { tape_open_send_reply(connection, err); --- 139,156 ---- if (sa) { scsi_find_sid_lun(sa, request->device.name, &sid, &lun); if (ndmp_open_list_find(request->device.name, sid, lun) == 0 && (devid = tape_open(request->device.name, O_RDWR | O_NDELAY)) < 0) { ! syslog(LOG_ERR, "Failed to open device %s: %m.", request->device.name); err = NDMP_NO_DEVICE_ERR; } else (void) close(devid); } else { ! syslog(LOG_ERR, "%s: No such tape device.", request->device.name); err = NDMP_NO_DEVICE_ERR; } if (err != NDMP_NO_ERR) { tape_open_send_reply(connection, err);
*** 190,200 **** } mode = (request->mode == NDMP_TAPE_READ_MODE) ? O_RDONLY : O_RDWR; mode |= O_NDELAY; if ((session->ns_tape.td_fd = open(request->device.name, mode)) < 0) { ! NDMP_LOG(LOG_ERR, "Failed to open tape device %s: %m.", request->device.name); switch (errno) { case EACCES: err = NDMP_WRITE_PROTECT_ERR; break; --- 189,199 ---- } mode = (request->mode == NDMP_TAPE_READ_MODE) ? O_RDONLY : O_RDWR; mode |= O_NDELAY; if ((session->ns_tape.td_fd = open(request->device.name, mode)) < 0) { ! syslog(LOG_ERR, "Failed to open tape device %s: %m.", request->device.name); switch (errno) { case EACCES: err = NDMP_WRITE_PROTECT_ERR; break;
*** 218,229 **** session->ns_tape.td_sid = sid; session->ns_tape.td_lun = lun; (void) strlcpy(session->ns_tape.td_adapter_name, adptnm, SCSI_MAX_NAME); session->ns_tape.td_record_count = 0; - NDMP_LOG(LOG_DEBUG, "Tape is opened fd: %d", session->ns_tape.td_fd); - tape_open_send_reply(connection, NDMP_NO_ERR); } /* --- 217,226 ----
*** 244,254 **** { ndmp_tape_close_reply reply; ndmpd_session_t *session = ndmp_get_client_data(connection); if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_close reply"); return; } --- 241,251 ---- { ndmp_tape_close_reply reply; ndmpd_session_t *session = ndmp_get_client_data(connection); if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_close reply"); return; }
*** 279,310 **** struct mtget mtstatus; struct mtdrivetype_request dtpr; struct mtdrivetype dtp; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; } if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) < 0) { ! NDMP_LOG(LOG_ERR, "Failed to get status from tape: %m."); ! NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGET) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! NDMP_LOG(LOG_ERR, "Failed to get drive type information from tape: %m."); - NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGETDRIVETYPE) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; } --- 276,305 ---- struct mtget mtstatus; struct mtdrivetype_request dtpr; struct mtdrivetype dtp; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; } if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) < 0) { ! syslog(LOG_ERR, "Failed to get status from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! syslog(LOG_ERR, "Failed to get drive type information from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; }
*** 322,335 **** reply.soft_errors = 0; reply.total_space = long_long_to_quad(0); /* not supported */ reply.space_remain = long_long_to_quad(0); /* not supported */ - NDMP_LOG(LOG_DEBUG, - "flags: 0x%x, file_num: %d, block_size: %d, blockno: %d", - reply.flags, reply.file_num, reply.block_size, reply.blockno); - reply.error = NDMP_NO_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); } --- 317,326 ----
*** 359,369 **** int rc; reply.resid_count = 0; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_mtio reply"); return; } --- 350,360 ---- int rc; reply.resid_count = 0; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_mtio reply"); return; }
*** 412,424 **** do { NS_UPD(twait, trun); errno = 0; rc = ioctl(session->ns_tape.td_fd, MTIOCTOP, &tapeop); NS_UPD(trun, twait); - NDMP_LOG(LOG_DEBUG, - "ioctl MTIO rc:%d, cmd:%d, retry:%d, error: %d", - rc, tapeop.mt_op, retry, errno); } while (rc < 0 && errno == EIO && retry++ < 5); /* * Ignore I/O errors since these usually are the result of --- 403,412 ----
*** 425,437 **** * attempting to position past the beginning or end of the tape. * The residual count will be returned and can be used to * determine that the call was not completely successful. */ if (rc < 0) { ! NDMP_LOG(LOG_ERR, "Failed to send command to tape: %m."); - NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCTOP) error: %m."); /* MTWEOF doesnt have residual count */ if (tapeop.mt_op == MTWEOF) reply.error = NDMP_IO_ERR; else --- 413,424 ---- * attempting to position past the beginning or end of the tape. * The residual count will be returned and can be used to * determine that the call was not completely successful. */ if (rc < 0) { ! syslog(LOG_ERR, "Failed to send command to tape: %m."); /* MTWEOF doesnt have residual count */ if (tapeop.mt_op == MTWEOF) reply.error = NDMP_IO_ERR; else
*** 444,457 **** if (request->tape_op != NDMP_MTIO_REW && request->tape_op != NDMP_MTIO_OFF) { if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) < 0) { ! NDMP_LOG(LOG_ERR, "Failed to send command to tape: %m."); - NDMP_LOG(LOG_DEBUG, - "ioctl(MTIOCGET) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_mtio reply"); return; --- 431,442 ---- if (request->tape_op != NDMP_MTIO_REW && request->tape_op != NDMP_MTIO_OFF) { if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) < 0) { ! syslog(LOG_ERR, "Failed to send command to tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_mtio reply"); return;
*** 459,470 **** reply.resid_count = labs(mtstatus.mt_resid); } } - NDMP_LOG(LOG_DEBUG, "resid_count: %d", - reply.resid_count); ndmp_send_reply(connection, (void *) &reply, "sending tape_mtio reply"); } /* --- 444,453 ----
*** 497,507 **** char *buf; reply.data_in.data_in_len = 0; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_read reply"); return; } --- 480,490 ---- char *buf; reply.data_in.data_in_len = 0; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_read reply"); return; }
*** 547,557 **** request = (ndmp_tape_execute_cdb_request *) body; if (session->ns_tape.td_fd == -1) { (void) memset((void *) &reply, 0, sizeof (reply)); ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_execute_cdb reply"); } else { ndmp_execute_cdb(session, session->ns_tape.td_adapter_name, --- 530,540 ---- request = (ndmp_tape_execute_cdb_request *) body; if (session->ns_tape.td_fd == -1) { (void) memset((void *) &reply, 0, sizeof (reply)); ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_execute_cdb reply"); } else { ndmp_execute_cdb(session, session->ns_tape.td_adapter_name,
*** 610,629 **** struct mtdrivetype_request dtpr; struct mtdrivetype dtp; struct mtget mtstatus; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; } if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) == -1) { ! NDMP_LOG(LOG_ERR, "Failed to get status from tape: %m."); ! NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGET) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; --- 593,611 ---- struct mtdrivetype_request dtpr; struct mtdrivetype dtp; struct mtget mtstatus; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; } if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) == -1) { ! syslog(LOG_ERR, "Failed to get status from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return;
*** 630,642 **** } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! NDMP_LOG(LOG_ERR, "Failed to get drive type information from tape: %m."); - NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGETDRIVETYPE) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; --- 612,623 ---- } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! syslog(LOG_ERR, "Failed to get drive type information from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return;
*** 663,676 **** reply.invalid = NDMP_TAPE_STATE_SOFT_ERRORS_INVALID | NDMP_TAPE_STATE_TOTAL_SPACE_INVALID | NDMP_TAPE_STATE_SPACE_REMAIN_INVALID | NDMP_TAPE_STATE_PARTITION_INVALID; - - NDMP_LOG(LOG_DEBUG, "f 0x%x, fnum %d, bsize %d, bno: %d", - reply.flags, reply.file_num, reply.block_size, reply.blockno); - reply.error = NDMP_NO_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); } --- 644,653 ----
*** 762,779 **** ndmp_get_client_data(connection); ssize_t n; reply.count = 0; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply"); return; } if (session->ns_tape.td_mode == NDMP_TAPE_READ_MODE) { ! NDMP_LOG(LOG_INFO, "Tape device opened in read-only mode"); reply.error = NDMP_PERMISSION_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply"); return; } --- 739,756 ---- ndmp_get_client_data(connection); ssize_t n; reply.count = 0; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply"); return; } if (session->ns_tape.td_mode == NDMP_TAPE_READ_MODE) { ! syslog(LOG_INFO, "Tape device opened in read-only mode"); reply.error = NDMP_PERMISSION_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply"); return; }
*** 800,821 **** n = write(session->ns_tape.td_fd, request->data_out.data_out_val, request->data_out.data_out_len); if (n < 0) { ! NDMP_LOG(LOG_ERR, "Tape write error: %m."); reply.error = NDMP_IO_ERR; } else if (n == 0) { ! NDMP_LOG(LOG_INFO, "EOM detected"); reply.error = NDMP_EOM_ERR; } else { NS_ADD(wtape, n); reply.count = n; reply.error = NDMP_NO_ERR; if (n < request->data_out.data_out_len) ! NDMP_LOG(LOG_DEBUG, "EOM is coming (partial write of %d bytes)", n); } ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply"); --- 777,798 ---- n = write(session->ns_tape.td_fd, request->data_out.data_out_val, request->data_out.data_out_len); if (n < 0) { ! syslog(LOG_ERR, "Tape write error: %m."); reply.error = NDMP_IO_ERR; } else if (n == 0) { ! syslog(LOG_INFO, "EOM detected"); reply.error = NDMP_EOM_ERR; } else { NS_ADD(wtape, n); reply.count = n; reply.error = NDMP_NO_ERR; if (n < request->data_out.data_out_len) ! syslog(LOG_DEBUG, "EOM is coming (partial write of %d bytes)", n); } ndmp_send_reply(connection, (void *) &reply, "sending tape_write reply");
*** 851,861 **** int n; reply.data_in.data_in_len = 0; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_read reply"); return; } --- 828,838 ---- int n; reply.data_in.data_in_len = 0; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_read reply"); return; }
*** 899,930 **** /* * If at beginning of file and read fails with EIO, then it's * repeated attempt to read at EOT. */ else if (errno == EIO && tape_is_at_bof(session)) { ! NDMP_LOG(LOG_DEBUG, "Repeated read at EOT"); reply.error = NDMP_EOM_ERR; } /* * According to NDMPv4 spec preferred error code when * trying to read from blank tape is NDMP_EOM_ERR. */ else if (errno == EIO && tape_is_at_bot(session)) { ! NDMP_LOG(LOG_ERR, "Blank tape detected, returning EOM"); reply.error = NDMP_EOM_ERR; } else { ! NDMP_LOG(LOG_ERR, "Tape read error: %m."); reply.error = NDMP_IO_ERR; } } else if (n == 0) { if (tape_is_at_bof(session)) { ! NDMP_LOG(LOG_DEBUG, "EOT detected"); reply.error = NDMP_EOM_ERR; } else { /* reposition the tape to BOT side of FM */ fm_dance(session); ! NDMP_LOG(LOG_DEBUG, "EOF detected"); reply.error = NDMP_EOF_ERR; } } else { session->ns_tape.td_pos += n; reply.data_in.data_in_len = n; --- 876,907 ---- /* * If at beginning of file and read fails with EIO, then it's * repeated attempt to read at EOT. */ else if (errno == EIO && tape_is_at_bof(session)) { ! syslog(LOG_DEBUG, "Repeated read at EOT"); reply.error = NDMP_EOM_ERR; } /* * According to NDMPv4 spec preferred error code when * trying to read from blank tape is NDMP_EOM_ERR. */ else if (errno == EIO && tape_is_at_bot(session)) { ! syslog(LOG_ERR, "Blank tape detected, returning EOM"); reply.error = NDMP_EOM_ERR; } else { ! syslog(LOG_ERR, "Tape read error: %m."); reply.error = NDMP_IO_ERR; } } else if (n == 0) { if (tape_is_at_bof(session)) { ! syslog(LOG_DEBUG, "EOT detected"); reply.error = NDMP_EOM_ERR; } else { /* reposition the tape to BOT side of FM */ fm_dance(session); ! syslog(LOG_DEBUG, "EOF detected"); reply.error = NDMP_EOF_ERR; } } else { session->ns_tape.td_pos += n; reply.data_in.data_in_len = n;
*** 966,976 **** struct mtget mtstatus; struct mtdrivetype_request dtpr; struct mtdrivetype dtp; if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; } --- 943,953 ---- struct mtget mtstatus; struct mtdrivetype_request dtpr; struct mtdrivetype dtp; if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); return; }
*** 978,990 **** /* * Need code to detect NDMP_TAPE_STATE_NOREWIND */ if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) == -1) { ! NDMP_LOG(LOG_ERR, "Failed to get status information from tape: %m."); - NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGET) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; --- 955,966 ---- /* * Need code to detect NDMP_TAPE_STATE_NOREWIND */ if (ioctl(session->ns_tape.td_fd, MTIOCGET, &mtstatus) == -1) { ! syslog(LOG_ERR, "Failed to get status information from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return;
*** 991,1003 **** } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! NDMP_LOG(LOG_ERR, "Failed to get drive type information from tape: %m."); - NDMP_LOG(LOG_DEBUG, "ioctl(MTIOCGETDRIVETYPE) error: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return; --- 967,978 ---- } dtpr.size = sizeof (struct mtdrivetype); dtpr.mtdtp = &dtp; if (ioctl(session->ns_tape.td_fd, MTIOCGETDRIVETYPE, &dtpr) == -1) { ! syslog(LOG_ERR, "Failed to get drive type information from tape: %m."); reply.error = NDMP_IO_ERR; ndmp_send_reply(connection, (void *)&reply, "sending tape_get_state reply"); return;
*** 1021,1033 **** reply.unsupported = NDMP_TAPE_STATE_SOFT_ERRORS_INVALID | NDMP_TAPE_STATE_TOTAL_SPACE_INVALID | NDMP_TAPE_STATE_SPACE_REMAIN_INVALID | NDMP_TAPE_STATE_PARTITION_INVALID; - NDMP_LOG(LOG_DEBUG, "f 0x%x, fnum %d, bsize %d, bno: %d", - reply.flags, reply.file_num, reply.block_size, reply.blockno); - reply.error = NDMP_NO_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_get_state reply"); } /* --- 996,1005 ----
*** 1048,1058 **** { ndmp_tape_close_reply reply; ndmpd_session_t *session = ndmp_get_client_data(connection); if (session->ns_tape.td_fd == -1) { ! NDMP_LOG(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_close reply"); return; } --- 1020,1030 ---- { ndmp_tape_close_reply reply; ndmpd_session_t *session = ndmp_get_client_data(connection); if (session->ns_tape.td_fd == -1) { ! syslog(LOG_ERR, "Tape device is not open."); reply.error = NDMP_DEV_NOT_OPEN_ERR; ndmp_send_reply(connection, (void *) &reply, "sending tape_close reply"); return; }
*** 1127,1153 **** * of spanned data between the tapes. */ if (errno == ENOSPC) { reply->error = NDMP_EOF_ERR; } else { ! NDMP_LOG(LOG_ERR, "Tape read error: %m."); reply->error = NDMP_IO_ERR; } } else if (n == 0) { - NDMP_LOG(LOG_DEBUG, "NDMP_EOF_ERR"); - reply->error = NDMP_EOF_ERR; (void) ndmp_mtioctl(session->ns_tape.td_fd, MTFSF, 1); len = strlen(NDMP_EOM_MAGIC); (void) memset(buf, 0, len); n = read(session->ns_tape.td_fd, buf, len); buf[len] = '\0'; - NDMP_LOG(LOG_DEBUG, "Checking EOM: nread %d [%s]", n, buf); - (void) ndmp_mtioctl(session->ns_tape.td_fd, MTBSF, 1); if (strncmp(buf, NDMP_EOM_MAGIC, len) != 0) (void) ndmp_mtioctl(session->ns_tape.td_fd, MTFSF, 1); } else { --- 1099,1121 ---- * of spanned data between the tapes. */ if (errno == ENOSPC) { reply->error = NDMP_EOF_ERR; } else { ! syslog(LOG_ERR, "Tape read error: %m."); reply->error = NDMP_IO_ERR; } } else if (n == 0) { reply->error = NDMP_EOF_ERR; (void) ndmp_mtioctl(session->ns_tape.td_fd, MTFSF, 1); len = strlen(NDMP_EOM_MAGIC); (void) memset(buf, 0, len); n = read(session->ns_tape.td_fd, buf, len); buf[len] = '\0'; (void) ndmp_mtioctl(session->ns_tape.td_fd, MTBSF, 1); if (strncmp(buf, NDMP_EOM_MAGIC, len) != 0) (void) ndmp_mtioctl(session->ns_tape.td_fd, MTFSF, 1); } else {
*** 1205,1242 **** char adptnm[SCSI_MAX_NAME]; int err; int mode; int sid, lun; scsi_adapter_t *sa; ! int devid; err = NDMP_NO_ERR; if (session->ns_tape.td_fd != -1 || session->ns_scsi.sd_is_open != -1) { ! NDMP_LOG(LOG_INFO, "Connection already has a tape or scsi device open"); err = NDMP_DEVICE_OPENED_ERR; } else if (!validmode(ndmpmode)) err = NDMP_ILLEGAL_ARGS_ERR; if ((sa = scsi_get_adapter(0)) != NULL) { - NDMP_LOG(LOG_DEBUG, "Adapter device opened: %s", devname); (void) strlcpy(adptnm, devname, SCSI_MAX_NAME-2); adptnm[SCSI_MAX_NAME-1] = '\0'; sid = lun = -1; } if (sa) { scsi_find_sid_lun(sa, devname, &sid, &lun); if (ndmp_open_list_find(devname, sid, lun) == 0 && (devid = open(devname, O_RDWR | O_NDELAY)) < 0) { ! NDMP_LOG(LOG_ERR, "Failed to open device %s: %m.", devname); err = NDMP_NO_DEVICE_ERR; } else { (void) close(devid); } } else { ! NDMP_LOG(LOG_ERR, "%s: No such tape device.", devname); err = NDMP_NO_DEVICE_ERR; } if (err != NDMP_NO_ERR) { tape_open_send_reply(connection, err); --- 1173,1209 ---- char adptnm[SCSI_MAX_NAME]; int err; int mode; int sid, lun; scsi_adapter_t *sa; ! int devid = -1; err = NDMP_NO_ERR; if (session->ns_tape.td_fd != -1 || session->ns_scsi.sd_is_open != -1) { ! syslog(LOG_INFO, "Connection already has a tape or scsi device open"); err = NDMP_DEVICE_OPENED_ERR; } else if (!validmode(ndmpmode)) err = NDMP_ILLEGAL_ARGS_ERR; if ((sa = scsi_get_adapter(0)) != NULL) { (void) strlcpy(adptnm, devname, SCSI_MAX_NAME-2); adptnm[SCSI_MAX_NAME-1] = '\0'; sid = lun = -1; } if (sa) { scsi_find_sid_lun(sa, devname, &sid, &lun); if (ndmp_open_list_find(devname, sid, lun) == 0 && (devid = open(devname, O_RDWR | O_NDELAY)) < 0) { ! syslog(LOG_ERR, "Failed to open device %s: %m.", devname); err = NDMP_NO_DEVICE_ERR; } else { (void) close(devid); } } else { ! syslog(LOG_ERR, "%s: No such tape device.", devname); err = NDMP_NO_DEVICE_ERR; } if (err != NDMP_NO_ERR) { tape_open_send_reply(connection, err);
*** 1267,1277 **** */ ndmpmode = NDMP_TAPE_READ_MODE; session->ns_tape.td_fd = open(devname, O_RDONLY); } if (session->ns_tape.td_fd < 0) { ! NDMP_LOG(LOG_ERR, "Failed to open tape device %s: %m.", devname); switch (errno) { case EACCES: err = NDMP_WRITE_PROTECT_ERR; break; --- 1234,1244 ---- */ ndmpmode = NDMP_TAPE_READ_MODE; session->ns_tape.td_fd = open(devname, O_RDONLY); } if (session->ns_tape.td_fd < 0) { ! syslog(LOG_ERR, "Failed to open tape device %s: %m.", devname); switch (errno) { case EACCES: err = NDMP_WRITE_PROTECT_ERR; break;
*** 1315,1326 **** session->ns_tape.td_sid = sid; session->ns_tape.td_lun = lun; (void) strlcpy(session->ns_tape.td_adapter_name, adptnm, SCSI_MAX_NAME); session->ns_tape.td_record_count = 0; - NDMP_LOG(LOG_DEBUG, "Tape is opened fd: %d", session->ns_tape.td_fd); - tape_open_send_reply(connection, NDMP_NO_ERR); } /* --- 1282,1291 ----