diff options
author | phk <phk@FreeBSD.org> | 1994-11-01 10:10:43 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1994-11-01 10:10:43 +0000 |
commit | 79436024c142d153a12cdf9995b92ea23ad02615 (patch) | |
tree | 3f6ff700acaa2869e5e6ea33e48b639db10f1d2f /sbin/sysinstall/stage1.c | |
parent | 8a9b63d2771180b6ef1c3e66ad93bf3c39a6381e (diff) | |
download | FreeBSD-src-79436024c142d153a12cdf9995b92ea23ad02615.zip FreeBSD-src-79436024c142d153a12cdf9995b92ea23ad02615.tar.gz |
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
Diffstat (limited to 'sbin/sysinstall/stage1.c')
-rw-r--r-- | sbin/sysinstall/stage1.c | 117 |
1 files changed, 89 insertions, 28 deletions
diff --git a/sbin/sysinstall/stage1.c b/sbin/sysinstall/stage1.c index b1f88fb..8c1a3ef 100644 --- a/sbin/sysinstall/stage1.c +++ b/sbin/sysinstall/stage1.c @@ -131,39 +131,48 @@ free_memory() } +char * device_list[] = {"wd","sd",0}; + void query_disks() { - int i; - char disk[15]; - char diskname[5]; - struct stat st; - int fd; - - no_disks = 0; - for (i=0;i<10;i++) { - sprintf(diskname,"wd%d",i); - sprintf(disk,"/dev/r%sd",diskname); - if ((stat(disk, &st) == 0) && (st.st_mode & S_IFCHR)) - if ((fd = open(disk, O_RDWR)) != -1) { - avail_fds[no_disks] = fd; - bcopy(diskname, avail_disknames[no_disks], strlen(diskname)); - if (ioctl(fd, DIOCGDINFO, &avail_disklabels[no_disks++]) == -1) - no_disks--; - } + int i,j; + char disk[15]; + char diskname[5]; + struct stat st; + struct disklabel dl; + int fd; + + for(i=0;i<MAX_NO_DISKS;i++) + if(Dname[i]) { + close(Dfd[i]); Dfd[i] = 0; + free(Dlbl[i]); Dlbl[i] = 0; + free(Dname[i]); Dname[i] = 0; } + Ndisk = 0; + + for (j=0; device_list[j]; j++) { for (i=0;i<10;i++) { - sprintf(diskname,"sd%d",i); - sprintf(disk,"/dev/r%sd",diskname); - if ((stat(disk, &st) == 0) && (st.st_mode & S_IFCHR)) - if ((fd = open(disk, O_RDWR)) != -1) { - avail_fds[no_disks] = fd; - bcopy(diskname, avail_disknames[no_disks], strlen(diskname)); - if (ioctl(fd, DIOCGDINFO, &avail_disklabels[no_disks++]) == -1) - no_disks--; - } + sprintf(diskname,"%s%d",device_list[j],i); + sprintf(disk,"/dev/r%sd",diskname); + if (stat(disk, &st) || !(st.st_mode & S_IFCHR)) + continue; + if ((fd = open(disk, O_RDWR)) == -1) + continue; + if (ioctl(fd, DIOCGDINFO, &dl) == -1) { + close(fd); + continue; + } + Dlbl[Ndisk] = Malloc(sizeof dl); + memcpy(Dlbl[Ndisk], &dl, sizeof dl); + Dname[Ndisk]=StrAlloc(diskname); + Dfd[Ndisk] = fd; + Ndisk++; + if(Ndisk == MAX_NO_DISKS) + return; } + } } int @@ -239,12 +248,61 @@ select_partition(int disk) void stage1() { - int i; + int i,j; int ok = 0; int ready = 0; query_disks(); + while (!ready) { + clear(); standend(); + j = 0; + mvprintw(j++,0,"%s -- Diskspace editor",TITLE); + j++; + mvprintw(j++,0,"Disks Total FreeBSD "); + j++; + for(i=0;i<MAX_NO_DISKS;i++) { + if(!Dname[i]) + continue; + mvprintw(j++,0,"%2d: %-6s %5lu MB %5lu MB", + i, + Dname[i], + PartMb(Dlbl[i],RAWPART), + PartMb(Dlbl[i],OURPART) ); + } + j++; + mvprintw(j++,0,"Filesystems Type Size Mountpoint"); + j++; + for(i=0;i<MAX_NO_FS;i++) { + if(!Fname[i]) + continue; + mvprintw(j++,0,"%2d: %-5s %-5s %5lu MB %-s", + i,Fname[i],Ftype[i],Fsize[i],Fmount[i]); + } + + mvprintw(21,0,"Commands available:"); + mvprintw(22,0,"(F)disk (D)isklabel (Q)uit"); + mvprintw(23,0,"Enter Command> "); + i = getch(); + switch(i) { + case 'q': case 'Q': + return; + case 'f': case 'F': + Fdisk(); + query_disks(); + break; + case 'd': case 'D': + DiskLabel(); + break; + default: + beep(); + } + } + for (i=0; Dname[i]; i++) + close(Dfd[i]); + return; +} +#if 0 while (!ready) { ready = 1; @@ -321,7 +379,9 @@ stage1() dialog_clear(); } } - + if(getenv("STAGE0")) { + Fatal("We stop here"); + } /* Write master boot record and bootblocks */ if (write_mbr(avail_fds[inst_disk], mbr) == -1) Fatal(errmsg); @@ -338,3 +398,4 @@ stage1() Fatal(errmsg); } } +#endif |