removing file by inode

Discussion in 'Python' started by s99999999s2003@yahoo.com, Mar 23, 2006.

  1. Guest

    hi
    this is pertain to unix environment.
    is it possible to remove a file by it's inode and not it's filename
    using Python? Just curious...
    thanks.
    , Mar 23, 2006
    #1
    1. Advertising

  2. On 2006-03-23, <> wrote:

    > is it possible to remove a file by it's inode and not it's filename
    > using Python?


    What do you mean "remove a file"?

    --
    Grant Edwards grante Yow! Life is a POPULARITY
    at CONTEST! I'm REFRESHINGLY
    visi.com CANDID!!
    Grant Edwards, Mar 23, 2006
    #2
    1. Advertising

  3. Arne Ludwig Guest

    Good answer. :) I seriously doubt it is possible except for the
    trivial solution:

    def remove_a_file(inode):
    os.system ("find / -inum %d | xargs rm -f" % (inode))

    PS. Don't blame me if this function destroys your hard disk. I wrote it
    off the top of my head.
    Arne Ludwig, Mar 23, 2006
    #3
  4. On 2006-03-23, Arne Ludwig <> wrote:

    > Good answer. :) I seriously doubt it is possible except for the
    > trivial solution: [...]


    I don't know if there is a Linux equivalent, but under SunOS
    there was a way to delete a file given it's i-node. And that's
    all it did was delete the file itself and mark the i-node as
    free. It didn't remove any directory entries referring to the
    i-node.

    It left your filesystem in a rather broken state, so you had to
    run fsck afterwards.

    --
    Grant Edwards grante Yow! I have a very good
    at DENTAL PLAN. Thank you.
    visi.com
    Grant Edwards, Mar 23, 2006
    #4
  5. Arne Ludwig Guest

    > under SunOS there was a way to delete a file given it's i-node.

    Yes and no. You probably mean "clri" which cleared the inode, but did
    not "remove the file", i.e. all the entries in directories pointing to
    it.

    In older Unices there was also "ncheck" to find the filesystem names
    for inode numbers.

    I cannot find either command in Linux.
    Arne Ludwig, Mar 23, 2006
    #5
  6. Arne Ludwig Guest

    Actually under Linux he could probably pipe "clri %d" to debugfs if
    that is what he wanted to do. On the other hand he said "unix
    environment" which could be anything really.
    Arne Ludwig, Mar 23, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan Stap
    Replies:
    16
    Views:
    533
    E. Robert Tisdale
    Nov 12, 2003
  2. kerb
    Replies:
    4
    Views:
    339
  3. asit

    inode number in windows XP

    asit, Jan 25, 2008, in forum: Python
    Replies:
    2
    Views:
    1,336
    Gabriel Genellina
    Jan 25, 2008
  4. open file by inode?

    , May 28, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    321
  5. Replies:
    4
    Views:
    253
    Nobody
    Jan 31, 2013
Loading...

Share This Page