>>>>> "Russell" == Russell Senior <russ...@personaltelco.net> writes:

>>>>> "Russell" == Russell Senior <russ...@personaltelco.net> writes:
>>>>> "Robert" == Robert Citek <robert.ci...@gmail.com> writes:
Robert> Greetings all, For a file that is open, but deleted, is there
Robert> a way to create a new filename for it given either the file
Robert> descriptor from the process or the inode?

Robert> Thus far, my Google searches suggest the answer is "no".  But
Robert> I find that hard to believe.

Russell> Check out debugfs or maybe one of the other tools in
Russell> e2fsprogs package.  This is assuming the filesystem is an
Russell> ext2/3/4.

Russell> As long as the process doesn't let go of the inode, the
Russell> storage won't be reclaimed.

Russell> Read the debugfs manpage.  Particularly, look for:

Russell>          ln filespec dest_file Create a link named dest_file
Russell> which is a hard link to filespec.  Note this does not adjust
Russell> the inode reference counts.

Russell> The 'filespec' would be the inode number, I think.

Hmm.  That note about not adjusting the reference counts might be
problematic.  Maybe you need to do this to create a temporary
dest_file name, then from outside debugfs make a hardlink using the ln
command, then use debugfs to remove the dest_file you created using
the unlink pathname command.  E.g., something like:

  [I am assuming the following, correct as necessary: the inode is
   from a filesystem from /dev/sda1 and $inode is the numeric value of
   the inode, and you run this all from the mount point of the
   filesystem (the tmpname will get created in the root directory of
   the mounted filesystem), and permname is a path on the same
   filesystem.  You'll need to be root.]

*** BE VERY CAREFUL! ***

  # cd /mountpoint_of_dev_sda1
  # debugfs -w /dev/sda1
  debugfs 1.42.9 (4-Feb-2014)
  debugfs:  ln <$inode> tmpname
  debugfs:  quit
  # ln tmpname permname
  # debugfs -w /dev/sda1
  debugfs 1.42.9 (4-Feb-2014)
  debugfs:  unlink tmpname
  debugfs:  quit

*** BE VERY CAREFUL! ***


-- 
Russell Senior, President
russ...@personaltelco.net
_______________________________________________
PLUG mailing list
PLUG@lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to