1995-05-04 23:36:23 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-05-04 23:36:23 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1997-01-03 06:32:39 +00:00
|
|
|
#include "sysinstall.h"
|
1995-05-04 23:36:23 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <err.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
scan_block(int fd, daddr_t block)
|
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
u_char foo[512];
|
1995-05-04 23:36:23 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
if (-1 == lseek(fd,block * 512,SEEK_SET))
|
|
|
|
err(1,"lseek");
|
|
|
|
if (512 != read(fd,foo, 512))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-05-20 10:33:14 +00:00
|
|
|
Scan_Disk(Disk *d)
|
1995-05-04 23:36:23 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
char device[64];
|
|
|
|
u_long l;
|
|
|
|
int i,j,fd;
|
1995-05-30 08:29:07 +00:00
|
|
|
|
2000-05-31 00:57:48 +00:00
|
|
|
strcpy(device,"/dev/");
|
1995-05-16 02:53:31 +00:00
|
|
|
strcat(device,d->name);
|
1995-05-30 08:29:07 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
fd = open(device,O_RDWR);
|
|
|
|
if (fd < 0) {
|
|
|
|
msgWarn("open(%s) failed", device);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(i=-1,l=0;;l++) {
|
|
|
|
j = scan_block(fd,l);
|
|
|
|
if (j != i) {
|
|
|
|
if (i == -1) {
|
|
|
|
printf("%c: %lu.",j ? 'B' : 'G', l);
|
|
|
|
fflush(stdout);
|
|
|
|
} else if (i == 0) {
|
|
|
|
printf(".%lu\nB: %lu.",l-1,l);
|
|
|
|
fflush(stdout);
|
|
|
|
} else {
|
|
|
|
printf(".%lu\nG: %lu.",l-1,l);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
1995-05-30 08:29:07 +00:00
|
|
|
i = j;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1995-05-30 08:29:07 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
close(fd);
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-05-20 10:33:14 +00:00
|
|
|
slice_wizard(Disk *d)
|
1995-05-04 23:36:23 +00:00
|
|
|
{
|
1995-05-20 10:33:14 +00:00
|
|
|
Disk *db;
|
1995-05-16 02:53:31 +00:00
|
|
|
char myprompt[BUFSIZ];
|
|
|
|
char input[BUFSIZ];
|
|
|
|
char *p,*q=0;
|
|
|
|
char **cp,*cmds[200];
|
|
|
|
int ncmd,i;
|
1995-05-30 08:29:07 +00:00
|
|
|
|
2001-03-23 08:26:43 +00:00
|
|
|
systemSuspendDialog();
|
1995-05-16 02:53:31 +00:00
|
|
|
sprintf(myprompt,"%s> ", d->name);
|
|
|
|
while(1) {
|
|
|
|
printf("--==##==--\n");
|
|
|
|
Debug_Disk(d);
|
|
|
|
p = CheckRules(d);
|
|
|
|
if (p) {
|
|
|
|
printf("%s",p);
|
|
|
|
free(p);
|
|
|
|
}
|
2001-07-05 09:51:09 +00:00
|
|
|
printf("%s", myprompt);
|
1995-05-16 02:53:31 +00:00
|
|
|
fflush(stdout);
|
|
|
|
q = p = fgets(input,sizeof(input),stdin);
|
|
|
|
if(!p)
|
|
|
|
break;
|
|
|
|
for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
|
|
|
|
if (**cp != '\0')
|
|
|
|
cp++;
|
|
|
|
ncmd = cp - cmds;
|
|
|
|
if(!ncmd)
|
|
|
|
continue;
|
|
|
|
if (!strcasecmp(*cmds,"quit")) { break; }
|
|
|
|
if (!strcasecmp(*cmds,"exit")) { break; }
|
|
|
|
if (!strcasecmp(*cmds,"q")) { break; }
|
|
|
|
if (!strcasecmp(*cmds,"x")) { break; }
|
|
|
|
if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
|
|
|
|
printf("delete = %d\n",
|
|
|
|
Delete_Chunk(d,
|
|
|
|
(struct chunk *)strtol(cmds[1],0,0)));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcasecmp(*cmds,"allfreebsd")) {
|
1995-12-07 10:34:59 +00:00
|
|
|
All_FreeBSD(d, 0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcasecmp(*cmds,"dedicate")) {
|
|
|
|
All_FreeBSD(d, 1);
|
1995-05-16 02:53:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
1995-05-30 08:29:07 +00:00
|
|
|
if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
|
1995-05-16 02:53:31 +00:00
|
|
|
Set_Bios_Geom(d,
|
|
|
|
strtol(cmds[1],0,0),
|
|
|
|
strtol(cmds[2],0,0),
|
|
|
|
strtol(cmds[3],0,0));
|
|
|
|
continue;
|
|
|
|
}
|
1995-05-30 08:29:07 +00:00
|
|
|
if (!strcasecmp(*cmds,"list")) {
|
1995-05-16 02:53:31 +00:00
|
|
|
cp = Disk_Names();
|
|
|
|
printf("Disks:");
|
|
|
|
for(i=0;cp[i];i++) {
|
|
|
|
printf(" %s",cp[i]);
|
|
|
|
free(cp[i]);
|
1995-05-30 08:29:07 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
free(cp);
|
|
|
|
continue;
|
|
|
|
}
|
2000-06-05 13:17:23 +00:00
|
|
|
#ifdef PC98
|
|
|
|
if (!strcasecmp(*cmds,"create") && ncmd == 7) {
|
|
|
|
printf("Create=%d\n",
|
|
|
|
Create_Chunk(d,
|
|
|
|
strtol(cmds[1],0,0),
|
|
|
|
strtol(cmds[2],0,0),
|
|
|
|
strtol(cmds[3],0,0),
|
|
|
|
strtol(cmds[4],0,0),
|
|
|
|
strtol(cmds[5],0,0),
|
|
|
|
cmds[6]));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#else
|
1995-05-30 08:29:07 +00:00
|
|
|
if (!strcasecmp(*cmds,"create") && ncmd == 6) {
|
1995-05-16 02:53:31 +00:00
|
|
|
printf("Create=%d\n",
|
|
|
|
Create_Chunk(d,
|
1995-05-04 23:36:23 +00:00
|
|
|
strtol(cmds[1],0,0),
|
|
|
|
strtol(cmds[2],0,0),
|
1995-05-16 02:53:31 +00:00
|
|
|
strtol(cmds[3],0,0),
|
|
|
|
strtol(cmds[4],0,0),
|
|
|
|
strtol(cmds[5],0,0)));
|
|
|
|
continue;
|
|
|
|
}
|
2000-06-05 13:17:23 +00:00
|
|
|
#endif
|
1995-05-16 02:53:31 +00:00
|
|
|
if (!strcasecmp(*cmds,"read")) {
|
|
|
|
db = d;
|
|
|
|
if (ncmd > 1)
|
|
|
|
d = Open_Disk(cmds[1]);
|
|
|
|
else
|
|
|
|
d = Open_Disk(d->name);
|
|
|
|
if (d)
|
|
|
|
Free_Disk(db);
|
|
|
|
else
|
|
|
|
d = db;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcasecmp(*cmds,"scan")) {
|
|
|
|
Scan_Disk(d);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcasecmp(*cmds,"write")) {
|
|
|
|
printf("Write=%d\n",
|
1996-04-28 20:54:11 +00:00
|
|
|
Fake ? 0 : Write_Disk(d));
|
1995-05-16 02:53:31 +00:00
|
|
|
Free_Disk(d);
|
|
|
|
d = Open_Disk(d->name);
|
|
|
|
continue;
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
if (strcasecmp(*cmds,"help"))
|
|
|
|
printf("\007ERROR\n");
|
|
|
|
printf("CMDS:\n");
|
|
|
|
printf("allfreebsd\t\t");
|
1995-12-07 10:34:59 +00:00
|
|
|
printf("dedicate\t\t");
|
1995-05-16 02:53:31 +00:00
|
|
|
printf("bios cyl hd sect\n");
|
|
|
|
printf("collapse [pointer]\t\t");
|
2000-06-05 13:17:23 +00:00
|
|
|
#ifdef PC98
|
|
|
|
printf("create offset size enum subtype flags name\n");
|
|
|
|
#else
|
1995-05-16 02:53:31 +00:00
|
|
|
printf("create offset size enum subtype flags\n");
|
2000-06-05 13:17:23 +00:00
|
|
|
#endif
|
1995-05-16 02:53:31 +00:00
|
|
|
printf("subtype(part): swap=1, ffs=7\t\t");
|
|
|
|
printf("delete pointer\n");
|
|
|
|
printf("list\t\t");
|
|
|
|
printf("quit\n");
|
|
|
|
printf("read [disk]\t\t");
|
|
|
|
printf("scan\n");
|
|
|
|
printf("write\t\t");
|
|
|
|
printf("ENUM:\n\t");
|
|
|
|
for(i=0;chunk_n[i];i++)
|
|
|
|
printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
|
|
|
|
printf("\n");
|
1995-05-30 08:29:07 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
2001-03-23 08:26:43 +00:00
|
|
|
systemResumeDialog();
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|