Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: always check mask returned by statmount(2)

STATMOUNT_MNT_OPTS can actually be missing if there are no options. This
is a change of behavior since 75ead69a7173 ("fs: don't let statmount return
empty strings").

The other checks shouldn't actually trigger, but add them for correctness
and for easier debugging if the test fails.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Link: https://lore.kernel.org/r/20250129160641.35485-1-mszeredi@redhat.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Miklos Szeredi and committed by
Christian Brauner
2cc02059 5eb98710

+21 -1
+21 -1
tools/testing/selftests/filesystems/statmount/statmount_test.c
··· 383 383 return; 384 384 } 385 385 386 + if (!(sm->mask & STATMOUNT_MNT_POINT)) { 387 + ksft_test_result_fail("missing STATMOUNT_MNT_POINT in mask\n"); 388 + return; 389 + } 386 390 if (strcmp(sm->str + sm->mnt_point, "/") != 0) { 387 391 ksft_test_result_fail("unexpected mount point: '%s' != '/'\n", 388 392 sm->str + sm->mnt_point); ··· 410 406 if (!sm) { 411 407 ksft_test_result_fail("statmount mount root: %s\n", 412 408 strerror(errno)); 409 + return; 410 + } 411 + if (!(sm->mask & STATMOUNT_MNT_ROOT)) { 412 + ksft_test_result_fail("missing STATMOUNT_MNT_ROOT in mask\n"); 413 413 return; 414 414 } 415 415 mnt_root = sm->str + sm->mnt_root; ··· 445 437 strerror(errno)); 446 438 return; 447 439 } 440 + if (!(sm->mask & STATMOUNT_FS_TYPE)) { 441 + ksft_test_result_fail("missing STATMOUNT_FS_TYPE in mask\n"); 442 + return; 443 + } 448 444 fs_type = sm->str + sm->fs_type; 449 445 for (s = known_fs; s != NULL; s++) { 450 446 if (strcmp(fs_type, *s) == 0) ··· 473 461 if (!sm) { 474 462 ksft_test_result_fail("statmount mnt opts: %s\n", 475 463 strerror(errno)); 464 + return; 465 + } 466 + 467 + if (!(sm->mask & STATMOUNT_MNT_BASIC)) { 468 + ksft_test_result_fail("missing STATMOUNT_MNT_BASIC in mask\n"); 476 469 return; 477 470 } 478 471 ··· 531 514 if (p2) 532 515 *p2 = '\0'; 533 516 534 - statmount_opts = sm->str + sm->mnt_opts; 517 + if (sm->mask & STATMOUNT_MNT_OPTS) 518 + statmount_opts = sm->str + sm->mnt_opts; 519 + else 520 + statmount_opts = ""; 535 521 if (strcmp(statmount_opts, p) != 0) 536 522 ksft_test_result_fail( 537 523 "unexpected mount options: '%s' != '%s'\n",