]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: safe_stat: support relative filenames
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 19 Apr 2023 19:48:00 +0000 (21:48 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 19 Apr 2023 20:45:00 +0000 (22:45 +0200)
By using AT_CWFD the call to statx() can also handle relative filenames.
Without this safe_stat() which is called on the fstab, source, target...

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libmount/src/utils.c
tests/ts/mount/fstab-all

index e03d9326513aa299dae7ca67d23ed5052338efed..50553f1d5a14261f8932be0c67991acef2c340df 100644 (file)
@@ -116,7 +116,7 @@ static int safe_stat(const char *target, struct stat *st, int nofollow)
                int rc;
                struct statx stx = { 0 };
 
-               rc = statx(-1,  target,
+               rc = statx(AT_FDCWD, target,
                                /* flags */
                                AT_STATX_DONT_SYNC
                                        | AT_NO_AUTOMOUNT
index 53b9651c2240657405b1f105d643e92d3ef1d595..83e1b636b315322ac3b5f695885950a41759649e 100755 (executable)
@@ -121,6 +121,17 @@ $TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
 ts_finalize_subtest
 
 
+ts_init_subtest "relative-path"
+cd "$TS_OUTDIR" > /dev/null
+$TS_CMD_MOUNT --all --fstab $(basename "$MY_FSTAB") >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+cd - > /dev/null
+ts_finalize_subtest
+
+
 ts_init_subtest "prefix"
 MY_ROOT="$TS_OUTDIR/${TS_TESTNAME}-rootdir"
 [ -d "${MY_ROOT}" ] || mkdir -p ${MY_ROOT}