Professional Web Applications Themes

Locate a file by Inode - UNIX Programming

This there a way with UNIX to locate a file by inode if you know the inode information? I'd like to do this on Darwin. Thanx in advance for any help. SD....

  1. #1

    Default Locate a file by Inode

    This there a way with UNIX to locate a file by inode if you know the
    inode information?

    I'd like to do this on Darwin.

    Thanx in advance for any help.

    SD.
    S Derman Guest

  2. #2

    Default Re: Locate a file by Inode

    >>>>> "S" == S Derman <S> writes:

    S> This there a way with UNIX to locate a file by inode if you know the
    S> inode information?

    Yes. Use the find command, like

    siwenna% cd /etc/X11/fs
    siwenna% ls -li
    total 8
    142831 -rw-r--r-- 1 root root 1562 Jul 1 08:11 config
    109865 -rw-r--r-- 1 root root 1460 Oct 1 2002 config~
    siwenna% df
    Filesystem Size Used Avail Use% Mounted on
    /dev/md0 16G 6.7G 9.1G 43% /
    /dev/sda1 699M 41M 658M 6% /boot
    siwenna% find / -inum 142831 -print
    /etc/X11/fs/config


    The catch is, you should give the root of the filesystem as the starting
    point, since each filesystem has its own inode numbers.

    --
    Arto V. Viitanen [email]av@cs.uta.fi[/email]
    University of Tampere, Department of Computer and Information Sciences
    Tampere, Finland [url]http://www.cs.uta.fi/~av/[/url]

    Arto V. Viitanen Guest

  3. #3

    Default Re: Locate a file by Inode


    Arto V. Viitanen <av@cs.uta.fi> schrieb
    >
    > The catch is, you should give the root of the filesystem as the starting
    > point, since each filesystem has its own inode numbers.
    >
    So this means, that given an inode number, a search could return more than
    one file, because the same number may be used at the same time in different
    filesystems?

    Regards
    Martin



    Martin Blume Guest

  4. #4

    Default Re: Locate a file by Inode

    Martin Blume wrote:
    > Arto V. Viitanen <av@cs.uta.fi> schrieb
    >
    >>The catch is, you should give the root of the filesystem as the starting
    >>point, since each filesystem has its own inode numbers.
    >>
    >
    > So this means, that given an inode number, a search could return more than
    > one file, because the same number may be used at the same time in different
    > filesystems?
    >
    Yes, an inode is filesystem specific so if you search multiple file
    systems that inode can be found on any or all of them.

    Also, there can be more than one link to the same inode in a file
    system so even within a filesystem you can get any number of hits.

    -- ced




    --
    Chuck Dillon
    Senior Software Engineer
    NimbleGen Systems Inc.

    Chuck Dillon Guest

  5. #5

    Default Re: Locate a file by Inode

    "Martin Blume" <mblume@socha.net> said:
    >Arto V. Viitanen <av@cs.uta.fi> schrieb
    >> The catch is, you should give the root of the filesystem as the starting
    >> point, since each filesystem has its own inode numbers.
    >>
    >So this means, that given an inode number, a search could return more than
    >one file, because the same number may be used at the same time in different
    >filesystems?
    It's also possible (and not even rare) for a single inode to have multiple
    names. The most common case for this is that every directory inode has
    at least two names:
    - base/dir
    - base/dir/.
    (as an example, see "ls -li /etc /etc/.")
    .... but this is frequently used for files as well.

    Another issue is that an existing and valid inode may have zero names.
    These are commonly used as temporary files private to a process:
    a process creates the file, and keeps it open while unlinking it.
    This'll cause the inode to stay valid, but will lose the last name
    pointing from the directory hierarchy to the inode. The inode will be
    cleared when the last process holding it open closes it.
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)
    Juha Laiho Guest

  6. #6

    Default Re: Locate a file by Inode

    In article <webmaster-C69BD6.12595611072003@news.telus.net>,
    S Derman <webmaster@derman.com> wrote:
    >Sorry, I was wondering if there was a system calls that would locate a
    >file by inode number.
    >
    >Similar to open(path name,...), I'd like to open(inode num,...).
    No. Two reasons:

    1) You would also need to supply the filesystem ID, since an inode number
    is only unique within a filesystem.

    2) It would allow you to get around directory permissions. Execute
    permission on a directory controls whether you can open any files named
    within it. If you could go directly to the file without specifying the
    pathname, it wouldn't be able to check this.

    --
    Barry Margolin, [email]barry.margolin@level3.com[/email]
    Level(3), Woburn, MA
    *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
    Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
    Barry Margolin Guest

Similar Threads

  1. #26241 [Csd->Bgs]: fopen fails to locate file
    By abies@php.net in forum PHP Development
    Replies: 0
    Last Post: November 13th, 11:24 PM
  2. #26241 [Opn->Fbk]: fopen fails to locate file
    By abies@php.net in forum PHP Development
    Replies: 0
    Last Post: November 13th, 04:40 PM
  3. #26241 [NEW]: fopen fails to locate file
    By Brad dot Youngblood at 4S dot com in forum PHP Development
    Replies: 0
    Last Post: November 13th, 04:18 PM
  4. How to locate memory dump file
    By Rebecca in forum SCO
    Replies: 7
    Last Post: July 23rd, 03:39 PM
  5. How to locate the password file?
    By Jeffrey Yee in forum Oracle Server
    Replies: 1
    Last Post: July 1st, 04:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139