From 98b1d2b8d9ea27087a5980b4b902b6a6ab716e03 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Wed, 17 Jan 2018 13:28:04 +0000 Subject: [PATCH] core: namespace: nitpick /dev/ptmx error handling If /dev/tty did not exist, or had st_rdev == 0, we ignored it. And the same is true for null, zero, full, random, urandom. If /dev/ptmx did not exist, we treated this as a failure. If /dev/ptmx had st_rdev == 0, we ignored it. This was a very recent change, but there was no reason for ptmx creation specifically to treat st_rdev == 0 differently from non-existence. This confuses me when reading it. Change the creation of /dev/ptmx so that st_rdev == 0 is treated as failure. This still leaves /dev/ptmx as a special case with stricter handling. However it is consistent with the immediately preceding creation of /dev/pts/, which is treated as essential, and is directly related to ptmx. I don't know why we check st_rdev. But I'd prefer to have only one unanswered question here, and not to have a second unanswered question added on top. --- src/core/namespace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/namespace.c b/src/core/namespace.c index d6c1b1b..e20c500 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -525,7 +525,7 @@ static int clone_device_node(const char *d, const char *temporary_mount) { if (r < 0) return -errno; - return 0; + return 1; } static int mount_private_dev(MountEntry *m) { @@ -582,7 +582,7 @@ static int mount_private_dev(MountEntry *m) { } } else { r = clone_device_node("/dev/ptmx", temporary_mount); - if (r < 0) + if (r != 1) goto fail; } -- 2.7.4