2 * Copyright (c) 2004, 2005, 2006 Christophe Varoqui
3 * Copyright (c) 2005 Stefan Bader, IBM
4 * Copyright (c) 2005 Mike Anderson
22 #include "blacklist.h"
25 #include "sg_include.h"
27 #include "discovery.h"
32 store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice,
33 int flag, struct path **pp_ptr)
42 devname = udev_device_get_sysname(udevice);
51 if(safe_sprintf(pp->dev, "%s", devname)) {
52 condlog(0, "pp->dev too small");
55 pp->udev = udev_device_ref(udevice);
56 err = pathinfo(pp, hwtable, flag | DI_BLACKLIST);
60 err = store_path(pathvec, pp);
73 path_discover (vector pathvec, struct config * conf,
74 struct udev_device *udevice, int flag)
79 devname = udev_device_get_sysname(udevice);
83 if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
87 pp = find_path_by_dev(pathvec, (char *)devname);
89 if (store_pathinfo(pathvec, conf->hwtable,
90 udevice, flag, NULL) != 1)
95 return pathinfo(pp, conf->hwtable, flag);
99 path_discovery (vector pathvec, struct config * conf, int flag)
101 struct udev_enumerate *udev_iter;
102 struct udev_list_entry *entry;
103 struct udev_device *udevice;
107 udev_iter = udev_enumerate_new(conf->udev);
111 udev_enumerate_add_match_subsystem(udev_iter, "block");
112 udev_enumerate_scan_devices(udev_iter);
114 udev_list_entry_foreach(entry,
115 udev_enumerate_get_list_entry(udev_iter)) {
117 devpath = udev_list_entry_get_name(entry);
118 condlog(4, "Discover device %s", devpath);
119 udevice = udev_device_new_from_syspath(conf->udev, devpath);
121 condlog(4, "%s: no udev information", devpath);
125 devtype = udev_device_get_devtype(udevice);
126 if(devtype && !strncmp(devtype, "disk", 4))
127 r += path_discover(pathvec, conf, udevice, flag);
128 udev_device_unref(udevice);
130 udev_enumerate_unref(udev_iter);
131 condlog(4, "Discovery status %d", r);
135 #define declare_sysfs_get_str(fname) \
137 sysfs_get_##fname (struct udev_device * udev, char * buff, size_t len) \
140 const char * devname; \
142 devname = udev_device_get_sysname(udev); \
144 attr = udev_device_get_sysattr_value(udev, #fname); \
146 condlog(3, "%s: attribute %s not found in sysfs", \
150 if (strlen(attr) > len) { \
151 condlog(3, "%s: overflow in attribute %s", \
155 strlcpy(buff, attr, len); \
159 declare_sysfs_get_str(devtype);
160 declare_sysfs_get_str(cutype);
161 declare_sysfs_get_str(vendor);
162 declare_sysfs_get_str(model);
163 declare_sysfs_get_str(rev);
164 declare_sysfs_get_str(state);
165 declare_sysfs_get_str(dev);
168 sysfs_get_timeout(struct path *pp, unsigned int *timeout)
170 const char *attr = NULL;
172 struct udev_device *parent;
176 if (!pp->udev || pp->bus != SYSFS_BUS_SCSI)
181 subsys = udev_device_get_subsystem(parent);
182 attr = udev_device_get_sysattr_value(parent, "timeout");
185 parent = udev_device_get_parent(parent);
188 condlog(3, "%s: No timeout value in sysfs", pp->dev);
192 r = sscanf(attr, "%u\n", &t);
195 condlog(3, "%s: Cannot parse timeout attribute '%s'",
206 sysfs_get_tgt_nodename (struct path *pp, char * node)
208 const char *tgtname, *value;
209 struct udev_device *parent, *tgtdev;
210 int host, channel, tgtid = -1;
212 parent = udev_device_get_parent_with_subsystem_devtype(pp->udev, "scsi", "scsi_device");
216 value = udev_device_get_sysattr_value(parent, "sas_address");
218 tgtdev = udev_device_get_parent(parent);
220 tgtname = udev_device_get_sysname(tgtdev);
221 if (sscanf(tgtname, "end_device-%d:%d",
224 tgtdev = udev_device_get_parent(tgtdev);
228 pp->sg_id.proto_id = SCSI_PROTOCOL_SAS;
229 pp->sg_id.transport_id = tgtid;
230 strncpy(node, value, NODE_NAME_SIZE);
235 parent = udev_device_get_parent_with_subsystem_devtype(pp->udev, "scsi", "scsi_target");
238 /* Check for FibreChannel */
239 tgtdev = udev_device_get_parent(parent);
240 value = udev_device_get_sysname(tgtdev);
241 if (sscanf(value, "rport-%d:%d-%d",
242 &host, &channel, &tgtid) == 3) {
243 tgtdev = udev_device_new_from_subsystem_sysname(conf->udev,
244 "fc_remote_ports", value);
246 condlog(3, "SCSI target %d:%d:%d -> "
248 pp->sg_id.host_no, pp->sg_id.channel,
249 pp->sg_id.scsi_id, host, channel,
251 value = udev_device_get_sysattr_value(tgtdev,
254 pp->sg_id.proto_id = SCSI_PROTOCOL_FCP;
255 pp->sg_id.transport_id = tgtid;
256 strncpy(node, value, NODE_NAME_SIZE);
257 udev_device_unref(tgtdev);
260 udev_device_unref(tgtdev);
264 /* Check for iSCSI */
268 tgtname = udev_device_get_sysname(parent);
269 if (tgtname && sscanf(tgtname , "session%d", &tgtid) == 1)
271 parent = udev_device_get_parent(parent);
275 if (parent && tgtname) {
276 tgtdev = udev_device_new_from_subsystem_sysname(conf->udev,
277 "iscsi_session", tgtname);
281 value = udev_device_get_sysattr_value(tgtdev, "tgtname");
283 pp->sg_id.proto_id = SCSI_PROTOCOL_ISCSI;
284 pp->sg_id.transport_id = tgtid;
285 strncpy(node, value, NODE_NAME_SIZE);
286 udev_device_unref(tgtdev);
290 udev_device_unref(tgtdev);
293 /* Check for libata */
297 tgtname = udev_device_get_sysname(parent);
298 if (tgtname && sscanf(tgtname, "ata%d", &tgtid) == 1)
300 parent = udev_device_get_parent(parent);
304 pp->sg_id.proto_id = SCSI_PROTOCOL_ATA;
305 pp->sg_id.transport_id = tgtid;
306 snprintf(node, NODE_NAME_SIZE, "ata-%d.00", tgtid);
309 pp->sg_id.proto_id = SCSI_PROTOCOL_UNSPEC;
314 sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
316 struct udev_device *rport_dev = NULL;
320 sprintf(rport_id, "rport-%d:%d-%d",
321 pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
322 rport_dev = udev_device_new_from_subsystem_sysname(conf->udev,
323 "fc_remote_ports", rport_id);
325 condlog(1, "%s: No fc_remote_port device for '%s'", pp->dev,
329 condlog(4, "target%d:%d:%d -> %s", pp->sg_id.host_no,
330 pp->sg_id.channel, pp->sg_id.scsi_id, rport_id);
332 snprintf(value, 11, "%u", mpp->dev_loss);
334 sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, 11) <= 0) {
335 if ((mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET ||
336 mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF)
337 && mpp->dev_loss > 600) {
338 condlog(3, "%s: limiting dev_loss_tmo to 600, since "
339 "fast_io_fail is not set", mpp->alias);
340 snprintf(value, 11, "%u", 600);
341 if (sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
343 condlog(0, "%s failed to set dev_loss_tmo",
348 if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET){
349 if (mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF)
350 sprintf(value, "off");
351 else if (mpp->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
354 snprintf(value, 11, "%u", mpp->fast_io_fail);
355 if (sysfs_attr_set_value(rport_dev, "fast_io_fail_tmo",
357 condlog(0, "%s failed to set fast_io_fail_tmo",
362 udev_device_unref(rport_dev);
366 sysfs_set_session_tmo(struct multipath *mpp, struct path *pp)
368 struct udev_device *session_dev = NULL;
372 sprintf(session_id, "session%d", pp->sg_id.transport_id);
373 session_dev = udev_device_new_from_subsystem_sysname(conf->udev,
374 "iscsi_session", session_id);
376 condlog(1, "%s: No iscsi session for '%s'", pp->dev,
380 condlog(4, "target%d:%d:%d -> %s", pp->sg_id.host_no,
381 pp->sg_id.channel, pp->sg_id.scsi_id, session_id);
384 condlog(3, "%s: ignoring dev_loss_tmo on iSCSI", pp->dev);
386 if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) {
387 if (mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF) {
388 condlog(3, "%s: can't switch off fast_io_fail_tmo "
389 "on iSCSI", pp->dev);
390 } else if (mpp->fast_io_fail == MP_FAST_IO_FAIL_ZERO) {
391 condlog(3, "%s: can't set fast_io_fail_tmo to '0'"
392 "on iSCSI", pp->dev);
394 snprintf(value, 11, "%u", mpp->fast_io_fail);
395 if (sysfs_attr_set_value(session_dev, "recovery_tmo",
397 condlog(3, "%s: Failed to set recovery_tmo, "
398 " error %d", pp->dev, errno);
402 udev_device_unref(session_dev);
407 sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp)
409 struct udev_device *sas_dev = NULL;
413 sprintf(end_dev_id, "end_device-%d:%d",
414 pp->sg_id.host_no, pp->sg_id.transport_id);
415 sas_dev = udev_device_new_from_subsystem_sysname(conf->udev,
416 "sas_end_device", end_dev_id);
418 condlog(1, "%s: No SAS end device for '%s'", pp->dev,
422 condlog(4, "target%d:%d:%d -> %s", pp->sg_id.host_no,
423 pp->sg_id.channel, pp->sg_id.scsi_id, end_dev_id);
426 snprintf(value, 11, "%u", mpp->dev_loss);
427 if (sysfs_attr_set_value(sas_dev, "I_T_nexus_loss_timeout",
429 condlog(3, "%s: failed to update "
430 "I_T Nexus loss timeout, error %d",
433 udev_device_unref(sas_dev);
438 sysfs_set_scsi_tmo (struct multipath *mpp)
442 int dev_loss_tmo = mpp->dev_loss;
444 if (mpp->no_path_retry > 0) {
445 int no_path_retry_tmo = mpp->no_path_retry * conf->checkint;
447 if (no_path_retry_tmo > MAX_DEV_LOSS_TMO)
448 no_path_retry_tmo = MAX_DEV_LOSS_TMO;
449 if (no_path_retry_tmo > dev_loss_tmo)
450 dev_loss_tmo = no_path_retry_tmo;
451 condlog(3, "%s: update dev_loss_tmo to %d",
452 mpp->alias, dev_loss_tmo);
453 } else if (mpp->no_path_retry == NO_PATH_RETRY_QUEUE) {
454 dev_loss_tmo = MAX_DEV_LOSS_TMO;
455 condlog(3, "%s: update dev_loss_tmo to %d",
456 mpp->alias, dev_loss_tmo);
458 mpp->dev_loss = dev_loss_tmo;
459 if (mpp->dev_loss && mpp->fast_io_fail >= (int)mpp->dev_loss) {
460 condlog(3, "%s: turning off fast_io_fail (%d is not smaller than dev_loss_tmo)",
461 mpp->alias, mpp->fast_io_fail);
462 mpp->fast_io_fail = MP_FAST_IO_FAIL_OFF;
464 if (!mpp->dev_loss && mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET)
467 vector_foreach_slot(mpp->paths, pp, i) {
468 if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
469 sysfs_set_rport_tmo(mpp, pp);
470 if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
471 sysfs_set_session_tmo(mpp, pp);
472 if (pp->sg_id.proto_id == SCSI_PROTOCOL_SAS)
473 sysfs_set_nexus_loss_tmo(mpp, pp);
479 do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
480 void *resp, int mx_resp_len)
482 unsigned char inqCmdBlk[INQUIRY_CMDLEN] =
483 { INQUIRY_CMD, 0, 0, 0, 0, 0 };
484 unsigned char sense_b[SENSE_BUFF_LEN];
485 struct sg_io_hdr io_hdr;
491 inqCmdBlk[2] = (unsigned char) pg_op;
492 inqCmdBlk[3] = (unsigned char)((mx_resp_len >> 8) & 0xff);
493 inqCmdBlk[4] = (unsigned char) (mx_resp_len & 0xff);
494 memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
495 memset(sense_b, 0, SENSE_BUFF_LEN);
496 io_hdr.interface_id = 'S';
497 io_hdr.cmd_len = sizeof (inqCmdBlk);
498 io_hdr.mx_sb_len = sizeof (sense_b);
499 io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
500 io_hdr.dxfer_len = mx_resp_len;
501 io_hdr.dxferp = resp;
502 io_hdr.cmdp = inqCmdBlk;
503 io_hdr.sbp = sense_b;
504 io_hdr.timeout = DEF_TIMEOUT;
506 if (ioctl(sg_fd, SG_IO, &io_hdr) < 0)
509 /* treat SG_ERR here to get rid of sg_err.[ch] */
510 io_hdr.status &= 0x7e;
511 if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
512 (0 == io_hdr.driver_status))
514 if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
515 (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
516 (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {
517 if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) {
519 unsigned char * sense_buffer = io_hdr.sbp;
520 if (sense_buffer[0] & 0x2)
521 sense_key = sense_buffer[1] & 0xf;
523 sense_key = sense_buffer[2] & 0xf;
524 if(RECOVERED_ERROR == sense_key)
532 get_serial (char * str, int maxlen, int fd)
535 char buff[MX_ALLOC_LEN + 1] = {0};
540 if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN)) {
545 memcpy(str, buff + 4, len);
554 get_geometry(struct path *pp)
559 if (ioctl(pp->fd, HDIO_GETGEO, &pp->geom)) {
560 condlog(2, "%s: HDIO_GETGEO failed with %d", pp->dev, errno);
561 memset(&pp->geom, 0, sizeof(pp->geom));
564 condlog(3, "%s: %u cyl, %u heads, %u sectors/track, start at %lu",
565 pp->dev, pp->geom.cylinders, pp->geom.heads,
566 pp->geom.sectors, pp->geom.start);
571 scsi_sysfs_pathinfo (struct path * pp)
573 struct udev_device *parent;
574 const char *attr_path = NULL;
578 const char *subsys = udev_device_get_subsystem(parent);
579 if (subsys && !strncmp(subsys, "scsi", 4)) {
580 attr_path = udev_device_get_sysname(parent);
583 if (sscanf(attr_path, "%i:%i:%i:%i",
587 &pp->sg_id.lun) == 4)
590 parent = udev_device_get_parent(parent);
592 if (!attr_path || pp->sg_id.host_no == -1)
595 if (sysfs_get_vendor(parent, pp->vendor_id, SCSI_VENDOR_SIZE))
598 condlog(3, "%s: vendor = %s", pp->dev, pp->vendor_id);
600 if (sysfs_get_model(parent, pp->product_id, SCSI_PRODUCT_SIZE))
603 condlog(3, "%s: product = %s", pp->dev, pp->product_id);
605 if (sysfs_get_rev(parent, pp->rev, SCSI_REV_SIZE))
608 condlog(3, "%s: rev = %s", pp->dev, pp->rev);
611 * set the hwe configlet pointer
613 pp->hwe = find_hwe(conf->hwtable, pp->vendor_id, pp->product_id, pp->rev);
616 * host / bus / target / lun
618 condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
628 if(!sysfs_get_tgt_nodename(pp, pp->tgt_node_name)) {
629 condlog(3, "%s: tgt_node_name = %s",
630 pp->dev, pp->tgt_node_name);
637 ccw_sysfs_pathinfo (struct path * pp)
639 struct udev_device *parent;
640 char attr_buff[NAME_SIZE];
641 const char *attr_path;
645 const char *subsys = udev_device_get_subsystem(parent);
646 if (subsys && !strncmp(subsys, "ccw", 3))
648 parent = udev_device_get_parent(parent);
653 sprintf(pp->vendor_id, "IBM");
655 condlog(3, "%s: vendor = %s", pp->dev, pp->vendor_id);
657 if (sysfs_get_devtype(parent, attr_buff, FILE_NAME_SIZE))
660 if (!strncmp(attr_buff, "3370", 4)) {
661 sprintf(pp->product_id,"S/390 DASD FBA");
662 } else if (!strncmp(attr_buff, "9336", 4)) {
663 sprintf(pp->product_id,"S/390 DASD FBA");
665 sprintf(pp->product_id,"S/390 DASD ECKD");
668 condlog(3, "%s: product = %s", pp->dev, pp->product_id);
671 * set the hwe configlet pointer
673 pp->hwe = find_hwe(conf->hwtable, pp->vendor_id, pp->product_id, NULL);
676 * host / bus / target / lun
678 attr_path = udev_device_get_sysname(parent);
680 sscanf(attr_path, "%i.%i.%x",
684 condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
695 cciss_sysfs_pathinfo (struct path * pp)
697 const char * attr_path = NULL;
698 struct udev_device *parent;
702 const char *subsys = udev_device_get_subsystem(parent);
703 if (subsys && !strncmp(subsys, "cciss", 5)) {
704 attr_path = udev_device_get_sysname(parent);
707 if (sscanf(attr_path, "c%id%i",
709 &pp->sg_id.scsi_id) == 2)
712 parent = udev_device_get_parent(parent);
714 if (!attr_path || pp->sg_id.host_no == -1)
717 if (sysfs_get_vendor(parent, pp->vendor_id, SCSI_VENDOR_SIZE))
720 condlog(3, "%s: vendor = %s", pp->dev, pp->vendor_id);
722 if (sysfs_get_model(parent, pp->product_id, SCSI_PRODUCT_SIZE))
725 condlog(3, "%s: product = %s", pp->dev, pp->product_id);
727 if (sysfs_get_rev(parent, pp->rev, SCSI_REV_SIZE))
730 condlog(3, "%s: rev = %s", pp->dev, pp->rev);
733 * set the hwe configlet pointer
735 pp->hwe = find_hwe(conf->hwtable, pp->vendor_id, pp->product_id, pp->rev);
738 * host / bus / target / lun
741 pp->sg_id.channel = 0;
742 condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
752 common_sysfs_pathinfo (struct path * pp)
755 condlog(4, "%s: udev not initialised", pp->dev);
758 if (sysfs_get_dev(pp->udev, pp->dev_t, BLK_DEV_SIZE)) {
759 condlog(3, "%s: no 'dev' attribute in sysfs", pp->dev);
763 condlog(3, "%s: dev_t = %s", pp->dev, pp->dev_t);
765 if (sysfs_get_size(pp, &pp->size))
768 condlog(3, "%s: size = %llu", pp->dev, pp->size);
774 path_offline (struct path * pp)
776 struct udev_device * parent;
777 char buff[SCSI_STATE_SIZE];
779 if (pp->bus != SYSFS_BUS_SCSI)
784 const char *subsys = udev_device_get_subsystem(parent);
785 if (subsys && !strncmp(subsys, "scsi", 4))
787 parent = udev_device_get_parent(parent);
791 condlog(1, "%s: failed to get sysfs information", pp->dev);
795 if (sysfs_get_state(parent, buff, SCSI_STATE_SIZE))
798 condlog(3, "%s: path state = %s", pp->dev, buff);
800 if (!strncmp(buff, "offline", 7) ||
801 !strncmp(buff, "transport-offline", 17)) {
806 if (!strncmp(buff, "blocked", 7) || !strncmp(buff, "quiesce", 7))
808 else if (!strncmp(buff, "running", 7))
815 sysfs_pathinfo(struct path * pp)
817 if (common_sysfs_pathinfo(pp))
820 pp->bus = SYSFS_BUS_UNDEF;
821 if (!strncmp(pp->dev,"cciss",5))
822 pp->bus = SYSFS_BUS_CCISS;
823 if (!strncmp(pp->dev,"dasd", 4))
824 pp->bus = SYSFS_BUS_CCW;
825 if (!strncmp(pp->dev,"sd", 2))
826 pp->bus = SYSFS_BUS_SCSI;
828 if (pp->bus == SYSFS_BUS_UNDEF)
830 else if (pp->bus == SYSFS_BUS_SCSI) {
831 if (scsi_sysfs_pathinfo(pp))
833 } else if (pp->bus == SYSFS_BUS_CCW) {
834 if (ccw_sysfs_pathinfo(pp))
836 } else if (pp->bus == SYSFS_BUS_CCISS) {
837 if (cciss_sysfs_pathinfo(pp))
844 scsi_ioctl_pathinfo (struct path * pp, int mask)
846 if (mask & DI_SERIAL) {
847 get_serial(pp->serial, SERIAL_SIZE, pp->fd);
848 condlog(3, "%s: serial = %s", pp->dev, pp->serial);
855 cciss_ioctl_pathinfo (struct path * pp, int mask)
857 if (mask & DI_SERIAL) {
858 get_serial(pp->serial, SERIAL_SIZE, pp->fd);
859 condlog(3, "%s: serial = %s", pp->dev, pp->serial);
865 get_state (struct path * pp, int daemon)
867 struct checker * c = &pp->checker;
870 condlog(3, "%s: get_state", pp->dev);
872 if (!checker_selected(c)) {
874 if (pathinfo(pp, conf->hwtable, DI_SYSFS) != 0) {
875 condlog(3, "%s: couldn't get sysfs pathinfo",
877 return PATH_UNCHECKED;
881 if (!checker_selected(c)) {
882 condlog(3, "%s: No checker selected", pp->dev);
883 return PATH_UNCHECKED;
885 checker_set_fd(c, pp->fd);
886 if (checker_init(c, pp->mpp?&pp->mpp->mpcontext:NULL)) {
887 memset(c, 0x0, sizeof(struct checker));
888 condlog(3, "%s: checker init failed", pp->dev);
889 return PATH_UNCHECKED;
892 checker_clear_message(c);
894 checker_set_async(c);
895 if (!conf->checker_timeout &&
896 (pp->bus != SYSFS_BUS_SCSI ||
897 sysfs_get_timeout(pp, &(c->timeout))))
898 c->timeout = DEF_TIMEOUT;
899 state = checker_check(c);
900 condlog(3, "%s: state = %s", pp->dev, checker_state_name(state));
901 if (state != PATH_UP && state != PATH_GHOST &&
902 strlen(checker_message(c)))
903 condlog(3, "%s: checker msg is \"%s\"",
904 pp->dev, checker_message(c));
909 get_prio (struct path * pp)
914 struct prio * p = &pp->prio;
916 if (!prio_selected(p)) {
917 select_detect_prio(pp);
919 if (!prio_selected(p)) {
920 condlog(3, "%s: no prio selected", pp->dev);
924 pp->priority = prio_getprio(p, pp);
925 if (pp->priority < 0) {
926 condlog(3, "%s: %s prio error", pp->dev, prio_name(p));
927 pp->priority = PRIO_UNDEF;
930 condlog(3, "%s: %s prio = %u",
931 pp->dev, prio_name(p), pp->priority);
936 get_uid (struct path * pp)
941 if (!pp->uid_attribute)
945 condlog(1, "%s: no udev information", pp->dev);
949 memset(pp->wwid, 0, WWID_SIZE);
950 value = udev_device_get_property_value(pp->udev, pp->uid_attribute);
951 if ((!value || strlen(value) == 0) && conf->dry_run == 2)
952 value = getenv(pp->uid_attribute);
953 if (value && strlen(value)) {
954 size_t len = WWID_SIZE;
956 if (strlen(value) + 1 > WWID_SIZE) {
957 condlog(0, "%s: wwid overflow", pp->dev);
961 strncpy(pp->wwid, value, len);
963 condlog(3, "%s: no %s attribute", pp->dev,
967 /* Strip any trailing blanks */
968 c = strchr(pp->wwid, '\0');
970 while (c && c >= pp->wwid && *c == ' ') {
974 condlog(3, "%s: uid = %s (udev)", pp->dev,
975 *pp->wwid == '\0' ? "<empty>" : pp->wwid);
980 pathinfo (struct path *pp, vector hwtable, int mask)
984 condlog(3, "%s: mask = 0x%x", pp->dev, mask);
987 * fetch info available in sysfs
989 if (mask & DI_SYSFS && sysfs_pathinfo(pp))
992 if (mask & DI_BLACKLIST && mask & DI_SYSFS) {
993 if (filter_device(conf->blist_device, conf->elist_device,
994 pp->vendor_id, pp->product_id) > 0) {
999 path_state = path_offline(pp);
1002 * fetch info not available through sysfs
1005 pp->fd = open(udev_device_get_devnode(pp->udev), O_RDONLY);
1008 condlog(4, "Couldn't open node for %s: %s",
1009 pp->dev, strerror(errno));
1013 if (mask & DI_SERIAL)
1016 if (path_state == PATH_UP && pp->bus == SYSFS_BUS_SCSI &&
1017 scsi_ioctl_pathinfo(pp, mask))
1020 if (pp->bus == SYSFS_BUS_CCISS &&
1021 cciss_ioctl_pathinfo(pp, mask))
1024 if (mask & DI_CHECKER) {
1025 if (path_state == PATH_UP) {
1026 pp->chkrstate = pp->state = get_state(pp, 0);
1027 if (pp->state == PATH_UNCHECKED ||
1028 pp->state == PATH_WILD)
1031 condlog(3, "%s: path inaccessible", pp->dev);
1032 pp->chkrstate = pp->state = path_state;
1036 if (path_state == PATH_UP && (mask & DI_WWID) && !strlen(pp->wwid))
1038 if (mask & DI_BLACKLIST && mask & DI_WWID) {
1039 if (filter_wwid(conf->blist_wwid, conf->elist_wwid,
1046 * Retrieve path priority, even for PATH_DOWN paths if it has never
1047 * been successfully obtained before.
1049 if ((mask & DI_PRIO) && path_state == PATH_UP) {
1050 if (pp->state != PATH_DOWN || pp->priority == PRIO_UNDEF) {
1051 if (!strlen(pp->wwid))
1055 pp->priority = PRIO_UNDEF;
1063 * Recoverable error, for example faulty or offline path
1065 memset(pp->wwid, 0, WWID_SIZE);
1066 pp->chkrstate = pp->state = PATH_DOWN;