#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <errno.h>
#include <sysfs/dlist.h>
#include <sysfs/libsysfs.h>
while (--loop) {
fd = open(devpath, mode);
- if (fd > 0)
+ if (fd > 0 || errno != ENOENT)
return fd;
usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
return -1;
}
-#if 0
int
-get_claimed(int fd)
+get_claimed(char * devname)
{
- /*
- * FIXME : O_EXCL always fails ?
- */
+ int fd = opennode(devname, O_EXCL);
+
+ if (fd < 0)
+ return 1;
+
+ close(fd);
return 0;
}
-#endif
extern int
devt2devname (char *devname, char *devt)
/*
* then those not available through sysfs
*/
+ if (mask & DI_CLAIMED) {
+ pp->claimed = get_claimed(pp->dev);
+ condlog(3, "claimed = %i", pp->claimed);
+ }
if (pp->fd <= 0)
pp->fd = opennode(pp->dev, O_RDONLY);
if (pp->bus == SYSFS_BUS_SCSI)
if (scsi_ioctl_pathinfo(pp, mask))
return 1;
-#if 0
- if (mask & DI_CLAIMED) {
- pp->claimed = get_claimed(pp->fd);
- condlog(3, "claimed = %i", pp->claimed);
- }
-#endif
/* get and store hwe pointer */
pp->hwe = find_hwe(hwtable, pp->vendor_id, pp->product_id);
int pathinfo (struct path *, vector hwtable, int mask);
struct path * store_pathinfo (vector pathvec, vector hwtable,
char * devname, int flag);
-
-
-#if 0
-int get_claimed(int fd);
-#endif
/*
* discovery bitmask