hab folgendes problem... ich wollte eine setup routine fuer ne livecd bauen (einfach blos root partition, swap und fs angeben - mkfs benutzen und alles rueberkopieren). soweit so gut... ist aber nich so einfach wie es sich anhoert (zumindest nicht fuer mich)...
wenn ich das program starte funktioniert es solang bis fork() kommt... dann springt das programm wirr in sich und arbeitet irgendwie immer irgendwelche teile (nicht sequentiell) ab. da der code etwas laenger ist paste ich nur mal einen kleinen teil:
Code: Select all
int build_partitions(part_table)
{
char answer;
pid_t kind;
system("clear");
printf("Your root partition is %s with filesystem %s\n", hdd_info.root, hdd_info.fs);
printf("Your swap partition is %s\n", hdd_info.swap);
printf("\n\tWhen you continue, you will lose _all_ data on these partitions \n");
printf("Hit 'a' if you really want to continue...\n");
fflush(stdin); fflush(stdout);
getchar();
scanf("%c", &answer);
if(answer != 'a'&& answer != 'A')
return 0;
FILE *fp;
fp = fopen("/mnt/edu", "r");
if(!fp)
{
printf("creating /mnt/edu directory... ");
system("mkdir /mnt/edu");
printf("done\n");
}
else
printf("/mnt/edu is available...\n");
fclose(fp);
printf("creating root partition... ");
int status = 0;
switch(kind = fork())
{
case -1: exit(0); break;
case 0: execl("/sbin/mkfs", "mkfs", "-t", hdd_info.fs, hdd_info.root, (char *)0);
printf("done\n"); exit(1);
default: wait(&status); break;
}
printf("creating swap partition... ");
switch(kind = fork())
{
case -1: exit(0); break;
case 0: execl("/sbin/mkswap", "mkswap", hdd_info.swap, (char *)0);
printf("done\n"); exit(1);
default: wait(&status); break;
}
printf("setting up swap partition... ");
switch(kind = fork())
{
case -1: exit(0); break;
case 0: execl("/sbin/swapon", "swapon", hdd_info.swap, (char *)0);
printf("done\n"); exit(1);
default: wait(&status); break;
}
return 1;
}
Code: Select all
Hit 'a' if you really want to continue...
a
/mnt/edu is available...
Detaching after fork from child process 4659.
mke2fs 1.35 (28-Feb-2004)
/dev/hde5 is mounted; will not make a filesystem here!
Detaching after fork from child process 4660.
Setting up swapspace version 1, size = 2023378 kB
Detaching after fork from child process 4661.
swapon: /dev/hde7: Device or resource busy
Detaching after fork from child process 4662.
mount: /dev/hde5 already mounted or /mnt/edu busy
mount: according to mtab, /dev/hde5 is already mounted on /mnt/edu
Detaching after fork from child process 4663.
`./a.out' -> `/mnt/edu/./a.out'
`./psr.c' -> `/mnt/edu/./psr.c'
`./psr.c~' -> `/mnt/edu/./psr.c~'
creating root partition... creating swap partition... setting up swap partition... mounting /dev/hde5 with filesystem ext3 to /mnt/edu... lets copy the cd to hdd... EDU linux is now installed...
thx
blubb