Subject: newfs(8) has too much hard coded information (+fix) Index: etc/newfs.c 2.11BSD The wrong "newfs.c.old" was used to generate the patch in the previous posting (sigh). Here's the correct etc/newfs.c patch. The updates to the manual page and setup documents were correct the first time. Sorry for the mixup. --------------------------------------------------------------------------- *** newfs.c.old Fri Jan 3 17:41:24 1992 --- newfs.c Fri Jan 3 17:38:32 1992 *************** *** 9,15 **** "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)newfs.c 5.3 (2.11BSD) 5/10/91"; #endif /* --- 9,15 ---- "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)newfs.c 6.0 (2.11BSD) 12/28/91"; #endif /* *************** *** 20,109 **** #include #include - typedef struct indx { - char *key; - int value; - } INDX; - - static INDX disks[] = { - { "rm02", 0 }, - { "rm03", 1 }, - { "rm05", 2 }, - { "rp04", 3 }, /* RP04/05/06 all have the same m/n numbers */ - { "rp05", 3 }, - { "rp06", 3 }, - { "rk06", 4 }, /* RK06/07 have the same m/n numbers */ - { "rk07", 4 }, - { "rl01", 5 }, /* RL01/02 have the same m/n numbers */ - { "rl02", 5 }, - { "rk05", 6 }, - { "ra60", 7 }, - { "ra80", 8 }, - { "ra81", 9 }, - { "rc25", 10 }, - { "rx50", 11 }, - { "rd51", 12 }, - { "rd52-rqdx2", 13 }, /* for RD52/53 m/n numbers are based on */ - { "rd53-rqdx2", 13 }, /* controller (RQDX2 or RQDX3), not drive */ - { "rd52-rqdx3", 14 }, /* type */ - { "rd53-rqdx3", 14 }, - { "rd54-rqdx3", 14 }, - { "rx02", 15 }, - { "rp03", 16 }, - { "br1538d", 17 }, - { "ra82", 18 }, - { "rm2x", 19 }, /* Fuji 160 in pseudo RM80 mode */ - { 0, 0 } - }; - - static INDX cpus[] = { - { "23", 0 }, - { "24", 1 }, - { "34", 2 }, - { "40", 2 }, /* use 11/34 values */ - { "44", 3 }, - { "45", 4 }, - { "53", 3 }, /* use 11/44 values */ - { "55", 4 }, /* use 11/45 values */ - { "60", 4 }, /* use 11/45 values */ - { "70", 5 }, - { "73", 3 }, /* use 11/44 values */ - { "83", 3 }, /* use 11/44 values - "m" a little too high, but ok */ - { "84", 5 }, /* use 11/70 values */ - { "93", 5 }, /* use 11/70 values */ - { "94", 5 }, /* use 11/70 values */ - { 0, 0 } - }; - - #define ASIZE(a) (sizeof(a)/sizeof(a[0])) - - static struct mn { - int m, n; - } mn[ASIZE(disks)][ASIZE(cpus)] = { - /* 23 24 34/40 44/53 45/55 70/84 */ - /* 73/83 60 */ - /* RM02 */ { {11, 80}, {10, 80}, { 8, 80}, { 6, 80}, { 7, 80}, { 5, 80} }, - /* RM03 */ { {16, 80}, {15, 80}, {12, 80}, { 8, 80}, {11, 80}, { 7, 80} }, - /* RM05 */ { {16,304}, {15,304}, {12,304}, { 8,304}, {11,304}, { 7,304} }, - /* RP04/05/06 */{ {11,209}, {10,209}, { 8,209}, { 6,209}, { 7,209}, { 5,209} }, - /* RK06/07 */ { { 8, 33}, { 7, 33}, { 6, 33}, { 4, 33}, { 5, 33}, { 3, 33} }, - /* RL01/02 */ { { 7, 10}, { 6, 10}, { 6, 10}, { 4, 10}, { 5, 10}, { 3, 10} }, - /* RK05 */ { { 4, 12}, { 4, 12}, { 3, 12}, { 2, 12}, { 3, 12}, { 2, 12} }, - /* RA60 */ { {21, 84}, {21, 84}, {17, 84}, {12, 84}, {15, 84}, {10, 84} }, - /* RA80 */ { {16,217}, {16,217}, {13,217}, { 9,217}, {11,217}, { 7,217} }, - /* RA81 */ { {26,357}, {26,357}, {21,357}, {14,357}, {18,357}, {12,357} }, - /* RC25 */ { {15, 31}, {15, 31}, {13, 31}, { 9, 31}, {11, 31}, { 7, 31} }, - /* RX50 */ { { 1, 5}, { 1, 5}, { 1, 5}, { 1, 5}, { 1, 5}, { 1, 5} }, - /* RD51 */ { { 1, 36}, { 1, 36}, { 1, 36}, { 1, 36}, { 1, 36}, { 1, 36} }, - /* RQDX2 */ { { 2, 36}, { 2, 36}, { 2, 36}, { 2, 36}, { 2, 36}, { 2, 36} }, - /* RQDX3 */ { { 7, 36}, { 7, 36}, { 7, 36}, { 7, 36}, { 7, 36}, { 7, 36} }, - /* RX02 */ { { 1, 7}, { 1, 7}, { 1, 7}, { 1, 7}, { 1, 7}, { 1, 7} }, - /* RP03 */ { {16,304}, {15,304}, {12,304}, { 7,304}, {11,304}, { 5,304} }, - /* BR1538D */ { {16,304}, {15,304}, {12,304}, { 7,304}, {11,304}, { 6,304} }, - /* RA82 */ { {26,435}, {26,435}, {21,435}, {14,435}, {18,435}, {12,435} }, - /* RM2X */ { {11,160}, {10,160}, { 8,160}, { 6,160}, { 7,160}, { 5,160} }, - }; - main(argc, argv) int argc; char **argv; --- 20,25 ---- *************** *** 112,122 **** extern int optind; register struct disktab *dp; register struct partition *pp; - register INDX *step; register char *cp; struct stat st; long fssize; ! int disk, cpu, ch, status; int just_looking, copy_boot; char *uboot; char device[MAXPATHLEN], cmd[BUFSIZ], --- 28,37 ---- extern int optind; register struct disktab *dp; register struct partition *pp; register char *cp; struct stat st; long fssize; ! int ch, status, logsec, m; int just_looking, copy_boot; char *uboot; char device[MAXPATHLEN], cmd[BUFSIZ], *************** *** 124,131 **** just_looking = 0; copy_boot = 0; uboot = (char *)0; ! while ((ch = getopt(argc,argv,"NvbB:")) != EOF) switch((char)ch) { case 'N': case 'v': --- 39,47 ---- just_looking = 0; copy_boot = 0; + m = 0; uboot = (char *)0; ! while ((ch = getopt(argc,argv,"NvbB:m:")) != EOF) switch((char)ch) { case 'N': case 'v': *************** *** 137,142 **** --- 53,61 ---- case 'b': ++copy_boot; break; + case 'm': + m = atoi(optarg); + break; case '?': default: usage(); *************** *** 144,172 **** argc -= optind; argv += optind; ! if (argc != 3) usage(); - /* check for legal disk and cpu type, get offsets into M/N array */ - for (step = disks; step->key; ++step) - if (!strcmp(argv[1], step->key)) { - disk = step->value; - break; - } - if (!step->key) { - fprintf(stderr, "newfs: unknown disk type %s.\n", argv[1]); - usage(); - } - for (step = cpus; step->key; ++step) - if (!strcmp(argv[2], step->key)) { - cpu = step->value; - break; - } - if (!step->key) { - fprintf(stderr, "newfs: unknown cpu type %s.\n", argv[2]); - usage(); - } - /* figure out device name */ cp = rindex(argv[0], '/'); if (cp) --- 63,71 ---- argc -= optind; argv += optind; ! if (argc != 2) usage(); /* figure out device name */ cp = rindex(argv[0], '/'); if (cp) *************** *** 213,223 **** * Convert from sectors to logical blocks. Note that sector size * must evenly devide DEV_BSIZE!!!!! */ ! fssize /= DEV_BSIZE/dp->d_secsize; /* build command */ ! sprintf(cmd, "/etc/mkfs %s %ld %d %d", ! device, fssize, mn[disk][cpu].m, mn[disk][cpu].n); printf("newfs: %s\n", cmd); if (just_looking) exit(0); --- 112,125 ---- * Convert from sectors to logical blocks. Note that sector size * must evenly devide DEV_BSIZE!!!!! */ ! logsec = DEV_BSIZE/dp->d_secsize; ! fssize /= logsec; /* build command */ ! if (m <= 0 || m > 31) ! m = 2; ! sprintf(cmd, "/etc/mkfs %s %ld %d %d", device, fssize, m, ! (dp->d_ntracks * dp->d_nsectors) / logsec); printf("newfs: %s\n", cmd); if (just_looking) exit(0); *************** *** 242,277 **** static usage() { - register INDX *off; - register int cnt, len; ! fputs("usage: newfs [ -N ] [ -b ] [ -B boot-block ] special-device device-type cpu\n", stderr); ! fputs("Known device-types are:\n\t", stderr); ! for (cnt = 8, off = disks;;) { ! len = strlen(off->key) + 2; ! if ((cnt += len) > 50) { ! fputs("\n\t", stderr); ! cnt = len + 8; ! } ! fputs(off->key, stderr); ! if ((++off)->key) ! fputs(", ", stderr); ! else ! break; ! } ! fputs("\n\nKnown cpu types are:\n\t", stderr); ! for (cnt = 8, off = cpus;;) { ! len = strlen(off->key) + 2; ! if ((cnt += len) > 50) { ! fputs("\n\t", stderr); ! cnt = len + 8; ! } ! fputs(off->key, stderr); ! if ((++off)->key) ! fputs(", ", stderr); ! else ! break; ! } ! putc('\n', stderr); exit(1); } --- 144,150 ---- static usage() { ! fputs("usage: newfs [ -N ] [ -b ] [ -B boot-block ] [-m free-list-gap] special-device device-type\n", stderr); exit(1); }