mirror of
https://github.com/linux-apfs/apfsprogs.git
synced 2026-08-18 02:19:50 -07:00
apfsck: ignore orphans in the volume file counts
It seems that orphans aren't counted in the file totals reported by the volume superblock. Fix this. Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
This commit is contained in:
@@ -206,6 +206,33 @@ void parse_dentry_record(void *key, struct apfs_drec_val *val, int len)
|
||||
inode->i_mode |= dtype << 12;
|
||||
}
|
||||
|
||||
/*
|
||||
* Orphans aren't counted for the file totals, but I can't tell them
|
||||
* apart inside parse_inode_record(), so do it here instead.
|
||||
*/
|
||||
if (parent_ino == APFS_PRIV_DIR_INO_NUM) {
|
||||
switch (dtype << 12) {
|
||||
case S_IFREG:
|
||||
vsb->v_file_count--;
|
||||
break;
|
||||
case S_IFDIR:
|
||||
if (inode->i_ino >= APFS_MIN_USER_INO_NUM)
|
||||
vsb->v_dir_count--;
|
||||
break;
|
||||
case S_IFLNK:
|
||||
vsb->v_symlink_count--;
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
vsb->v_special_count--;
|
||||
break;
|
||||
default:
|
||||
report("Dentry record", "invalid file mode.");
|
||||
}
|
||||
}
|
||||
|
||||
parse_dentry_xfields((struct apfs_xf_blob *)val->xfields,
|
||||
len - sizeof(*val), &sibling_id);
|
||||
|
||||
|
||||
+1
-2
@@ -860,8 +860,7 @@ void check_volume_super(void)
|
||||
report("Catalog", "the private directory is missing.");
|
||||
|
||||
if (le64_to_cpu(vsb_raw->apfs_num_files) != vsb->v_file_count)
|
||||
/* Sometimes this is off by one. TODO: why? */
|
||||
report_weird("File count in volume superblock");
|
||||
report("Volume superblock", "bad regular file count.");
|
||||
if (le64_to_cpu(vsb_raw->apfs_num_directories) != vsb->v_dir_count)
|
||||
report("Volume superblock", "bad directory count.");
|
||||
if (le64_to_cpu(vsb_raw->apfs_num_symlinks) != vsb->v_symlink_count)
|
||||
|
||||
Reference in New Issue
Block a user