[systemd-devel] [PATCH] [PATCH v2] nspawn: fallback on bind mount when mknod fails
Lennart Poettering
lennart at poettering.net
Tue Mar 31 07:56:59 PDT 2015
On Tue, 31.03.15 16:51, Alban Crequy (alban.crequy at gmail.com) wrote:
> - if (mknod(to, st.st_mode, st.st_rdev) < 0)
> - return log_error_errno(errno, "mknod(%s) failed: %m", to);
> + if (mknod(to, st.st_mode, st.st_rdev) < 0) {
> + if (errno != EPERM)
> + return log_error_errno(errno, "mknod(%s) failed: %m", to);
> +
> + /* Some systems abusively restrict mknod but
> + * allow bind mounts. */
> + if (touch(to) < 0)
> + return
> - log_error_errno(errno, "touch (%s)
> - failed: %m", to);
touch() is our call, please use its return code for showing the error,
not errno.
For our own calls we exclusively use kernel-style error handling by
returning -errno, while not making any guarantees on errno being
set. Hence: whenever you invoke a naked syscall, use errno, if you use
one of our own calls use the negative return code.
> + if (mount(from, to, NULL, MS_BIND, NULL) < 0)
> + return log_error_errno(errno, "both mknod and bind mount (%s) failed: %m", to);
Nitpick: Could you uppercase the "B" in "both", please? It's the
beginning of a sentence, and not a syscall name or so...
> - if (mknod(to, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0)
> - return log_error_errno(errno, "mknod() for /dev/console failed: %m");
> + if (touch(to) < 0)
> + return log_error_errno(errno, "touch() for
> - /dev/console failed: %m");
Same here, as above.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list