[systemd-devel] [PATCH] [PATCH v3] nspawn: fallback on bind mount when mknod fails

Lennart Poettering lennart at poettering.net
Tue Mar 31 10:14:26 PDT 2015

On Tue, 31.03.15 11:35, Dave Reisner (d at falconindy.com) wrote:

> > +                                /* Some systems abusively restrict mknod but
> > +                                 * allow bind mounts. */
> > +                                r = touch(to);
> > +                                if (r < 0)
> > +                                        return log_error_errno(r, "touch (%s) failed: %m", to);
> Is this really what you wanted? It's not obvious that errno will have
> the correct value when %m is evaluated. I would have used strerror(-r)
> here.

No. The log_error_errno() macro will set errno explicitly before
invoking sprintf() to resolve %m, so that %m actually maps to the
passed error instead of the original errno.

In fact, I really recommend against strerror() since it is not
thread-safe. Whenever possible we should use the %m thing like in
Alban's patch. And if that's not appropriate then we should use
strerror_r() instead of strerror().


Lennart Poettering, Red Hat

More information about the systemd-devel mailing list