int host_info_print(int info_level, uint32_t host_no) { int num_found = 0, err = 0; char *version; unsigned int flags = 0; switch (info_level) { case 0: case -1: err = iscsi_sysfs_for_each_host(NULL, &num_found, host_info_print_flat); break; case 4: version = iscsi_sysfs_get_iscsi_kernel_version(); if (version) { printf("iSCSI Transport Class version %s\n", version); printf("version %s\n", ISCSI_VERSION_STR); free(version); } flags |= SESSION_INFO_SCSI_DEVS; /* fall through */ case 3: flags |= SESSION_INFO_ISCSI_PARAMS; /* fall through */ case 2: flags |= SESSION_INFO_ISCSI_STATE | SESSION_INFO_IFACE; /* fall through */ case 1: if (host_no != -1) { struct host_info hinfo; memset(&hinfo, 0, sizeof(struct host_info)); hinfo.host_no = host_no; iscsi_sysfs_get_hostinfo_by_host_no(&hinfo); host_info_print_tree(&flags, &hinfo); num_found = 1; break; } transport_probe_for_offload(); err = iscsi_sysfs_for_each_host(&flags, &num_found, host_info_print_tree); break; default: log_error("Invalid info level %d. Try 0 - 4.", info_level); return ISCSI_ERR_INVAL; } if (err) { log_error("Can not get list of iSCSI hosts: %s", iscsi_err_to_str(err)); return err; } else if (!num_found) { log_error("No iSCSI hosts."); return ISCSI_ERR_NO_OBJS_FOUND; } return 0; }
/* * Create a default iface for offload cards. We assume that we will * be able identify each host by MAC. */ void iface_setup_host_bindings(void) { int nr_found = 0; if (idbm_lock()) return; if (access(IFACE_CONFIG_DIR, F_OK) != 0) { if (mkdir(IFACE_CONFIG_DIR, 0660) != 0) { log_error("Could not make %s. HW/OFFLOAD iscsi " "may not be supported", IFACE_CONFIG_DIR); idbm_unlock(); return; } } idbm_unlock(); transport_probe_for_offload(); if (iscsi_sysfs_for_each_host(NULL, &nr_found, __iface_setup_host_bindings)) log_error("Could not scan scsi hosts. HW/OFFLOAD iscsi " "operations may not be supported, or please " "see README for instructions on setting up ifaces."); }