removing file by inode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • s99999999s2003@yahoo.com

    #1

    removing file by inode

    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.

  • Grant Edwards

    #2
    Re: removing file by inode

    On 2006-03-23, s99999999s2003@ yahoo.com <s99999999s2003 @yahoo.com> wrote:
    [color=blue]
    > is it possible to remove a file by it's inode and not it's filename
    > using Python?[/color]

    What do you mean "remove a file"?

    --
    Grant Edwards grante Yow! Life is a POPULARITY
    at CONTEST! I'm REFRESHINGLY
    visi.com CANDID!!

    Comment

    • Arne Ludwig

      #3
      Re: removing file by inode

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

      def remove_a_file(i node):
      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.

      Comment

      • Grant Edwards

        #4
        Re: removing file by inode

        On 2006-03-23, Arne Ludwig <arne@citde.net > wrote:
        [color=blue]
        > Good answer. :) I seriously doubt it is possible except for the
        > trivial solution: [...][/color]

        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

        Comment

        • Arne Ludwig

          #5
          Re: removing file by inode

          > 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.

          Comment

          • Arne Ludwig

            #6
            Re: removing file by inode

            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.

            Comment

            Working...