Example #1
0
/*
 * ndmpd_main
 *
 * NDMP main function called from main().
 *
 * Parameters:
 *   void
 *
 * Returns:
 *   void
 */
void
ndmpd_main(void)
{
	char *propval;

	ndmp_load_params();

	/*
	 * Find ndmp port number to be used. If ndmpd is run as command line
	 * and port number is supplied, use that port number. If port number is
	 * is not supplied, find out if ndmp port property is set. If ndmp
	 * port property is set, use that port number otherwise use the defaule
	 * port number.
	 */
	if (ndmp_port == 0) {
		if ((propval = ndmpd_get_prop(NDMP_TCP_PORT)) == NULL ||
		    *propval == 0)
			ndmp_port = NDMPPORT;
		else
			ndmp_port = strtol(propval, 0, 0);
	}

	if (ndmp_run(ndmp_port, connection_handler) == -1)
		perror("ndmp_run ERROR");
}
Example #2
0
/*
 * Returns the value of a yes/no config param.
 * Returns 1 is config is set to "yes", otherwise 0.
 */
int
ndmpd_get_prop_yorn(ndmpd_cfg_id_t id)
{
	char *val;

	val = ndmpd_get_prop(id);
	if (val) {
		if (strcasecmp(val, "yes") == 0)
			return (1);
	}

	return (0);
}
Example #3
0
/*
 * Similar to ndmpd_get_prop except it will return dflt value
 * if env is not set.
 */
char *
ndmpd_get_prop_default(ndmpd_cfg_id_t id, char *dflt)
{
	char *env;

	env = ndmpd_get_prop(id);

	if (env && *env != 0) {
		return (env);
	} else {
		return (dflt);
	}
}
Example #4
0
/*
 * Go through the attached devices and detect the tape
 * and robot by checking the /dev entries
 */
int
probe_scsi(void)
{
    DIR *dirp;
    struct dirent *dp;
    scsi_adapter_t *sa = &my_sa;
    char *p;
    int lun = 0;
    int sid = 0;
    char *drive_type;

    /* Initialize the scsi adapter link */
    sa->sa_link_head.sl_next = &sa->sa_link_head;

    /* Scan for the changer */
    dirp = opendir(SCSI_CHANGER_DIR);
    if (dirp == NULL) {
        NDMP_LOG(LOG_DEBUG,
                 "Changer directory read error %s", SCSI_CHANGER_DIR);
    } else {
        while ((dp = readdir(dirp)) != NULL) {
            if ((strcmp(dp->d_name, ".") == 0) ||
                    (strcmp(dp->d_name, "..") == 0))
                continue;

            if ((p = strchr(dp->d_name, 'd')) != NULL) {
                lun = atoi(++p);
                p = strchr(dp->d_name, 't');
                sid = atoi(++p);
            }
            else
                sid = atoi(dp->d_name);

            scsi_sasd_attach(sa, 0, lun, dp->d_name,
                             DTYPE_CHANGER);
        }
        (void) closedir(dirp);
    }

    /* Scan for tape drives */
    dirp = opendir(SCSI_TAPE_DIR);
    if (dirp == NULL) {
        NDMP_LOG(LOG_DEBUG,
                 "Tape directory read error %s", SCSI_TAPE_DIR);
    } else {
        drive_type = ndmpd_get_prop(NDMP_DRIVE_TYPE);

        if ((strcasecmp(drive_type, "sysv") != 0) &&
                (strcasecmp(drive_type, "bsd") != 0)) {
            NDMP_LOG(LOG_ERR, "Invalid ndmpd/drive-type value. "
                     "Valid values are 'sysv' and 'bsd'.");
            return (-1);
        }

        while ((dp = readdir(dirp)) != NULL) {
            if ((strcmp(dp->d_name, ".") == 0) ||
                    (strcmp(dp->d_name, "..") == 0))
                continue;

            /* Skip special modes */
            if (strpbrk(dp->d_name, "chlmu") != NULL)
                continue;

            /* Pick the non-rewind device */
            if (strchr(dp->d_name, 'n') == NULL)
                continue;

            if (strcasecmp(drive_type, "sysv") == 0) {
                if (strchr(dp->d_name, 'b') != NULL)
                    continue;
            } else if (strcasecmp(drive_type, "bsd") == 0) {
                if (strchr(dp->d_name, 'b') == NULL)
                    continue;
            }

            sid = atoi(dp->d_name);

            /*
             * SCSI ID should match with the ID of the device
             * (will be checked by SCSI get elements page later)
             */
            scsi_sasd_attach(sa, sid, 0, dp->d_name,
                             DTYPE_SEQUENTIAL);
        }
        (void) closedir(dirp);
    }

    return (0);
}