losetup -sf prints trailing newline, which confuses the mount command: mount /mnt/test.img /mnt/mntpoint > mount: '/dev/block/loop48 > '->'/mnt/test': No such file or directory
Bug: 243494992
From cad3c19434b3578544877b867f7b46b4ef72f235 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang <yochi...@google.com> Date: Tue, 23 Aug 2022 23:45:33 +0800 Subject: [PATCH] mount: chomp() trailing '\n' off xrunread() return value losetup -sf prints trailing newline, which confuses the mount command: mount /mnt/test.img /mnt/mntpoint > mount: '/dev/block/loop48 > '->'/mnt/test': No such file or directory Bug: 243494992 Change-Id: Ie238e096f159f65901f430c3b921344bb797f3bd --- toys/lsb/mount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/lsb/mount.c b/toys/lsb/mount.c index 16b67eda..dc379fc4 100644 --- a/toys/lsb/mount.c +++ b/toys/lsb/mount.c @@ -166,7 +166,7 @@ static void mount_filesystem(char *dev, char *dir, char *type, } if (strstart(&dev, "UUID=")) { - char *s = xrunread((char *[]){"blkid", "-U", dev, 0}, 0); + char *s = chomp(xrunread((char *[]){"blkid", "-U", dev, 0}, 0)); if (!s || strlen(s)>=sizeof(toybuf)) return error_msg("No uuid %s", dev); strcpy(dev = toybuf, s); @@ -253,7 +253,7 @@ static void mount_filesystem(char *dev, char *dir, char *type, if (rc && errno == ENOTBLK) { char *losetup[] = {"losetup", (flags&MS_RDONLY)?"-fsr":"-fs", dev, 0}; - if ((dev = xrunread(losetup, 0))) continue; + if ((dev = chomp(xrunread(losetup, 0)))) continue; error_msg("%s failed", *losetup); break; } -- 2.37.1.595.g718a3a8f04-goog
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net