diff options
author | Karel Zak | 2016-06-02 14:40:13 +0200 |
---|---|---|
committer | Karel Zak | 2016-06-02 14:40:13 +0200 |
commit | 638402edb039d58df04cc9aaf48e08fe184b3b4b (patch) | |
tree | 3975cbd0eb50fba09697b2c270019ff61d5aaf0d | |
parent | lib/ttyutils: use stdout for get_terminal_width() (diff) | |
download | kernel-qcow2-util-linux-638402edb039d58df04cc9aaf48e08fe184b3b4b.tar.gz kernel-qcow2-util-linux-638402edb039d58df04cc9aaf48e08fe184b3b4b.tar.xz kernel-qcow2-util-linux-638402edb039d58df04cc9aaf48e08fe184b3b4b.zip |
lib/sysfs: be more smart for non-scsi devices
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | include/sysfs.h | 3 | ||||
-rw-r--r-- | lib/sysfs.c | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/sysfs.h b/include/sysfs.h index 664359243..36d3cbd4f 100644 --- a/include/sysfs.h +++ b/include/sysfs.h @@ -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 } diff --git a/lib/sysfs.c b/lib/sysfs.c index b6501291c..f52b7a885 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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; } |