Re: [OT] Hardlinks and directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 12 February 2010 07:20 PM, Suvayu Ali wrote:
> On Friday 12 February 2010 05:57 PM, Patrick O'Callaghan wrote:
>> On Fri, 2010-02-12 at 16:42 -0800, Suvayu Ali wrote:
>>> On Friday 12 February 2010 04:36 PM, Suvayu Ali wrote:
>>>> On Friday 12 February 2010 04:07 PM, Patrick O'Callaghan wrote:
>>>>> Editors can do funny things with backup files in the interests of
>>>>> preserving your work. An easier test would be:
>>>>>
>>>>> cat> foo&
>>>>> rm foo
>>>>> lsof +L1 -s
>>>>>
>>>>> When I do this the "cat" process shows up (and foo is marked as
>>>>> deleted). You can then reconnect to "cat" (using fg) and write stuff
>>>>> into the "non-existent" file.
>>>
>>> Another observation I forgot to mention, when I used fg and wrote to the
>>> (deleted) file I could also see the size of the file increase. However
>>> using `C-z' and fg again gave me back the orginal empty file _without_
>>> the edits.
>>
>> How do you know it doesn't have the edits if you can't open it?
>
> So after I resume the edit with fg %1, I can't see what I had input the
> last time. Strangely though I see the size is the same (same as after my
> first edit). Here is the transcript from my terminal.
>
>> $ cat > foo &
>> [1] 3843
>>
>> [1]+ Stopped cat > foo
>> $ rm foo
>> $ lsof +L1 -s
>> COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
>> cat 3843 jallad 1w REG 253,2 0 0 15032 /home/jallad/foo (deleted)
>> $ fg %1
>> cat > foo
>> testing deleted files
>> ^Z
>> [1]+ Stopped cat > foo
>> $ lsof +L1 -s
>> COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
>> cat 3843 jallad 1w REG 253,2 22 0 15032 /home/jallad/foo (deleted)
>> $ fg %1
>> cat > foo
>> ^Z
>> [1]+ Stopped cat > foo
>> $ lsof +L1 -s
>> COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
>> cat 3843 jallad 1w REG 253,2 22 0 15032 /home/jallad/foo (deleted)

Although I can't see it there, as per Roberto's suggestion, I tried 
looking at the contents using the /proc filesystem.

> $ fg %1
> cat > foo
> this is the 2nd line
> ^Z
> [1]+  Stopped                 cat > foo
> $ lsof +L1 -s
> COMMAND  PID   USER   FD   TYPE DEVICE SIZE NLINK  NODE NAME
> cat     3843 jallad    1w   REG  253,2   43     0 15032 /home/jallad/foo (deleted)
> $ cat /proc/3843/fd/1
> testing deleted files
> this is the 2nd line

So my edits are not exactly lost its simply not shown when I fg it again 
;) Even the size of the deleted file increases and includes my newer edits!

-- 
Suvayu

Open source is the future. It sets us free.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux