Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Kids,
I need to restore about 4000 files in a ext2fs. This can be done using the debugfs-command with the modify inode option. This works interactivly, I have to enter the inode-number and I have to set the deletion-time to zero (0) and the link entry to one (1). The other entrys must be untouched which can be achieved with bressing enter.
This is slightly annoying. I already have a list of the inode-numbers stored in a file, one entry per line.

My question is:
Is there any perl-way to automate it, I mean some ext2::ModifyInode or Filesystem::ext2Undelete?
Regards...

Replies are listed 'Best First'.
Re: restoring files in ext2fs
by Zaxo (Archbishop) on Feb 06, 2002 at 10:50 UTC
      I am sorry, but this is not what I have meant.
      Somebody (not me, I immediatly fell on my knees and sweared that that I will look at my fingers while I am root) removed a big portion of the entire filesystem by entering
      rm -r /some_path/ *
      The white space causes rm to remove all files recursivly under the current directory tree. If there were only one or two files I could do it from the command line by modifying the inodes. This would be a a better (forgive me, gods of perl!) way, because the files would be undeleted as they are (I am not to good in reading binary files).
      Unfortunatly we are talking about 4000 files. Finding borders takes more time than removing the deletion time of inodes.
      So the question was:
      Is there any way to manipulate inode-information with perl?
      I am looking for something like
      use CodeFromTheGodsofExt2fs; my %inode = getInode($InodeNumber); $inode{"DeletionTime"}=0; $inode{"Link"}=1; writeInode(%Inode);
      This could be done several (4000) times to recover all files that were deleted until that guy (not me I swear it) realized that Control-C would be a good idea.
      The harddisk stayed untouched, so the last command which accessed the hdd was the rm -r - command.

      Regards ...

      P.S.: I wrote my previous posting anonymous NOT because I am that guy (nope, it was not me - I have aliased rm to rm -i on my machines) but because the enemy-machine did not accept cookies at all.
        One way could be to patch the debugfs-sourcecode, but this is too dirty for me.

        Regards...