Can a file be deleted even if it is in use. - Unix

This is a discussion on Can a file be deleted even if it is in use. - Unix ; Rainer Weikusat writes: > Ravi writes: > > [...] > >> But just for curiosity still I ask, >> Can we create a file out of inode? > > The answer is still 'no'. Depending on the OS, you can ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 24 of 24

Thread: Can a file be deleted even if it is in use.

  1. Re: Can a file be deleted even if it is in use.

    Rainer Weikusat writes:

    > Ravi writes:
    >
    > [...]
    >
    >> But just for curiosity still I ask,
    >> Can we create a file out of inode?

    >
    > The answer is still 'no'. Depending on the OS, you can still access
    > the contents using 'unrelated programs', eg via opening
    > /proc//fd/ on Linux, but there is no way to create a link to
    > an i-node.


    It may be possible using special debugging tools such as debugfs for
    ext2/3.

    --
    Måns Rullgård
    mans@mansr.com

  2. Re: Can a file be deleted even if it is in use.

    Ravi writes:

    > Suppose somebody deleted the file that is being accessed by the only
    > (hard) link it has, while I am read/write-ing to it. How can I
    > generate the link for the file again??


    In the GNU Hurd, this can be done with the file_getlinknode and
    dir_link RPCs, it seems.

    http://sourceware.org/cgi-bin/cvsweb...&cvsroot=glibc
    http://sourceware.org/cgi-bin/cvsweb...&cvsroot=glibc
    http://sourceware.org/cgi-bin/cvsweb...&cvsroot=glibc
    http://cvs.savannah.gnu.org/viewvc/h...rd&view=markup

    These show that from the viewpoint of the file system, link(2)
    first opens the file without requesting any rwx access bits.
    flink(2) could be implemented by skipping that first step,
    I think.

    There is also a dir_mkfile RPC that creates an anonymous file,
    which can later be named with dir_link:

    http://sourceware.org/cgi-bin/cvsweb...&cvsroot=glibc

  3. Re: Can a file be deleted even if it is in use.

    Måns Rullgård wrote:
    > Rainer Weikusat writes:
    >
    >> Ravi writes:
    >>
    >> [...]
    >>
    >>> But just for curiosity still I ask,
    >>> Can we create a file out of inode?

    >> The answer is still 'no'. Depending on the OS, you can still access
    >> the contents using 'unrelated programs', eg via opening
    >> /proc//fd/ on Linux, but there is no way to create a link to
    >> an i-node.

    >
    > It may be possible using special debugging tools such as debugfs for
    > ext2/3.
    >


    And of course if you control the program and can anticipate the need,
    you could always make an extra link to the file beforehand. This could
    even be somewhat hidden, e.g. by prepending a "." and/or placing it in
    some out-of-the-way directory (as long as it's within the same file
    system). Then just rename that link to the name you prefer whenever you
    feel the need. But again, this requires that you can anticipate the removal

    It also requires that you remove that link whenever it turns out not to
    be needed and this in turn gets into signal handling complexities.

    RM

  4. Re: Can a file be deleted even if it is in use.

    Måns Rullgård writes:
    > Rainer Weikusat writes:
    >> Ravi writes:
    >>
    >> [...]
    >>
    >>> But just for curiosity still I ask,
    >>> Can we create a file out of inode?

    >>
    >> The answer is still 'no'. Depending on the OS, you can still access
    >> the contents using 'unrelated programs', eg via opening
    >> /proc//fd/ on Linux, but there is no way to create a link to
    >> an i-node.

    >
    > It may be possible using special debugging tools such as debugfs for
    > ext2/3.


    It is certainly possible by modifying the file system on the
    corresponding block device suitably, which would presumably include
    changing the kernel such that it can be told to discard all cached
    information regarding this particular FS and reload it from disk.

    The more general answer would 'Sure. Just write a filesystem which
    supports this and use it'. But I somehow believe this would be outside
    the scope of the original question ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2