]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: be more smart for non-scsi devices
authorKarel Zak <kzak@redhat.com>
Thu, 2 Jun 2016 12:40:13 +0000 (14:40 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 2 Jun 2016 12:40:13 +0000 (14:40 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/sysfs.h
lib/sysfs.c

index 66435924305563c2c53f7c744dff6781aaad60ab..36d3cbd4f00f9565b98e1ba81f809c260ccd8d80 100644 (file)
@@ -27,7 +27,8 @@ struct sysfs_cxt {
                        scsi_target,
                        scsi_lun;
 
-       unsigned int    has_hctl : 1;
+       unsigned int    has_hctl   : 1,
+                       hctl_error : 1 ;
 };
 
 #define UL_SYSFSCXT_EMPTY { 0, -1, NULL, NULL, 0, 0, 0, 0, 0 }
index b6501291c980ec9f0bbe4d60a620a25d638bf6d6..f52b7a885f89755b7df2119203b822b594b57e5f 100644 (file)
@@ -882,11 +882,12 @@ int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h, int *c, int *t, int *l)
        char buf[PATH_MAX], *hctl;
        ssize_t len;
 
-       if (!cxt)
+       if (!cxt || cxt->hctl_error)
                return -EINVAL;
        if (cxt->has_hctl)
                goto done;
 
+       cxt->hctl_error = 1;
        len = sysfs_readlink(cxt, "device", buf, sizeof(buf) - 1);
        if (len < 0)
                return len;
@@ -911,6 +912,8 @@ done:
                *t = cxt->scsi_target;
        if (l)
                *l = cxt->scsi_lun;
+
+       cxt->hctl_error = 0;
        return 0;
 }