cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.68k stars 205 forks source link

[Feature Request] Option to disable resolving symlinks #125

Open Hate9 opened 2 years ago

Hate9 commented 2 years ago

I've been trying to recover some files, but unfortunately, somewhere in the directory I'm trying to recover, there's a symbolic link to the root directory, which means that any file recovery attempts just fill up with repeat copies of the same files, over and over again, without getting to the things I actually care about.

In theory, it should be very easy to fix this, by just turning off the feature that resolves symbolic links, but there doesn't appear to be an option to do that anywhere.

It would do me a great deal of good if someone could implement this, or if that's too much trouble, possibly inform me on where I'd want to look to disable the feature in a local build. Or, I've just missed the option to disable it, in which case I greatly appreciate you pointing out where it is, and I apologize for wasting your time lol

cgsecurity commented 2 years ago

I am unable to reproduce the problem. Do you have the problem with latest 7.2-WIP version ? Symlinks are ignored by Testdisk. There is also some code to prevent infinite loop when parsing directories.

I have tried with the following disk image

├── dir1
│   ├── dir2
│   │   ├── file2
│   │   ├── symlink_dir1 -> ../../dir1/
│   │   ├── symlink_dir3 -> ../dir3
│   │   ├── symlink_parent -> ..
│   │   └── symlink_root -> /
│   ├── dir3
│   │   └── file3
│   ├── file1
│   ├── symlink_parent -> ..
│   └── symlink_root -> /
├── lost+found
└── symlink_root -> /

Using testdisk to copy everything, the destination contains

.
├── dir1
│   ├── dir2
│   │   └── file2
│   ├── dir3
│   │   └── file3
│   └── file1
└── lost+found
Hate9 commented 2 years ago

I have not tried it with the latest version (this was a little while ago); I'll have to do that.

Hate9 commented 2 years ago

no, it's definitely still doing it.

Hate9 commented 2 years ago

I recovered some files (and stopped at some point, because it was looping again), and here's the result of tree on the dir. You can see that it recurses at line 1597, where it enters the home directory again.

files.txt

acsezen commented 2 months ago

Is there anyway to copy with symbolic links?