* loopback on block device
@ 2004-10-27 18:20 Lei Yang
2004-10-27 18:29 ` Lei Yang
2004-10-27 18:58 ` linux-os
0 siblings, 2 replies; 6+ messages in thread
From: Lei Yang @ 2004-10-27 18:20 UTC (permalink / raw)
To: linux-kernel
Hello,
Here is a question for loopback device. As far as I understand, the
loopback device is used to mount files as if they were block devices.
Then Why I could do "losetup -e XOR /dev/loop0 /dev/ram0" ? Notice that
ram0 is not mounted anywhere and does not have a filesystem on it. I've
tried that command and there seems to be no error. I got confused and
looked into loop.c, it seems to me that a loopback device should be
associated with a "backing file", why would it work on a block device
anyway?
I'd appreciate your comments greatly!
TIA,
Lei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: loopback on block device
2004-10-27 18:20 loopback on block device Lei Yang
@ 2004-10-27 18:29 ` Lei Yang
2004-10-28 0:31 ` Al Viro
2004-10-27 18:58 ` linux-os
1 sibling, 1 reply; 6+ messages in thread
From: Lei Yang @ 2004-10-27 18:29 UTC (permalink / raw)
To: linux-kernel; +Cc: Lei Yang
Please cc me if you have answers to this, I am not on the list. Thanks a
lot!
Lei Yang wrote:
> Hello,
>
> Here is a question for loopback device. As far as I understand, the
> loopback device is used to mount files as if they were block devices.
>
> Then Why I could do "losetup -e XOR /dev/loop0 /dev/ram0" ? Notice
> that ram0 is not mounted anywhere and does not have a filesystem on
> it. I've tried that command and there seems to be no error. I got
> confused and looked into loop.c, it seems to me that a loopback device
> should be associated with a "backing file", why would it work on a
> block device anyway?
>
> I'd appreciate your comments greatly!
>
> TIA,
> Lei
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: loopback on block device
2004-10-27 18:20 loopback on block device Lei Yang
2004-10-27 18:29 ` Lei Yang
@ 2004-10-27 18:58 ` linux-os
2004-10-27 19:42 ` Lei Yang
1 sibling, 1 reply; 6+ messages in thread
From: linux-os @ 2004-10-27 18:58 UTC (permalink / raw)
To: Lei Yang; +Cc: linux-kernel
On Wed, 27 Oct 2004, Lei Yang wrote:
> Hello,
>
> Here is a question for loopback device. As far as I understand, the loopback
> device is used to mount files as if they were block devices.
>
> Then Why I could do "losetup -e XOR /dev/loop0 /dev/ram0" ? Notice that ram0
> is not mounted anywhere and does not have a filesystem on it. I've tried that
> command and there seems to be no error. I got confused and looked into
> loop.c, it seems to me that a loopback device should be associated with a
> "backing file", why would it work on a block device anyway?
>
> I'd appreciate your comments greatly!
>
> TIA,
> Lei
>
`man losetup`
You just set up the loop device to enable encryption on
/dev/ram0. /dev/ram0 is a "file". It's a special-file,
but a file nevertheless. It can contain a file-system,
therefore act as a RAM disk, but it doesn't have to.
In principle, you could make an encrypted file-system
in which you couldn't even know what kind of file-
system it was, without an encryption key.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached and reviewed by John Ashcroft.
98.36% of all statistics are fiction.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: loopback on block device
2004-10-27 18:58 ` linux-os
@ 2004-10-27 19:42 ` Lei Yang
2004-10-28 9:48 ` Helge Hafting
0 siblings, 1 reply; 6+ messages in thread
From: Lei Yang @ 2004-10-27 19:42 UTC (permalink / raw)
To: linux-os; +Cc: linux-kernel
Why /dev/ram0 is a file? Can you get into more details? For example, if
I want to do some system level programming and write to a /dev/ram0, how
do I do it?
Thanks very much for your reply!
Lei
linux-os wrote:
> On Wed, 27 Oct 2004, Lei Yang wrote:
>
>> Hello,
>>
>> Here is a question for loopback device. As far as I understand, the
>> loopback device is used to mount files as if they were block devices.
>>
>> Then Why I could do "losetup -e XOR /dev/loop0 /dev/ram0" ? Notice
>> that ram0 is not mounted anywhere and does not have a filesystem on
>> it. I've tried that command and there seems to be no error. I got
>> confused and looked into loop.c, it seems to me that a loopback
>> device should be associated with a "backing file", why would it work
>> on a block device anyway?
>>
>> I'd appreciate your comments greatly!
>>
>> TIA,
>> Lei
>>
>
> `man losetup`
> You just set up the loop device to enable encryption on
> /dev/ram0. /dev/ram0 is a "file". It's a special-file,
> but a file nevertheless. It can contain a file-system,
> therefore act as a RAM disk, but it doesn't have to.
>
> In principle, you could make an encrypted file-system
> in which you couldn't even know what kind of file-
> system it was, without an encryption key.
>
>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
> Notice : All mail here is now cached and reviewed by John Ashcroft.
> 98.36% of all statistics are fiction.
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: loopback on block device
2004-10-27 18:29 ` Lei Yang
@ 2004-10-28 0:31 ` Al Viro
0 siblings, 0 replies; 6+ messages in thread
From: Al Viro @ 2004-10-28 0:31 UTC (permalink / raw)
To: Lei Yang; +Cc: linux-kernel
On Wed, Oct 27, 2004 at 01:29:54PM -0500, Lei Yang wrote:
> >Here is a question for loopback device. As far as I understand, the
> >loopback device is used to mount files as if they were block devices.
> >
> >Then Why I could do "losetup -e XOR /dev/loop0 /dev/ram0" ? Notice
> >that ram0 is not mounted anywhere and does not have a filesystem on
> >it. I've tried that command and there seems to be no error. I got
> >confused and looked into loop.c, it seems to me that a loopback device
> >should be associated with a "backing file", why would it work on a
> >block device anyway?
Because block device is a file.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: loopback on block device
2004-10-27 19:42 ` Lei Yang
@ 2004-10-28 9:48 ` Helge Hafting
0 siblings, 0 replies; 6+ messages in thread
From: Helge Hafting @ 2004-10-28 9:48 UTC (permalink / raw)
To: Lei Yang; +Cc: linux-os, linux-kernel
On Wed, Oct 27, 2004 at 02:42:48PM -0500, Lei Yang wrote:
> Why /dev/ram0 is a file? Can you get into more details? For example, if
> I want to do some system level programming and write to a /dev/ram0, how
> do I do it?
>
I don't think you need an example. You can open it in exactly
the same way as you open regular files like /etc/resolv.conf.
ie.
FILE *f = fopen("/dev/ram0", "rw");
Then use fseek, fwrite and fread as usual.
Helge Hafting
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-10-28 9:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-27 18:20 loopback on block device Lei Yang
2004-10-27 18:29 ` Lei Yang
2004-10-28 0:31 ` Al Viro
2004-10-27 18:58 ` linux-os
2004-10-27 19:42 ` Lei Yang
2004-10-28 9:48 ` Helge Hafting
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox