* [Qemu-devel] Utilities directory
@ 2004-06-26 15:12 Hetz Ben Hamo
2004-06-28 13:19 ` Jean-Michel POURE
0 siblings, 1 reply; 3+ messages in thread
From: Hetz Ben Hamo @ 2004-06-26 15:12 UTC (permalink / raw)
To: qemu-devel
Hi,
I added a directory called "utilities" in my web site:
http://www.dad-answers.com/qemu/
This directory contains utilities to be used with QEMU and/or QEMU Hard
disk images.
The first utility comes from James C Brown, which lets you mount a
partition from a virtual hard disk to a mount point (in Linux as a host).
If you have any QEMU related utility you want to share with people, send
it to me and I'll publish it..
Thanks,
Hetz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Utilities directory
2004-06-26 15:12 [Qemu-devel] Utilities directory Hetz Ben Hamo
@ 2004-06-28 13:19 ` Jean-Michel POURE
2004-06-28 20:24 ` Jim C. Brown
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Michel POURE @ 2004-06-28 13:19 UTC (permalink / raw)
To: qemu-devel
Le samedi 26 Juin 2004 17:12, Hetz Ben Hamo a écrit :
> The first utility comes from James C Brown, which lets you mount a
> partition from a virtual hard disk to a mount point (in Linux as a host).
Dearn James,
I am trying to mount the first partition as explained in lomount -h and my
computer is stuck with 99% activity. Is this normal?
Basically, I did:
lomount -t ext3 -diskimage hda.img -partition 1 /mnt/qemu
where /mnt/qemu is the mount point
as root
Cheers,
Jean-Michel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Utilities directory
2004-06-28 13:19 ` Jean-Michel POURE
@ 2004-06-28 20:24 ` Jim C. Brown
0 siblings, 0 replies; 3+ messages in thread
From: Jim C. Brown @ 2004-06-28 20:24 UTC (permalink / raw)
To: Jean-Michel POURE; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]
On Mon, Jun 28, 2004 at 03:19:52PM +0200, Jean-Michel POURE wrote:
> Le samedi 26 Juin 2004 17:12, Hetz Ben Hamo a ?crit :
> > The first utility comes from James C Brown, which lets you mount a
> > partition from a virtual hard disk to a mount point (in Linux as a host).
>
> Dearn James,
>
> I am trying to mount the first partition as explained in lomount -h and my
> computer is stuck with 99% activity. Is this normal?
>
> Basically, I did:
> lomount -t ext3 -diskimage hda.img -partition 1 /mnt/qemu
>
> where /mnt/qemu is the mount point
> as root
>
> Cheers,
> Jean-Michel
I just checked http://www.dad-answers.com/qemu/utilities/QEMU-HD-Mounter/qemu-hd-mounter.tar.gz
and it is a version that has the infinite looping bug (if it can't find the
partition in the disk image, it keeps searching forever).
Fixed version is attached here. It is not likely to work either, but it will
report an error instead of hanging forever.
To be sure what is going on, I'll need to see the output from this lomount
(be sure to compile with -DDEBUG) and from the command "fdisk -lu hda.img".
Knowing what version of fdisk you have (fdisk -v) is helpful as well.
--
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
[-- Attachment #2: lomount.c --]
[-- Type: text/plain, Size: 2873 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define BUF 4096
#define TEMPFILE "/tmp/temp.minix"
int partnum(char * diskimage, FILE * temp, int * pnum)
{
int num=0, c, i;
char buf[BUF], buf2[BUF];
strncpy(buf, diskimage, BUF);
strncat(buf, "%d", BUF-strlen(buf));
fscanf(temp, buf, pnum); /* skip start of line */
#ifdef DEBUG
printf("pnum = %d\n", *pnum);
#endif
c = fgetc(temp);
while (c == ' ' || c == '*' || c == '@')
{
c = fgetc(temp);
#ifdef DEBUG
printf("c = %d ", c);
#endif
}
/*ungetc(c, temp);
fscanf(temp, "%d", &num);*/
#ifdef DEBUG
printf("c = %d\n", c);
#endif
buf2[0] = c;
c = fgetc(temp);
i = 1;
while (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
{
buf2[i] = c;
c = fgetc(temp);
i++;
}
buf2[i] = '\0';
num = atoi(buf2);
#ifdef DEBUG
printf("buf2 = %s num = %d\n", buf2, num);
#endif
fgets(buf, BUF, temp); /* skip rest of line */
return num;
}
int main(int argc, char ** argv)
{
FILE * temp;
char buf[BUF], argv2[BUF], diskimage[BUF];
int partition = 1, sec1, sec2, num = 0, pnum = 0, len = BUF, i, f = 0;
int pressed_key=0;
for (i = 1; i < argc; i ++)
{
if (strncmp(argv[i], "-diskimage", BUF)==0)
{
strncpy(diskimage, argv[i+1], BUF);
i++; f = 1;
}
else if (strncmp(argv[i], "-partition", BUF)==0)
{
partition = atoi(argv[i+1]);
i++;
if (partition < 1) partition = 1;
}
else
{
strncat(argv2, argv[i], len);
strncat(argv2, " ", len-1);
len -= strlen(argv[i]);
len--;
}
}
if (!f)
{
printf("You must specify -diskimage and -partition\n");
printf("ex. lomount -t fs-type -diskimage hda.img -partition 1 /mnt\n");
return 0;
}
snprintf(buf, BUF, "/sbin/fdisk -lu %s > %s 2>&1", diskimage, TEMPFILE);
system(buf);
temp = fopen(TEMPFILE, "r");
do
{
fgets(buf, BUF, temp); /* skip until we get "Disk" */
#ifdef DEBUG
printf("spare line: %s\n", buf);
#endif
} while (strncasecmp(buf, "Disk", 4)!=0);
//fgets(buf, BUF, temp); //skip once more
fscanf(temp, "Units = sectors of %d * %d\n", &sec1, &sec2);
#ifdef DEBUG
printf("sec1: %d sec2: %d\n", sec1, sec2);
#endif
fgets(buf, BUF, temp); /* skip sixth line */
#ifdef DEBUG
printf("spare line: %s\n", buf);
#endif
while (pnum != partition)
{
num = partnum(diskimage, temp, &pnum);
if (feof(temp))
{
/* This means that we went through the entire file, but we couldn't find the
partition that we were told to mount. If we get here it means something
fishy is going on (or the user had a typo). */
printf("Partition %d was not found in %s.\n", partition, diskimage);
fclose(temp);
return 1;
}
}
fclose(temp);
pnum = sec1 * sec2 * num;
#ifdef DEBUG
printf("offset = %d\n", pnum);
#endif
snprintf(buf, BUF, "mount -oloop,offset=%d %s %s", pnum, diskimage, argv2);
system(buf);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-28 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-26 15:12 [Qemu-devel] Utilities directory Hetz Ben Hamo
2004-06-28 13:19 ` Jean-Michel POURE
2004-06-28 20:24 ` Jim C. Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).