Re: Ext-2fs volume support (patch)

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Sun, 1 Jun 1997 10:39:04 +0200 (MET DST)


Andrew E. Mileski wrote:
>
> > WARNING: Please keep in mind that this is a very experimental
> > patch. This patch may crash your information. Be extremely
> > careful. Do not use it for your work machine. Test this code only
> > on a developement machine or in a scratch disk.
>
> Hint: Create a bunch of files (say four 8MB ones) with "dd"", and use
> the loop device to make them look like block devices. Format them,
> and play with them :-) I don't recommend you put them on a fs you
> are afraid to use (just being paranoid).

Hey Andrew, you know what I do?

I do "seekwrite 100000000 > mydisk ; echo y | mke2fs mydisk".
That creates a 100Mb disk. It only takes about 3Mb on disk.

As long as you don't fill the whole thing, you need much less free
disk space than the size you made the loop. In this case you only need
3Mb + whatever data you put on it. Mtools and hfstools correctly
handle this type of "disk".

I think the loopback device gets an "io error" and "ext2fs" then
usually gets into trouble.

Roger.

-----------------------------

#include <stdio.h>
/* #include <fcntl.h> */

#include <unistd.h>
#include <string.h>

char buf[1024];

int main (int argc,char **argv)
{
long long off;
long long tt;

if (strncmp (argv[1],"0x",2) )
sscanf (argv[1],"%Ld",&off);
else
sscanf (argv[1],"%Lx",&off);

if (argc > 3) {
if (strncmp (argv[3],"0x",2) )
sscanf (argv[3],"%Ld",&tt);
else
sscanf (argv[3],"%Lx",&tt);
if (argv[2][0] == '+')
off += tt;
else
off -= tt;
}

if (llseek (1,off-1024,0) < 0)
perror ("seek");
write (1,buf,1024);
exit (0);
}