[PATCH v2 1/3] libdwfl: specify optional sysroot to search for shared libraries and binaries

Michal Sekletar msekleta@redhat.com
Wed Jul 3 15:47:42 GMT 2024


On Wed, Jul 3, 2024 at 4:38 PM Dmitry V. Levin <ldv@strace.io> wrote:

> On Tue, Jul 02, 2024 at 07:30:58PM +0200, Michal Sekletar wrote:
> [...]
> > +int
> > +dwfl_set_sysroot (Dwfl *dwfl, const char *sysroot)
> > +{
> > +  if (!sysroot)
> > +    {
> > +      free (dwfl->sysroot);
> > +      dwfl->sysroot = NULL;
> > +      return 0;
> > +    }
> > +
> > +  char *r, *s;
> > +  r = realpath (sysroot, NULL);
> > +  if (!r)
> > +    return -1;
> > +
> > +  int rc;
> > +  struct stat sb;
> > +
> > +  rc = stat (r, &sb);
> > +  if (rc < 0 || !S_ISDIR (sb.st_mode))
> > +    {
> > +      errno = EINVAL;
> > +      return -1;
> > +    }
> > +
> > +  rc = asprintf (&s, "%s/", r);
>
> There is a case when realpath() returns a path ending with '/':
> when the path is "/".  I'm mentioning this just in case, not sure whether
> sysroot == "/" makes any sense at all, and whether this needs a special

attention.
>

I think that should be fine, //sysroot should be equivalent to /sysroot,
IOW, multiple slashes shouldn't cause any issues.

Michal


>
> --
> ldv
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/elfutils-devel/attachments/20240703/304a2717/attachment.htm>


More information about the Elfutils-devel mailing list