On Mon, 2020-03-30 at 21:00 -0500, Benjamin Marzinski wrote: > sysfs_is_multipathed reads the wwid of the dm device holding a path > to > check if its a multipath device. Add code to optinally set pp->wwid > to > that wwid. This will be used by a future patch. > > Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> > --- > libmultipath/sysfs.c | 22 +++++++++++++++++++--- > libmultipath/sysfs.h | 2 +- > multipath/main.c | 7 ++++--- > 3 files changed, 24 insertions(+), 7 deletions(-) > > diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c > index 62ec2ed7..034f082f 100644 > --- a/libmultipath/sysfs.c > +++ b/libmultipath/sysfs.c > @@ -295,7 +295,7 @@ static int select_dm_devs(const struct dirent > *di) > return fnmatch("dm-*", di->d_name, FNM_FILE_NAME) == 0; > } > > -bool sysfs_is_multipathed(const struct path *pp) > +bool sysfs_is_multipathed(struct path *pp, bool set_wwid) > { > char pathbuf[PATH_MAX]; > struct scandir_result sr; > @@ -342,9 +342,25 @@ bool sysfs_is_multipathed(const struct path *pp) > if (nr == sizeof(uuid) && !memcmp(uuid, "mpath-", > sizeof(uuid))) > found = true; > else if (nr < 0) { > - condlog(1, "%s: error reading from %s: %s", > - __func__, pathbuf, strerror(errno)); > + condlog(1, "%s: error reading from %s: %m", > + __func__, pathbuf); > } > + if (found && set_wwid) { > + nr = read(fd, pp->wwid, WWID_SIZE); I'd rather read the whole UUID in a single syscall (i.e. merge this with the previous read() that fetched the first 6 chars). Regards, Martin -- Dr. Martin Wilck <mwilck@xxxxxxxx>, Tel. +49 (0)911 74053 2107 SUSE Software Solutions Germany GmbH HRB 36809, AG Nürnberg GF: Felix Imendörffer -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel