zdev: Add function for reading text files

Reduce code complexity by adding a utility function for reading text
files based on a variable path.

Note: chzdev/lszdev tools apply special path-handling via command line
option --base to allow redirecting hard-coded paths therefore libutil's
util_file functions cannot easily be used.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2024-07-04 15:51:00 +02:00
committed by Jan Höppner
parent c0f02d2f68
commit cad4e9e15b
2 changed files with 19 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ char *path_get_zfcp_lun_dev(struct zfcp_lun_devid *);
char *path_get_zfcp_port_dev(struct zfcp_lun_devid *);
char *path_get_scsi_hctl_dev(const char *);
char *path_get_bus_attr(const char *, const char *);
char *path_read_text_file(int chomp, err_t err, char *fmt, ...);
exit_code_t path_for_each(const char *,
exit_code_t (*callback)(const char *, const char *,