-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/*
+ * Copyright (C) IBM Corp. 2003
*
- * scsi_serial.c
+ * Author: Patrick Mansfield<patmans@us.ibm.com>
*
- * Code related to requesting and getting an id from a scsi device
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
*
- * Copyright (C) IBM Corp. 2003
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Author:
- * Patrick Mansfield<patmans@us.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 of the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/types.h>
{
unsigned char page0[SCSI_INQ_BUFF_LEN];
int fd = -1;
- int cnt = 10;
+ int cnt;
int ind;
int retval;
memset(dev_scsi->serial, 0, len);
dbg(udev, "opening %s\n", devname);
- while (--cnt) {
- const struct timespec duration = { 0, 500 * 1000 * 1000 };
+ srand((unsigned int)getpid());
+ for (cnt = 20; cnt > 0; cnt--) {
+ struct timespec duration;
fd = open(devname, O_RDONLY | O_NONBLOCK);
- if (fd >= 0)
- break;
- info(udev, "%s: cannot open %s: %s\n", dev_scsi->kernel, devname, strerror(errno));
- if (errno != EBUSY)
+ if (fd >= 0 || errno != EBUSY)
break;
+ duration.tv_sec = 0;
+ duration.tv_nsec = (200 * 1000 * 1000) + (rand() % 100 * 1000 * 1000);
nanosleep(&duration, NULL);
}
if (fd < 0)