pp->sg_id.channel, pp->sg_id.scsi_id, rport_id);
snprintf(value, 11, "%u", mpp->dev_loss);
- if (sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, 11) < 0) {
+ if (mpp->dev_loss &&
+ sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, 11) <= 0) {
if ((!mpp->fast_io_fail ||
mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF)
&& mpp->dev_loss > 600) {
"fast_io_fail is not set", mpp->alias);
snprintf(value, 11, "%u", 600);
if (sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
- value, 11) < 0)
+ value, 11) <= 0)
condlog(0, "%s failed to set dev_loss_tmo",
mpp->alias);
goto out;
else
snprintf(value, 11, "%u", mpp->fast_io_fail);
if (sysfs_attr_set_value(rport_dev, "fast_io_fail_tmo",
- value, 11) < 0) {
+ value, 11) <= 0) {
condlog(0, "%s failed to set fast_io_fail_tmo",
mpp->alias);
}
ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
char * value, size_t value_len)
{
- const char *devpath;
+ char devpath[PATH_SIZE];
struct stat statbuf;
int fd;
ssize_t size = -1;
if (!dev || !attr_name || !value)
return 0;
- devpath = udev_device_get_syspath(dev);
- condlog(4, "open '%s'/'%s'", devpath, attr_name);
+ snprintf(devpath, PATH_SIZE, "%s/%s", udev_device_get_syspath(dev),
+ attr_name);
+ condlog(4, "open '%s'", devpath);
if (stat(devpath, &statbuf) != 0) {
condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
return 0;