Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
DISCONTINUED:openSUSE:11.2:Update
lsscsi
lsscsi-0.21-usb-transport
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File lsscsi-0.21-usb-transport of Package lsscsi
Index: lsscsi.c =================================================================== --- lsscsi.c.orig +++ lsscsi.c @@ -39,8 +39,9 @@ static const char * version_str = "0.21 #define TRANSPORT_SAS 3 #define TRANSPORT_SAS_CLASS 4 #define TRANSPORT_ISCSI 5 #define TRANSPORT_SBP 6 +#define TRANSPORT_USB 6 static int transport_id = TRANSPORT_UNKNOWN; @@ -49,8 +50,9 @@ static const char * sysfs_name = "sysfs" static const char * sysfs_test_dir = "/sys/class"; static const char * sysfs_test_top = "/sys"; static const char * proc_mounts = "/proc/mounts"; static const char * bus_scsi_devs = "/bus/scsi/devices"; +static const char * bus_usb_devs = "/bus/usb/devices"; static const char * class_scsi_dev = "/class/scsi_device/"; static const char * scsi_host = "/class/scsi_host"; static const char * spi_host = "/class/spi_host/"; static const char * spi_transport = "/class/spi_transport/"; @@ -894,8 +925,50 @@ transport_init(const char * devname, /* // host output? // Hmmm, probably would like SAM-4 ",i,0x" notation here. return 1; } + + /* USB host */ + do { + char *t, buff2[NAME_LEN_MAX]; + + /* resolve SCSI host device */ + strcpy(buff, sysfsroot); + strcat(buff, scsi_host); + strcat(buff, "/"); + strcat(buff, devname); + strcat(buff, "/device"); + if (readlink(buff, buff2, sizeof(buff2)) <= 0) + break; + + /* check if the SCSI host has a USB host as ancestor */ + if (!(t = strstr(buff2, "/usb"))) + break; + transport_id = TRANSPORT_USB; + + /* Get USB id */ + if (!(t = strstr(buff2, "/host"))) + break; + /* terminate buff2 after USB host */ + if (!(t = strchr(t - 1, '/'))) + break; + *t = 0; + + /* resolve USB host device */ + buff[strlen(buff) - strlen("device")] = 0; + if (strlen(buff) + strlen(buff2) + strlen("devnum") + 2 + > NAME_LEN_MAX) + break; + strcat(buff, buff2); + + /* read the USB device number */ + if (!get_value(buff, "devnum", buff2, sizeof(buff)) || + strlen(buff2) < 1) + break; + snprintf(b, b_len, "usb:%s", buff2); + return 1; + } while (0); + return 0; } static void @@ -1146,9 +1219,9 @@ transport_tport(const char * devname, /* IEEE1394 SBP device */ transport_id = TRANSPORT_SBP; snprintf(b, b_len, "sbp:%s", wd); return 1; - } + } /* iSCSI device? */ strcpy(buff, sysfsroot); strcat(buff, iscsi_host); off = strlen(buff); @@ -1172,8 +1245,40 @@ transport_tport(const char * devname, // >>> That reference says maximum length of targetname is 223 bytes // (UTF-8) excluding trailing null. return 1; } + /* USB device? */ + strcpy(buff, sysfsroot); + strcat(buff, bus_scsi_devs); + if (if_directory_chdir(buff, devname)) { + if (NULL == getcwd(wd, NAME_LEN_MAX)) + return 0; + if (!(cp = strstr(wd, "/usb"))) + return 0; + transport_id = TRANSPORT_USB; + if (!(cp = strstr(wd, "/host"))) + return 0; + *cp = 0; + if (!(cp = strrchr(wd, ':'))) + return 0; + *cp = 0; + cp = basename(wd); + strcpy(buff, sysfsroot); + strcat(buff, bus_usb_devs); + strcat(buff, "/"); + strcat(buff, cp); + if (sscanf(cp, "%d-%*d", &n) != 1) + return 0; + + snprintf(b, b_len, "usb:%d-", n); + off = strlen(b); + if (get_value(buff, "devnum", b + off, b_len + off)) + return 1; + else + fprintf(stderr, "_tport: no " + "usb bus id, wd=%s\n", buff); + } + return 0; } static void
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor