summaryrefslogtreecommitdiff
path: root/extras/scsi_id/scsi_serial.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2008-06-11 23:26:18 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-06-11 23:26:18 +0200
commit1ecb0864600073a5d63c2298239cd04e7bf8d527 (patch)
tree6d840c80ce59502f96687309ee028aa348c15a9f /extras/scsi_id/scsi_serial.c
parentec404619a6867d14adebe107a1ed74475ae2413f (diff)
scsi_id: retry open() on -EBUSY
Diffstat (limited to 'extras/scsi_id/scsi_serial.c')
-rw-r--r--extras/scsi_id/scsi_serial.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c
index c5cacfa114..bea447fdac 100644
--- a/extras/scsi_id/scsi_serial.c
+++ b/extras/scsi_id/scsi_serial.c
@@ -819,18 +819,24 @@ int scsi_get_serial (struct scsi_id_device *dev_scsi, const char *devname,
int page_code, char *serial_short, int len)
{
unsigned char page0[SCSI_INQ_BUFF_LEN];
- int fd;
+ int fd = -1;
+ int cnt = 10;
int ind;
int retval;
memset(dev_scsi->serial, 0, len);
dbg("opening %s\n", devname);
- fd = open(devname, O_RDONLY | O_NONBLOCK);
- if (fd < 0) {
- info("%s: cannot open %s: %s\n",
- dev_scsi->kernel, devname, strerror(errno));
- return 1;
+ while (--cnt) {
+ fd = open(devname, O_RDONLY | O_NONBLOCK);
+ if (fd >= 0)
+ break;
+ info("%s: cannot open %s: %s\n", dev_scsi->kernel, devname, strerror(errno));
+ if (errno != EBUSY)
+ break;
+ usleep(500000 + (rand() % 100000) );
}
+ if (fd < 0)
+ return 1;
if (page_code == PAGE_80) {
if (do_scsi_page80_inquiry(dev_scsi, fd, dev_scsi->serial, serial_short, len)) {