Sponsored Content
Special Forums Hardware Filesystems, Disks and Memory Recreating a deleted hardlink to a file if I know the inode number Post 302223619 by Smiling Dragon on Monday 11th of August 2008 01:44:29 AM
Old 08-11-2008
Recreating a deleted hardlink to a file if I know the inode number

At risk of twisting the rules to nearly the point of breaking (if you think this goes too far mods, I apologise and accept that this should be deleted), I'm hoping someone might be able to cast a little light on the following problem regarding hard links to files.

Creating a hardlink to a file
Quote:
I'm trying to relink a file someone tried to delete while a process (that we don't want to shutdown) also had a filehandle open to it.
Consequently, we've got an inode entry but no directory entry (aka 'file') for it.

I've tracked the inode number down via lsof, as well as the particular filehandle the process has within the /proc filesystem.

This filehandle is presented as a standard "file"/directory entry in /proc/<pid>/fd and I can read from it ok as I would any other file.

I was hoping to create a link to it back where it used to be but I keep getting a 'No such file or directory' error. I know I've got my ln syntax correct as I've tested it out on plain files elsewhere.
Code:
ln /proc/<pid>/fd/<handle> /path/to/application/logs/access

Is ln the tool to use here? Surely if I know the inode number, filehandle and what it used to be called, I can recreate it?
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Inode number

as kernel keeps track of user activities on a file by its INODE number and I node table . what is the structure of Inode table. and where does this Inode table mapped into?user space or kernel space? is the Inode Number is fixed for a file till its deletion? thanks (1 Reply)
Discussion started by: compbug
1 Replies

2. Solaris

Creating a hardlink to a file

I'm trying to relink a file someone tried to delete while a process (that we don't want to shutdown) also had a filehandle open to it. Consequently, we've got an inode entry but no directory entry (aka 'file') for it. I've tracked the inode number down via lsof, as well as the particular... (0 Replies)
Discussion started by: Smiling Dragon
0 Replies

3. UNIX for Dummies Questions & Answers

Number of Inode on a disk

How we can know number of inode present in my Disk including free and occupied. Is there any tool or program to know how much free inode are there in inode free list . (2 Replies)
Discussion started by: mr_deb
2 Replies

4. Solaris

Recreating .xml file in /etc/zones

Folks, just wondering if there is a way to recreate this file if inadvertantly removed ?? (8 Replies)
Discussion started by: trevagreene
8 Replies

5. AIX

How to get the filename of which has been deleted if I know the inode number?

How to get the filename of which has been deleted if I know the inode number. i can use the command "istat" to get the inode number of the file. # istat /proc//fd/x If this file has been deleted,but the process of this file has not been closed and handle has not been released ,so this... (3 Replies)
Discussion started by: JoyOnLine
3 Replies

6. Shell Programming and Scripting

Modifying a file without changing inode number

Hi all, I am struggling to change the content of a file without changing the inode number. The exact issue is as below. I have a file name test.bak which has 100 lines of text. I am trying to to delete the first 90 lines of the text in the file. I know that using sed/awk/head/tail I can... (3 Replies)
Discussion started by: sathishkmrv
3 Replies

7. Red Hat

Inode number changes for a file in Redhat Linux

Hi, I have created a file abc.log in Redhat Linux. Inode number for a file get changes every time i update the file using vi editor. Is there any setting that can be made , such that inode number never gets changed? Or if we cannot restrict from inode number getting changed , is... (9 Replies)
Discussion started by: raghu.amilineni
9 Replies

8. Solaris

Retreive deleted file name if you having inode number

Some one please help me to find deleted file name, if I am having inode number in Solaris without using any 3rd party tool. Thanks :) (3 Replies)
Discussion started by: aksijain
3 Replies

9. Shell Programming and Scripting

Changing inode value of a hardlink

is it possible to change the inode value/ file path of a hard link? (2 Replies)
Discussion started by: fhill2
2 Replies

10. Linux

Inode number changes for a file in Redhat Linux

Hi, I have created a file a.txt in Redhat Linux. Inode number for a file changes every time i update the file using vi editor , gedit etc. Is there any setting that can be made , such that inode number never changes as that is supposed to be the expected behavior? Or if we cannot... (13 Replies)
Discussion started by: srirammanohar
13 Replies
VFS_FHTOVP(9)						   BSD Kernel Developer's Manual					     VFS_FHTOVP(9)

NAME
VFS_FHTOVP -- turn an NFS filehandle into a vnode SYNOPSIS
#include <sys/param.h> #include <sys/mount.h> #include <sys/vnode.h> int VFS_FHTOVP(struct mount *mp, struct fid *fhp, struct vnode **vpp); DESCRIPTION
The VFS_FHTOVP() macro is used by the NFS server to turn an NFS filehandle into a vnode. The arguments it expects are: mp The file system. fhp The filehandle to convert. vpp Return parameter for the new locked vnode. The contents of the filehandle are defined by the file system and are not examined by any other part of the system. It should contain enough information to uniquely identify a file within the file system as well as noticing when a file has been removed and the file system resources have been reused for a new file. For instance, UFS file system stores the inode number and inode generation counter in its filehandle. A call to VFS_FHTOVP() should generally be preceded by a call to VFS_CHECKEXP(9) to check if the file is accessible to the client. RETURN VALUES
The locked vnode for the file will be returned in *vpp. SEE ALSO
VFS(9), VFS_CHECKEXP(9), VOP_VPTOFH(9), vnode(9) AUTHORS
This manual page was written by Doug Rabson. BSD
January 4, 2010 BSD
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy