From c4db11752da2b5f064f89128a07cb4f3286b5f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 12 May 2021 19:44:08 +0200 Subject: [PATCH] RFC: alternative mountfile escape handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia ZiemiaƄska --- etc/systemd/system-generators/zfs-mount-generator.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/etc/systemd/system-generators/zfs-mount-generator.c b/etc/systemd/system-generators/zfs-mount-generator.c index be0470511d04..32a6a7cfd4b0 100644 --- a/etc/systemd/system-generators/zfs-mount-generator.c +++ b/etc/systemd/system-generators/zfs-mount-generator.c @@ -592,6 +592,7 @@ line_worker(char *line, const char *cachefile) bool already_exists = fstatat(destdir_fd, mountfile, &stbuf, 0) == 0; bool is_known = tfind(mountfile, &noauto_files, STRCMP) != NULL; + *(tofree++) = (void *)mountfile; if (already_exists) { if (is_known) { /* If it's in noauto_files, we must be noauto too */ @@ -615,23 +616,21 @@ line_worker(char *line, const char *cachefile) } /* File exists: skip current dataset */ - *(tofree++) = (void *)mountfile; goto end; } else { if (is_known) { /* See 4 */ - *(tofree++) = (void *)mountfile; goto end; } else if (strcmp(p_canmount, "noauto") == 0) { - if (tsearch(mountfile, &noauto_files, STRCMP) == NULL) { + if (tsearch(mountfile, &noauto_files, STRCMP) == NULL) fprintf(stderr, PROGNAME "[%d]: %s: " "out of memory for noauto datasets! " "Not tracking %s.\n", getpid(), dataset, mountfile); - *(tofree++) = (void *)mountfile; - } - } else - *(tofree++) = (void *)mountfile; + else + /* mountfile escaped to noauto_files */ + *(--tofree) = NULL; + } }