]> Zhao Yanbai Git Server - minix.git/commitdiff
autopart, setupcd updates
authorBen Gras <ben@minix3.org>
Fri, 22 Jul 2005 18:30:40 +0000 (18:30 +0000)
committerBen Gras <ben@minix3.org>
Fri, 22 Jul 2005 18:30:40 +0000 (18:30 +0000)
commands/Makefile
commands/ibm/Makefile
commands/ibm/autopart.c
commands/ibm/postmort.c
commands/scripts/setupcd.sh

index 75c1f3e949adbf8c30e6477ff569260e9e58f525..17dd09291c5bb6c89778085b1c5eaefbcc8d0b9b 100755 (executable)
@@ -41,6 +41,7 @@ all install clean::
        cd ftpd && $(MAKE) $@
        cd ftpd200 && $(MAKE) $@
        cd ibm && $(MAKE) $@
+       cd indent && $(MAKE) $@
        cd kermit && $(MAKE) $@
        cd m4 && $(MAKE) $@
        cd make && $(MAKE) $@
index 6318a44cd7baf8d36bdfda2e0980d500f571069e..8a0f4ebcefb39da4ac6e41bd24dfdc287957fab8 100755 (executable)
@@ -13,6 +13,7 @@ ALL   = \
        loadfont \
        loadkeys \
        mixer \
+       autopart \
        part \
        partition \
        playwave \
index c2774cf1ad1f70aaa8cfb0a6e02dbc229908ae0a..cbdf8e6a176ccc16db804bea43c0e4241cc88ef1 100755 (executable)
@@ -237,7 +237,8 @@ typedef struct region {
         * 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;
 
@@ -251,6 +252,13 @@ int nordonly = 0;
 
 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.
@@ -1680,18 +1688,18 @@ ssize_t boot_readwrite(int rw)
 
 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)) {
@@ -1822,7 +1830,7 @@ void m_read(int ev, object_t *op)
                        /* 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(&regions[nr_regions])) {
                                nr_regions++;
                                free_regions++;
@@ -1838,7 +1846,7 @@ void m_read(int ev, object_t *op)
                        }
                }
 
-               regions[nr_regions].used_part = &table[i];
+               memcpy(&regions[nr_regions].used_part, &table[i], sizeof(table[i]));
                free_sec = table[i].lowsec+table[i].size;
                nr_partitions++;
 
@@ -1850,7 +1858,7 @@ void m_read(int ev, object_t *op)
        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(&regions[nr_regions])) {
                        nr_regions++;
                        free_regions++;
@@ -2192,11 +2200,40 @@ prettysizeprint(int kb)
                        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)
 {
@@ -2223,25 +2260,9 @@ 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");
@@ -2262,7 +2283,7 @@ select_region(void)
                                continue;
                        }
 
-                       if(nofree && !regions[rn].used_part) {
+                       if(nofree && !regions[rn].is_used_part) {
                                printf("That region number isn't available.\n");
                                continue;
                        }
@@ -2285,11 +2306,7 @@ select_region(void)
 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];
 
@@ -2306,8 +2323,11 @@ select_disk(void)
                        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++;
                        }
 
@@ -2338,7 +2358,13 @@ select_disk(void)
                                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) {
@@ -2374,13 +2400,13 @@ scribble_region(region_t *reg, struct part_entry **pe)
 {
        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;
@@ -2392,7 +2418,7 @@ scribble_region(region_t *reg, struct part_entry **pe)
        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;
@@ -2405,7 +2431,7 @@ scribble_region(region_t *reg, struct part_entry **pe)
                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 = &reg->used_part;
        newpart->sysind = MINIX_PART;
        *pe = newpart;
        changed = 1;
@@ -2444,6 +2470,7 @@ do_autopart(int resultfd)
 
        /* Write things. */
        if(scribble_region(r, &pe)) {
+               char *name;
                int i, found = -1;
                char partbuf[100];
                dirty = 1;
@@ -2466,7 +2493,10 @@ do_autopart(int resultfd)
                        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;
index 0859f3d053cfe5b47ed026e0c99f986be01f7989..c054a8b5a7d065aa0198fa2ec4141133234b03a3 100755 (executable)
@@ -238,7 +238,7 @@ struct proc *pt;
   printf("Nonzero if held by busy syscall:     0x%04.4x\n", pt->p_ntf_held);   /* int */
   printf("Next in chain of held-up processes:  0x%04.4x\n", pt->p_ntf_nextheld);       /* struct proc * */
 #endif
-  printf("SENDING, RECEIVING, etc.:            0x%04.4x\n", pt->p_flags);      /* int */
+  printf("SENDING, RECEIVING, etc.:            0x%04.4x\n", pt->p_rts_flags);  /* int */
 #if 0
   printf("Memory map:                          0x%04.4x\n", pt->p_map[NR_LOCAL_SEGS]); /* struct mem_map */
 #endif
index 8f97814fd72ff99680a5603c19cd0f7ed602e100..2f5725b80eff1032d1bc7fd5bcfa0bf80db3875c 100755 (executable)
@@ -193,7 +193,7 @@ echo "3. A different Ethernet card is installed (no networking)"
 echo ""
 echo "You can always change your mind after the install."
 echo ""
-echo "Choice? "
+echo -n "Choice? "
 read eth
 driver=""
 inetparams=""
@@ -224,6 +224,27 @@ i86)
 *)  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
@@ -263,12 +284,11 @@ else
     # 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.)"
@@ -314,7 +334,7 @@ echo "
 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
@@ -357,14 +377,14 @@ if [ $cache -eq 0 ]; then cache=; else cache="ramsize=$cache"; fi
 
                                        # 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."