Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the order of deletion when I do "rm -rf data"? [closed]

Tags:

linux

bash

shell

I accidentally did a rm -rf data in a huge directory. I exited immediately.

The directory has a simple structure (they are all date-keyed sub-directories, like 2015/07/06) but the directory is huge and I don't want to regenerate the whole thing. If I knew how rm removed the files, I could find and regenerate just the missing ones.

How does rm -rf go about deleting files?

like image 489
CuriousMind Avatar asked Feb 09 '23 15:02

CuriousMind


1 Answers

rm performs a depth-first search, walking the results of the xfts_open call.

FTS is the standard means by which files are traversed in all the Linux tools. You can write your own fts consumer, or trust the output from find, since it also uses xfts_open.

find . will list the files that exist. You can then use your knowledge of the expected structure to reverse the list that are missing.

Alternatively, you can use debugfs to help you get at the files.

like image 106
bishop Avatar answered Feb 12 '23 06:02

bishop