From a7022857d15b722d43bd070587e8299865597572 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 3 Jul 2024 14:21:28 -0700 Subject: [PATCH] libfrog: add directory tree structure scrubber to scrub library Make it so that scrub clients can detect corruptions within the directory tree structure itself. Update the documentation for the scrub ioctl to mention this new functionality. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libfrog/scrub.c | 5 +++++ man/man2/ioctl_xfs_scrub_metadata.2 | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libfrog/scrub.c b/libfrog/scrub.c index baaa4b4d9..a2146e228 100644 --- a/libfrog/scrub.c +++ b/libfrog/scrub.c @@ -149,6 +149,11 @@ const struct xfrog_scrub_descr xfrog_scrubbers[XFS_SCRUB_TYPE_NR] = { .descr = "retained health records", .group = XFROG_SCRUB_GROUP_NONE, }, + [XFS_SCRUB_TYPE_DIRTREE] = { + .name = "dirtree", + .descr = "directory tree structure", + .group = XFROG_SCRUB_GROUP_INODE, + }, }; #undef DEP diff --git a/man/man2/ioctl_xfs_scrub_metadata.2 b/man/man2/ioctl_xfs_scrub_metadata.2 index 75ae52bb5..44aa139b2 100644 --- a/man/man2/ioctl_xfs_scrub_metadata.2 +++ b/man/man2/ioctl_xfs_scrub_metadata.2 @@ -148,6 +148,20 @@ that points back to the subdirectory. The inode to examine can be specified in the same manner as .BR XFS_SCRUB_TYPE_INODE "." +.TP +.B XFS_SCRUB_TYPE_DIRTREE +This scrubber looks for problems in the directory tree structure such as loops +and directories accessible through more than one path. +Problems are detected by walking parent pointers upwards towards the root. +Loops are detected by comparing the parent directory at each step against the +directories already examined. +Directories with multiple paths are detected by counting the parent pointers +attached to a directory. +Non-directories do not have links pointing away from the directory tree root +and can be skipped. +The directory to examine can be specified in the same manner as +.BR XFS_SCRUB_TYPE_INODE "." + .TP .B XFS_SCRUB_TYPE_SYMLINK Examine the target of a symbolic link for obvious pathname problems. -- 2.50.1