Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move orphan inode(mft entry) to lost & found directory #4

Open
namjaejeon opened this issue Nov 10, 2022 · 0 comments
Open

Move orphan inode(mft entry) to lost & found directory #4

namjaejeon opened this issue Nov 10, 2022 · 0 comments

Comments

@namjaejeon
Copy link
Owner

Currently we just remove orphan inode(mft entry), We need to move it to lost&found directory.

namjaejeon added a commit that referenced this issue Feb 2, 2023
This message is comming after merging the recent PR to #master.
Parse #4: Check mft entries in volume...
Clear the bit of mft no(447) in the $MFT/$BITMAP corresponding orphaned MFT record (y/N)? N

It mean fsck try to clear bits of external mft entry. When fsck set bits
of mft entries, the call of ntfs_inode_attach_all_extents is missing
about inode that included attrlist attribute. So fsck decided external
mft entries are orphaned. This patch add the call
ntfs_inode_attach_all_extents() before checking ->nr_extents and
->extent_nis.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 2, 2023
This message is comming after merging the recent PR to #master.
Parse #4: Check mft entries in volume...
Clear the bit of mft no(447) in the $MFT/$BITMAP corresponding orphaned MFT record (y/N)? N

It mean fsck try to clear bits of external mft entry. When fsck set bits
of mft entries, the call of ntfs_inode_attach_all_extents is missing
about inode that included attrlist attribute. So fsck decided external
mft entries are orphaned. This patch add the call
ntfs_inode_attach_all_extents() before checking ->nr_extents and
->extent_nis.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 14, 2023
After creating / deleting files ntfsck show this error.

# ntfsck /dev/sdc2
Parse #1: Check system files...
Index is over 32 level deep: Operation not supported
Failed to find index entry of 10 system file
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:0, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 14, 2023
Windows client doesn't find any issue on ntfs dump image, but fsck found
orphan entries like this.

Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 4096). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4097). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4098). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4099). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4100). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4101). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4102). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4103). Try to add index entry (y/N)? N

If mft entry number is 4096, fsck_mft_bmp buffer should be increased
using realloc().

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
when lcn number in cluster run is 4096, fsck_lcn_bitmap_size should be
increased...

Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(4096) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(4097) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(4098) in $Bitmap. Clear it (y/N)? N
3 errors found, 0 fixed

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
After creating / deleting files ntfsck show this error.

# ntfsck /dev/sdc2
Parse #1: Check system files...
Index is over 32 level deep: Operation not supported
Failed to find index entry of 10 system file
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:0, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
Windows client doesn't find any issue on ntfs dump image, but fsck found
orphan entries like this.

Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 4096). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4097). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4098). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4099). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4100). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4101). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4102). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 4103). Try to add index entry (y/N)? N

If mft entry number is 4096, fsck_mft_bmp buffer should be increased
using realloc().

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
when lcn number in cluster run is 4096, fsck_lcn_bitmap_size should be
increased...

Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(4096) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(4097) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(4098) in $Bitmap. Clear it (y/N)? N
3 errors found, 0 fixed

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
no error on previous versions... Add missing ntfsck_update_lcn_bitmap
calling in ntfsck_verify_mft_record().

Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(17735931) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17736983) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17771531) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17772038) in $Bitmap. Clear it (y/N)? N
4 errors found, 0 fixed

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 15, 2023
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Corrupt index block: VCN (1) is different from expected VCN (0) in inode 28 (y/N)? N
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 29). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 30). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 31). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 32). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 33). Try to add index entry (y/N)? N
....

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 16, 2023
no error on previous versions... Add missing ntfsck_update_lcn_bitmap
calling in ntfsck_verify_mft_record().

Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(17735931) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17736983) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17771531) in $Bitmap. Clear it (y/N)? N
Found orphaned cluster bit(17772038) in $Bitmap. Clear it (y/N)? N
4 errors found, 0 fixed

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 16, 2023
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Corrupt index block: VCN (1) is different from expected VCN (0) in inode 28 (y/N)? N
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 29). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 30). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 31). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 32). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 33). Try to add index entry (y/N)? N
....

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
@jaysim jaysim mentioned this issue Feb 20, 2023
namjaejeon added a commit that referenced this issue Feb 22, 2023
…ssing in parent

1. try to fix using auto.

$ sudo ntfsck -a /dev/sdc1
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 317). Try to add index entry (y/N)? y
$IR is missing in inode(167): No such file or directory
Failed to check parent directory(317) for repairing orphan inode
Found an orphaned file(mft no: 318). Try to add index entry (y/N)? y
$IR is missing in inode(100): No such file or directory
Failed to check parent directory(318) for repairing orphan inode
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(17746536) in $Bitmap. Clear it (y/N)? y
Clean, No errors found or left (errors:3, fixed:3)

2. can see that errors are not fixed.
$ sudo ntfsck -n /dev/sdc1
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 317). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 318). Try to add index entry (y/N)? N
Parse #5: Check cluster bitmap...
Found missing cluster bit(70984606) in $Bitmap. Set it (y/N)? N
Found missing cluster bit(70984607) in $Bitmap. Set it (y/N)? N
4 errors left (errors:4, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 23, 2023
…ssing in parent

1. try to fix using auto.

$ sudo ntfsck -a /dev/sdc1
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 317). Try to add index entry (y/N)? y
$IR is missing in inode(167): No such file or directory
Failed to check parent directory(317) for repairing orphan inode
Found an orphaned file(mft no: 318). Try to add index entry (y/N)? y
$IR is missing in inode(100): No such file or directory
Failed to check parent directory(318) for repairing orphan inode
Parse #5: Check cluster bitmap...
Found orphaned cluster bit(17746536) in $Bitmap. Clear it (y/N)? y
Clean, No errors found or left (errors:3, fixed:3)

2. can see that errors are not fixed.
$ sudo ntfsck -n /dev/sdc1
Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Found an orphaned file(mft no: 317). Try to add index entry (y/N)? N
Found an orphaned file(mft no: 318). Try to add index entry (y/N)? N
Parse #5: Check cluster bitmap...
Found missing cluster bit(70984606) in $Bitmap. Set it (y/N)? N
Found missing cluster bit(70984607) in $Bitmap. Set it (y/N)? N
4 errors left (errors:4, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 24, 2023
< ntfs 3.0 version doesn't have FILE_Extend in system files.
So ntfsck show the following error message with NTFS 1.2 version.

Parse #1: Check system files...
Failed to lookup file name attribute of 11 system file
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:0, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Feb 27, 2023
< ntfs 3.0 version doesn't have FILE_Extend in system files.
So ntfsck show the following error message with NTFS 1.2 version.

Parse #1: Check system files...
Failed to lookup file name attribute of 11 system file
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:0, fixed:0)

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Mar 9, 2023
./make_disk_crrouption.sh [offset] [length] [device node]

offset : 0
length : 8bytes
disk device : /dev/sdb1

./make_disk_corruption.sh 8 8 /dev/sdb1
OFFSET:14 , PATTERN:0xFF
wrote 1/1 bytes at offset 14
1.000000 bytes, 1 ops; 0.0202 sec (49.487801 bytes/sec and 49.4878 ops/sec)
Parse #1: Check check system files...
Reserved fields aren't zero (255, 0, 0, 0, 0, 0).
Boot sector: invalid boot sector, Fix (y/N)? y
The alternate bootsector is usable
Rewriting the bootsector
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found
Parse #1: Check check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue May 15, 2023
When running fsck with -n option, can see lost+found failure message.

Parse #1: Check system files...
Parse #2: Replay logfile...
Parse #3: Check index entries in volume...
Failed to convert 'lost+found' to unicode: No such file or directory
Parse #4: Check mft entries in volume...
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:0, fixed:0

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon added a commit that referenced this issue Jul 18, 2023
commit 8d99e00 ("ntfsck: remove multiple inode open") cause that
extents mft records of secure system files are removed.

Parse #4: Check mft entries in volume...
Record(1354) used. Mark the mft record as not in use.
Record(3815) used. Mark the mft record as not in use.
Record(112068) used. Mark the mft record as not in use.
Clear MFT bitmap count:3
Parse #5: Check cluster bitmap...
Clean, No errors found or left (errors:12, fixed:12)

$ sudo ./src/ntfsck -a ../ntfs.img
Parse #1: Check system files...
Record 1354 has wrong SeqNo (1 <> 2)
Corrupt attribute list entry in MFT record 9

ntfs_check_inode no longer check opened system files.
This patch set fsck mft bitmap bits in ntfsck_check_system_files().

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant