Skip to contentSkip to conversation

tst_supported_fs: Implement checking paths against skiplist

PATCH In review Martin Doucha 4 participants 19 messages Sep 21, 2022 – Sep 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_supported_fs: Implement checking paths against skiplist

---

Implement tst_supported_fs feature suggested by pvorel in his patch:
tst_test.sh: Fix filesystem support detection

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly skipped and vfat is missing from the list of known filesystems.

 testcases/lib/tst_supported_fs.c | 49 ++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)
testcases/lib/tst_supported_fs.c +41 -8
index 70d4d38c7..5873d0ba1 100644
@@ -32,9 +32,13 @@ static void usage(void)
 	fprintf(stderr, "tst_supported_fs -s skip_list fs_type\n");
 	fprintf(stderr, "   if fs_type is in skip_list, return 1 otherwise return 0\n\n");
 
+	fprintf(stderr, "tst_supported_fs -s skip_list -d path\n");
+	fprintf(stderr, "   if filesystem mounted on path is in skip_list, return 1 otherwise return 0\n\n");
+
 	fprintf(stderr, "fs_type - a specified filesystem type\n");
 	fprintf(stderr, "skip_list - filesystems to skip, delimiter: '%c'\n",
 			SKIP_DELIMITER);
+	fprintf(stderr, "path - any valid file or directory\n");
 }
 
 static char **parse_skiplist(char *fs)
@@ -62,10 +66,11 @@ static char **parse_skiplist(char *fs)
 int main(int argc, char *argv[])
 {
 	const char *const *filesystems;
+	const char *fsname = NULL;
 	int i, ret;
 	char **skiplist = NULL;
 
-	while ((ret = getopt(argc, argv, "hs:"))) {
+	while ((ret = getopt(argc, argv, "hs:d:"))) {
 		if (ret < 0)
 			break;
 
@@ -83,9 +88,26 @@ int main(int argc, char *argv[])
 			if (!skiplist)
 				return 1;
 			break;
+
+		case 'd':
+			if (fsname) {
+				fprintf(stderr,
+					"Can't specify multiple paths\n");
+				usage();
+				return 2;
+			}
+
+			fsname = tst_fs_type_name(tst_fs_type(optarg));
+			break;
 		}
 	}
 
+	if (fsname && !skiplist) {
+		fprintf(stderr, "Parameter -d requires skiplist\n");
+		usage();
+		return 2;
+	}
+
 	if (argc - optind > 1) {
 		fprintf(stderr, "Can't specify multiple fs_type\n");
 		usage();
@@ -94,22 +116,33 @@ int main(int argc, char *argv[])
 
 	/* fs_type */
 	if (optind < argc) {
-		if (argv[optind][0] == '\0')
+		if (fsname) {
+			fprintf(stderr, "Can't specify fs_type and -d together\n");
+			usage();
+			return 2;
+
+		}
+
+		fsname = argv[optind];
+	}
+
+	if (fsname) {
+		if (fsname[0] == '\0')
 			tst_brk(TCONF, "fs_type is empty");
 
 		if (skiplist) {
-			if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
-				tst_brk(TCONF, "%s is skipped", argv[optind]);
+			if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))
+				tst_brk(TCONF, "%s is skipped", fsname);
 			else
-				tst_res(TINFO, "%s is not skipped", argv[optind]);
+				tst_res(TINFO, "%s is not skipped", fsname);
 
 			return 0;
 		}
 
-		if (tst_fs_is_supported(argv[optind]) == TST_FS_UNSUPPORTED)
-			tst_brk(TCONF, "%s is not supported", argv[optind]);
+		if (tst_fs_is_supported(fsname) == TST_FS_UNSUPPORTED)
+			tst_brk(TCONF, "%s is not supported", fsname);
 		else
-			tst_res(TINFO, "%s is supported", argv[optind]);
+			tst_res(TINFO, "%s is supported", fsname);
 
 		return 0;
 	}
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw
Quoted 9 lines · Martin Doucha

---

Implement tst_supported_fs feature suggested by pvorel in his patch:
tst_test.sh: Fix filesystem support detection

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly

Yes, that's true, we need to make it keep consistent with two skipping ways. Otherwise below test output "ext2/ext3/ext4" looks like a bit mess to remember.

Better going with a single FS for matching (i.e. "ext4" for both fs_type and '-d path').
But we can solve this in a separate patch later.

$ df -T . | tail -1 | awk '{print $2}'
ext4
$ ./tst_supported_fs -s "ext4" ext4
tst_supported_fs.c:135: TCONF: ext4 is skipped
$ echo $?
32
$ ./tst_supported_fs -s "ext4" -d .
tst_supported_fs.c:137: TINFO: ext2/ext3/ext4 is not skipped
$ echo $?
0
$ ./tst_supported_fs -s "ext2/ext3/ext4" -d .
tst_supported_fs.c:135: TCONF: ext2/ext3/ext4 is skipped
$ echo $?
32
Quoted 11 lines

skipped and vfat is missing from the list of known filesystems.

 testcases/lib/tst_supported_fs.c | 49 ++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)
testcases/lib/tst_supported_fs.c +0 -0
index 70d4d38c7..5873d0ba1 100644

testcases/lib/tst_supported_fs.c static void usage(void) · line 38

Quoted 7 lines
testcases/lib/tst_supported_fs.c +2 -0
@@ -32,9 +32,13 @@ static void usage(void)
        fprintf(stderr, "tst_supported_fs -s skip_list fs_type\n");
        fprintf(stderr, "   if fs_type is in skip_list, return 1 otherwise
 return 0\n\n");
 
+       fprintf(stderr, "tst_supported_fs -s skip_list -d path\n");
+       fprintf(stderr, "   if filesystem mounted on path is in skip_list,
 return 1 otherwise return 0\n\n");

+

Quoted 67 lines
testcases/lib/tst_supported_fs.c +32 -2
        fprintf(stderr, "fs_type - a specified filesystem type\n");
        fprintf(stderr, "skip_list - filesystems to skip, delimiter:
 '%c'\n",
                        SKIP_DELIMITER);
+       fprintf(stderr, "path - any valid file or directory\n");
 }
 
 static char **parse_skiplist(char *fs)
@@ -62,10 +66,11 @@ static char **parse_skiplist(char *fs)
 int main(int argc, char *argv[])
 {
        const char *const *filesystems;
+       const char *fsname = NULL;
        int i, ret;
        char **skiplist = NULL;
 
-       while ((ret = getopt(argc, argv, "hs:"))) {
+       while ((ret = getopt(argc, argv, "hs:d:"))) {
                if (ret < 0)
                        break;
 
@@ -83,9 +88,26 @@ int main(int argc, char *argv[])
                        if (!skiplist)
                                return 1;
                        break;
+
+               case 'd':
+                       if (fsname) {
+                               fprintf(stderr,
+                                       "Can't specify multiple paths\n");
+                               usage();
+                               return 2;
+                       }
+
+                       fsname = tst_fs_type_name(tst_fs_type(optarg));
+                       break;
                }
        }
 
+       if (fsname && !skiplist) {
+               fprintf(stderr, "Parameter -d requires skiplist\n");
+               usage();
+               return 2;
+       }
+
        if (argc - optind > 1) {
                fprintf(stderr, "Can't specify multiple fs_type\n");
                usage();
@@ -94,22 +116,33 @@ int main(int argc, char *argv[])
 
        /* fs_type */
        if (optind < argc) {
-               if (argv[optind][0] == '\0')
+               if (fsname) {
+                       fprintf(stderr, "Can't specify fs_type and -d
 together\n");
+                       usage();
+                       return 2;
+
+               }
+
+               fsname = argv[optind];
+       }
+
+       if (fsname) {
+               if (fsname[0] == '\0')
                        tst_brk(TCONF, "fs_type is empty");

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 140

Quoted 10 lines
testcases/lib/tst_supported_fs.c +2 -2
 
                if (skiplist) {
-                       if (tst_fs_in_skiplist(argv[optind], (const char *
 const*)skiplist))
-                               tst_brk(TCONF, "%s is skipped",
 argv[optind]);
+                       if (tst_fs_in_skiplist(fsname, (const char *
 const*)skiplist))
+                               tst_brk(TCONF, "%s is skipped", fsname);
 

TCONF does not means return 1, we might need explicitly 'return 1' here.

else

Quoted 13 lines
testcases/lib/tst_supported_fs.c +1 -2
-                               tst_res(TINFO, "%s is not skipped",
 argv[optind]);
+                               tst_res(TINFO, "%s is not skipped",
 fsname);
 
                        return 0;
                }
 
-               if (tst_fs_is_supported(argv[optind]) ==

TST_FS_UNSUPPORTED)
- tst_brk(TCONF, "%s is not supported",
argv[optind]);

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 143

Quoted 2 lines
testcases/lib/tst_supported_fs.c +2 -0
+               if (tst_fs_is_supported(fsname) == TST_FS_UNSUPPORTED)
+                       tst_brk(TCONF, "%s is not supported", fsname);

Same here.

Quoted 14 lines

else

testcases/lib/tst_supported_fs.c +1 -2
-                       tst_res(TINFO, "%s is supported", argv[optind]);
+                       tst_res(TINFO, "%s is supported", fsname);
 
                return 0;
        }
--

2.37.3

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 8 lines · Li Wang
                     if (skiplist) {
    -                       if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
    -                               tst_brk(TCONF, "%s is skipped", argv[optind]);
    +                       if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))
    +                               tst_brk(TCONF, "%s is skipped", fsname);

TCONF does not means return 1, we might need explicitly 'return 1' here.

Yes, but that's a problem which already existed before my patch and affects the other single-FS checks as well. The fix should go into a separate patch after release.

Signature · 11 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 8 lines · Li Wang
Quoted 5 lines
                     if (skiplist) {
    -                       if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
    -                               tst_brk(TCONF, "%s is skipped", argv[optind]);
    +                       if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))
    +                               tst_brk(TCONF, "%s is skipped", fsname);
Quoted 5 lines
Quoted 1 line

TCONF does not means return 1, we might need explicitly 'return 1' here.

Yes, but that's a problem which already existed before my patch and affects the other single-FS checks as well. The fix should go into a separate patch after release.

Yes, that's not related. I changed it in eb47b4497 ("tst_supported_fs: Support skip list when query single fs") as with 32 one can detect it's TCONF. As long as 0 is success, non-zero for failure.
But I forget to update doc.

Thus I'll wait for feedback from others whether we should get back to 1 as error (thus use TINFO) or update doc to mention to exit 32 (or more generally non-zero exit).
very nit: I'd use exit instead of return in docs.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#4 lore raw
Quoted 17 lines · Petr Vorel
Quoted 3 lines · Li Wang
Quoted 2 lines

if (skiplist) {
- if (tst_fs_in_skiplist(argv[optind],

(const char * const*)skiplist))

Quoted 1 line
Quoted 1 line

- tst_brk(TCONF, "%s is skipped",

argv[optind]);

Quoted 1 line
Quoted 1 line

+ if (tst_fs_in_skiplist(fsname, (const char

* const*)skiplist))

Quoted 1 line
Quoted 1 line

+ tst_brk(TCONF, "%s is skipped",

fsname);

Quoted 1 line
Quoted 1 line

TCONF does not means return 1, we might need explicitly 'return 1'

here.

Quoted 1 line

Yes, but that's a problem which already existed before my patch and

affects

Quoted 9 lines
Quoted 1 line

the other single-FS checks as well. The fix should go into a separate

patch

Quoted 1 line

after release.

Yes, that's not related. I changed it in eb47b4497 ("tst_supported_fs:
Support
skip list when query single fs") as with 32 one can detect it's TCONF. As long as 0 is success, non-zero for failure.

Looks like there is no difference to use whatever 32 or 1, as long as it's a non-zero, it will work well in the shell.

Ok, I agree to update the doc (also usage() should be updated) later.

Quoted 13 lines

But I forget to update doc.

Thus I'll wait for feedback from others whether we should get back to 1 as error
(thus use TINFO) or update doc to mention to exit 32 (or more generally non-zero
exit).
very nit: I'd use exit instead of return in docs.

Kind regards,
Petr

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

...

Quoted 10 lines
Quoted 4 lines

Yes, that's not related. I changed it in eb47b4497 ("tst_supported_fs:
Support
skip list when query single fs") as with 32 one can detect it's TCONF. As long as 0 is success, non-zero for failure.

Looks like there is no difference to use whatever 32 or 1, as long as it's a non-zero, it will work well in the shell.

Ok, I agree to update the doc (also usage() should be updated) later.

+1, I actually meant usage() in testcases/lib/tst_supported_fs.c.

Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Li Wang

Hi all,

Quoted 24 lines
Quoted 2 lines

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly

Yes, that's true, we need to make it keep consistent with two skipping ways. Otherwise below test output "ext2/ext3/ext4" looks like a bit mess to remember.

Better going with a single FS for matching (i.e. "ext4" for both fs_type and '-d path').
But we can solve this in a separate patch later.

$ df -T . | tail -1 | awk '{print $2}'
ext4
$ ./tst_supported_fs -s "ext4" ext4
tst_supported_fs.c:135: TCONF: ext4 is skipped
$ echo $?
32
$ ./tst_supported_fs -s "ext4" -d .
tst_supported_fs.c:137: TINFO: ext2/ext3/ext4 is not skipped
$ echo $?
0
Quoted 4 lines
$ ./tst_supported_fs -s "ext2/ext3/ext4" -d .
tst_supported_fs.c:135: TCONF: ext2/ext3/ext4 is skipped
$ echo $?
32

The same problem is for .skip_filesystems on tests which does not use .all_filesystems. We only haven't noticed, because there was no reason to skip ext[234] so far. I'm looking into this.

BTW .skip_filesystems without .all_filesystems have other problems, e.g. using filesystems which aren't in fs_type_whitelist[] array (e.g. ramfs, nfs). That'd be nice to fix after the release.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
Quoted 32 lines · Petr Vorel

Hi all,

Quoted 2 lines
Quoted 2 lines

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get

properly

Quoted 21 lines

Yes, that's true, we need to make it keep consistent with two skipping ways. Otherwise below test output "ext2/ext3/ext4" looks like a bit mess to remember.

Better going with a single FS for matching (i.e. "ext4" for both fs_type and '-d path').
But we can solve this in a separate patch later.

$ df -T . | tail -1 | awk '{print $2}'
ext4
$ ./tst_supported_fs -s "ext4" ext4
tst_supported_fs.c:135: TCONF: ext4 is skipped
$ echo $?
32
$ ./tst_supported_fs -s "ext4" -d .
tst_supported_fs.c:137: TINFO: ext2/ext3/ext4 is not skipped
$ echo $?
0
Quoted 4 lines
$ ./tst_supported_fs -s "ext2/ext3/ext4" -d .
tst_supported_fs.c:135: TCONF: ext2/ext3/ext4 is skipped
$ echo $?
32
Quoted 5 lines

The same problem is for .skip_filesystems on tests which does not use .all_filesystems. We only haven't noticed, because there was no reason to skip
ext[234] so far. I'm looking into this.

This seems a bit tricky to distinguish EXT2,3,4, from what I know, they use the same magic number. It will be difficult to get the FS block and extract smaller granularity of feature without using fs helper tools.

Quoted 6 lines

BTW .skip_filesystems without .all_filesystems have other problems, e.g. using
filesystems which aren't in fs_type_whitelist[] array (e.g. ramfs, nfs). That'd be nice to fix after the release.

+1

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw
Quoted 40 lines · Petr Vorel
Quoted 33 lines

Hi all,

Quoted 2 lines
Quoted 2 lines

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get

properly

Quoted 21 lines

Yes, that's true, we need to make it keep consistent with two skipping ways. Otherwise below test output "ext2/ext3/ext4" looks like a bit mess to remember.

Better going with a single FS for matching (i.e. "ext4" for both fs_type and '-d path').
But we can solve this in a separate patch later.

$ df -T . | tail -1 | awk '{print $2}'
ext4
$ ./tst_supported_fs -s "ext4" ext4
tst_supported_fs.c:135: TCONF: ext4 is skipped
$ echo $?
32
$ ./tst_supported_fs -s "ext4" -d .
tst_supported_fs.c:137: TINFO: ext2/ext3/ext4 is not skipped
$ echo $?
0
Quoted 4 lines
$ ./tst_supported_fs -s "ext2/ext3/ext4" -d .
tst_supported_fs.c:135: TCONF: ext2/ext3/ext4 is skipped
$ echo $?
32
Quoted 4 lines

The same problem is for .skip_filesystems on tests which does not use .all_filesystems. We only haven't noticed, because there was no reason to skip
ext[234] so far. I'm looking into this.

Quoted 4 lines

This seems a bit tricky to distinguish EXT2,3,4, from what I know, they use the same magic number. It will be difficult to get the FS block and extract smaller granularity of feature without using fs helper tools.

Yep, magic is the same: 0xef53 (not count the old ext2: 0xef51). I thought that I'd map ext[235] to "ext2/ext3/ext4". But maybe it's not a good idea.

OTOH df (coreutils) manages to distinguish them, stat can't.
I looked into df sources, it looks read_file_system_list() from gnulib which it uses, reads /proc/self/mountinfo. Wouldn't be better to follow this approach in tst_fs_type_() instead of using statfs()? (using st_dev - major:minor from stat to match). I guess we always read mounted filesystem, thus it'd be a drop-in replacement, we'd not need tst_fs_type_name() any more.

Kind regards,
Petr

Quoted 7 lines
Quoted 4 lines

BTW .skip_filesystems without .all_filesystems have other problems, e.g. using
filesystems which aren't in fs_type_whitelist[] array (e.g. ramfs, nfs). That'd be nice to fix after the release.

+1

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Hi!

Quoted 9 lines
Quoted 4 lines

This seems a bit tricky to distinguish EXT2,3,4, from what I know, they use the same magic number. It will be difficult to get the FS block and extract smaller granularity of feature without using fs helper tools.

Yep, magic is the same: 0xef53 (not count the old ext2: 0xef51). I thought that I'd map ext[235] to "ext2/ext3/ext4". But maybe it's not a good idea.

Quoted 6 lines

OTOH df (coreutils) manages to distinguish them, stat can't.
I looked into df sources, it looks read_file_system_list() from gnulib which it uses, reads /proc/self/mountinfo. Wouldn't be better to follow this approach in tst_fs_type_() instead of using statfs()? (using st_dev - major:minor from stat to match). I guess we always read mounted filesystem, thus it'd be a drop-in replacement, we'd not need tst_fs_type_name() any more.

The real problem is that the line between ext2, ext3 and ext4 is really blurry to an extend where it's hard to say which filesystem are you working with. For example while ext2 kernel driver still exists and is in use on embedded hardware modern distributions use single ext driver to handle all three filesystems. Also I think that it was possible to mount ext3 with ext2 driver at some point which disabled the journaling.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw
Quoted 6 lines · Cyril Hrubis

The real problem is that the line between ext2, ext3 and ext4 is really blurry to an extend where it's hard to say which filesystem are you working with. For example while ext2 kernel driver still exists and is in use on embedded hardware modern distributions use single ext driver to handle all three filesystems. Also I think that it was possible to mount ext3 with ext2 driver at some point which disabled the journaling.

Still, I'd argue that blindly assuming any FS with ext2/3/4 magic number is always mounted as ext4 is a better solution than returning a string that never matches skiplists.

Signature · 11 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw
Quoted 7 lines · Cyril Hrubis
Quoted 6 lines

The real problem is that the line between ext2, ext3 and ext4 is really blurry to an extend where it's hard to say which filesystem are you working with. For example while ext2 kernel driver still exists and is in use on embedded hardware modern distributions use single ext driver to handle all three filesystems. Also I think that it was possible to mount ext3 with ext2 driver at some point which disabled the journaling.

Should I understand this that you don't trust /proc/self/mountinfo output? (show_mountinfo() in fs/proc_namespace.c in kernel git)?

Petr

Quoted 3 lines

Still, I'd argue that blindly assuming any FS with ext2/3/4 magic number is always mounted as ext4 is a better solution than returning a string that never matches skiplists.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Hi!

Quoted 2 lines

Should I understand this that you don't trust /proc/self/mountinfo output? (show_mountinfo() in fs/proc_namespace.c in kernel git)?

Not much as I wouldn't trust it, it's just that the ext2/ext3/ext4 names are just short names for a subset of additional functionality.

Consider this:

$ dd if=/dev/zero of=fsimage.img bs=1024 count=32768
$ mkfs.ext3 fsimage.img
$ tune2fs -O ^has_journal fsimage.img
$ mount -o loop fsimage.img /mntpoint
$ cat /proc/self/mountinfo
43 19 7:0 / /mntpoint rw,relatime - ext3 /dev/loop0 rw

Now we have mounted ext3 without journaling, is that really ext3?

$ umount /mntpoint
$ mount -t ext2 -o loop fsimage.img /mntpoint
$ cat /proc/self/mountinfo
43 19 7:0 / /mntpoint rw,relatime - ext2 /dev/loop0 rw

Now we mounted the same filesystem as ext2.

And in both cases this is handled by the ext4 kernel driver anyways:

$ dmesg
...
EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
...
EXT4-fs (loop0): mounting ext2 file system using the ext4 subsystem
...

So I would argue that these are not three different filesystems, but just one that can turn on and off various features. And if you look at 'man ext4' you will see that the set of supported features for any extX variant does change with kernel version.

The question is if we really need to be able to distinguish them or if we can keep calling them by a common name.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw
Quoted 25 lines

Hi!

Quoted 2 lines

Should I understand this that you don't trust /proc/self/mountinfo output? (show_mountinfo() in fs/proc_namespace.c in kernel git)?

Not much as I wouldn't trust it, it's just that the ext2/ext3/ext4 names are just short names for a subset of additional functionality.

Consider this:

$ dd if=/dev/zero of=fsimage.img bs=1024 count=32768
$ mkfs.ext3 fsimage.img
$ tune2fs -O ^has_journal fsimage.img
$ mount -o loop fsimage.img /mntpoint
$ cat /proc/self/mountinfo
43 19 7:0 / /mntpoint rw,relatime - ext3 /dev/loop0 rw

Now we have mounted ext3 without journaling, is that really ext3?

$ umount /mntpoint
$ mount -t ext2 -o loop fsimage.img /mntpoint
$ cat /proc/self/mountinfo
43 19 7:0 / /mntpoint rw,relatime - ext2 /dev/loop0 rw

Now we mounted the same filesystem as ext2.

Quoted 8 lines

And in both cases this is handled by the ext4 kernel driver anyways:

$ dmesg
...
EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
...
EXT4-fs (loop0): mounting ext2 file system using the ext4 subsystem
...

Thanks a lot for a nice example to document the problem.

Quoted 4 lines

So I would argue that these are not three different filesystems, but just one that can turn on and off various features. And if you look at 'man ext4' you will see that the set of supported features for any extX variant does change with kernel version.

Makes sense.

Quoted 2 lines

The question is if we really need to be able to distinguish them or if we can keep calling them by a common name.

As I noted before, using Martin's patch require to use ext2/ext3/ext4 for .skip_filesystems and $TST_SKIP_FILESYSTEMS. I'm OK with it, although it's a bit misleading.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#14 lore raw
In reply to Martin Doucha

Hi Martin,

Thanks for implementing this.

I guess after accepting this and my v2 (not yet sent), we could remove 'tst_supported_fs -s skip_list fs_type' as nothing uses it. But OTOH it does not harm to keep it.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw
In reply to Martin Doucha

Hi,

Quoted 1 line

+++ b/testcases/lib/tst_supported_fs.c

...

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 123

Quoted 8 lines
testcases/lib/tst_supported_fs.c +5 -1
 	/* fs_type */
 	if (optind < argc) {
-		if (argv[optind][0] == '\0')
+		if (fsname) {
+			fprintf(stderr, "Can't specify fs_type and -d together\n");
+			usage();
+			return 2;
+

nit: remove this extra line before merging.

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 127

Quoted 4 lines
testcases/lib/tst_supported_fs.c +4 -0
+		}
+
+		fsname = argv[optind];
+	}

...

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw
In reply to Martin Doucha

Hi all,

Quoted 2 lines

Implement tst_supported_fs feature suggested by pvorel in his patch:
tst_test.sh: Fix filesystem support detection

FYI there is still be need to detect filesystem in particular directory in ima_setup.sh [1] to avoid df dependency:

if [ "$(df -T $TMPDIR | tail -1 | awk '{print $2}')" != "tmpfs" -a -n "$TST_NEEDS_DEVICE" ]; then
unset TST_NEEDS_DEVICE
fi

But I guess I'll just reuse the exit code of: ./tst_supported_fs -d $TMPDIR -s "tmpfs"

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/blob/74e4a5c6fb42a1231c149c57efbca345aa93777d/testcases/kernel/security/integrity/ima/tests/ima_setup.sh#L355

Quoted 3 lines

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly skipped and vfat is missing from the list of known filesystems.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#17 lore raw

Hi all,

merged this one with 2 tiny fixes (sort getopts string, remove blank line).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#18 lore raw
In reply to Martin Doucha

Hi!

Quoted 32 lines

---

Implement tst_supported_fs feature suggested by pvorel in his patch:
tst_test.sh: Fix filesystem support detection

Although the tst_fs_type_name() functions could use some improvements, e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly skipped and vfat is missing from the list of known filesystems.

 testcases/lib/tst_supported_fs.c | 49 ++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)
testcases/lib/tst_supported_fs.c +4 -0
index 70d4d38c7..5873d0ba1 100644
@@ -32,9 +32,13 @@ static void usage(void)
 	fprintf(stderr, "tst_supported_fs -s skip_list fs_type\n");
 	fprintf(stderr, "   if fs_type is in skip_list, return 1 otherwise return 0\n\n");
 
+	fprintf(stderr, "tst_supported_fs -s skip_list -d path\n");
+	fprintf(stderr, "   if filesystem mounted on path is in skip_list, return 1 otherwise return 0\n\n");
+
 	fprintf(stderr, "fs_type - a specified filesystem type\n");
 	fprintf(stderr, "skip_list - filesystems to skip, delimiter: '%c'\n",
 			SKIP_DELIMITER);
+	fprintf(stderr, "path - any valid file or directory\n");
 }
 
 static char **parse_skiplist(char *fs)

testcases/lib/tst_supported_fs.c static char **parse_skiplist(char *fs) · line 73

Quoted 9 lines
testcases/lib/tst_supported_fs.c +2 -1
@@ -62,10 +66,11 @@ static char **parse_skiplist(char *fs)
 int main(int argc, char *argv[])
 {
 	const char *const *filesystems;
+	const char *fsname = NULL;
 	int i, ret;
 	char **skiplist = NULL;
 
-	while ((ret = getopt(argc, argv, "hs:"))) {
+	while ((ret = getopt(argc, argv, "hs:d:"))) {

^
It's customary to sort these in alphabetical order.

Other than that:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp