title: what api can be used to create a hard link to an existing inode on ext2/3
body: <p>I did a big oops, but the file is still open and in use.</p>
  
  <p>Following (<a href="https://stackoverflow.com/questions/1178593/link-to-a-specific-inode">Link to a specific inode</a>),
   copying from the <code>/proc/###/fd/###</code> to a new file is not useful because:</p>
  
  <ol>
  <li>the file is changing</li>
  <li>The filesize is 40G and the disk is full (150MB free)</li>
  </ol>
  
  <p>I am attempting to relink it to the filesystem (undelete it).</p>
  
  <pre><code>    COMMAND    PID    USER   FD      TYPE             DEVICE        SIZE       NODE NAME
  vmware-vm 4281    root  126u      REG              253,0 40020664320   10928132 /var/mnt/partial.img
  </code></pre>
  
  <p>I held the file open with a "wc /proc/4281/fd/126", then suspended it.</p>
  
  <p>I created a link on the filesystem by using debugfs (inspired from <a href="http://dag.wieers.com/blog/undeleting-an-open-file-by-inode" rel="nofollow noreferrer">dag wieers</a>) then edited the directory entry to set the deleted time to 0, update the link count. reboot and run fsck all is well.</p>
  
  <p><a href="http://fdlink.svn.sourceforge.net/viewvc/fdlink/trunk/flink/README?revision=2&amp;view=markup" rel="nofollow noreferrer">This is a kernel mod to do it</a>, I have not tested it yet.</p>