Inode2filename

From: Miller Alan (Alan.Miller_at_is-energy.de)
Date: 09/26/03

  • Next message: Naresh: "Donovan Server down - SUN OS 5.7"
    To: sunmanagers@sunmanagers.org
    Date: Fri, 26 Sep 2003 12:39:39 +0200
    
    

    What's the best way to determine the filename given an inode?

    I know about lsof which does this for me, but I don't have lsof
    On many of my machines.

    When truss-ing a process I see the open file pointers:

            [root@server] truss -p 2112
            ....
            read(3, "F1 %\v\b", 4) = 4
            read(3, "A1ABE9D5", 4) = 4
            poll(0xFFBFF148, 2, -1) = 1
            write(5, "8D1FD403 l J oBE1FC4 v 8".., 2000) = 2000
            poll(0xFFBFF148, 2, -1) (sleeping...)
            poll(0xFFBFF148, 2, -1) = 1
            ....

    Then I use pfiles <PID> to get the inode

            [root@server] pfiles 2112
            2112: /usr/lib/ssh/sshd
              Current rlimit: 2048 file descriptors
               0: S_IFCHR mode:0666 dev:240,0 ino:985623 uid:0 gid:3 rdev:13,2
                  O_RDWR|O_LARGEFILE
               1: S_IFCHR mode:0666 dev:240,0 ino:985623 uid:0 gid:3 rdev:13,2
                  O_RDWR|O_LARGEFILE
               2: S_IFCHR mode:0666 dev:240,0 ino:985623 uid:0 gid:3 rdev:13,2
                  O_RDWR|O_LARGEFILE
               3: S_IFCHR mode:0644 dev:240,0 ino:986876 uid:0 gid:3 rdev:190,1
                  O_RDONLY|O_LARGEFILE
               4: S_IFDOOR mode:0444 dev:338,0 ino:8456 uid:0 gid:0 size:0
                  O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[2455]
               5: S_IFSOCK mode:0666 dev:332,0 ino:63363 uid:0 gid:0 size:0
                  O_RDWR|O_NONBLOCK

    Now how do I get the Fully qualified filename?
    Anybody have a suggestion?

    --
    Alan Miller	
    is:energy  GmbH	
    Unit Operations, Operating Systems - OPOO 	
    Tresckowstrasse 3		
    30457 Hannover		
    Telefon: (0511) 439-4292		Telefax: (0511) 439-4226	
    Email: alan.miller@is-energy.de	I-Net: <www.is-energy.de>
    _______________________________________________
    sunmanagers mailing list
    sunmanagers@sunmanagers.org
    http://www.sunmanagers.org/mailman/listinfo/sunmanagers
    

  • Next message: Naresh: "Donovan Server down - SUN OS 5.7"

    Relevant Pages

    • Re: newbie symlink question
      ... > I've used symbolic links alot, but never a hard link. ... The directory, as a file, is just an array of filename parts of ... hardlink.file shares the same inode as basic.file ... permission bit: the 'l' (softlink) bit. ...
      (comp.unix.questions)
    • Re: the disk space restored when i kill the process
      ... > The data part is associated with something called an 'inode'. ... > The filename part carries a name and an associated inode number. ... the log messages before making logger and the log messages from my ... print not only error log but also a normal debugging log in my own library. ...
      (comp.unix.programmer)
    • Re: When parse result of lsof command, use awk
      ... but if filename field includes whitespaces charactor, ... lsof 736 /home/common ... It'll only work if your awk supports RE intervals. ...
      (comp.lang.awk)
    • SUMMARY: large phantom files
      ... Run "lsof +L1" and look for large entries in the SIZE column. ... I haven't used the "fsck" approach recentl. ... use lsof to find a pid associated with that inode. ... Orca server was sol10 but at end of day so we went with the easy fix & ...
      (SunManagers)
    • Re: req: New feature to rm? Remove file by the inode number
      ... then i remembered ls showed inode number of the file. ... You are trying to remove one specific filename from one specific ... has *some* unprintable characters, ... I've never had to do more than pick a reasonable filename pattern ...
      (freebsd-hackers)