* entry (used_part is non-NULL) or free space (free_*
* contains data).
*/
- struct part_entry *used_part;
+ struct part_entry used_part;
+ int is_used_part;
int free_sec_start, free_sec_last;
} region_t;
device_t *firstdev= nil, *curdev;
+#define MAX_DEVICES 100
+ static struct {
+ device_t *dev;
+ int nr_partitions, free_regions, used_regions, sectors, nr_regions;
+ region_t regions[NR_REGIONS];
+ } devices[MAX_DEVICES];
+
void newdevice(char *name, int scanning, int disk_only)
/* Add a device to the device list. If scanning is set then we are reading
* /dev, so insert the device in device number order and make /dev/c0d0 current.
int cylinderalign(region_t *reg)
{
- if(reg->used_part) {
- if(reg->used_part->lowsec != table[0].lowsec + sectors
- && (reg->used_part->lowsec % secpcyl)) {
+ if(reg->is_used_part) {
+ if(reg->used_part.lowsec != table[0].lowsec + sectors
+ && (reg->used_part.lowsec % secpcyl)) {
int extra;
- extra = secpcyl - (reg->used_part->lowsec % secpcyl);
- reg->used_part->lowsec += extra;
- reg->used_part->size -= extra;
+ extra = secpcyl - (reg->used_part.lowsec % secpcyl);
+ reg->used_part.lowsec += extra;
+ reg->used_part.size -= extra;
}
- if((reg->used_part->size+1) % secpcyl) {
- reg->used_part->size -= secpcyl - ((reg->used_part->size + 1) % secpcyl);
+ if((reg->used_part.size+1) % secpcyl) {
+ reg->used_part.size -= secpcyl - ((reg->used_part.size + 1) % secpcyl);
}
- return reg->used_part->size > 0;
+ return reg->used_part.size > 0;
}
if(reg->free_sec_start != table[0].lowsec + sectors && (reg->free_sec_start % secpcyl)) {
/* Free region before this partition. */
regions[nr_regions].free_sec_start = free_sec;
regions[nr_regions].free_sec_last = table[i].lowsec-1;
- regions[nr_regions].used_part = NULL;
+ regions[nr_regions].is_used_part = 0;
if(cylinderalign(®ions[nr_regions])) {
nr_regions++;
free_regions++;
}
}
- regions[nr_regions].used_part = &table[i];
+ memcpy(®ions[nr_regions].used_part, &table[i], sizeof(table[i]));
free_sec = table[i].lowsec+table[i].size;
nr_partitions++;
if(free_sec < table[0].size-1) {
regions[nr_regions].free_sec_start = free_sec;
regions[nr_regions].free_sec_last = table[0].lowsec + table[0].size-1;
- regions[nr_regions].used_part = NULL;
+ regions[nr_regions].is_used_part = 0;
if(cylinderalign(®ions[nr_regions])) {
nr_regions++;
free_regions++;
unit = 'G';
}
}
- sprintf(str, "%d%cB%s", kb, unit,
- toosmall ? " - too small for MINIX" : "");
+ sprintf(str, "%d %cB%s", kb, unit,
+ toosmall ? " - too small for MINIX3" : "");
return str;
}
+void
+printregions(region_t *theregions, int indent, int p_nr_partitions, int p_free_regions, int p_nr_regions)
+{
+ int r, nofree = 0;
+ region_t *reg;
+ reg = theregions;
+
+ if((p_nr_partitions >= NR_PARTITIONS || !p_free_regions) && p_free_regions)
+ nofree = 1;
+ for(r = 0; r < p_nr_regions; r++, reg++) {
+ unsigned long units;
+ if(reg->is_used_part) {
+ char *name;
+ name = typ2txt(reg->used_part.sysind);
+ if(!name || strlen(name) < 2)
+ name = "unknown system";
+ printf("%*s\033[31m%2d. in use by %s", indent, "", r, name);
+ units = reg->used_part.size / 2;
+ printf("\033[0m (%s)\n", prettysizeprint(units));
+ } else if(!nofree) {
+ printf("%*s\033[36m%2d. free space", indent, "", r);
+ units = ((reg->free_sec_last - reg->free_sec_start+1))/2;
+ printf("\033[0m (%s)\n", prettysizeprint(units));
+ }
+ }
+
+ return;
+}
+
region_t *
select_region(void)
{
}
do {
- reg = regions;
printf("\nI've found the following region%s on this disk (%s).\n\n",
SORNOT(nr_regions), prettysizeprint(table[0].size/2));
- for(r = 0; r < nr_regions; r++, reg++) {
- unsigned long units;
- if(reg->used_part) {
- char *name;
- name = typ2txt(reg->used_part->sysind);
- if(!name || strlen(name) < 2)
- name = "unknown system";
- printf("\033[31m%2d. in use by %s", r, name);
- units = reg->used_part->size / 2;
- printf("\033[0m (%s)\n", prettysizeprint(units));
- } else if(!nofree) {
- printf("\033[36m%2d. free space", r);
- units = ((reg->free_sec_last - reg->free_sec_start+1))/2;
- printf("\033[0m (%s)\n", prettysizeprint(units));
- }
- }
+ printregions(regions, 0, nr_partitions, free_regions, nr_regions);
if(nofree) {
printf("\nOnly the expert mode can free a slot to use the free space.\n");
continue;
}
- if(nofree && !regions[rn].used_part) {
+ if(nofree && !regions[rn].is_used_part) {
printf("That region number isn't available.\n");
continue;
}
device_t *
select_disk(void)
{
-#define MAX_DEVICES 100
- static struct {
- device_t *dev;
- int free_regions, used_regions, sectors;
- } devices[MAX_DEVICES];
+
int i, choice, drives;
static char line[500];
if(device >= 0) {
devices[i].dev = curdev;
devices[i].free_regions = free_regions;
+ devices[i].nr_regions = nr_regions;
+ devices[i].nr_partitions = nr_partitions;
devices[i].used_regions = used_regions;
devices[i].sectors = table[0].size;
+ memcpy(devices[i].regions, regions, sizeof(regions));
i++;
}
printf(", %d unallocated one%s ",
devices[i].free_regions, SORNOT(devices[i].free_regions));
}
- printf(" (%s)\n", prettysizeprint(devices[i].sectors/2));
+ printf(" (%s)\n\n", prettysizeprint(devices[i].sectors/2));
+ printf("regions :%d %d %d\n",
+ i, devices[i].nr_partitions, devices[i].free_regions);
+ printregions(devices[i].regions, 8,
+ devices[i].nr_partitions,
+ devices[i].free_regions,
+ devices[i].nr_regions);
}
if(drives > 1) {
{
int ex, trunc = 0, changed = 0, i;
struct part_entry *newpart;
- if(reg->used_part && reg->used_part->size > MAX_REGION_SECTORS) {
- reg->used_part->size = MAX_REGION_SECTORS;
+ if(reg->is_used_part && reg->used_part.size > MAX_REGION_SECTORS) {
+ reg->used_part.size = MAX_REGION_SECTORS;
trunc = 1;
changed = 1;
cylinderalign(reg);
}
- if(!reg->used_part) {
+ if(!reg->is_used_part) {
ex = reg->free_sec_last - reg->free_sec_start + 1;
if(ex > MAX_REGION_SECTORS) {
reg->free_sec_last -= ex - MAX_REGION_SECTORS;
if(trunc) {
printf("\nWill only use %dMB.\n", MAX_REGION_MB);
}
- if(!reg->used_part) {
+ if(!reg->is_used_part) {
for(i = 1; i <= NR_PARTITIONS; i++)
if(table[i].sysind == NO_PART)
break;
newpart->lowsec = reg->free_sec_start;
newpart->size = reg->free_sec_last - reg->free_sec_start + 1;
changed = 1;
- } else newpart = reg->used_part;
+ } else newpart = ®->used_part;
newpart->sysind = MINIX_PART;
*pe = newpart;
changed = 1;
/* Write things. */
if(scribble_region(r, &pe)) {
+ char *name;
int i, found = -1;
char partbuf[100];
dirty = 1;
fprintf(stderr, "Internal error (2).\n");
return 1;
}
- sprintf(partbuf, "%sp%d\n", curdev->name, found-1);
+ name=strrchr(curdev->name, '/');
+ if(!name) name = curdev->name;
+ else name++;
+ sprintf(partbuf, "%sp%d\n", name, found-1);
if(resultfd >= 0 && write(resultfd, partbuf, strlen(partbuf)) < strlen(partbuf)) {
fprintf(stderr, "Couldn't write result.\n");
return 1;
echo ""
echo "You can always change your mind after the install."
echo ""
-echo "Choice? "
+echo -n "Choice? "
read eth
driver=""
inetparams=""
*) test $memsize -lt 6144 && swapadv=$(expr 6144 - $memsize)
esac
+blockdefault=8
+echo "\
+The default block size on the disk is $blockdefault KB. However, sizes of 1 to $blockdefault KB
+are also supported. If you have a small disk or small RAM you may want less
+than $blockdefault KB, in which case type a block size from 1 to 8 (1, 2, 4 or $blockdefault are
+suggested values). Otherwise hit ENTER for the default of $blockdefault KB blocks, which
+should be fine in most cases."
+
+while [ -z "$blocksize" ]
+do echo -n "Block size [$blockdefault KB]? "
+ read blocksize
+ if [ -z "$blocksize" ]
+ then blocksize=$blockdefault
+ fi
+ if [ $blocksize -gt $blockdefault -o $blocksize -lt 1 ]
+ then echo "$blocksize bogus block size. 1-$blockdefault please."
+ blocksize=""
+ fi
+done
+
+
echo -n "
How much swap space would you like? Swapspace is only needed if this
system is memory starved, like a 16-bit system with less then 2M, or a
# Forget about swap.
swap=
fi
-
echo "
Migrating to disk...
"
-mkfs /dev/$usr
+mkfs -B $blocksize /dev/$usr
echo "\
Scanning /dev/$usr for bad blocks. (Hit DEL to stop the scan if you are
absolutely sure that there can not be any bad blocks. Otherwise just wait.)"
Copying $fdroot to /dev/$root
"
-mkfs /dev/$root || exit
+mkfs -B $blocksize /dev/$root || exit
mount /dev/$root /mnt || exit
# Running from the installation CD.
cpdir -vx / /mnt || exit
# Make bootable.
installboot -d /dev/$root /usr/mdec/bootblock /boot/boot >/dev/null || exit
-edparams /dev/$root "rootdev=$root; ramimagedev=$root; $cache; $inetparams; save" || exit
+edparams /dev/$root "rootdev=$root; ramimagedev=$root; $cache; $inetparams; main() { delay 2000; boot }; save" || exit
pfile="/usr/src/tools/fdbootparams"
echo "Remembering boot parameters in ${pfile}."
echo "rootdev=$root; ramimagedev=$root; $cache; save" >$pfile || exit
sync
echo "
-Please type 'halt' to exit Minix.
+Please type 'shutdown' to exit Minix.
You can type 'boot $primary' to try the newly installed Minix system. See
\"TESTING\" in the usage manual."