Re: a conceptual confusion -- loop device

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

 



On Fri, Mar 5, 2010 at 6:37 AM, nidhi mittal hada
<nidhimittal19@xxxxxxxxx> wrote:
>
> hi all
> I created a loop device
> /dev/loop0 ------------>with the image file ---------->file.img
> then
> mkfs and
> mount /dev/loop0 to /mnt
>
> cd /mnt
> created files a.c , b.c
> rm file.img  ------- removed file.img
>
> cd /mnt
> still i am able to see a.c b.c here
> How are these files present here ?
> they should have been deleted as underlying storage file is no where present
> !!

Nidhi,

For this think of rm as what it really is "unlink".

When you unlink a file all that happens is the directory entry for
that link is tagged as deleted / reusable, and the link count field in
the inode is decremented by one.

After the decrement there is code to do:

if (inode.link_count == 0 and inode.is_open == 0) then delete inode
and associated data blocks.

When your loop mount is unmounted it should close the fd associated
with the image file and invoke the above logic again which I assume at
that point will cause the inode and data blocks to be freed up.

Greg

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux