[systemd-devel] [PATCH] libudev: replace name_to_handle_at with normal sscanf
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Sun Apr 20 11:08:04 PDT 2014
On Sun, Apr 20, 2014 at 03:53:05PM +0200, Kay Sievers wrote:
> On Sun, Apr 20, 2014 at 5:36 AM, Zbigniew Jędrzejewski-Szmek
> <zbyszek at in.waw.pl> wrote:
>
> > Hi Kay,
> > it seems that handles are not crucial, and the simplified version below
> > works too. Is there something I'm missing?
>
> The name_to_handle API works properly with bind mounts, it's the more
> reliable API.
>
> It also was intentional to support any filesystem with the prefix
> devtmpfs*, like "devtmpfs2" or whatever it might be named in the
> future.
>
> What actual problem are we trying to solve here with not requiring a
> common kernel config option? We want/need it in other places too, and
> the current fallback logic to figure out the mount point is really not
> that great with bind mounts. We just need the fallback for filesystems
> which do not support the API, but most common and tmpfs/devtmpfs do.
>
> I don't necessarily see the point in supporting the idea of the
> kernel's uber-configurability and the massive pain it causes for tools
> to make things work.
Yeah, I'm just trying to reduce the confusion that people experience
on kernels without CONFIG_FHANDLE.
What about this:
--------8<-------------------------------------------------------------
Subject: [PATCH] udev: assume /dev is devtmpfs if name_to_handle_at is not
implemented
We have a bunch of reports from people who have a custom kernel and
are confused why udev is not running. This raises the possibility of a
false positive when running on a kernel without CONFIG_FHANDLE but in a
container. Nevertheless, this caes should be easier to diagnose than
the opposite of running on bare metal with the same kernel.
https://bugzilla.redhat.com/show_bug.cgi?id=1072966
Also, if we find a mountpoint with a matching id, and it doesn't have
devtmpfs mounted, return false.
---
src/libudev/libudev-monitor.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 3f7436b..dd5f862 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -117,9 +117,16 @@ static bool udev_has_devtmpfs(struct udev *udev) {
h = alloca(MAX_HANDLE_SZ);
h->handle_bytes = MAX_HANDLE_SZ;
r = name_to_handle_at(AT_FDCWD, "/dev", h, &mount_id, 0);
- if (r < 0)
- return false;
+ if (r < 0) {
+ if (errno == ENOSYS || errno == ENOTSUP) {
+ /* This kernel or file system does not support
+ * name_to_handle_at(). */
+ log_warning("name_to_handle_at syscall failed, assuming /dev is volatile.");
+ return true;
+ }
+ return false;
+ }
f = fopen("/proc/self/mountinfo", "re");
if (!f)
@@ -139,8 +146,7 @@ static bool udev_has_devtmpfs(struct udev *udev) {
continue;
/* accept any name that starts with the currently expected type */
- if (startswith(e + 3, "devtmpfs"))
- return true;
+ return startswith(e + 3, "devtmpfs");
}
return false;
--
1.8.5.2
--------8<-------------------------------------------------------------
?
Zbyszek
More information about the systemd-devel
mailing list