mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdev: add proper value input for the ZDEV_SITE_ID key
udev does not allow an empty value for keys when importing output
from an external program. Providing an empty value for any key
invokes a warning during the parsing. Currently, ZDEV_SITE_ID for
fallback sites are not assigned any value. Add an empty double
quotes as the value in case of failover sites.
This modification is tested on udevadm version 253 on fedora38.
Also verify that the ZDEV_SITE_ID is properly written, if not log
the error.
Fixes: c8ad5f57d0 ("zdev: modify zdev_id to read the site_id from loadparm")
Reported-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
a8d328bba2
commit
27902c9106
@@ -213,16 +213,28 @@ out:
|
||||
static void write_zdev_site_id(int site_id)
|
||||
{
|
||||
FILE *fd;
|
||||
int rc;
|
||||
|
||||
fd = fopen(ZDEV_SITE_ID_FILE, "w");
|
||||
if (!fd)
|
||||
err(1, "Could not write to zdev_site_id file");
|
||||
if (site_id == SITE_FALLBACK)
|
||||
fprintf(fd, "ZDEV_SITE_ID=\n");
|
||||
else
|
||||
fprintf(fd, "ZDEV_SITE_ID=%d\n", site_id);
|
||||
goto err;
|
||||
|
||||
fclose(fd);
|
||||
if (site_id == SITE_FALLBACK)
|
||||
rc = fprintf(fd, "ZDEV_SITE_ID=\"\"\n");
|
||||
else
|
||||
rc = fprintf(fd, "ZDEV_SITE_ID=%d\n", site_id);
|
||||
|
||||
if (rc < 0) {
|
||||
fclose(fd);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (fclose(fd))
|
||||
goto err;
|
||||
|
||||
return;
|
||||
err:
|
||||
err(1, "Could not write to zdev_site_id file");
|
||||
}
|
||||
|
||||
/* Read the loadparm and extract the current site_id.
|
||||
@@ -265,7 +277,7 @@ static void process_loadparm(const char *filename)
|
||||
out:
|
||||
write_zdev_site_id(site_id);
|
||||
if (site_id == SITE_FALLBACK)
|
||||
printf("ZDEV_SITE_ID=\n");
|
||||
printf("ZDEV_SITE_ID=\"\"\n");
|
||||
else
|
||||
printf("ZDEV_SITE_ID=%d\n", site_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user