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

samples/vfs: check whether flag was raised

For string options the kernel will raise the corresponding flag only if
the string isn't empty. So check for the flag.

Link: https://lore.kernel.org/r/20250204-work-mnt_idmap-statmount-v2-3-007720f39f2e@kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+5 -4
+5 -4
samples/vfs/test-list-all-mounts.c
··· 138 138 printf("mnt_id:\t\t%" PRIu64 "\nmnt_parent_id:\t%" PRIu64 "\nfs_type:\t%s\nmnt_root:\t%s\nmnt_point:\t%s\nmnt_opts:\t%s\n\n", 139 139 (uint64_t)stmnt->mnt_id, 140 140 (uint64_t)stmnt->mnt_parent_id, 141 - stmnt->str + stmnt->fs_type, 142 - stmnt->str + stmnt->mnt_root, 143 - stmnt->str + stmnt->mnt_point, 144 - stmnt->str + stmnt->mnt_opts); 141 + (stmnt->mask & STATMOUNT_FS_TYPE) ? stmnt->str + stmnt->fs_type : "", 142 + (stmnt->mask & STATMOUNT_MNT_ROOT) ? stmnt->str + stmnt->mnt_root : "", 143 + (stmnt->mask & STATMOUNT_MNT_POINT) ? stmnt->str + stmnt->mnt_point : "", 144 + (stmnt->mask & STATMOUNT_MNT_OPTS) ? stmnt->str + stmnt->mnt_opts : ""); 145 + 145 146 free(stmnt); 146 147 } 147 148 }