Baho Utot wrote:
> On Monday, July 16, 2012 08:09:23 PM Bruce Dubbs wrote:
>> Baho Utot wrote:
>>> One could do this
>>>
>>> echo "test file" > test
>>> ln test link1
>>> ln test link2
>>> ln link1 link3
>>>
>>> ls -i
>>>
>>> 1333952 test 1333952 link1 1333952 link2 1333952 link3
>>>
>>> rm test
>>> ls -i
>>> 1333952 link1 1333952 link2 1333952 link3
>>>
>>> Doesn't link[1..3] point to "no where"  or garbage?
>>
>> No, they point to the data.  The rm command only deletes the data when
>> the link count goes to zero.  That is, rm removes the entry from
>> directory, and decrements the link count.
>>
>> $ echo "test file" > test
>> $ ls -l test
>> -rw-rw-r-- 1 bdubbs bdubbs 10 Jul 16 18:58 test
>> $ ls -i test
>> 1016053 test
>>
>> Note in the fist form the refernece count is 1.
>> $ ln test1 test
>> $ ls -l test*
>> -rw-rw-r-- 2 bdubbs bdubbs 10 Jul 16 18:58 test
>> -rw-rw-r-- 2 bdubbs bdubbs 10 Jul 16 18:58 test1
>> $ ls -1i test*
>> 1016053 test
>> 1016053 test1
>>
>> The link count is 2.
>>
>> $ rm test
>> $ cat test1
>> test file
>>
>> The data is still there.
>>
>> $ ls -l test*
>> -rw-rw-r-- 1 bdubbs bdubbs 10 Jul 16 18:58 test1
>>
>> but now the link count is 1.  This is also the reason you cannot rmdir a
>> directory that is not empty.  Note too that if you have two files with
>> the same inode, the system will copy the data if you edit either one.
>> You then have two different files, each with a count of 1.
>
> That is weird, I would have expected both files to contain the same data.  Not
> for the "system" to go behind your back and create two separate files.
> I guess I have too much C programming (from my old programming days) in my
> line of thought.  I would have been nice to add data to one "file" and readout
> the data with the other (aka) dup file handles under C.

You can do that with a symbolic link.

   -- Bruce

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to