Fix support for non-512-byte/sector disks again after I broke it when introducing the abstract partition backends.diff -r1.37 -r1.38 src/usr.sbin/sysinst/bsddisklabel.c
(martin)
--- src/usr.sbin/sysinst/bsddisklabel.c 2020/01/24 07:31:15 1.37
+++ src/usr.sbin/sysinst/bsddisklabel.c 2020/01/27 21:21:21 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bsddisklabel.c,v 1.37 2020/01/24 07:31:15 martin Exp $ */ | 1 | /* $NetBSD: bsddisklabel.c,v 1.38 2020/01/27 21:21:21 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -612,27 +612,27 @@ set_ptn_size(menudesc *m, void *arg) | @@ -612,27 +612,27 @@ set_ptn_size(menudesc *m, void *arg) | |||
612 | 612 | |||
613 | if (is_ram_size) { | 613 | if (is_ram_size) { | |
614 | new_size_val = parse_ram_size(answer, &is_percent); | 614 | new_size_val = parse_ram_size(answer, &is_percent); | |
615 | if (is_percent && | 615 | if (is_percent && | |
616 | (new_size_val < 0 || new_size_val > 100)) | 616 | (new_size_val < 0 || new_size_val > 100)) | |
617 | continue; | 617 | continue; | |
618 | if (!is_percent && new_size_val < 0) | 618 | if (!is_percent && new_size_val < 0) | |
619 | continue; | 619 | continue; | |
620 | size = new_size_val; | 620 | size = new_size_val; | |
621 | extend = false; | 621 | extend = false; | |
622 | break; | 622 | break; | |
623 | } | 623 | } | |
624 | mult = sizemult; | 624 | mult = sizemult; | |
625 | new_size_val = parse_disk_pos(answer, &mult, | 625 | new_size_val = parse_disk_pos(answer, &mult, pm->sectorsize, | |
626 | pm->dlcylsize, &extend); | 626 | pm->dlcylsize, &extend); | |
627 | 627 | |||
628 | if (strcmp(answer, dflt) == 0) | 628 | if (strcmp(answer, dflt) == 0) | |
629 | non_zero = p->def_size > 0; | 629 | non_zero = p->def_size > 0; | |
630 | else | 630 | else | |
631 | non_zero = new_size_val > 0; | 631 | non_zero = new_size_val > 0; | |
632 | 632 | |||
633 | /* Some special cases when /usr is first given a size */ | 633 | /* Some special cases when /usr is first given a size */ | |
634 | if (old_size == 0 && non_zero && | 634 | if (old_size == 0 && non_zero && | |
635 | strcmp(p->mount, "/usr") == 0) { | 635 | strcmp(p->mount, "/usr") == 0) { | |
636 | for (i = 0; i < pset->num; i++) { | 636 | for (i = 0; i < pset->num; i++) { | |
637 | if (strcmp(pset->infos[i].mount, "/") == 0) { | 637 | if (strcmp(pset->infos[i].mount, "/") == 0) { | |
638 | root = i; | 638 | root = i; | |
@@ -1624,27 +1624,27 @@ make_bsd_partitions(struct install_parti | @@ -1624,27 +1624,27 @@ make_bsd_partitions(struct install_parti | |||
1624 | const struct disk_partitioning_scheme *pscheme; | 1624 | const struct disk_partitioning_scheme *pscheme; | |
1625 | struct partition_usage_set wanted; | 1625 | struct partition_usage_set wanted; | |
1626 | enum layout_type layoutkind = LY_SETSIZES; | 1626 | enum layout_type layoutkind = LY_SETSIZES; | |
1627 | bool have_existing; | 1627 | bool have_existing; | |
1628 | 1628 | |||
1629 | if (pm && pm->no_part && parts == NULL) | 1629 | if (pm && pm->no_part && parts == NULL) | |
1630 | return true; | 1630 | return true; | |
1631 | 1631 | |||
1632 | if (parts == NULL) { | 1632 | if (parts == NULL) { | |
1633 | pscheme = select_part_scheme(pm, NULL, !pm->no_mbr, NULL); | 1633 | pscheme = select_part_scheme(pm, NULL, !pm->no_mbr, NULL); | |
1634 | if (pscheme == NULL) | 1634 | if (pscheme == NULL) | |
1635 | return false; | 1635 | return false; | |
1636 | parts = pscheme->create_new_for_disk(pm->diskdev, | 1636 | parts = pscheme->create_new_for_disk(pm->diskdev, | |
1637 | 0, pm->dlsize, pm->dlsize, true, NULL); | 1637 | 0, pm->dlsize, true, NULL); | |
1638 | if (parts == NULL) | 1638 | if (parts == NULL) | |
1639 | return false; | 1639 | return false; | |
1640 | pm->parts = parts; | 1640 | pm->parts = parts; | |
1641 | } else { | 1641 | } else { | |
1642 | pscheme = parts->pscheme; | 1642 | pscheme = parts->pscheme; | |
1643 | } | 1643 | } | |
1644 | 1644 | |||
1645 | if (pscheme->secondary_partitions) { | 1645 | if (pscheme->secondary_partitions) { | |
1646 | struct disk_partitions *p; | 1646 | struct disk_partitions *p; | |
1647 | 1647 | |||
1648 | p = pscheme->secondary_partitions(parts, pm->ptstart, false); | 1648 | p = pscheme->secondary_partitions(parts, pm->ptstart, false); | |
1649 | if (p) { | 1649 | if (p) { | |
1650 | parts = p; | 1650 | parts = p; |
--- src/usr.sbin/sysinst/defs.h 2020/01/24 07:31:15 1.53
+++ src/usr.sbin/sysinst/defs.h 2020/01/27 21:21:22 1.54
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: defs.h,v 1.53 2020/01/24 07:31:15 martin Exp $ */ | 1 | /* $NetBSD: defs.h,v 1.54 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -358,27 +358,27 @@ struct install_partition_desc { | @@ -358,27 +358,27 @@ struct install_partition_desc { | |||
358 | bool cur_system; /* target is the life system */ | 358 | bool cur_system; /* target is the life system */ | |
359 | }; | 359 | }; | |
360 | 360 | |||
361 | /* variables */ | 361 | /* variables */ | |
362 | 362 | |||
363 | int debug; /* set by -D option */ | 363 | int debug; /* set by -D option */ | |
364 | 364 | |||
365 | char rel[SSTRSIZE]; | 365 | char rel[SSTRSIZE]; | |
366 | char machine[SSTRSIZE]; | 366 | char machine[SSTRSIZE]; | |
367 | 367 | |||
368 | int ignorerror; | 368 | int ignorerror; | |
369 | int ttysig_ignore; | 369 | int ttysig_ignore; | |
370 | pid_t ttysig_forward; | 370 | pid_t ttysig_forward; | |
371 | int sizemult; | 371 | uint sizemult; | |
372 | extern const char *multname; | 372 | extern const char *multname; | |
373 | extern const char *err_outofmem; | 373 | extern const char *err_outofmem; | |
374 | int partman_go; /* run extended partition manager */ | 374 | int partman_go; /* run extended partition manager */ | |
375 | 375 | |||
376 | /* logging variables */ | 376 | /* logging variables */ | |
377 | 377 | |||
378 | FILE *logfp; | 378 | FILE *logfp; | |
379 | FILE *script; | 379 | FILE *script; | |
380 | 380 | |||
381 | #define MAX_DISKS 15 | 381 | #define MAX_DISKS 15 | |
382 | 382 | |||
383 | daddr_t root_limit; /* BIOS (etc) read limit */ | 383 | daddr_t root_limit; /* BIOS (etc) read limit */ | |
384 | 384 | |||
@@ -411,32 +411,36 @@ struct pm_devs { | @@ -411,32 +411,36 @@ struct pm_devs { | |||
411 | 411 | |||
412 | /* | 412 | /* | |
413 | * This device can not be partitioned (in any way). | 413 | * This device can not be partitioned (in any way). | |
414 | * Used for wedges (dk*) or LVM devices. | 414 | * Used for wedges (dk*) or LVM devices. | |
415 | */ | 415 | */ | |
416 | bool no_part; | 416 | bool no_part; | |
417 | 417 | |||
418 | /* | 418 | /* | |
419 | * This is a pseudo-device representing the currently running | 419 | * This is a pseudo-device representing the currently running | |
420 | * system (i.e. all mounted file systems). | 420 | * system (i.e. all mounted file systems). | |
421 | */ | 421 | */ | |
422 | bool cur_system; | 422 | bool cur_system; | |
423 | 423 | |||
424 | /* Actual values for current disk - set by find_disks() or | 424 | /* Actual values for current disk geometry - set by find_disks() or | |
425 | md_get_info() */ | 425 | * md_get_info() | |
426 | int sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize; | 426 | */ | |
427 | daddr_t dlsize; | 427 | uint sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize; | |
428 | /* | |||
429 | * Total size of the disk - in 'sectorsize' units (!) | |||
430 | */ | |||
431 | daddr_t dlsize; /* total number of disk sectors */ | |||
428 | 432 | |||
429 | /* Area of disk we can allocate, start and size in disk sectors. */ | 433 | /* Area of disk we can allocate, start and size in sectors. */ | |
430 | daddr_t ptstart, ptsize; | 434 | daddr_t ptstart, ptsize; | |
431 | 435 | |||
432 | /* For some bootblocks we need to know the CHS addressable limit */ | 436 | /* For some bootblocks we need to know the CHS addressable limit */ | |
433 | daddr_t max_chs; /* bcyl * bhead * bsec */ | 437 | daddr_t max_chs; /* bcyl * bhead * bsec */ | |
434 | 438 | |||
435 | /* If we have an MBR boot partition, start and size in sectors */ | 439 | /* If we have an MBR boot partition, start and size in sectors */ | |
436 | daddr_t bootstart, bootsize; | 440 | daddr_t bootstart, bootsize; | |
437 | 441 | |||
438 | /* | 442 | /* | |
439 | * In extended partitioning: all partitions in parts (number of | 443 | * In extended partitioning: all partitions in parts (number of | |
440 | * entries is parts->num_part) may actually be mounted (temporarily) | 444 | * entries is parts->num_part) may actually be mounted (temporarily) | |
441 | * somewhere, e.g. to access a vnd device on them. This list has | 445 | * somewhere, e.g. to access a vnd device on them. This list has | |
442 | * a pointer to the current mount point (strdup()'d) if mounted, | 446 | * a pointer to the current mount point (strdup()'d) if mounted, | |
@@ -803,28 +807,28 @@ void make_ramdisk_dir(const char *); | @@ -803,28 +807,28 @@ void make_ramdisk_dir(const char *); | |||
803 | void set_kernel_set(unsigned int); | 807 | void set_kernel_set(unsigned int); | |
804 | void set_noextract_set(unsigned int); | 808 | void set_noextract_set(unsigned int); | |
805 | unsigned int get_kernel_set(void); | 809 | unsigned int get_kernel_set(void); | |
806 | unsigned int set_X11_selected(void); | 810 | unsigned int set_X11_selected(void); | |
807 | int get_and_unpack_sets(int, msg, msg, msg); | 811 | int get_and_unpack_sets(int, msg, msg, msg); | |
808 | int sanity_check(void); | 812 | int sanity_check(void); | |
809 | int set_timezone(void); | 813 | int set_timezone(void); | |
810 | void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); | 814 | void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); | |
811 | void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); | 815 | void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); | |
812 | void add_rc_conf(const char *, ...) __printflike(1, 2); | 816 | void add_rc_conf(const char *, ...) __printflike(1, 2); | |
813 | int del_rc_conf(const char *); | 817 | int del_rc_conf(const char *); | |
814 | void add_sysctl_conf(const char *, ...) __printflike(1, 2); | 818 | void add_sysctl_conf(const char *, ...) __printflike(1, 2); | |
815 | void enable_rc_conf(void); | 819 | void enable_rc_conf(void); | |
816 | void set_sizemult(uint secs); | 820 | void set_sizemult(daddr_t, uint bps); | |
817 | void set_default_sizemult(uint secs); | 821 | void set_default_sizemult(const char *disk, daddr_t unit, uint bps); | |
818 | int check_lfs_progs(void); | 822 | int check_lfs_progs(void); | |
819 | void init_set_status(int); | 823 | void init_set_status(int); | |
820 | void customise_sets(void); | 824 | void customise_sets(void); | |
821 | void umount_mnt2(void); | 825 | void umount_mnt2(void); | |
822 | int set_is_source(const char *); | 826 | int set_is_source(const char *); | |
823 | const char *set_dir_for_set(const char *); | 827 | const char *set_dir_for_set(const char *); | |
824 | const char *ext_dir_for_set(const char *); | 828 | const char *ext_dir_for_set(const char *); | |
825 | void replace(const char *, const char *, ...) __printflike(2, 3); | 829 | void replace(const char *, const char *, ...) __printflike(2, 3); | |
826 | void get_tz_default(void); | 830 | void get_tz_default(void); | |
827 | distinfo* get_set_distinfo(int); | 831 | distinfo* get_set_distinfo(int); | |
828 | int extract_file(distinfo *, int); | 832 | int extract_file(distinfo *, int); | |
829 | int extract_file_to(distinfo *dist, int update, const char *dest_dir, | 833 | int extract_file_to(distinfo *dist, int update, const char *dest_dir, | |
830 | const char *extr_pattern, bool do_stats); | 834 | const char *extr_pattern, bool do_stats); | |
@@ -903,27 +907,28 @@ part_id pm_whole_disk(struct part_entry | @@ -903,27 +907,28 @@ part_id pm_whole_disk(struct part_entry | |||
903 | struct pm_devs * pm_from_pe(struct part_entry *); | 907 | struct pm_devs * pm_from_pe(struct part_entry *); | |
904 | bool pm_force_parts(struct pm_devs *); | 908 | bool pm_force_parts(struct pm_devs *); | |
905 | 909 | |||
906 | /* | 910 | /* | |
907 | * Parse a file system position or size in a common way, return | 911 | * Parse a file system position or size in a common way, return | |
908 | * sector count and multiplicator. | 912 | * sector count and multiplicator. | |
909 | * If "extend" is supported, things like 120+ will be parsed as | 913 | * If "extend" is supported, things like 120+ will be parsed as | |
910 | * 120 plus "extend this" flag. | 914 | * 120 plus "extend this" flag. | |
911 | * Caller needs to init muliplicator upfront to the default value. | 915 | * Caller needs to init muliplicator upfront to the default value. | |
912 | */ | 916 | */ | |
913 | daddr_t parse_disk_pos( | 917 | daddr_t parse_disk_pos( | |
914 | const char *, /* in: input string */ | 918 | const char *, /* in: input string */ | |
915 | daddr_t *, /* in/out: multiplicator for return value */ | 919 | daddr_t *, /* in/out: multiplicator for return value */ | |
916 | daddr_t, /* in: cylinder size in blocks */ | 920 | daddr_t bps, /* in: sector size in bytes */ | |
921 | daddr_t, /* in: cylinder size in sectors */ | |||
917 | bool *); /* NULL if "extend" is not supported, & of | 922 | bool *); /* NULL if "extend" is not supported, & of | |
918 | * "extend" flag otherwise */ | 923 | * "extend" flag otherwise */ | |
919 | 924 | |||
920 | /* flags whether to offer the respective options (depending on helper | 925 | /* flags whether to offer the respective options (depending on helper | |
921 | programs available on install media */ | 926 | programs available on install media */ | |
922 | extern int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk; | 927 | extern int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk; | |
923 | /* initialize above variables */ | 928 | /* initialize above variables */ | |
924 | void check_available_binaries(void); | 929 | void check_available_binaries(void); | |
925 | 930 | |||
926 | /* from bsddisklabel.c */ | 931 | /* from bsddisklabel.c */ | |
927 | bool make_bsd_partitions(struct install_partition_desc*); | 932 | bool make_bsd_partitions(struct install_partition_desc*); | |
928 | void set_ptn_titles(menudesc *, int, void *); | 933 | void set_ptn_titles(menudesc *, int, void *); | |
929 | int set_ptn_size(menudesc *, void *); | 934 | int set_ptn_size(menudesc *, void *); |
--- src/usr.sbin/sysinst/disklabel.c 2020/01/21 20:04:30 1.33
+++ src/usr.sbin/sysinst/disklabel.c 2020/01/27 21:21:22 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: disklabel.c,v 1.33 2020/01/21 20:04:30 martin Exp $ */ | 1 | /* $NetBSD: disklabel.c,v 1.34 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2018 The NetBSD Foundation, Inc. | 4 | * Copyright 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -60,142 +60,148 @@ struct dl_custom_ptype { | @@ -60,142 +60,148 @@ struct dl_custom_ptype { | |||
60 | char short_desc[6], description[30]; | 60 | char short_desc[6], description[30]; | |
61 | struct part_type_desc desc; | 61 | struct part_type_desc desc; | |
62 | }; | 62 | }; | |
63 | struct dl_custom_ptype * dl_custom_ptypes; | 63 | struct dl_custom_ptype * dl_custom_ptypes; | |
64 | size_t dl_custom_ptype_count; | 64 | size_t dl_custom_ptype_count; | |
65 | 65 | |||
66 | static uint8_t dl_part_type_from_generic(const struct part_type_desc*); | 66 | static uint8_t dl_part_type_from_generic(const struct part_type_desc*); | |
67 | 67 | |||
68 | static void | 68 | static void | |
69 | disklabel_init_default_alignment(struct disklabel_disk_partitions *parts, | 69 | disklabel_init_default_alignment(struct disklabel_disk_partitions *parts, | |
70 | uint track) | 70 | uint track) | |
71 | { | 71 | { | |
72 | if (track == 0) | 72 | if (track == 0) | |
73 | track = MEG / 512; | 73 | track = MEG / parts->dp.bytes_per_sector; | |
74 | 74 | |||
75 | if (dl_maxpart == 0) | 75 | if (dl_maxpart == 0) | |
76 | dl_maxpart = getmaxpartitions(); | 76 | dl_maxpart = getmaxpartitions(); | |
77 | 77 | |||
78 | #ifdef MD_DISKLABEL_SET_ALIGN_PRE | 78 | #ifdef MD_DISKLABEL_SET_ALIGN_PRE | |
79 | if (MD_DISKLABEL_SET_ALIGN_PRE(parts->ptn_alignment, track)) | 79 | if (MD_DISKLABEL_SET_ALIGN_PRE(parts->ptn_alignment, track)) | |
80 | return; | 80 | return; | |
81 | #endif | 81 | #endif | |
82 | /* Use 1MB alignemnt for large (>128GB) disks */ | 82 | /* Use 1MB alignemnt for large (>128GB) disks */ | |
83 | if (parts->dp.disk_size > HUGE_DISK_SIZE) { | 83 | if (parts->dp.disk_size > HUGE_DISK_SIZE) { | |
84 | parts->ptn_alignment = 2048; | 84 | parts->ptn_alignment = 2048; | |
85 | } else if (parts->dp.disk_size > TINY_DISK_SIZE) { | 85 | } else if (parts->dp.disk_size > TINY_DISK_SIZE || | |
86 | parts->dp.bytes_per_sector > 512) { | |||
86 | parts->ptn_alignment = 64; | 87 | parts->ptn_alignment = 64; | |
87 | } else { | 88 | } else { | |
88 | parts->ptn_alignment = 1; | 89 | parts->ptn_alignment = 1; | |
89 | } | 90 | } | |
90 | #ifdef MD_DISKLABEL_SET_ALIGN_POST | 91 | #ifdef MD_DISKLABEL_SET_ALIGN_POST | |
91 | MD_DISKLABEL_SET_ALIGN_POST(parts->ptn_alignment, track); | 92 | MD_DISKLABEL_SET_ALIGN_POST(parts->ptn_alignment, track); | |
92 | #endif | 93 | #endif | |
93 | } | 94 | } | |
94 | 95 | |||
95 | static bool | 96 | static bool | |
96 | disklabel_change_geom(struct disk_partitions *arg, int ncyl, int nhead, | 97 | disklabel_change_geom(struct disk_partitions *arg, int ncyl, int nhead, | |
97 | int nsec) | 98 | int nsec) | |
98 | { | 99 | { | |
99 | struct disklabel_disk_partitions *parts = | 100 | struct disklabel_disk_partitions *parts = | |
100 | (struct disklabel_disk_partitions*)arg; | 101 | (struct disklabel_disk_partitions*)arg; | |
101 | 102 | |||
102 | assert(parts->l.d_secsize != 0); | 103 | assert(parts->l.d_secsize != 0); | |
103 | assert(parts->l.d_nsectors != 0); | 104 | assert(parts->l.d_nsectors != 0); | |
104 | assert(parts->l.d_ntracks != 0); | 105 | assert(parts->l.d_ntracks != 0); | |
105 | assert(parts->l.d_ncylinders != 0); | 106 | assert(parts->l.d_ncylinders != 0); | |
106 | assert(parts->l.d_secpercyl != 0); | 107 | assert(parts->l.d_secpercyl != 0); | |
107 | 108 | |||
108 | disklabel_init_default_alignment(parts, nhead * nsec); | 109 | disklabel_init_default_alignment(parts, nhead * nsec); | |
109 | if (ncyl*nhead*nsec <= TINY_DISK_SIZE) | 110 | if (ncyl*nhead*nsec <= TINY_DISK_SIZE) | |
110 | set_default_sizemult(1); | 111 | set_default_sizemult(arg->disk, | |
112 | arg->bytes_per_sector, arg->bytes_per_sector); | |||
111 | else | 113 | else | |
112 | set_default_sizemult(MEG/512); | 114 | set_default_sizemult(arg->disk, MEG, | |
115 | arg->bytes_per_sector); | |||
113 | 116 | |||
114 | return true; | 117 | return true; | |
115 | } | 118 | } | |
116 | 119 | |||
117 | static size_t | 120 | static size_t | |
118 | disklabel_cylinder_size(const struct disk_partitions *arg) | 121 | disklabel_cylinder_size(const struct disk_partitions *arg) | |
119 | { | 122 | { | |
120 | const struct disklabel_disk_partitions *parts = | 123 | const struct disklabel_disk_partitions *parts = | |
121 | (const struct disklabel_disk_partitions*)arg; | 124 | (const struct disklabel_disk_partitions*)arg; | |
122 | 125 | |||
123 | return parts->l.d_secpercyl; | 126 | return parts->l.d_secpercyl; | |
124 | } | 127 | } | |
125 | 128 | |||
126 | #ifdef NO_DISKLABEL_BOOT | 129 | #ifdef NO_DISKLABEL_BOOT | |
127 | static bool | 130 | static bool | |
128 | disklabel_non_bootable(const char *disk) | 131 | disklabel_non_bootable(const char *disk) | |
129 | { | 132 | { | |
130 | 133 | |||
131 | return false; | 134 | return false; | |
132 | } | 135 | } | |
133 | #endif | 136 | #endif | |
134 | 137 | |||
135 | static struct disk_partitions * | 138 | static struct disk_partitions * | |
136 | disklabel_parts_new(const char *dev, daddr_t start, daddr_t len, | 139 | disklabel_parts_new(const char *dev, daddr_t start, daddr_t len, | |
137 | daddr_t total_size, bool is_boot_drive, struct disk_partitions *parent) | 140 | bool is_boot_drive, struct disk_partitions *parent) | |
138 | { | 141 | { | |
139 | struct disklabel_disk_partitions *parts; | 142 | struct disklabel_disk_partitions *parts; | |
140 | struct disk_geom geo; | 143 | struct disk_geom geo; | |
144 | daddr_t total_size; | |||
141 | 145 | |||
142 | if (!get_disk_geom(dev, &geo)) | 146 | if (!get_disk_geom(dev, &geo)) | |
143 | return NULL; | 147 | return NULL; | |
144 | 148 | |||
145 | parts = calloc(1, sizeof(*parts)); | 149 | parts = calloc(1, sizeof(*parts)); | |
146 | if (parts == NULL) | 150 | if (parts == NULL) | |
147 | return NULL; | 151 | return NULL; | |
148 | 152 | |||
149 | if (len > disklabel_parts.size_limit) | 153 | total_size = geo.dg_secperunit; | |
150 | len = disklabel_parts.size_limit; | 154 | if (len*(geo.dg_secsize/512) > disklabel_parts.size_limit) | |
151 | if (total_size > disklabel_parts.size_limit) | 155 | len = disklabel_parts.size_limit/(geo.dg_secsize/512); | |
152 | total_size = disklabel_parts.size_limit; | 156 | if (total_size*(geo.dg_secsize/512) > disklabel_parts.size_limit) | |
157 | total_size = disklabel_parts.size_limit/(geo.dg_secsize/512); | |||
153 | 158 | |||
154 | parts->l.d_ncylinders = geo.dg_ncylinders; | 159 | parts->l.d_ncylinders = geo.dg_ncylinders; | |
155 | parts->l.d_ntracks = geo.dg_ntracks; | 160 | parts->l.d_ntracks = geo.dg_ntracks; | |
156 | parts->l.d_nsectors = geo.dg_nsectors; | 161 | parts->l.d_nsectors = geo.dg_nsectors; | |
157 | parts->l.d_secsize = geo.dg_secsize; | 162 | parts->l.d_secsize = geo.dg_secsize; | |
158 | parts->l.d_secpercyl = geo.dg_nsectors * geo.dg_ntracks; | 163 | parts->l.d_secpercyl = geo.dg_nsectors * geo.dg_ntracks; | |
159 | 164 | |||
160 | parts->dp.pscheme = &disklabel_parts; | 165 | parts->dp.pscheme = &disklabel_parts; | |
161 | parts->dp.disk = strdup(dev); | 166 | parts->dp.disk = strdup(dev); | |
162 | parts->dp.disk_start = start; | 167 | parts->dp.disk_start = start; | |
163 | parts->dp.disk_size = parts->dp.free_space = len; | 168 | parts->dp.disk_size = parts->dp.free_space = len; | |
169 | parts->dp.bytes_per_sector = parts->l.d_secsize; | |||
164 | disklabel_init_default_alignment(parts, parts->l.d_secpercyl); | 170 | disklabel_init_default_alignment(parts, parts->l.d_secpercyl); | |
165 | parts->dp.parent = parent; | 171 | parts->dp.parent = parent; | |
166 | 172 | |||
167 | strncpy(parts->l.d_packname, "fictious", sizeof parts->l.d_packname); | 173 | strncpy(parts->l.d_packname, "fictious", sizeof parts->l.d_packname); | |
168 | 174 | |||
169 | #if RAW_PART > 2 | 175 | #if RAW_PART > 2 | |
170 | if (parts->dp.parent != NULL) { | 176 | if (parts->dp.parent != NULL) { | |
171 | parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED; | 177 | parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED; | |
172 | parts->l.d_partitions[RAW_PART-1].p_offset = start; | 178 | parts->l.d_partitions[RAW_PART-1].p_offset = start; | |
173 | parts->l.d_partitions[RAW_PART-1].p_size = len; | 179 | parts->l.d_partitions[RAW_PART-1].p_size = len; | |
174 | parts->dp.num_part++; | 180 | parts->dp.num_part++; | |
175 | } | 181 | } | |
176 | #endif | 182 | #endif | |
177 | parts->l.d_partitions[RAW_PART].p_fstype = FS_UNUSED; | 183 | parts->l.d_partitions[RAW_PART].p_fstype = FS_UNUSED; | |
178 | parts->l.d_partitions[RAW_PART].p_offset = 0; | 184 | parts->l.d_partitions[RAW_PART].p_offset = 0; | |
179 | parts->l.d_partitions[RAW_PART].p_size = total_size; | 185 | parts->l.d_partitions[RAW_PART].p_size = total_size; | |
180 | parts->dp.num_part++; | 186 | parts->dp.num_part++; | |
181 | 187 | |||
182 | parts->l.d_npartitions = RAW_PART+1; | 188 | parts->l.d_npartitions = RAW_PART+1; | |
183 | 189 | |||
184 | return &parts->dp; | 190 | return &parts->dp; | |
185 | } | 191 | } | |
186 | 192 | |||
187 | static struct disk_partitions * | 193 | static struct disk_partitions * | |
188 | disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, | 194 | disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps, | |
189 | const struct disk_partitioning_scheme *scheme) | 195 | const struct disk_partitioning_scheme *scheme) | |
190 | { | 196 | { | |
191 | int fd; | 197 | int fd; | |
192 | char diskpath[MAXPATHLEN]; | 198 | char diskpath[MAXPATHLEN]; | |
193 | uint flags; | 199 | uint flags; | |
194 | #ifndef DISKLABEL_NO_ONDISK_VERIFY | 200 | #ifndef DISKLABEL_NO_ONDISK_VERIFY | |
195 | bool have_raw_label = false; | 201 | bool have_raw_label = false; | |
196 | 202 | |||
197 | /* | 203 | /* | |
198 | * Verify we really have a disklabel. | 204 | * Verify we really have a disklabel. | |
199 | */ | 205 | */ | |
200 | if (run_program(RUN_SILENT | RUN_ERROR_OK, | 206 | if (run_program(RUN_SILENT | RUN_ERROR_OK, | |
201 | "disklabel -r %s", disk) == 0) | 207 | "disklabel -r %s", disk) == 0) | |
@@ -236,26 +242,28 @@ disklabel_parts_read(const char *disk, d | @@ -236,26 +242,28 @@ disklabel_parts_read(const char *disk, d | |||
236 | free(parts); | 242 | free(parts); | |
237 | close(fd); | 243 | close(fd); | |
238 | return NULL; | 244 | return NULL; | |
239 | } | 245 | } | |
240 | } | 246 | } | |
241 | #endif | 247 | #endif | |
242 | 248 | |||
243 | if (len > disklabel_parts.size_limit) | 249 | if (len > disklabel_parts.size_limit) | |
244 | len = disklabel_parts.size_limit; | 250 | len = disklabel_parts.size_limit; | |
245 | parts->dp.pscheme = scheme; | 251 | parts->dp.pscheme = scheme; | |
246 | parts->dp.disk = strdup(disk); | 252 | parts->dp.disk = strdup(disk); | |
247 | parts->dp.disk_start = start; | 253 | parts->dp.disk_start = start; | |
248 | parts->dp.disk_size = parts->dp.free_space = len; | 254 | parts->dp.disk_size = parts->dp.free_space = len; | |
255 | parts->l.d_secsize = bps; | |||
256 | parts->dp.bytes_per_sector = bps; | |||
249 | disklabel_init_default_alignment(parts, parts->l.d_secpercyl); | 257 | disklabel_init_default_alignment(parts, parts->l.d_secpercyl); | |
250 | 258 | |||
251 | for (int part = 0; part < parts->l.d_npartitions; part++) { | 259 | for (int part = 0; part < parts->l.d_npartitions; part++) { | |
252 | if (parts->l.d_partitions[part].p_fstype == FS_UNUSED | 260 | if (parts->l.d_partitions[part].p_fstype == FS_UNUSED | |
253 | && parts->l.d_partitions[part].p_size == 0) | 261 | && parts->l.d_partitions[part].p_size == 0) | |
254 | continue; | 262 | continue; | |
255 | 263 | |||
256 | parts->dp.num_part++; | 264 | parts->dp.num_part++; | |
257 | if (parts->l.d_partitions[part].p_fstype == FS_UNUSED) | 265 | if (parts->l.d_partitions[part].p_fstype == FS_UNUSED) | |
258 | continue; | 266 | continue; | |
259 | 267 | |||
260 | flags = 0; | 268 | flags = 0; | |
261 | if (parts->l.d_partitions[part].p_fstype == FS_MSDOS) | 269 | if (parts->l.d_partitions[part].p_fstype == FS_MSDOS) | |
@@ -1003,92 +1011,92 @@ need_to_skip_past_label(const struct dis | @@ -1003,92 +1011,92 @@ need_to_skip_past_label(const struct dis | |||
1003 | 1011 | |||
1004 | static part_id | 1012 | static part_id | |
1005 | disklabel_add_partition(struct disk_partitions *arg, | 1013 | disklabel_add_partition(struct disk_partitions *arg, | |
1006 | const struct disk_part_info *info, const char **err_msg) | 1014 | const struct disk_part_info *info, const char **err_msg) | |
1007 | { | 1015 | { | |
1008 | struct disklabel_disk_partitions *parts = | 1016 | struct disklabel_disk_partitions *parts = | |
1009 | (struct disklabel_disk_partitions*)arg; | 1017 | (struct disklabel_disk_partitions*)arg; | |
1010 | int i, part = -1; | 1018 | int i, part = -1; | |
1011 | part_id new_id; | 1019 | part_id new_id; | |
1012 | struct disk_part_free_space space; | 1020 | struct disk_part_free_space space; | |
1013 | struct disk_part_info data = *info; | 1021 | struct disk_part_info data = *info; | |
1014 | 1022 | |||
1015 | if (disklabel_get_free_spaces_internal(parts, &space, 1, 1, 1, | 1023 | if (disklabel_get_free_spaces_internal(parts, &space, 1, 1, 1, | |
1016 | info->start, -1) < 1) { | 1024 | data.start, -1) < 1) { | |
1017 | if (err_msg) | 1025 | if (err_msg) | |
1018 | *err_msg = msg_string(MSG_No_free_space); | 1026 | *err_msg = msg_string(MSG_No_free_space); | |
1019 | return NO_PART; | 1027 | return NO_PART; | |
1020 | } | 1028 | } | |
1021 | if (space.start <= (parts->dp.disk_start + LABELSECTOR) && | 1029 | if (space.start <= (parts->dp.disk_start + LABELSECTOR) && | |
1022 | need_to_skip_past_label(info)) { | 1030 | need_to_skip_past_label(&data)) { | |
1023 | daddr_t new_start = roundup(parts->dp.disk_start + LABELSECTOR, | 1031 | daddr_t new_start = roundup(parts->dp.disk_start + LABELSECTOR, | |
1024 | parts->ptn_alignment); | 1032 | parts->ptn_alignment); | |
1025 | daddr_t off = new_start - space.start; | 1033 | daddr_t off = new_start - space.start; | |
1026 | space.start += off; | 1034 | space.start += off; | |
1027 | space.size -= off; | 1035 | space.size -= off; | |
1028 | } | 1036 | } | |
1029 | if (data.size > space.size) | 1037 | if (data.size > space.size) | |
1030 | data.size = space.size; | 1038 | data.size = space.size; | |
1031 | daddr_t dend = data.start+data.size; | 1039 | daddr_t dend = data.start+data.size; | |
1032 | if (space.start > data.start) | 1040 | if (space.start > data.start) | |
1033 | data.start = space.start; | 1041 | data.start = space.start; | |
1034 | if (space.start + space.size < dend) | 1042 | if (space.start + space.size < dend) | |
1035 | data.size = space.start+space.size-data.start; | 1043 | data.size = space.start+space.size-data.start; | |
1036 | 1044 | |||
1037 | if (dl_maxpart == 0) | 1045 | if (dl_maxpart == 0) | |
1038 | dl_maxpart = getmaxpartitions(); | 1046 | dl_maxpart = getmaxpartitions(); | |
1039 | 1047 | |||
1040 | for (new_id = 0, i = 0; i < parts->l.d_npartitions; i++) { | 1048 | for (new_id = 0, i = 0; i < parts->l.d_npartitions; i++) { | |
1041 | if (parts->l.d_partitions[i].p_size > 0) | 1049 | if (parts->l.d_partitions[i].p_size > 0) | |
1042 | new_id++; | 1050 | new_id++; | |
1043 | if (info->nat_type->generic_ptype != PT_root && | 1051 | if (data.nat_type->generic_ptype != PT_root && | |
1044 | info->nat_type->generic_ptype != PT_swap && i < RAW_PART) | 1052 | data.nat_type->generic_ptype != PT_swap && i < RAW_PART) | |
1045 | continue; | 1053 | continue; | |
1046 | if (i == 0 && info->nat_type->generic_ptype != PT_root) | 1054 | if (i == 0 && data.nat_type->generic_ptype != PT_root) | |
1047 | continue; | 1055 | continue; | |
1048 | if (i == 1 && info->nat_type->generic_ptype != PT_swap) | 1056 | if (i == 1 && data.nat_type->generic_ptype != PT_swap) | |
1049 | continue; | 1057 | continue; | |
1050 | if (i == RAW_PART) | 1058 | if (i == RAW_PART) | |
1051 | continue; | 1059 | continue; | |
1052 | #if RAW_PART > 2 | 1060 | #if RAW_PART > 2 | |
1053 | if (i == RAW_PART-1 && parts->dp.parent != NULL) | 1061 | if (i == RAW_PART-1 && parts->dp.parent != NULL) | |
1054 | continue; | 1062 | continue; | |
1055 | #endif | 1063 | #endif | |
1056 | if (parts->l.d_partitions[i].p_size > 0) | 1064 | if (parts->l.d_partitions[i].p_size > 0) | |
1057 | continue; | 1065 | continue; | |
1058 | part = i; | 1066 | part = i; | |
1059 | break; | 1067 | break; | |
1060 | } | 1068 | } | |
1061 | 1069 | |||
1062 | if (part < 0) { | 1070 | if (part < 0) { | |
1063 | if (parts->l.d_npartitions >= dl_maxpart) { | 1071 | if (parts->l.d_npartitions >= dl_maxpart) { | |
1064 | if (err_msg) | 1072 | if (err_msg) | |
1065 | *err_msg = | 1073 | *err_msg = | |
1066 | msg_string(MSG_err_too_many_partitions); | 1074 | msg_string(MSG_err_too_many_partitions); | |
1067 | return NO_PART; | 1075 | return NO_PART; | |
1068 | } | 1076 | } | |
1069 | 1077 | |||
1070 | part = parts->l.d_npartitions++; | 1078 | part = parts->l.d_npartitions++; | |
1071 | } | 1079 | } | |
1072 | parts->l.d_partitions[part].p_offset = data.start; | 1080 | parts->l.d_partitions[part].p_offset = data.start; | |
1073 | parts->l.d_partitions[part].p_size = data.size; | 1081 | parts->l.d_partitions[part].p_size = data.size; | |
1074 | parts->l.d_partitions[part].p_fstype = | 1082 | parts->l.d_partitions[part].p_fstype = | |
1075 | dl_part_type_from_generic(info->nat_type); | 1083 | dl_part_type_from_generic(data.nat_type); | |
1076 | if (info->last_mounted && info->last_mounted[0]) | 1084 | if (data.last_mounted && data.last_mounted[0]) | |
1077 | strlcpy(parts->last_mounted[part], info->last_mounted, | 1085 | strlcpy(parts->last_mounted[part], data.last_mounted, | |
1078 | sizeof(parts->last_mounted[part])); | 1086 | sizeof(parts->last_mounted[part])); | |
1079 | else | 1087 | else | |
1080 | parts->last_mounted[part][0] = 0; | 1088 | parts->last_mounted[part][0] = 0; | |
1081 | parts->fs_sub_type[part] = info->fs_sub_type; | 1089 | parts->fs_sub_type[part] = data.fs_sub_type; | |
1082 | parts->dp.num_part++; | 1090 | parts->dp.num_part++; | |
1083 | if (data.size <= parts->dp.free_space) | 1091 | if (data.size <= parts->dp.free_space) | |
1084 | parts->dp.free_space -= data.size; | 1092 | parts->dp.free_space -= data.size; | |
1085 | else | 1093 | else | |
1086 | parts->dp.free_space = 0; | 1094 | parts->dp.free_space = 0; | |
1087 | 1095 | |||
1088 | return new_id; | 1096 | return new_id; | |
1089 | } | 1097 | } | |
1090 | 1098 | |||
1091 | static part_id | 1099 | static part_id | |
1092 | disklabel_add_outer_partition(struct disk_partitions *arg, | 1100 | disklabel_add_outer_partition(struct disk_partitions *arg, | |
1093 | const struct disk_part_info *info, const char **err_msg) | 1101 | const struct disk_part_info *info, const char **err_msg) | |
1094 | { | 1102 | { |
--- src/usr.sbin/sysinst/disks.c 2020/01/24 07:31:15 1.61
+++ src/usr.sbin/sysinst/disks.c 2020/01/27 21:21:22 1.62
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: disks.c,v 1.61 2020/01/24 07:31:15 martin Exp $ */ | 1 | /* $NetBSD: disks.c,v 1.62 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -748,27 +748,27 @@ convert_scheme(struct pm_devs *p, bool i | @@ -748,27 +748,27 @@ convert_scheme(struct pm_devs *p, bool i | |||
748 | struct disk_partitions *old_parts, *new_parts; | 748 | struct disk_partitions *old_parts, *new_parts; | |
749 | const struct disk_partitioning_scheme *new_scheme; | 749 | const struct disk_partitioning_scheme *new_scheme; | |
750 | 750 | |||
751 | *err_msg = NULL; | 751 | *err_msg = NULL; | |
752 | 752 | |||
753 | old_parts = p->parts; | 753 | old_parts = p->parts; | |
754 | new_scheme = select_part_scheme(p, old_parts->pscheme, | 754 | new_scheme = select_part_scheme(p, old_parts->pscheme, | |
755 | false, MSG_select_other_partscheme); | 755 | false, MSG_select_other_partscheme); | |
756 | 756 | |||
757 | if (new_scheme == NULL) | 757 | if (new_scheme == NULL) | |
758 | return false; | 758 | return false; | |
759 | 759 | |||
760 | new_parts = new_scheme->create_new_for_disk(p->diskdev, | 760 | new_parts = new_scheme->create_new_for_disk(p->diskdev, | |
761 | 0, p->dlsize, p->dlsize, is_boot_drive, NULL); | 761 | 0, p->dlsize, is_boot_drive, NULL); | |
762 | if (new_parts == NULL) | 762 | if (new_parts == NULL) | |
763 | return false; | 763 | return false; | |
764 | 764 | |||
765 | convert_copy(old_parts, new_parts); | 765 | convert_copy(old_parts, new_parts); | |
766 | 766 | |||
767 | if (new_parts->num_part == 0) { | 767 | if (new_parts->num_part == 0) { | |
768 | /* need to cleanup */ | 768 | /* need to cleanup */ | |
769 | new_parts->pscheme->free(new_parts); | 769 | new_parts->pscheme->free(new_parts); | |
770 | return false; | 770 | return false; | |
771 | } | 771 | } | |
772 | 772 | |||
773 | old_parts->pscheme->free(old_parts); | 773 | old_parts->pscheme->free(old_parts); | |
774 | p->parts = new_parts; | 774 | p->parts = new_parts; | |
@@ -894,55 +894,56 @@ find_disks(const char *doingwhat, bool a | @@ -894,55 +894,56 @@ find_disks(const char *doingwhat, bool a | |||
894 | } | 894 | } | |
895 | if (pm_i != NULL && already_found) { | 895 | if (pm_i != NULL && already_found) { | |
896 | /* | 896 | /* | |
897 | * We already added this device, but | 897 | * We already added this device, but | |
898 | * partitions might have changed | 898 | * partitions might have changed | |
899 | */ | 899 | */ | |
900 | if (!pm_i->found) { | 900 | if (!pm_i->found) { | |
901 | pm_i->found = true; | 901 | pm_i->found = true; | |
902 | if (pm_i->parts == NULL) { | 902 | if (pm_i->parts == NULL) { | |
903 | pm_i->parts = | 903 | pm_i->parts = | |
904 | partitions_read_disk( | 904 | partitions_read_disk( | |
905 | pm_i->diskdev, | 905 | pm_i->diskdev, | |
906 | disk->dd_totsec, | 906 | disk->dd_totsec, | |
907 | disk->dd_secsize, | |||
907 | disk->dd_no_mbr); | 908 | disk->dd_no_mbr); | |
908 | } | 909 | } | |
909 | } | 910 | } | |
910 | continue; | 911 | continue; | |
911 | } | 912 | } | |
912 | } | 913 | } | |
913 | pm = pm_new; | 914 | pm = pm_new; | |
914 | pm->found = 1; | 915 | pm->found = 1; | |
915 | pm->ptstart = 0; | 916 | pm->ptstart = 0; | |
916 | pm->ptsize = 0; | 917 | pm->ptsize = 0; | |
917 | strlcpy(pm->diskdev, disk->dd_name, sizeof pm->diskdev); | 918 | strlcpy(pm->diskdev, disk->dd_name, sizeof pm->diskdev); | |
918 | strlcpy(pm->diskdev_descr, disk->dd_descr, sizeof pm->diskdev_descr); | 919 | strlcpy(pm->diskdev_descr, disk->dd_descr, sizeof pm->diskdev_descr); | |
919 | /* Use as a default disk if the user has the sets on a local disk */ | 920 | /* Use as a default disk if the user has the sets on a local disk */ | |
920 | strlcpy(localfs_dev, disk->dd_name, sizeof localfs_dev); | 921 | strlcpy(localfs_dev, disk->dd_name, sizeof localfs_dev); | |
921 | 922 | |||
922 | /* | 923 | /* | |
923 | * Init disk size and geometry | 924 | * Init disk size and geometry | |
924 | */ | 925 | */ | |
925 | pm->sectorsize = disk->dd_secsize; | 926 | pm->sectorsize = disk->dd_secsize; | |
926 | pm->dlcyl = disk->dd_cyl; | 927 | pm->dlcyl = disk->dd_cyl; | |
927 | pm->dlhead = disk->dd_head; | 928 | pm->dlhead = disk->dd_head; | |
928 | pm->dlsec = disk->dd_sec; | 929 | pm->dlsec = disk->dd_sec; | |
929 | pm->dlsize = disk->dd_totsec; | 930 | pm->dlsize = disk->dd_totsec; | |
930 | if (pm->dlsize == 0) | 931 | if (pm->dlsize == 0) | |
931 | pm->dlsize = disk->dd_cyl * disk->dd_head | 932 | pm->dlsize = | |
932 | * disk->dd_sec; | 933 | disk->dd_cyl * disk->dd_head * disk->dd_sec; | |
933 | 934 | |||
934 | pm->parts = partitions_read_disk(pm->diskdev, | 935 | pm->parts = partitions_read_disk(pm->diskdev, | |
935 | disk->dd_totsec, disk->dd_no_mbr); | 936 | pm->dlsize, disk->dd_secsize, disk->dd_no_mbr); | |
936 | 937 | |||
937 | again: | 938 | again: | |
938 | 939 | |||
939 | #ifdef DEBUG_VERBOSE | 940 | #ifdef DEBUG_VERBOSE | |
940 | if (pm->parts) { | 941 | if (pm->parts) { | |
941 | fputs("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", stderr); | 942 | fputs("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", stderr); | |
942 | dump_parts(pm->parts); | 943 | dump_parts(pm->parts); | |
943 | 944 | |||
944 | if (pm->parts->pscheme->secondary_partitions) { | 945 | if (pm->parts->pscheme->secondary_partitions) { | |
945 | const struct disk_partitions *sparts = | 946 | const struct disk_partitions *sparts = | |
946 | pm->parts->pscheme->secondary_partitions( | 947 | pm->parts->pscheme->secondary_partitions( | |
947 | pm->parts, pm->ptstart, false); | 948 | pm->parts, pm->ptstart, false); | |
948 | if (sparts != NULL) | 949 | if (sparts != NULL) | |
@@ -950,37 +951,37 @@ again: | @@ -950,37 +951,37 @@ again: | |||
950 | } | 951 | } | |
951 | } | 952 | } | |
952 | #endif | 953 | #endif | |
953 | 954 | |||
954 | pm->no_mbr = disk->dd_no_mbr; | 955 | pm->no_mbr = disk->dd_no_mbr; | |
955 | pm->no_part = disk->dd_no_part; | 956 | pm->no_part = disk->dd_no_part; | |
956 | if (!pm->no_part) { | 957 | if (!pm->no_part) { | |
957 | pm->sectorsize = disk->dd_secsize; | 958 | pm->sectorsize = disk->dd_secsize; | |
958 | pm->dlcyl = disk->dd_cyl; | 959 | pm->dlcyl = disk->dd_cyl; | |
959 | pm->dlhead = disk->dd_head; | 960 | pm->dlhead = disk->dd_head; | |
960 | pm->dlsec = disk->dd_sec; | 961 | pm->dlsec = disk->dd_sec; | |
961 | pm->dlsize = disk->dd_totsec; | 962 | pm->dlsize = disk->dd_totsec; | |
962 | if (pm->dlsize == 0) | 963 | if (pm->dlsize == 0) | |
963 | pm->dlsize = disk->dd_cyl * disk->dd_head | 964 | pm->dlsize = | |
964 | * disk->dd_sec; | 965 | disk->dd_cyl * disk->dd_head * disk->dd_sec; | |
965 | 966 | |||
966 | if (pm->parts && pm->parts->pscheme->size_limit != 0 | 967 | if (pm->parts && pm->parts->pscheme->size_limit != 0 | |
967 | && pm->dlsize > pm->parts->pscheme->size_limit | 968 | && pm->dlsize > pm->parts->pscheme->size_limit | |
968 | && ! partman_go) { | 969 | && ! partman_go) { | |
969 | 970 | |||
970 | char size[5], limit[5]; | 971 | char size[5], limit[5]; | |
971 | 972 | |||
972 | humanize_number(size, sizeof(size), | 973 | humanize_number(size, sizeof(size), | |
973 | (uint64_t)pm->dlsize * 512U, | 974 | (uint64_t)pm->dlsize * pm->sectorsize, | |
974 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | 975 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | |
975 | | HN_DECIMAL); | 976 | | HN_DECIMAL); | |
976 | 977 | |||
977 | humanize_number(limit, sizeof(limit), | 978 | humanize_number(limit, sizeof(limit), | |
978 | (uint64_t)pm->parts->pscheme->size_limit | 979 | (uint64_t)pm->parts->pscheme->size_limit | |
979 | * 512U, | 980 | * 512U, | |
980 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | 981 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | |
981 | | HN_DECIMAL); | 982 | | HN_DECIMAL); | |
982 | 983 | |||
983 | if (logfp) | 984 | if (logfp) | |
984 | fprintf(logfp, | 985 | fprintf(logfp, | |
985 | "disk %s: is too big (%" PRIu64 | 986 | "disk %s: is too big (%" PRIu64 | |
986 | " blocks, %s), will be truncated\n", | 987 | " blocks, %s), will be truncated\n", | |
@@ -1451,27 +1452,29 @@ find_part_by_name(const char *name, stru | @@ -1451,27 +1452,29 @@ find_part_by_name(const char *name, stru | |||
1451 | *pno = id; | 1452 | *pno = id; | |
1452 | *parts = pm->parts; | 1453 | *parts = pm->parts; | |
1453 | return true; | 1454 | return true; | |
1454 | } | 1455 | } | |
1455 | } | 1456 | } | |
1456 | /* | 1457 | /* | |
1457 | * Not that easy - check all other disks | 1458 | * Not that easy - check all other disks | |
1458 | */ | 1459 | */ | |
1459 | cnt = get_disks(disks, false); | 1460 | cnt = get_disks(disks, false); | |
1460 | for (n = 0; n < cnt; n++) { | 1461 | for (n = 0; n < cnt; n++) { | |
1461 | if (strcmp(disks[n].dd_name, pm->diskdev) == 0) | 1462 | if (strcmp(disks[n].dd_name, pm->diskdev) == 0) | |
1462 | continue; | 1463 | continue; | |
1463 | ps = partitions_read_disk(disks[n].dd_name, | 1464 | ps = partitions_read_disk(disks[n].dd_name, | |
1464 | disks[n].dd_totsec, disks[n].dd_no_mbr); | 1465 | disks[n].dd_totsec, | |
1466 | disks[n].dd_secsize, | |||
1467 | disks[n].dd_no_mbr); | |||
1465 | if (ps == NULL) | 1468 | if (ps == NULL) | |
1466 | continue; | 1469 | continue; | |
1467 | if (ps->pscheme->find_by_name == NULL) | 1470 | if (ps->pscheme->find_by_name == NULL) | |
1468 | continue; | 1471 | continue; | |
1469 | id = ps->pscheme->find_by_name(ps, name); | 1472 | id = ps->pscheme->find_by_name(ps, name); | |
1470 | if (id != NO_PART) { | 1473 | if (id != NO_PART) { | |
1471 | *pno = id; | 1474 | *pno = id; | |
1472 | *parts = ps; | 1475 | *parts = ps; | |
1473 | return true; /* XXX this leaks memory */ | 1476 | return true; /* XXX this leaks memory */ | |
1474 | } | 1477 | } | |
1475 | ps->pscheme->free(ps); | 1478 | ps->pscheme->free(ps); | |
1476 | } | 1479 | } | |
1477 | } else { | 1480 | } else { | |
@@ -2381,27 +2384,29 @@ select_partitions(struct selected_partit | @@ -2381,27 +2384,29 @@ select_partitions(struct selected_partit | |||
2381 | /* | 2384 | /* | |
2382 | * allocate two slots for each disk (primary/secondary) | 2385 | * allocate two slots for each disk (primary/secondary) | |
2383 | */ | 2386 | */ | |
2384 | data.all_parts = calloc(2*cnt, sizeof *data.all_parts); | 2387 | data.all_parts = calloc(2*cnt, sizeof *data.all_parts); | |
2385 | if (data.all_parts == NULL) | 2388 | if (data.all_parts == NULL) | |
2386 | return false; | 2389 | return false; | |
2387 | 2390 | |||
2388 | for (n = 0; n < cnt; n++) { | 2391 | for (n = 0; n < cnt; n++) { | |
2389 | if (ignore != NULL && | 2392 | if (ignore != NULL && | |
2390 | strcmp(disks[n].dd_name, ignore->disk) == 0) | 2393 | strcmp(disks[n].dd_name, ignore->disk) == 0) | |
2391 | continue; | 2394 | continue; | |
2392 | 2395 | |||
2393 | ps = partitions_read_disk(disks[n].dd_name, | 2396 | ps = partitions_read_disk(disks[n].dd_name, | |
2394 | disks[n].dd_totsec, disks[n].dd_no_mbr); | 2397 | disks[n].dd_totsec, | |
2398 | disks[n].dd_secsize, | |||
2399 | disks[n].dd_no_mbr); | |||
2395 | if (ps == NULL) | 2400 | if (ps == NULL) | |
2396 | continue; | 2401 | continue; | |
2397 | data.all_parts[data.all_cnt++] = ps; | 2402 | data.all_parts[data.all_cnt++] = ps; | |
2398 | ps = get_inner_parts(ps); | 2403 | ps = get_inner_parts(ps); | |
2399 | if (ps == NULL) | 2404 | if (ps == NULL) | |
2400 | continue; | 2405 | continue; | |
2401 | data.all_parts[data.all_cnt++] = ps; | 2406 | data.all_parts[data.all_cnt++] = ps; | |
2402 | } | 2407 | } | |
2403 | if (data.all_cnt > 0) | 2408 | if (data.all_cnt > 0) | |
2404 | res->free_parts = true; | 2409 | res->free_parts = true; | |
2405 | } else { | 2410 | } else { | |
2406 | cnt = 0; | 2411 | cnt = 0; | |
2407 | SLIST_FOREACH(i, &pm_head, l) | 2412 | SLIST_FOREACH(i, &pm_head, l) |
--- src/usr.sbin/sysinst/gpt.c 2020/01/15 19:36:30 1.15
+++ src/usr.sbin/sysinst/gpt.c 2020/01/27 21:21:22 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gpt.c,v 1.15 2020/01/15 19:36:30 martin Exp $ */ | 1 | /* $NetBSD: gpt.c,v 1.16 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2018 The NetBSD Foundation, Inc. | 4 | * Copyright 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | #include <uuid.h> | 40 | #include <uuid.h> | |
41 | 41 | |||
42 | bool gpt_parts_check(void); /* check for needed binaries */ | 42 | bool gpt_parts_check(void); /* check for needed binaries */ | |
43 | 43 | |||
44 | 44 | |||
45 | /*************** GPT ************************************************/ | 45 | /*************** GPT ************************************************/ | |
46 | /* a GPT based disk_partitions interface */ | 46 | /* a GPT based disk_partitions interface */ | |
47 | 47 | |||
48 | #define GUID_STR_LEN 40 | 48 | #define GUID_STR_LEN 40 | |
49 | #define GPT_PTYPE_ALLOC 32 /* initial type array allocation, should be > | 49 | #define GPT_PTYPE_ALLOC 32 /* initial type array allocation, should be > | |
50 | * gpt type -l | wc -l */ | 50 | * gpt type -l | wc -l */ | |
51 | #define GPT_DEV_LEN 16 /* dkNN */ | 51 | #define GPT_DEV_LEN 16 /* dkNN */ | |
52 | 52 | |||
53 | #define GPT_PARTS_PER_SEC 4 /* a 512 byte sector hols 4 entries */ | 53 | #define GPT_PARTS_PER_SEC 4 /* a 512 byte sector holds 4 entries */ | |
54 | #define GPT_DEFAULT_MAX_PARTS 128 | 54 | #define GPT_DEFAULT_MAX_PARTS 128 | |
55 | 55 | |||
56 | /* a usable label will be short, so we can get away with an arbitrary limit */ | 56 | /* a usable label will be short, so we can get away with an arbitrary limit */ | |
57 | #define GPT_LABEL_LEN 96 | 57 | #define GPT_LABEL_LEN 96 | |
58 | 58 | |||
59 | #define GPT_ATTR_BIOSBOOT 1 | 59 | #define GPT_ATTR_BIOSBOOT 1 | |
60 | #define GPT_ATTR_BOOTME 2 | 60 | #define GPT_ATTR_BOOTME 2 | |
61 | #define GPT_ATTR_BOOTONCE 4 | 61 | #define GPT_ATTR_BOOTONCE 4 | |
62 | #define GPT_ATTR_BOOTFAILED 8 | 62 | #define GPT_ATTR_BOOTFAILED 8 | |
63 | #define GPT_ATTR_NOBLOCKIO 16 | 63 | #define GPT_ATTR_NOBLOCKIO 16 | |
64 | #define GPT_ATTR_REQUIRED 32 | 64 | #define GPT_ATTR_REQUIRED 32 | |
65 | 65 | |||
66 | /* when we don't care for BIOS or UEFI boot, use the combined boot flags */ | 66 | /* when we don't care for BIOS or UEFI boot, use the combined boot flags */ | |
@@ -245,27 +245,27 @@ update_part_from_wedge_info(struct gpt_d | @@ -245,27 +245,27 @@ update_part_from_wedge_info(struct gpt_d | |||
245 | for (struct gpt_part_entry *p = parts->partitions; p != NULL; | 245 | for (struct gpt_part_entry *p = parts->partitions; p != NULL; | |
246 | p = p->gp_next) { | 246 | p = p->gp_next) { | |
247 | if (p->gp_start != dkw->dkw_offset || | 247 | if (p->gp_start != dkw->dkw_offset || | |
248 | (uint64_t)p->gp_size != dkw->dkw_size) | 248 | (uint64_t)p->gp_size != dkw->dkw_size) | |
249 | continue; | 249 | continue; | |
250 | p->gp_flags |= GPEF_WEDGE; | 250 | p->gp_flags |= GPEF_WEDGE; | |
251 | strlcpy(p->gp_dev_name, dkw->dkw_devname, | 251 | strlcpy(p->gp_dev_name, dkw->dkw_devname, | |
252 | sizeof p->gp_dev_name); | 252 | sizeof p->gp_dev_name); | |
253 | return; | 253 | return; | |
254 | } | 254 | } | |
255 | } | 255 | } | |
256 | 256 | |||
257 | static struct disk_partitions * | 257 | static struct disk_partitions * | |
258 | gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len, | 258 | gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len, size_t bps, | |
259 | const struct disk_partitioning_scheme *scheme) | 259 | const struct disk_partitioning_scheme *scheme) | |
260 | { | 260 | { | |
261 | char diskpath[MAXPATHLEN]; | 261 | char diskpath[MAXPATHLEN]; | |
262 | int fd; | 262 | int fd; | |
263 | struct dkwedge_info *dkw; | 263 | struct dkwedge_info *dkw; | |
264 | struct dkwedge_list dkwl; | 264 | struct dkwedge_list dkwl; | |
265 | size_t bufsize, dk; | 265 | size_t bufsize, dk; | |
266 | 266 | |||
267 | assert(start == 0); | 267 | assert(start == 0); | |
268 | assert(have_gpt); | 268 | assert(have_gpt); | |
269 | 269 | |||
270 | if (run_program(RUN_SILENT | RUN_ERROR_OK, | 270 | if (run_program(RUN_SILENT | RUN_ERROR_OK, | |
271 | "gpt -rq header %s", dev) != 0) | 271 | "gpt -rq header %s", dev) != 0) | |
@@ -364,26 +364,27 @@ gpt_read_from_disk(const char *dev, dadd | @@ -364,26 +364,27 @@ gpt_read_from_disk(const char *dev, dadd | |||
364 | free(textbuf); | 364 | free(textbuf); | |
365 | 365 | |||
366 | /* If the GPT was not complete (e.g. truncated image), barf */ | 366 | /* If the GPT was not complete (e.g. truncated image), barf */ | |
367 | if (disk_size <= 0) { | 367 | if (disk_size <= 0) { | |
368 | free(parts); | 368 | free(parts); | |
369 | return NULL; | 369 | return NULL; | |
370 | } | 370 | } | |
371 | 371 | |||
372 | parts->dp.pscheme = scheme; | 372 | parts->dp.pscheme = scheme; | |
373 | parts->dp.disk = strdup(dev); | 373 | parts->dp.disk = strdup(dev); | |
374 | parts->dp.disk_start = start; | 374 | parts->dp.disk_start = start; | |
375 | parts->dp.disk_size = disk_size; | 375 | parts->dp.disk_size = disk_size; | |
376 | parts->dp.free_space = avail_size; | 376 | parts->dp.free_space = avail_size; | |
377 | parts->dp.bytes_per_sector = bps; | |||
377 | parts->has_gpt = true; | 378 | parts->has_gpt = true; | |
378 | 379 | |||
379 | fd = opendisk(parts->dp.disk, O_RDONLY, diskpath, sizeof(diskpath), 0); | 380 | fd = opendisk(parts->dp.disk, O_RDONLY, diskpath, sizeof(diskpath), 0); | |
380 | for (struct gpt_part_entry *p = parts->partitions; p != NULL; | 381 | for (struct gpt_part_entry *p = parts->partitions; p != NULL; | |
381 | p = p->gp_next) { | 382 | p = p->gp_next) { | |
382 | #ifdef DEFAULT_UFS2 | 383 | #ifdef DEFAULT_UFS2 | |
383 | bool fs_is_default = false; | 384 | bool fs_is_default = false; | |
384 | #endif | 385 | #endif | |
385 | 386 | |||
386 | if (p->gp_type != NULL) { | 387 | if (p->gp_type != NULL) { | |
387 | 388 | |||
388 | if (p->gp_type->fsflags != 0) { | 389 | if (p->gp_type->fsflags != 0) { | |
389 | const char *lm = get_last_mounted(fd, | 390 | const char *lm = get_last_mounted(fd, | |
@@ -436,48 +437,53 @@ gpt_read_from_disk(const char *dev, dadd | @@ -436,48 +437,53 @@ gpt_read_from_disk(const char *dev, dadd | |||
436 | 437 | |||
437 | close(fd); | 438 | close(fd); | |
438 | 439 | |||
439 | return &parts->dp; | 440 | return &parts->dp; | |
440 | } | 441 | } | |
441 | 442 | |||
442 | static size_t | 443 | static size_t | |
443 | gpt_cyl_size(const struct disk_partitions *arg) | 444 | gpt_cyl_size(const struct disk_partitions *arg) | |
444 | { | 445 | { | |
445 | return MEG / 512; | 446 | return MEG / 512; | |
446 | } | 447 | } | |
447 | 448 | |||
448 | static struct disk_partitions * | 449 | static struct disk_partitions * | |
449 | gpt_create_new(const char *disk, daddr_t start, daddr_t len, daddr_t total, | 450 | gpt_create_new(const char *disk, daddr_t start, daddr_t len, | |
450 | bool is_boot_drive, struct disk_partitions *parent) | 451 | bool is_boot_drive, struct disk_partitions *parent) | |
451 | { | 452 | { | |
452 | struct gpt_disk_partitions *parts; | 453 | struct gpt_disk_partitions *parts; | |
454 | struct disk_geom geo; | |||
453 | 455 | |||
454 | if (start != 0) { | 456 | if (start != 0) { | |
455 | assert(0); | 457 | assert(0); | |
456 | return NULL; | 458 | return NULL; | |
457 | } | 459 | } | |
458 | 460 | |||
461 | if (!get_disk_geom(disk, &geo)) | |||
462 | return NULL; | |||
463 | ||||
459 | parts = calloc(1, sizeof(*parts)); | 464 | parts = calloc(1, sizeof(*parts)); | |
460 | if (!parts) | 465 | if (!parts) | |
461 | return NULL; | 466 | return NULL; | |
462 | 467 | |||
463 | parts->dp.pscheme = &gpt_parts; | 468 | parts->dp.pscheme = &gpt_parts; | |
464 | parts->dp.disk = strdup(disk); | 469 | parts->dp.disk = strdup(disk); | |
465 | 470 | |||
466 | gpt_md_init(is_boot_drive, &parts->max_num_parts, &parts->prologue, | 471 | gpt_md_init(is_boot_drive, &parts->max_num_parts, &parts->prologue, | |
467 | &parts->epilogue); | 472 | &parts->epilogue); | |
468 | 473 | |||
469 | parts->dp.disk_start = start; | 474 | parts->dp.disk_start = start; | |
470 | parts->dp.disk_size = len; | 475 | parts->dp.disk_size = len; | |
476 | parts->dp.bytes_per_sector = geo.dg_secsize; | |||
471 | parts->dp.free_space = len - start - parts->prologue - parts->epilogue; | 477 | parts->dp.free_space = len - start - parts->prologue - parts->epilogue; | |
472 | parts->has_gpt = false; | 478 | parts->has_gpt = false; | |
473 | 479 | |||
474 | return &parts->dp; | 480 | return &parts->dp; | |
475 | } | 481 | } | |
476 | 482 | |||
477 | static bool | 483 | static bool | |
478 | gpt_get_part_info(const struct disk_partitions *arg, part_id id, | 484 | gpt_get_part_info(const struct disk_partitions *arg, part_id id, | |
479 | struct disk_part_info *info) | 485 | struct disk_part_info *info) | |
480 | { | 486 | { | |
481 | static const struct part_type_desc gpt_unknown_type = | 487 | static const struct part_type_desc gpt_unknown_type = | |
482 | { .generic_ptype = PT_undef, | 488 | { .generic_ptype = PT_undef, | |
483 | .short_desc = "<unknown>" }; | 489 | .short_desc = "<unknown>" }; |
--- src/usr.sbin/sysinst/part_edit.c 2020/01/20 21:26:35 1.15
+++ src/usr.sbin/sysinst/part_edit.c 2020/01/27 21:21:22 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: part_edit.c,v 1.15 2020/01/20 21:26:35 martin Exp $ */ | 1 | /* $NetBSD: part_edit.c,v 1.16 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -1179,27 +1179,27 @@ ask_outer_partsizes(struct disk_partitio | @@ -1179,27 +1179,27 @@ ask_outer_partsizes(struct disk_partitio | |||
1179 | 1179 | |||
1180 | part_menu_opts = outer_fill_part_menu_opts(parts, &num_opts); | 1180 | part_menu_opts = outer_fill_part_menu_opts(parts, &num_opts); | |
1181 | part_menu = new_menu(outer_part_title, part_menu_opts, num_opts, | 1181 | part_menu = new_menu(outer_part_title, part_menu_opts, num_opts, | |
1182 | 0, -1, 15, 70, | 1182 | 0, -1, 15, 70, | |
1183 | MC_NOBOX|MC_ALWAYS_SCROLL|MC_NOCLEAR|MC_CONTINUOUS, | 1183 | MC_NOBOX|MC_ALWAYS_SCROLL|MC_NOCLEAR|MC_CONTINUOUS, | |
1184 | draw_outer_part_header, draw_outer_part_line, NULL, | 1184 | draw_outer_part_header, draw_outer_part_line, NULL, | |
1185 | NULL, MSG_Partition_table_ok); | 1185 | NULL, MSG_Partition_table_ok); | |
1186 | if (part_menu == -1) { | 1186 | if (part_menu == -1) { | |
1187 | free(part_menu_opts); | 1187 | free(part_menu_opts); | |
1188 | return false; | 1188 | return false; | |
1189 | } | 1189 | } | |
1190 | 1190 | |||
1191 | /* Default to MB, and use bios geometry for cylinder size */ | 1191 | /* Default to MB, and use bios geometry for cylinder size */ | |
1192 | set_default_sizemult(MEG/512); | 1192 | set_default_sizemult(parts->disk, MEG, parts->bytes_per_sector); | |
1193 | if (pm->current_cylsize == 0) | 1193 | if (pm->current_cylsize == 0) | |
1194 | pm->current_cylsize = 16065; /* noone cares nowadays */ | 1194 | pm->current_cylsize = 16065; /* noone cares nowadays */ | |
1195 | pm->ptstart = 0; | 1195 | pm->ptstart = 0; | |
1196 | pm->ptsize = 0; | 1196 | pm->ptsize = 0; | |
1197 | memset(&data, 0, sizeof data); | 1197 | memset(&data, 0, sizeof data); | |
1198 | data.av.arg = parts; | 1198 | data.av.arg = parts; | |
1199 | 1199 | |||
1200 | for (;;) { | 1200 | for (;;) { | |
1201 | data.av.rv = 0; | 1201 | data.av.rv = 0; | |
1202 | process_menu(part_menu, &data); | 1202 | process_menu(part_menu, &data); | |
1203 | if (data.av.rv < 0) | 1203 | if (data.av.rv < 0) | |
1204 | break; | 1204 | break; | |
1205 | 1205 | |||
@@ -1384,27 +1384,28 @@ select_part_scheme( | @@ -1384,27 +1384,28 @@ select_part_scheme( | |||
1384 | * Do not match exactly, we want to skip all lookalikes | 1384 | * Do not match exactly, we want to skip all lookalikes | |
1385 | * too (only_disklabel_parts vs. disklabel_parts) | 1385 | * too (only_disklabel_parts vs. disklabel_parts) | |
1386 | */ | 1386 | */ | |
1387 | if (skip != NULL && | 1387 | if (skip != NULL && | |
1388 | p->create_new_for_disk == skip->create_new_for_disk) | 1388 | p->create_new_for_disk == skip->create_new_for_disk) | |
1389 | continue; | 1389 | continue; | |
1390 | if (bootable && p->have_boot_support != NULL && | 1390 | if (bootable && p->have_boot_support != NULL && | |
1391 | !p->have_boot_support(dev->diskdev)) | 1391 | !p->have_boot_support(dev->diskdev)) | |
1392 | continue; | 1392 | continue; | |
1393 | #ifdef HAVE_MBR | 1393 | #ifdef HAVE_MBR | |
1394 | if (dev->no_mbr && p->name == MSG_parttype_mbr) | 1394 | if (dev->no_mbr && p->name == MSG_parttype_mbr) | |
1395 | continue; | 1395 | continue; | |
1396 | #endif | 1396 | #endif | |
1397 | if (p->size_limit && dev->dlsize > p->size_limit) { | 1397 | if (p->size_limit && dev->dlsize*(dev->sectorsize/512) > | |
1398 | p->size_limit) { | |||
1398 | char buf[255], hum_lim[5]; | 1399 | char buf[255], hum_lim[5]; | |
1399 | 1400 | |||
1400 | humanize_number(hum_lim, sizeof(hum_lim), | 1401 | humanize_number(hum_lim, sizeof(hum_lim), | |
1401 | (uint64_t)p->size_limit*512UL, | 1402 | (uint64_t)p->size_limit*512UL, | |
1402 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | 1403 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | |
1403 | sprintf(buf, "%s [%s %s]", msg_string(p->name), | 1404 | sprintf(buf, "%s [%s %s]", msg_string(p->name), | |
1404 | msg_string(MSG_size_limit), hum_lim); | 1405 | msg_string(MSG_size_limit), hum_lim); | |
1405 | str[used] = strdup(buf); | 1406 | str[used] = strdup(buf); | |
1406 | showing_limit = true; | 1407 | showing_limit = true; | |
1407 | } else { | 1408 | } else { | |
1408 | str[used] = strdup(msg_string(p->name)); | 1409 | str[used] = strdup(msg_string(p->name)); | |
1409 | } | 1410 | } | |
1410 | if (!str[used]) | 1411 | if (!str[used]) | |
@@ -1420,27 +1421,27 @@ select_part_scheme( | @@ -1420,27 +1421,27 @@ select_part_scheme( | |||
1420 | if (used <= 1) { | 1421 | if (used <= 1) { | |
1421 | selected = (used == 1) ? 0 : ~0U; | 1422 | selected = (used == 1) ? 0 : ~0U; | |
1422 | goto out; | 1423 | goto out; | |
1423 | } | 1424 | } | |
1424 | 1425 | |||
1425 | if (showing_limit) { | 1426 | if (showing_limit) { | |
1426 | char hum_lim[5], *tmp; | 1427 | char hum_lim[5], *tmp; | |
1427 | size_t total; | 1428 | size_t total; | |
1428 | 1429 | |||
1429 | const char *p1 = msg_string(hdr); | 1430 | const char *p1 = msg_string(hdr); | |
1430 | const char *p2 = msg_string(MSG_select_part_limit); | 1431 | const char *p2 = msg_string(MSG_select_part_limit); | |
1431 | 1432 | |||
1432 | humanize_number(hum_lim, sizeof(hum_lim), | 1433 | humanize_number(hum_lim, sizeof(hum_lim), | |
1433 | (uint64_t)dev->dlsize*512, "", | 1434 | (uint64_t)dev->dlsize*dev->sectorsize, "", | |
1434 | HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | 1435 | HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | |
1435 | 1436 | |||
1436 | const char *args[] = { dev->diskdev, hum_lim }; | 1437 | const char *args[] = { dev->diskdev, hum_lim }; | |
1437 | char *p3 = str_arg_subst(msg_string(MSG_part_limit_disksize), | 1438 | char *p3 = str_arg_subst(msg_string(MSG_part_limit_disksize), | |
1438 | __arraycount(args), args); | 1439 | __arraycount(args), args); | |
1439 | 1440 | |||
1440 | total = strlen(p1) + strlen(p2) + strlen(p3) | 1441 | total = strlen(p1) + strlen(p2) + strlen(p3) | |
1441 | + sizeof(hum_lim) + 5; | 1442 | + sizeof(hum_lim) + 5; | |
1442 | ms = tmp = malloc(total); | 1443 | ms = tmp = malloc(total); | |
1443 | title = tmp; | 1444 | title = tmp; | |
1444 | strcpy(tmp, p1); tmp += strlen(p1); | 1445 | strcpy(tmp, p1); tmp += strlen(p1); | |
1445 | *tmp++ = '\n'; *tmp++ = '\n'; | 1446 | *tmp++ = '\n'; *tmp++ = '\n'; | |
1446 | strcpy(tmp, p2); tmp += strlen(p2); | 1447 | strcpy(tmp, p2); tmp += strlen(p2); |
--- src/usr.sbin/sysinst/label.c 2020/01/15 19:37:41 1.19
+++ src/usr.sbin/sysinst/label.c 2020/01/27 21:21:22 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $ */ | 1 | /* $NetBSD: label.c,v 1.20 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Jonathan Stone | 4 | * Copyright 1997 Jonathan Stone | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | 26 | * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE | |
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
33 | * THE POSSIBILITY OF SUCH DAMAGE. | 33 | * THE POSSIBILITY OF SUCH DAMAGE. | |
34 | * | 34 | * | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | #if defined(LIBC_SCCS) && !defined(lint) | 38 | #if defined(LIBC_SCCS) && !defined(lint) | |
39 | __RCSID("$NetBSD: label.c,v 1.19 2020/01/15 19:37:41 martin Exp $"); | 39 | __RCSID("$NetBSD: label.c,v 1.20 2020/01/27 21:21:22 martin Exp $"); | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | #include <sys/types.h> | 42 | #include <sys/types.h> | |
43 | #include <stddef.h> | 43 | #include <stddef.h> | |
44 | #include <assert.h> | 44 | #include <assert.h> | |
45 | #include <errno.h> | 45 | #include <errno.h> | |
46 | #include <stdio.h> | 46 | #include <stdio.h> | |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> | |
48 | #include <util.h> | 48 | #include <util.h> | |
49 | #include <unistd.h> | 49 | #include <unistd.h> | |
50 | #include <sys/dkio.h> | 50 | #include <sys/dkio.h> | |
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | #include <sys/bootblock.h> | 52 | #include <sys/bootblock.h> | |
@@ -1132,30 +1132,30 @@ fmt_fspart_header(menudesc *menu, void * | @@ -1132,30 +1132,30 @@ fmt_fspart_header(menudesc *menu, void * | |||
1132 | struct partition_usage_set *pset = arg; | 1132 | struct partition_usage_set *pset = arg; | |
1133 | char total[6], free_space[6], scol[13], ecol[13], szcol[13], | 1133 | char total[6], free_space[6], scol[13], ecol[13], szcol[13], | |
1134 | sepline[MENUSTRSIZE], *p, desc[MENUSTRSIZE]; | 1134 | sepline[MENUSTRSIZE], *p, desc[MENUSTRSIZE]; | |
1135 | const char *fstype, *flags; | 1135 | const char *fstype, *flags; | |
1136 | int i; | 1136 | int i; | |
1137 | size_t ptn; | 1137 | size_t ptn; | |
1138 | bool with_clone, with_inst_flag = pset->parts->parent == NULL; | 1138 | bool with_clone, with_inst_flag = pset->parts->parent == NULL; | |
1139 | 1139 | |||
1140 | with_clone = false; | 1140 | with_clone = false; | |
1141 | for (ptn = 0; ptn < pset->num && !with_clone; ptn++) | 1141 | for (ptn = 0; ptn < pset->num && !with_clone; ptn++) | |
1142 | if (pset->infos[ptn].flags & PUIFLG_CLONE_PARTS) | 1142 | if (pset->infos[ptn].flags & PUIFLG_CLONE_PARTS) | |
1143 | with_clone = true; | 1143 | with_clone = true; | |
1144 | humanize_number(total, sizeof total, | 1144 | humanize_number(total, sizeof total, | |
1145 | pset->parts->disk_size * 512, | 1145 | pset->parts->disk_size * pset->parts->bytes_per_sector, | |
1146 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | 1146 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | |
1147 | humanize_number(free_space, sizeof free_space, | 1147 | humanize_number(free_space, sizeof free_space, | |
1148 | pset->cur_free_space * 512, | 1148 | pset->cur_free_space * pset->parts->bytes_per_sector, | |
1149 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | 1149 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | |
1150 | 1150 | |||
1151 | if (with_clone) | 1151 | if (with_clone) | |
1152 | strlcpy(desc, msg_string(MSG_clone_flag_desc), sizeof desc); | 1152 | strlcpy(desc, msg_string(MSG_clone_flag_desc), sizeof desc); | |
1153 | else | 1153 | else | |
1154 | desc[0] = 0; | 1154 | desc[0] = 0; | |
1155 | if (pset->parts->pscheme->part_flag_desc) | 1155 | if (pset->parts->pscheme->part_flag_desc) | |
1156 | strlcat(desc, msg_string(pset->parts->pscheme->part_flag_desc), | 1156 | strlcat(desc, msg_string(pset->parts->pscheme->part_flag_desc), | |
1157 | sizeof desc); | 1157 | sizeof desc); | |
1158 | 1158 | |||
1159 | msg_display_subst(MSG_fspart, 7, pset->parts->disk, | 1159 | msg_display_subst(MSG_fspart, 7, pset->parts->disk, | |
1160 | msg_string(pset->parts->pscheme->name), | 1160 | msg_string(pset->parts->pscheme->name), | |
1161 | msg_string(pset->parts->pscheme->short_name), | 1161 | msg_string(pset->parts->pscheme->short_name), | |
@@ -1973,27 +1973,28 @@ getpartoff(struct disk_partitions *parts | @@ -1973,27 +1973,28 @@ getpartoff(struct disk_partitions *parts | |||
1973 | } else { | 1973 | } else { | |
1974 | errmsg = msg_string(MSG_invalid_sector_number); | 1974 | errmsg = msg_string(MSG_invalid_sector_number); | |
1975 | continue; | 1975 | continue; | |
1976 | } | 1976 | } | |
1977 | } else if (isize[1] == '\0' && isize[0] >= minspace && | 1977 | } else if (isize[1] == '\0' && isize[0] >= minspace && | |
1978 | isize[0] <= maxspace) { | 1978 | isize[0] <= maxspace) { | |
1979 | ndx = isize[0] - minspace; | 1979 | ndx = isize[0] - minspace; | |
1980 | i = freespace[ndx].start; | 1980 | i = freespace[ndx].start; | |
1981 | localsizemult = 1; | 1981 | localsizemult = 1; | |
1982 | } else if (atoi(isize) == -1) { | 1982 | } else if (atoi(isize) == -1) { | |
1983 | i = min; | 1983 | i = min; | |
1984 | localsizemult = 1; | 1984 | localsizemult = 1; | |
1985 | } else { | 1985 | } else { | |
1986 | i = parse_disk_pos(isize, &localsizemult, | 1986 | i = parse_disk_pos(isize, &localsizemult, | |
1987 | parts->bytes_per_sector, | |||
1987 | parts->pscheme->get_cylinder_size(parts), NULL); | 1988 | parts->pscheme->get_cylinder_size(parts), NULL); | |
1988 | if (i < 0) { | 1989 | if (i < 0) { | |
1989 | errmsg = msg_string(MSG_invalid_sector_number); | 1990 | errmsg = msg_string(MSG_invalid_sector_number); | |
1990 | continue; | 1991 | continue; | |
1991 | } | 1992 | } | |
1992 | } | 1993 | } | |
1993 | /* round to cylinder size if localsizemult != 1 */ | 1994 | /* round to cylinder size if localsizemult != 1 */ | |
1994 | int cylsize = parts->pscheme->get_cylinder_size(parts); | 1995 | int cylsize = parts->pscheme->get_cylinder_size(parts); | |
1995 | i = NUMSEC(i, localsizemult, cylsize); | 1996 | i = NUMSEC(i, localsizemult, cylsize); | |
1996 | /* Adjust to start of slice if needed */ | 1997 | /* Adjust to start of slice if needed */ | |
1997 | if ((i < min && (min - i) < localsizemult) || | 1998 | if ((i < min && (min - i) < localsizemult) || | |
1998 | (i > min && (i - min) < localsizemult)) { | 1999 | (i > min && (i - min) < localsizemult)) { | |
1999 | i = min; | 2000 | i = min; | |
@@ -2085,26 +2086,27 @@ getpartsize(struct disk_partitions *part | @@ -2085,26 +2086,27 @@ getpartsize(struct disk_partitions *part | |||
2085 | partn = isize[0] - 'a'; | 2086 | partn = isize[0] - 'a'; | |
2086 | if (parts->pscheme->get_part_info(parts, partn, | 2087 | if (parts->pscheme->get_part_info(parts, partn, | |
2087 | &info)) { | 2088 | &info)) { | |
2088 | i = info.start - partstart -1; | 2089 | i = info.start - partstart -1; | |
2089 | localsizemult = 1; | 2090 | localsizemult = 1; | |
2090 | max_r = max; | 2091 | max_r = max; | |
2091 | } | 2092 | } | |
2092 | } else if (atoi(isize) == -1) { | 2093 | } else if (atoi(isize) == -1) { | |
2093 | i = max; | 2094 | i = max; | |
2094 | localsizemult = 1; | 2095 | localsizemult = 1; | |
2095 | max_r = max; | 2096 | max_r = max; | |
2096 | } else { | 2097 | } else { | |
2097 | i = parse_disk_pos(isize, &localsizemult, | 2098 | i = parse_disk_pos(isize, &localsizemult, | |
2099 | parts->bytes_per_sector, | |||
2098 | parts->pscheme->get_cylinder_size(parts), NULL); | 2100 | parts->pscheme->get_cylinder_size(parts), NULL); | |
2099 | if (localsizemult != sizemult) | 2101 | if (localsizemult != sizemult) | |
2100 | max_r = max; | 2102 | max_r = max; | |
2101 | } | 2103 | } | |
2102 | if (i < 0) { | 2104 | if (i < 0) { | |
2103 | errmsg = msg_string(MSG_Invalid_numeric); | 2105 | errmsg = msg_string(MSG_Invalid_numeric); | |
2104 | continue; | 2106 | continue; | |
2105 | } else if (i > max_r) { | 2107 | } else if (i > max_r) { | |
2106 | errmsg = msg_string(MSG_Too_large); | 2108 | errmsg = msg_string(MSG_Too_large); | |
2107 | continue; | 2109 | continue; | |
2108 | } | 2110 | } | |
2109 | /* | 2111 | /* | |
2110 | * partend is aligned to a cylinder if localsizemult | 2112 | * partend is aligned to a cylinder if localsizemult | |
@@ -2137,51 +2139,52 @@ getpartsize(struct disk_partitions *part | @@ -2137,51 +2139,52 @@ getpartsize(struct disk_partitions *part | |||
2137 | /* | 2139 | /* | |
2138 | * convert a string to a number of sectors, with a possible unit | 2140 | * convert a string to a number of sectors, with a possible unit | |
2139 | * 150M = 150 Megabytes | 2141 | * 150M = 150 Megabytes | |
2140 | * 2000c = 2000 cylinders | 2142 | * 2000c = 2000 cylinders | |
2141 | * 150256s = 150256 sectors | 2143 | * 150256s = 150256 sectors | |
2142 | * Without units, use the default (sizemult). | 2144 | * Without units, use the default (sizemult). | |
2143 | * returns the raw input value, and the unit used. Caller needs to multiply! | 2145 | * returns the raw input value, and the unit used. Caller needs to multiply! | |
2144 | * On invalid inputs, returns -1. | 2146 | * On invalid inputs, returns -1. | |
2145 | */ | 2147 | */ | |
2146 | daddr_t | 2148 | daddr_t | |
2147 | parse_disk_pos( | 2149 | parse_disk_pos( | |
2148 | const char *str, | 2150 | const char *str, | |
2149 | daddr_t *localsizemult, | 2151 | daddr_t *localsizemult, | |
2152 | daddr_t bps, | |||
2150 | daddr_t cyl_size, | 2153 | daddr_t cyl_size, | |
2151 | bool *extend_this) | 2154 | bool *extend_this) | |
2152 | { | 2155 | { | |
2153 | daddr_t val; | 2156 | daddr_t val; | |
2154 | char *cp; | 2157 | char *cp; | |
2155 | bool mult_found; | 2158 | bool mult_found; | |
2156 | 2159 | |||
2157 | if (str[0] == '\0') { | 2160 | if (str[0] == '\0') { | |
2158 | return -1; | 2161 | return -1; | |
2159 | } | 2162 | } | |
2160 | val = strtoull(str, &cp, 10); | 2163 | val = strtoull(str, &cp, 10); | |
2161 | mult_found = false; | 2164 | mult_found = false; | |
2162 | if (extend_this) | 2165 | if (extend_this) | |
2163 | *extend_this = false; | 2166 | *extend_this = false; | |
2164 | while (*cp != 0) { | 2167 | while (*cp != 0) { | |
2165 | if (*cp == 'G' || *cp == 'g') { | 2168 | if (*cp == 'G' || *cp == 'g') { | |
2166 | if (mult_found) | 2169 | if (mult_found) | |
2167 | return -1; | 2170 | return -1; | |
2168 | *localsizemult = GIG / 512; | 2171 | *localsizemult = GIG / bps; | |
2169 | goto next; | 2172 | goto next; | |
2170 | } | 2173 | } | |
2171 | if (*cp == 'M' || *cp == 'm') { | 2174 | if (*cp == 'M' || *cp == 'm') { | |
2172 | if (mult_found) | 2175 | if (mult_found) | |
2173 | return -1; | 2176 | return -1; | |
2174 | *localsizemult = MEG / 512; | 2177 | *localsizemult = MEG / bps; | |
2175 | goto next; | 2178 | goto next; | |
2176 | } | 2179 | } | |
2177 | if (*cp == 'c' || *cp == 'C') { | 2180 | if (*cp == 'c' || *cp == 'C') { | |
2178 | if (mult_found) | 2181 | if (mult_found) | |
2179 | return -1; | 2182 | return -1; | |
2180 | *localsizemult = cyl_size; | 2183 | *localsizemult = cyl_size; | |
2181 | goto next; | 2184 | goto next; | |
2182 | } | 2185 | } | |
2183 | if (*cp == 's' || *cp == 'S') { | 2186 | if (*cp == 's' || *cp == 'S') { | |
2184 | if (mult_found) | 2187 | if (mult_found) | |
2185 | return -1; | 2188 | return -1; | |
2186 | *localsizemult = 1; | 2189 | *localsizemult = 1; | |
2187 | goto next; | 2190 | goto next; |
--- src/usr.sbin/sysinst/mbr.c 2020/01/20 21:26:35 1.29
+++ src/usr.sbin/sysinst/mbr.c 2020/01/27 21:21:22 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mbr.c,v 1.29 2020/01/20 21:26:35 martin Exp $ */ | 1 | /* $NetBSD: mbr.c,v 1.30 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -224,26 +224,87 @@ dump_mbr(mbr_info_t *m, const char *labe | @@ -224,26 +224,87 @@ dump_mbr(mbr_info_t *m, const char *labe | |||
224 | fprintf(stderr, " -> [%u .. %u]", | 224 | fprintf(stderr, " -> [%u .. %u]", | |
225 | m->mbr.mbr_parts[i].mbrp_start + off, | 225 | m->mbr.mbr_parts[i].mbrp_start + off, | |
226 | m->mbr.mbr_parts[i].mbrp_size + | 226 | m->mbr.mbr_parts[i].mbrp_size + | |
227 | m->mbr.mbr_parts[i].mbrp_start + off); | 227 | m->mbr.mbr_parts[i].mbrp_start + off); | |
228 | } | 228 | } | |
229 | fprintf(stderr, ",\n"); | 229 | fprintf(stderr, ",\n"); | |
230 | if (m->sector > 0 && i >= 1) | 230 | if (m->sector > 0 && i >= 1) | |
231 | break; | 231 | break; | |
232 | } | 232 | } | |
233 | } while ((m = m->extended)); | 233 | } while ((m = m->extended)); | |
234 | } | 234 | } | |
235 | #endif | 235 | #endif | |
236 | 236 | |||
237 | /* | |||
238 | * Like pread, but handles re-blocking for non 512 byte sector disks | |||
239 | */ | |||
240 | static ssize_t | |||
241 | blockread(int fd, size_t secsize, void *buf, size_t nbytes, off_t offset) | |||
242 | { | |||
243 | ssize_t nr; | |||
244 | off_t sector = offset / 512; | |||
245 | off_t offs = sector * (off_t)secsize; | |||
246 | off_t mod = offs & (secsize - 1); | |||
247 | off_t rnd = offs & ~(secsize - 1); | |||
248 | char *iobuf; | |||
249 | ||||
250 | assert(nbytes <= 512); | |||
251 | ||||
252 | if (secsize == 512) | |||
253 | return pread(fd, buf, nbytes, offset); | |||
254 | ||||
255 | iobuf = malloc(secsize); | |||
256 | if (iobuf == NULL) | |||
257 | return -1; | |||
258 | nr = pread(fd, iobuf, secsize, rnd); | |||
259 | if (nr == (off_t)secsize) | |||
260 | memcpy(buf, &iobuf[mod], nbytes); | |||
261 | free(iobuf); | |||
262 | ||||
263 | return nr == (off_t)secsize ? (off_t)nbytes : -1; | |||
264 | } | |||
265 | ||||
266 | /* | |||
267 | * Same for pwrite | |||
268 | */ | |||
269 | static ssize_t | |||
270 | blockwrite(int fd, size_t secsize, const void *buf, size_t nbytes, | |||
271 | off_t offset) | |||
272 | { | |||
273 | ssize_t nr; | |||
274 | off_t sector = offset / secsize; | |||
275 | off_t offs = sector * (off_t)secsize; | |||
276 | off_t mod = offs & (secsize - 1); | |||
277 | off_t rnd = offs & ~(secsize - 1); | |||
278 | char *iobuf; | |||
279 | ||||
280 | assert(nbytes <= 512); | |||
281 | ||||
282 | if (secsize == 512) | |||
283 | return pwrite(fd, buf, nbytes, offset); | |||
284 | ||||
285 | iobuf = malloc(secsize); | |||
286 | if (iobuf == NULL) | |||
287 | return -1; | |||
288 | nr = pread(fd, iobuf, secsize, rnd); | |||
289 | if (nr == (off_t)secsize) { | |||
290 | memcpy(&iobuf[mod], buf, nbytes); | |||
291 | nr = pwrite(fd, iobuf, secsize, rnd); | |||
292 | } | |||
293 | free(iobuf); | |||
294 | ||||
295 | return nr == (off_t)secsize ? (off_t)nbytes : -1; | |||
296 | } | |||
297 | ||||
237 | static void | 298 | static void | |
238 | free_last_mounted(mbr_info_t *m) | 299 | free_last_mounted(mbr_info_t *m) | |
239 | { | 300 | { | |
240 | size_t i; | 301 | size_t i; | |
241 | 302 | |||
242 | for (i = 0; i < MBR_PART_COUNT; i++) | 303 | for (i = 0; i < MBR_PART_COUNT; i++) | |
243 | free(__UNCONST(m->last_mounted[i])); | 304 | free(__UNCONST(m->last_mounted[i])); | |
244 | } | 305 | } | |
245 | 306 | |||
246 | static void | 307 | static void | |
247 | free_mbr_info(mbr_info_t *m) | 308 | free_mbr_info(mbr_info_t *m) | |
248 | { | 309 | { | |
249 | if (m == NULL) | 310 | if (m == NULL) | |
@@ -456,49 +517,49 @@ validate_and_set_names(mbr_info_t *mbri, | @@ -456,49 +517,49 @@ validate_and_set_names(mbr_info_t *mbri, | |||
456 | return mbri->mbrb.mbrbs_defkey - SCAN_1; | 517 | return mbri->mbrb.mbrbs_defkey - SCAN_1; | |
457 | return 0; | 518 | return 0; | |
458 | } | 519 | } | |
459 | #endif | 520 | #endif | |
460 | 521 | |||
461 | static int | 522 | static int | |
462 | valid_mbr(struct mbr_sector *mbrs) | 523 | valid_mbr(struct mbr_sector *mbrs) | |
463 | { | 524 | { | |
464 | 525 | |||
465 | return (le16toh(mbrs->mbr_magic) == MBR_MAGIC); | 526 | return (le16toh(mbrs->mbr_magic) == MBR_MAGIC); | |
466 | } | 527 | } | |
467 | 528 | |||
468 | static int | 529 | static int | |
469 | read_mbr(const char *disk, mbr_info_t *mbri) | 530 | read_mbr(const char *disk, size_t secsize, mbr_info_t *mbri) | |
470 | { | 531 | { | |
471 | struct mbr_partition *mbrp; | 532 | struct mbr_partition *mbrp; | |
472 | struct mbr_sector *mbrs = &mbri->mbr; | 533 | struct mbr_sector *mbrs = &mbri->mbr; | |
473 | mbr_info_t *ext = NULL; | 534 | mbr_info_t *ext = NULL; | |
474 | char diskpath[MAXPATHLEN]; | 535 | char diskpath[MAXPATHLEN]; | |
475 | int fd, i; | 536 | int fd, i; | |
476 | uint32_t ext_base = 0, next_ext = 0; | 537 | uint32_t ext_base = 0, next_ext = 0; | |
477 | int rval = -1; | 538 | int rval = -1; | |
478 | #ifdef BOOTSEL | 539 | #ifdef BOOTSEL | |
479 | mbr_info_t *ombri = mbri; | 540 | mbr_info_t *ombri = mbri; | |
480 | int bootkey = 0; | 541 | int bootkey = 0; | |
481 | #endif | 542 | #endif | |
482 | 543 | |||
483 | memset(mbri, 0, sizeof *mbri); | 544 | memset(mbri, 0, sizeof *mbri); | |
484 | 545 | |||
485 | /* Open the disk. */ | 546 | /* Open the disk. */ | |
486 | fd = opendisk(disk, O_RDONLY, diskpath, sizeof(diskpath), 0); | 547 | fd = opendisk(disk, O_RDONLY, diskpath, sizeof(diskpath), 0); | |
487 | if (fd < 0) | 548 | if (fd < 0) | |
488 | goto bad_mbr; | 549 | goto bad_mbr; | |
489 | 550 | |||
490 | for (;;) { | 551 | for (;;) { | |
491 | if (pread(fd, mbrs, sizeof *mbrs, | 552 | if (blockread(fd, secsize, mbrs, sizeof *mbrs, | |
492 | (ext_base + next_ext) * (off_t)MBR_SECSIZE) - sizeof *mbrs != 0) | 553 | (ext_base + next_ext) * (off_t)MBR_SECSIZE) - sizeof *mbrs != 0) | |
493 | break; | 554 | break; | |
494 | 555 | |||
495 | if (!valid_mbr(mbrs)) | 556 | if (!valid_mbr(mbrs)) | |
496 | break; | 557 | break; | |
497 | 558 | |||
498 | mbrp = &mbrs->mbr_parts[0]; | 559 | mbrp = &mbrs->mbr_parts[0]; | |
499 | if (ext_base != 0) { | 560 | if (ext_base != 0) { | |
500 | /* sanity check extended chain */ | 561 | /* sanity check extended chain */ | |
501 | if (MBR_IS_EXTENDED(mbrp[0].mbrp_type)) | 562 | if (MBR_IS_EXTENDED(mbrp[0].mbrp_type)) | |
502 | break; | 563 | break; | |
503 | if (mbrp[1].mbrp_type != MBR_PTYPE_UNUSED && | 564 | if (mbrp[1].mbrp_type != MBR_PTYPE_UNUSED && | |
504 | !MBR_IS_EXTENDED(mbrp[1].mbrp_type)) | 565 | !MBR_IS_EXTENDED(mbrp[1].mbrp_type)) | |
@@ -587,43 +648,45 @@ read_mbr(const char *disk, mbr_info_t *m | @@ -587,43 +648,45 @@ read_mbr(const char *disk, mbr_info_t *m | |||
587 | bad_mbr: | 648 | bad_mbr: | |
588 | free_mbr_info(ext); | 649 | free_mbr_info(ext); | |
589 | if (fd >= 0) | 650 | if (fd >= 0) | |
590 | close(fd); | 651 | close(fd); | |
591 | if (rval == -1) { | 652 | if (rval == -1) { | |
592 | memset(&mbrs->mbr_parts, 0, sizeof mbrs->mbr_parts); | 653 | memset(&mbrs->mbr_parts, 0, sizeof mbrs->mbr_parts); | |
593 | mbrs->mbr_magic = htole16(MBR_MAGIC); | 654 | mbrs->mbr_magic = htole16(MBR_MAGIC); | |
594 | } | 655 | } | |
595 | dump_mbr(ombri, "read"); | 656 | dump_mbr(ombri, "read"); | |
596 | return rval; | 657 | return rval; | |
597 | } | 658 | } | |
598 | 659 | |||
599 | static int | 660 | static int | |
600 | write_mbr(const char *disk, mbr_info_t *mbri, int bsec, int bhead, int bcyl) | 661 | write_mbr(const char *disk, size_t secsize, mbr_info_t *mbri, int bsec, | |
662 | int bhead, int bcyl) | |||
601 | { | 663 | { | |
602 | char diskpath[MAXPATHLEN]; | 664 | char diskpath[MAXPATHLEN]; | |
603 | int fd, i, ret = 0, bits = 0; | 665 | int fd, i, ret = 0, bits = 0; | |
604 | struct mbr_partition *mbrp; | 666 | struct mbr_partition *mbrp; | |
605 | u_int32_t pstart, psize; | 667 | u_int32_t pstart, psize; | |
606 | #ifdef BOOTSEL | 668 | #ifdef BOOTSEL | |
607 | struct mbr_sector *mbrs; | 669 | struct mbr_sector *mbrs; | |
608 | #endif | 670 | #endif | |
609 | struct mbr_sector mbrsec; | 671 | struct mbr_sector mbrsec; | |
610 | mbr_info_t *ext; | 672 | mbr_info_t *ext; | |
611 | uint sector; | 673 | uint sector; | |
612 | 674 | |||
613 | dump_mbr(mbri, "write"); | 675 | dump_mbr(mbri, "write"); | |
614 | 676 | |||
615 | /* Open the disk. */ | 677 | /* Open the disk. */ | |
616 | fd = opendisk(disk, O_WRONLY, diskpath, sizeof(diskpath), 0); | 678 | fd = opendisk(disk, secsize == 512 ? O_WRONLY : O_RDWR, | |
679 | diskpath, sizeof(diskpath), 0); | |||
617 | if (fd < 0) | 680 | if (fd < 0) | |
618 | return -1; | 681 | return -1; | |
619 | 682 | |||
620 | /* Remove all wedges */ | 683 | /* Remove all wedges */ | |
621 | if (ioctl(fd, DIOCRMWEDGES, &bits) == -1) | 684 | if (ioctl(fd, DIOCRMWEDGES, &bits) == -1) | |
622 | return -1; | 685 | return -1; | |
623 | 686 | |||
624 | #ifdef BOOTSEL | 687 | #ifdef BOOTSEL | |
625 | /* | 688 | /* | |
626 | * If the main boot code (appears to) contain the netbsd bootcode, | 689 | * If the main boot code (appears to) contain the netbsd bootcode, | |
627 | * copy in all the menu strings and set the default keycode | 690 | * copy in all the menu strings and set the default keycode | |
628 | * to be that for the default partition. | 691 | * to be that for the default partition. | |
629 | * Unfortunately we can't rely on the user having actually updated | 692 | * Unfortunately we can't rely on the user having actually updated | |
@@ -699,27 +762,27 @@ write_mbr(const char *disk, mbr_info_t * | @@ -699,27 +762,27 @@ write_mbr(const char *disk, mbr_info_t * | |||
699 | mbrp[i].mbrp_start = htole32(pstart); | 762 | mbrp[i].mbrp_start = htole32(pstart); | |
700 | mbrp[i].mbrp_size = htole32(psize); | 763 | mbrp[i].mbrp_size = htole32(psize); | |
701 | if (bsec && bcyl && bhead) { | 764 | if (bsec && bcyl && bhead) { | |
702 | convert_mbr_chs(bcyl, bhead, bsec, | 765 | convert_mbr_chs(bcyl, bhead, bsec, | |
703 | &mbrp[i].mbrp_scyl, &mbrp[i].mbrp_shd, | 766 | &mbrp[i].mbrp_scyl, &mbrp[i].mbrp_shd, | |
704 | &mbrp[i].mbrp_ssect, pstart); | 767 | &mbrp[i].mbrp_ssect, pstart); | |
705 | convert_mbr_chs(bcyl, bhead, bsec, | 768 | convert_mbr_chs(bcyl, bhead, bsec, | |
706 | &mbrp[i].mbrp_ecyl, &mbrp[i].mbrp_ehd, | 769 | &mbrp[i].mbrp_ecyl, &mbrp[i].mbrp_ehd, | |
707 | &mbrp[i].mbrp_esect, pstart + psize - 1); | 770 | &mbrp[i].mbrp_esect, pstart + psize - 1); | |
708 | } | 771 | } | |
709 | } | 772 | } | |
710 | 773 | |||
711 | mbrsec.mbr_magic = htole16(MBR_MAGIC); | 774 | mbrsec.mbr_magic = htole16(MBR_MAGIC); | |
712 | if (pwrite(fd, &mbrsec, sizeof mbrsec, | 775 | if (blockwrite(fd, secsize, &mbrsec, sizeof mbrsec, | |
713 | sector * (off_t)MBR_SECSIZE) < 0) { | 776 | sector * (off_t)MBR_SECSIZE) < 0) { | |
714 | ret = -1; | 777 | ret = -1; | |
715 | break; | 778 | break; | |
716 | } | 779 | } | |
717 | } | 780 | } | |
718 | 781 | |||
719 | (void)close(fd); | 782 | (void)close(fd); | |
720 | return ret; | 783 | return ret; | |
721 | } | 784 | } | |
722 | 785 | |||
723 | static void | 786 | static void | |
724 | convert_mbr_chs(int cyl, int head, int sec, | 787 | convert_mbr_chs(int cyl, int head, int sec, | |
725 | uint8_t *cylp, uint8_t *headp, uint8_t *secp, | 788 | uint8_t *cylp, uint8_t *headp, uint8_t *secp, | |
@@ -823,49 +886,59 @@ mbr_init_default_alignments(struct mbr_d | @@ -823,49 +886,59 @@ mbr_init_default_alignments(struct mbr_d | |||
823 | parts->ptn_alignment = 2048; | 886 | parts->ptn_alignment = 2048; | |
824 | parts->ptn_0_offset = 2048; | 887 | parts->ptn_0_offset = 2048; | |
825 | } else if (parts->dp.disk_size > TINY_DISK_SIZE) { | 888 | } else if (parts->dp.disk_size > TINY_DISK_SIZE) { | |
826 | parts->ptn_alignment = 64; | 889 | parts->ptn_alignment = 64; | |
827 | parts->ptn_0_offset = parts->geo_sec; | 890 | parts->ptn_0_offset = parts->geo_sec; | |
828 | } else { | 891 | } else { | |
829 | parts->ptn_alignment = 1; | 892 | parts->ptn_alignment = 1; | |
830 | parts->ptn_0_offset = parts->geo_sec; | 893 | parts->ptn_0_offset = parts->geo_sec; | |
831 | } | 894 | } | |
832 | parts->ext_ptn_alignment = track; | 895 | parts->ext_ptn_alignment = track; | |
833 | } | 896 | } | |
834 | 897 | |||
835 | static struct disk_partitions * | 898 | static struct disk_partitions * | |
836 | mbr_create_new(const char *disk, daddr_t start, daddr_t len, daddr_t total, | 899 | mbr_create_new(const char *disk, daddr_t start, daddr_t len, | |
837 | bool is_boot_drive, struct disk_partitions *parent) | 900 | bool is_boot_drive, struct disk_partitions *parent) | |
838 | { | 901 | { | |
839 | struct mbr_disk_partitions *parts; | 902 | struct mbr_disk_partitions *parts; | |
903 | struct disk_geom geo; | |||
840 | 904 | |||
841 | assert(start == 0); | 905 | assert(start == 0); | |
842 | if (start != 0) | 906 | if (start != 0) | |
843 | return NULL; | 907 | return NULL; | |
844 | 908 | |||
845 | parts = calloc(1, sizeof(*parts)); | 909 | parts = calloc(1, sizeof(*parts)); | |
846 | if (!parts) | 910 | if (!parts) | |
847 | return NULL; | 911 | return NULL; | |
848 | 912 | |||
849 | parts->dp.pscheme = &mbr_parts; | 913 | parts->dp.pscheme = &mbr_parts; | |
850 | parts->dp.disk = strdup(disk); | 914 | parts->dp.disk = strdup(disk); | |
851 | if (len > mbr_parts.size_limit) | 915 | if (len > mbr_parts.size_limit) | |
852 | len = mbr_parts.size_limit; | 916 | len = mbr_parts.size_limit; | |
853 | parts->dp.disk_start = start; | 917 | parts->dp.disk_start = start; | |
854 | parts->dp.disk_size = len; | 918 | parts->dp.disk_size = len; | |
855 | parts->dp.free_space = len-1; | 919 | parts->dp.free_space = len-1; | |
920 | parts->dp.bytes_per_sector = 512; | |||
856 | parts->geo_sec = MAXSECTOR; | 921 | parts->geo_sec = MAXSECTOR; | |
857 | parts->geo_head = MAXHEAD; | 922 | parts->geo_head = MAXHEAD; | |
858 | parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; | 923 | parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; | |
924 | ||||
925 | if (get_disk_geom(disk, &geo)) { | |||
926 | parts->geo_sec = geo.dg_nsectors; | |||
927 | parts->geo_head = geo.dg_ntracks; | |||
928 | parts->geo_cyl = geo.dg_ncylinders; | |||
929 | parts->dp.bytes_per_sector = geo.dg_secsize; | |||
930 | } | |||
931 | ||||
859 | mbr_init_default_alignments(parts, 0); | 932 | mbr_init_default_alignments(parts, 0); | |
860 | 933 | |||
861 | return &parts->dp; | 934 | return &parts->dp; | |
862 | } | 935 | } | |
863 | 936 | |||
864 | static void | 937 | static void | |
865 | mbr_calc_free_space(struct mbr_disk_partitions *parts) | 938 | mbr_calc_free_space(struct mbr_disk_partitions *parts) | |
866 | { | 939 | { | |
867 | size_t i; | 940 | size_t i; | |
868 | mbr_info_t *m; | 941 | mbr_info_t *m; | |
869 | 942 | |||
870 | parts->dp.free_space = parts->dp.disk_size - 1; | 943 | parts->dp.free_space = parts->dp.disk_size - 1; | |
871 | parts->dp.num_part = 0; | 944 | parts->dp.num_part = 0; | |
@@ -887,50 +960,51 @@ mbr_calc_free_space(struct mbr_disk_part | @@ -887,50 +960,51 @@ mbr_calc_free_space(struct mbr_disk_part | |||
887 | if (m != &parts->mbr) | 960 | if (m != &parts->mbr) | |
888 | psize += m->mbr.mbr_parts[i].mbrp_start; | 961 | psize += m->mbr.mbr_parts[i].mbrp_start; | |
889 | 962 | |||
890 | if (psize > parts->dp.free_space) | 963 | if (psize > parts->dp.free_space) | |
891 | parts->dp.free_space = 0; | 964 | parts->dp.free_space = 0; | |
892 | else | 965 | else | |
893 | parts->dp.free_space -= psize; | 966 | parts->dp.free_space -= psize; | |
894 | 967 | |||
895 | } | 968 | } | |
896 | } while ((m = m->extended)); | 969 | } while ((m = m->extended)); | |
897 | } | 970 | } | |
898 | 971 | |||
899 | static struct disk_partitions * | 972 | static struct disk_partitions * | |
900 | mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len, | 973 | mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len, size_t bps, | |
901 | const struct disk_partitioning_scheme *scheme) | 974 | const struct disk_partitioning_scheme *scheme) | |
902 | { | 975 | { | |
903 | struct mbr_disk_partitions *parts; | 976 | struct mbr_disk_partitions *parts; | |
904 | 977 | |||
905 | assert(start == 0); | 978 | assert(start == 0); | |
906 | if (start != 0) | 979 | if (start != 0) | |
907 | return NULL; | 980 | return NULL; | |
908 | 981 | |||
909 | parts = calloc(1, sizeof(*parts)); | 982 | parts = calloc(1, sizeof(*parts)); | |
910 | if (!parts) | 983 | if (!parts) | |
911 | return NULL; | 984 | return NULL; | |
912 | 985 | |||
913 | parts->dp.pscheme = scheme; | 986 | parts->dp.pscheme = scheme; | |
914 | parts->dp.disk = strdup(disk); | 987 | parts->dp.disk = strdup(disk); | |
915 | if (len >= mbr_parts.size_limit) | 988 | if (len >= mbr_parts.size_limit) | |
916 | len = mbr_parts.size_limit; | 989 | len = mbr_parts.size_limit; | |
917 | parts->dp.disk_start = start; | 990 | parts->dp.disk_start = start; | |
918 | parts->dp.disk_size = len; | 991 | parts->dp.disk_size = len; | |
919 | parts->geo_sec = MAXSECTOR; | 992 | parts->geo_sec = MAXSECTOR; | |
920 | parts->geo_head = MAXHEAD; | 993 | parts->geo_head = MAXHEAD; | |
921 | parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; | 994 | parts->geo_cyl = len/MAXHEAD/MAXSECTOR+1; | |
995 | parts->dp.bytes_per_sector = bps; | |||
922 | mbr_init_default_alignments(parts, 0); | 996 | mbr_init_default_alignments(parts, 0); | |
923 | if (read_mbr(disk, &parts->mbr) == -1) { | 997 | if (read_mbr(disk, parts->dp.bytes_per_sector, &parts->mbr) == -1) { | |
924 | free(parts); | 998 | free(parts); | |
925 | return NULL; | 999 | return NULL; | |
926 | } | 1000 | } | |
927 | mbr_calc_free_space(parts); | 1001 | mbr_calc_free_space(parts); | |
928 | 1002 | |||
929 | return &parts->dp; | 1003 | return &parts->dp; | |
930 | } | 1004 | } | |
931 | 1005 | |||
932 | static bool | 1006 | static bool | |
933 | mbr_write_to_disk(struct disk_partitions *new_state) | 1007 | mbr_write_to_disk(struct disk_partitions *new_state) | |
934 | { | 1008 | { | |
935 | struct mbr_disk_partitions *parts = | 1009 | struct mbr_disk_partitions *parts = | |
936 | (struct mbr_disk_partitions *)new_state; | 1010 | (struct mbr_disk_partitions *)new_state; | |
@@ -942,71 +1016,72 @@ mbr_write_to_disk(struct disk_partitions | @@ -942,71 +1016,72 @@ mbr_write_to_disk(struct disk_partitions | |||
942 | bsec = parts->geo_sec; | 1016 | bsec = parts->geo_sec; | |
943 | bhead = parts->ext_ptn_alignment / bsec; | 1017 | bhead = parts->ext_ptn_alignment / bsec; | |
944 | } else { | 1018 | } else { | |
945 | bsec = MAXSECTOR; | 1019 | bsec = MAXSECTOR; | |
946 | bhead = MAXHEAD; | 1020 | bhead = MAXHEAD; | |
947 | } | 1021 | } | |
948 | t = bsec * bhead; | 1022 | t = bsec * bhead; | |
949 | assert(t != 0); | 1023 | assert(t != 0); | |
950 | if ((daddr_t)(1UL<<10) * t <= parts->dp.disk_size) | 1024 | if ((daddr_t)(1UL<<10) * t <= parts->dp.disk_size) | |
951 | bcyl = (1UL<<10) - 1; | 1025 | bcyl = (1UL<<10) - 1; | |
952 | else | 1026 | else | |
953 | bcyl = (unsigned long)(parts->dp.disk_size / t); | 1027 | bcyl = (unsigned long)(parts->dp.disk_size / t); | |
954 | 1028 | |||
955 | return write_mbr(parts->dp.disk, &parts->mbr, | 1029 | return write_mbr(parts->dp.disk, parts->dp.bytes_per_sector, | |
956 | bsec, bhead, bcyl) == 0; | 1030 | &parts->mbr, bsec, bhead, bcyl) == 0; | |
957 | } | 1031 | } | |
958 | 1032 | |||
959 | static bool | 1033 | static bool | |
960 | mbr_change_disk_geom(struct disk_partitions *arg, int ncyl, int nhead, | 1034 | mbr_change_disk_geom(struct disk_partitions *arg, int ncyl, int nhead, | |
961 | int nsec) | 1035 | int nsec) | |
962 | { | 1036 | { | |
963 | struct mbr_disk_partitions *parts = (struct mbr_disk_partitions *)arg; | 1037 | struct mbr_disk_partitions *parts = (struct mbr_disk_partitions *)arg; | |
964 | daddr_t ptn_0_base, ptn_0_limit; | 1038 | daddr_t ptn_0_base, ptn_0_limit; | |
965 | struct disk_part_info info; | 1039 | struct disk_part_info info; | |
966 | 1040 | |||
967 | /* Default to using 'traditional' cylinder alignment */ | 1041 | /* Default to using 'traditional' cylinder alignment */ | |
968 | mbr_init_chs(parts, ncyl, nhead, nsec); | 1042 | mbr_init_chs(parts, ncyl, nhead, nsec); | |
969 | mbr_init_default_alignments(parts, nhead * nsec); | 1043 | mbr_init_default_alignments(parts, nhead * nsec); | |
970 | 1044 | |||
971 | if (parts->dp.disk_size <= TINY_DISK_SIZE) { | 1045 | if (parts->dp.disk_size <= TINY_DISK_SIZE) { | |
972 | set_default_sizemult(1); | 1046 | set_default_sizemult(arg->disk, | |
1047 | parts->dp.bytes_per_sector, parts->dp.bytes_per_sector); | |||
973 | return true; | 1048 | return true; | |
974 | } | 1049 | } | |
975 | 1050 | |||
976 | if (parts->dp.num_part > 0 && | 1051 | if (parts->dp.num_part > 0 && | |
977 | parts->dp.pscheme->get_part_info(arg, 0, &info)) { | 1052 | parts->dp.pscheme->get_part_info(arg, 0, &info)) { | |
978 | 1053 | |||
979 | /* Try to copy offset of first partition */ | 1054 | /* Try to copy offset of first partition */ | |
980 | ptn_0_base = info.start; | 1055 | ptn_0_base = info.start; | |
981 | ptn_0_limit = info.start + info.size; | 1056 | ptn_0_limit = info.start + info.size; | |
982 | if (!(ptn_0_limit & 2047)) { | 1057 | if (!(ptn_0_limit & 2047)) { | |
983 | /* Partition ends on a 1MB boundary, align to 1MB */ | 1058 | /* Partition ends on a 1MB boundary, align to 1MB */ | |
984 | parts->ptn_alignment = 2048; | 1059 | parts->ptn_alignment = 2048; | |
985 | if ((ptn_0_base <= 2048 | 1060 | if ((ptn_0_base <= 2048 | |
986 | && !(ptn_0_base & (ptn_0_base - 1))) | 1061 | && !(ptn_0_base & (ptn_0_base - 1))) | |
987 | || (ptn_0_base < parts->ptn_0_offset)) { | 1062 | || (ptn_0_base < parts->ptn_0_offset)) { | |
988 | /* | 1063 | /* | |
989 | * If ptn_base is a power of 2, use it. | 1064 | * If ptn_base is a power of 2, use it. | |
990 | * Also use it if the first partition | 1065 | * Also use it if the first partition | |
991 | * already is close to the begining | 1066 | * already is close to the begining | |
992 | * of the disk and we can't enforce | 1067 | * of the disk and we can't enforce | |
993 | * better alignment. | 1068 | * better alignment. | |
994 | */ | 1069 | */ | |
995 | parts->ptn_0_offset = ptn_0_base; | 1070 | parts->ptn_0_offset = ptn_0_base; | |
996 | } | 1071 | } | |
997 | } | 1072 | } | |
998 | } | 1073 | } | |
999 | set_default_sizemult(MEG/512); | 1074 | set_default_sizemult(arg->disk, MEG, parts->dp.bytes_per_sector); | |
1000 | return true; | 1075 | return true; | |
1001 | } | 1076 | } | |
1002 | 1077 | |||
1003 | static size_t | 1078 | static size_t | |
1004 | mbr_type_from_gen_desc(const struct part_type_desc *desc) | 1079 | mbr_type_from_gen_desc(const struct part_type_desc *desc) | |
1005 | { | 1080 | { | |
1006 | for (size_t i = 0; i < __arraycount(mbr_gen_type_desc); i++) | 1081 | for (size_t i = 0; i < __arraycount(mbr_gen_type_desc); i++) | |
1007 | if (&mbr_gen_type_desc[i].gen == desc) | 1082 | if (&mbr_gen_type_desc[i].gen == desc) | |
1008 | return i; | 1083 | return i; | |
1009 | 1084 | |||
1010 | return SIZE_T_MAX; | 1085 | return SIZE_T_MAX; | |
1011 | } | 1086 | } | |
1012 | 1087 | |||
@@ -1747,37 +1822,37 @@ mbr_read_disklabel(struct disk_partition | @@ -1747,37 +1822,37 @@ mbr_read_disklabel(struct disk_partition | |||
1747 | part.start, myparts->ptn_alignment, -1, -1)) | 1822 | part.start, myparts->ptn_alignment, -1, -1)) | |
1748 | return NULL; | 1823 | return NULL; | |
1749 | part.start = space.start; | 1824 | part.start = space.start; | |
1750 | part.size = space.size; | 1825 | part.size = space.size; | |
1751 | part.nat_type = &mbr_gen_type_desc[MBR_PTYPE_NETBSD].gen; | 1826 | part.nat_type = &mbr_gen_type_desc[MBR_PTYPE_NETBSD].gen; | |
1752 | mbr_add_part(arg, &part, NULL); | 1827 | mbr_add_part(arg, &part, NULL); | |
1753 | if (!mbr_find_netbsd(&myparts->mbr, start, &part)) | 1828 | if (!mbr_find_netbsd(&myparts->mbr, start, &part)) | |
1754 | return NULL; | 1829 | return NULL; | |
1755 | } | 1830 | } | |
1756 | 1831 | |||
1757 | if (!force_empty) { | 1832 | if (!force_empty) { | |
1758 | myparts->dlabel = disklabel_parts.read_from_disk( | 1833 | myparts->dlabel = disklabel_parts.read_from_disk( | |
1759 | myparts->dp.disk, part.start, part.size, | 1834 | myparts->dp.disk, part.start, part.size, | |
1760 | &disklabel_parts); | 1835 | myparts->dp.bytes_per_sector, &disklabel_parts); | |
1761 | if (myparts->dlabel != NULL) | 1836 | if (myparts->dlabel != NULL) | |
1762 | myparts->dlabel->parent = &myparts->dp; | 1837 | myparts->dlabel->parent = &myparts->dp; | |
1763 | } | 1838 | } | |
1764 | 1839 | |||
1765 | if (myparts->dlabel == NULL && part.size > 0) { | 1840 | if (myparts->dlabel == NULL && part.size > 0) { | |
1766 | /* we just created the outer partitions? */ | 1841 | /* we just created the outer partitions? */ | |
1767 | myparts->dlabel = | 1842 | myparts->dlabel = | |
1768 | disklabel_parts.create_new_for_disk( | 1843 | disklabel_parts.create_new_for_disk( | |
1769 | myparts->dp.disk, part.start, part.size, | 1844 | myparts->dp.disk, part.start, part.size, | |
1770 | myparts->dp.disk_size, false, &myparts->dp); | 1845 | false, &myparts->dp); | |
1771 | } | 1846 | } | |
1772 | 1847 | |||
1773 | if (myparts->dlabel != NULL) | 1848 | if (myparts->dlabel != NULL) | |
1774 | myparts->dlabel->pscheme->change_disk_geom( | 1849 | myparts->dlabel->pscheme->change_disk_geom( | |
1775 | myparts->dlabel, myparts->geo_cyl, | 1850 | myparts->dlabel, myparts->geo_cyl, | |
1776 | myparts->geo_head, myparts->geo_sec); | 1851 | myparts->geo_head, myparts->geo_sec); | |
1777 | } | 1852 | } | |
1778 | return myparts->dlabel; | 1853 | return myparts->dlabel; | |
1779 | } | 1854 | } | |
1780 | 1855 | |||
1781 | static int | 1856 | static int | |
1782 | get_mapping(struct mbr_partition *parts, int i, | 1857 | get_mapping(struct mbr_partition *parts, int i, | |
1783 | int *cylinder, int *head, int *sector, daddr_t *absolute) | 1858 | int *cylinder, int *head, int *sector, daddr_t *absolute) |
--- src/usr.sbin/sysinst/menus.mi 2020/01/09 13:22:30 1.20
+++ src/usr.sbin/sysinst/menus.mi 2020/01/27 21:21:22 1.21
--- src/usr.sbin/sysinst/partitions.c 2019/12/15 12:01:05 1.8
+++ src/usr.sbin/sysinst/partitions.c 2020/01/27 21:21:22 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: partitions.c,v 1.8 2019/12/15 12:01:05 martin Exp $ */ | 1 | /* $NetBSD: partitions.c,v 1.9 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2018 The NetBSD Foundation, Inc. | 4 | * Copyright 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -32,43 +32,47 @@ | @@ -32,43 +32,47 @@ | |||
32 | #include <assert.h> | 32 | #include <assert.h> | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * A list of partitioning schemes, so we can iterate over everything | 35 | * A list of partitioning schemes, so we can iterate over everything | |
36 | * supported (e.g. when partitioning a new disk). NULL terminated. | 36 | * supported (e.g. when partitioning a new disk). NULL terminated. | |
37 | */ | 37 | */ | |
38 | const struct disk_partitioning_scheme **available_part_schemes; | 38 | const struct disk_partitioning_scheme **available_part_schemes; | |
39 | /* | 39 | /* | |
40 | * The number of valid entries on above list | 40 | * The number of valid entries on above list | |
41 | */ | 41 | */ | |
42 | size_t num_available_part_schemes; | 42 | size_t num_available_part_schemes; | |
43 | 43 | |||
44 | /* | 44 | /* | |
45 | * Generic reader - query a disk device and read all partitions from it | 45 | * Generic reader - query a disk device and read all partitions from it. | |
46 | * disk_size is in units of physical sector size, which is passe as | |||
47 | * bytes_per_sec. | |||
46 | */ | 48 | */ | |
47 | struct disk_partitions * | 49 | struct disk_partitions * | |
48 | partitions_read_disk(const char *dev, daddr_t disk_size, bool no_mbr) | 50 | partitions_read_disk(const char *dev, daddr_t disk_size, size_t bytes_per_sec, | |
51 | bool no_mbr) | |||
49 | { | 52 | { | |
50 | const struct disk_partitioning_scheme **ps; | 53 | const struct disk_partitioning_scheme **ps; | |
51 | 54 | |||
52 | if (!available_part_schemes) | 55 | if (!available_part_schemes) | |
53 | return NULL; | 56 | return NULL; | |
54 | 57 | |||
55 | for (ps = available_part_schemes; *ps; ps++) { | 58 | for (ps = available_part_schemes; *ps; ps++) { | |
56 | #ifdef HAVE_MBR | 59 | #ifdef HAVE_MBR | |
57 | if (no_mbr && (*ps)->name == MSG_parttype_mbr) | 60 | if (no_mbr && (*ps)->name == MSG_parttype_mbr) | |
58 | continue; | 61 | continue; | |
59 | #endif | 62 | #endif | |
60 | struct disk_partitions *parts = | 63 | struct disk_partitions *parts = | |
61 | (*ps)->read_from_disk(dev, 0, disk_size, *ps); | 64 | (*ps)->read_from_disk(dev, 0, disk_size, bytes_per_sec, | |
65 | *ps); | |||
62 | if (parts) | 66 | if (parts) | |
63 | return parts; | 67 | return parts; | |
64 | } | 68 | } | |
65 | return NULL; | 69 | return NULL; | |
66 | } | 70 | } | |
67 | 71 | |||
68 | bool | 72 | bool | |
69 | generic_adapt_foreign_part_info(const struct disk_partitions *myself, | 73 | generic_adapt_foreign_part_info(const struct disk_partitions *myself, | |
70 | struct disk_part_info *dest, | 74 | struct disk_part_info *dest, | |
71 | const struct disk_partitioning_scheme *src_scheme, | 75 | const struct disk_partitioning_scheme *src_scheme, | |
72 | const struct disk_part_info *src) | 76 | const struct disk_part_info *src) | |
73 | { | 77 | { | |
74 | *dest = *src; | 78 | *dest = *src; |
--- src/usr.sbin/sysinst/partitions.h 2020/01/15 19:36:30 1.14
+++ src/usr.sbin/sysinst/partitions.h 2020/01/27 21:21:22 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: partitions.h,v 1.14 2020/01/15 19:36:30 martin Exp $ */ | 1 | /* $NetBSD: partitions.h,v 1.15 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2018 The NetBSD Foundation, Inc. | 4 | * Copyright 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,26 +21,37 @@ | @@ -21,26 +21,37 @@ | |||
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
26 | * THE POSSIBILITY OF SUCH DAMAGE. | 26 | * THE POSSIBILITY OF SUCH DAMAGE. | |
27 | * | 27 | * | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | /* | 30 | /* | |
31 | * Abstract interface to access arbitrary disk partitioning schemes and | 31 | * Abstract interface to access arbitrary disk partitioning schemes and | |
32 | * keep Sysinst proper independent of the implementation / on-disk | 32 | * keep Sysinst proper independent of the implementation / on-disk | |
33 | * details. | 33 | * details. | |
34 | * | |||
35 | * NOTE: | |||
36 | * - all sector numbers, alignement and sizes are in units of the | |||
37 | * disks physical sector size (not necessarily 512 bytes)! | |||
38 | * - some interfaces pass the disks sector size (when it is easily | |||
39 | * available at typical callers), but the backends can always | |||
40 | * assume it to be equal to the real physical sector size. If | |||
41 | * no value is passed, the backend can query the disk data | |||
42 | * via get_disk_geom(). | |||
43 | * - single exception: disk_partitioning_scheme::size_limit is in 512 | |||
44 | * byte sectors (as it is not associated with a concrete disk) | |||
34 | */ | 45 | */ | |
35 | 46 | |||
36 | #include <sys/types.h> | 47 | #include <sys/types.h> | |
37 | #include <stdbool.h> | 48 | #include <stdbool.h> | |
38 | #include "msg_defs.h" | 49 | #include "msg_defs.h" | |
39 | 50 | |||
40 | /* | 51 | /* | |
41 | * Import all the file system types, as enum fs_type. | 52 | * Import all the file system types, as enum fs_type. | |
42 | */ | 53 | */ | |
43 | #define FSTYPE_ENUMNAME fs_type | 54 | #define FSTYPE_ENUMNAME fs_type | |
44 | #define FSTYPENAMES | 55 | #define FSTYPENAMES | |
45 | #include <sys/disklabel.h> | 56 | #include <sys/disklabel.h> | |
46 | #undef FSTYPE_ENUMNAME | 57 | #undef FSTYPE_ENUMNAME | |
@@ -170,27 +181,30 @@ enum dev_name_usage { | @@ -170,27 +181,30 @@ enum dev_name_usage { | |||
170 | * A scheme how to store partitions on-disk, and methods to read/write | 181 | * A scheme how to store partitions on-disk, and methods to read/write | |
171 | * them to/from our abstract internal presentation. | 182 | * them to/from our abstract internal presentation. | |
172 | */ | 183 | */ | |
173 | struct disk_partitioning_scheme { | 184 | struct disk_partitioning_scheme { | |
174 | /* name of the on-disk scheme, retrieved via msg_string */ | 185 | /* name of the on-disk scheme, retrieved via msg_string */ | |
175 | msg name, short_name; | 186 | msg name, short_name; | |
176 | 187 | |||
177 | /* prompt shown when creating custom partition types */ | 188 | /* prompt shown when creating custom partition types */ | |
178 | msg new_type_prompt; | 189 | msg new_type_prompt; | |
179 | 190 | |||
180 | /* description of scheme specific partition flags */ | 191 | /* description of scheme specific partition flags */ | |
181 | msg part_flag_desc; | 192 | msg part_flag_desc; | |
182 | 193 | |||
183 | /* size restrictions for this partitioning scheme */ | 194 | /* | |
195 | * size restrictions for this partitioning scheme (number | |||
196 | * of 512 byte sectors max) | |||
197 | */ | |||
184 | daddr_t size_limit; /* 0 if not limited */ | 198 | daddr_t size_limit; /* 0 if not limited */ | |
185 | 199 | |||
186 | /* | 200 | /* | |
187 | * If this scheme allows sub-partitions (i.e. MBR -> disklabel), | 201 | * If this scheme allows sub-partitions (i.e. MBR -> disklabel), | |
188 | * this is a pointer to the (potential/optional) secondary | 202 | * this is a pointer to the (potential/optional) secondary | |
189 | * scheme. Depending on partitioning details it may not be | 203 | * scheme. Depending on partitioning details it may not be | |
190 | * used in the end. | 204 | * used in the end. | |
191 | * This link is only here for better help messages. | 205 | * This link is only here for better help messages. | |
192 | * See *secondary_partitions further below for actually accesing | 206 | * See *secondary_partitions further below for actually accesing | |
193 | * secondary partitions. | 207 | * secondary partitions. | |
194 | */ | 208 | */ | |
195 | const struct disk_partitioning_scheme *secondary_scheme; | 209 | const struct disk_partitioning_scheme *secondary_scheme; | |
196 | 210 | |||
@@ -425,35 +439,35 @@ struct disk_partitioning_scheme { | @@ -425,35 +439,35 @@ struct disk_partitioning_scheme { | |||
425 | * Write the whole set (in new_state) back to disk. | 439 | * Write the whole set (in new_state) back to disk. | |
426 | */ | 440 | */ | |
427 | bool (*write_to_disk)(struct disk_partitions *new_state); | 441 | bool (*write_to_disk)(struct disk_partitions *new_state); | |
428 | 442 | |||
429 | /* | 443 | /* | |
430 | * Try to read partitions from a disk, return NULL if this is not | 444 | * Try to read partitions from a disk, return NULL if this is not | |
431 | * the partitioning scheme in use on that device. | 445 | * the partitioning scheme in use on that device. | |
432 | * Usually start and len are 0 (and ignored). | 446 | * Usually start and len are 0 (and ignored). | |
433 | * If this is about a part of a disk (like only the NetBSD | 447 | * If this is about a part of a disk (like only the NetBSD | |
434 | * MBR partition, start and len are the valid part of the | 448 | * MBR partition, start and len are the valid part of the | |
435 | * disk. | 449 | * disk. | |
436 | */ | 450 | */ | |
437 | struct disk_partitions * (*read_from_disk)(const char *, | 451 | struct disk_partitions * (*read_from_disk)(const char *, | |
438 | daddr_t start, daddr_t len, const struct | 452 | daddr_t start, daddr_t len, size_t bytes_per_sec, | |
439 | disk_partitioning_scheme *); | 453 | const struct disk_partitioning_scheme *); | |
440 | 454 | |||
441 | /* | 455 | /* | |
442 | * Set up all internal data for a new disk | 456 | * Set up all internal data for a new disk. | |
443 | */ | 457 | */ | |
444 | struct disk_partitions * (*create_new_for_disk)(const char *, | 458 | struct disk_partitions * (*create_new_for_disk)(const char *, | |
445 | daddr_t start, daddr_t len, daddr_t disk_total_size, | 459 | daddr_t start, daddr_t len, bool is_boot_drive, | |
446 | bool is_boot_drive, struct disk_partitions *parent); | 460 | struct disk_partitions *parent); | |
447 | 461 | |||
448 | /* | 462 | /* | |
449 | * Optional: this scheme may be used to boot from the given disk | 463 | * Optional: this scheme may be used to boot from the given disk | |
450 | */ | 464 | */ | |
451 | bool (*have_boot_support)(const char *disk); | 465 | bool (*have_boot_support)(const char *disk); | |
452 | 466 | |||
453 | /* | 467 | /* | |
454 | * Optional: try to guess disk geometry from the partition information | 468 | * Optional: try to guess disk geometry from the partition information | |
455 | */ | 469 | */ | |
456 | int (*guess_disk_geom)(struct disk_partitions *, | 470 | int (*guess_disk_geom)(struct disk_partitions *, | |
457 | int *cyl, int *head, int *sec); | 471 | int *cyl, int *head, int *sec); | |
458 | 472 | |||
459 | /* | 473 | /* | |
@@ -532,26 +546,32 @@ struct disk_partitioning_scheme { | @@ -532,26 +546,32 @@ struct disk_partitioning_scheme { | |||
532 | * structure (by aggregation), but consumers of the API will only | 546 | * structure (by aggregation), but consumers of the API will only | |
533 | * ever see this public part. | 547 | * ever see this public part. | |
534 | */ | 548 | */ | |
535 | struct disk_partitions { | 549 | struct disk_partitions { | |
536 | /* which partitioning scheme is in use */ | 550 | /* which partitioning scheme is in use */ | |
537 | const struct disk_partitioning_scheme *pscheme; | 551 | const struct disk_partitioning_scheme *pscheme; | |
538 | 552 | |||
539 | /* the disk device this came from (or should go to) */ | 553 | /* the disk device this came from (or should go to) */ | |
540 | const char *disk; | 554 | const char *disk; | |
541 | 555 | |||
542 | /* global/public disk data */ | 556 | /* global/public disk data */ | |
543 | 557 | |||
544 | /* | 558 | /* | |
559 | * The basic unit of size used for this disk (all "start", | |||
560 | * "size" and "align" values are in this unit). | |||
561 | */ | |||
562 | size_t bytes_per_sector; /* must be 2^n and >= 512 */ | |||
563 | ||||
564 | /* | |||
545 | * Valid partitions may have IDs in the range 0 .. num_part (excl.) | 565 | * Valid partitions may have IDs in the range 0 .. num_part (excl.) | |
546 | */ | 566 | */ | |
547 | part_id num_part; | 567 | part_id num_part; | |
548 | 568 | |||
549 | /* | 569 | /* | |
550 | * If this is a sub-partitioning, the start of the "disk" is | 570 | * If this is a sub-partitioning, the start of the "disk" is | |
551 | * some arbitrary partition in the parent. Sometimes we need | 571 | * some arbitrary partition in the parent. Sometimes we need | |
552 | * to be able to calculate absoluted offsets. | 572 | * to be able to calculate absoluted offsets. | |
553 | */ | 573 | */ | |
554 | daddr_t disk_start; | 574 | daddr_t disk_start; | |
555 | /* | 575 | /* | |
556 | * Total size of the disk (usable for partitioning) | 576 | * Total size of the disk (usable for partitioning) | |
557 | */ | 577 | */ | |
@@ -570,27 +590,28 @@ struct disk_partitions { | @@ -570,27 +590,28 @@ struct disk_partitions { | |||
570 | }; | 590 | }; | |
571 | 591 | |||
572 | /* | 592 | /* | |
573 | * A list of partitioning schemes, so we can iterate over everything | 593 | * A list of partitioning schemes, so we can iterate over everything | |
574 | * supported (e.g. when partitioning a new disk). NULL terminated. | 594 | * supported (e.g. when partitioning a new disk). NULL terminated. | |
575 | */ | 595 | */ | |
576 | extern const struct disk_partitioning_scheme **available_part_schemes; | 596 | extern const struct disk_partitioning_scheme **available_part_schemes; | |
577 | extern size_t num_available_part_schemes; | 597 | extern size_t num_available_part_schemes; | |
578 | 598 | |||
579 | /* | 599 | /* | |
580 | * Generic reader - query a disk device and read all partitions from it | 600 | * Generic reader - query a disk device and read all partitions from it | |
581 | */ | 601 | */ | |
582 | struct disk_partitions * | 602 | struct disk_partitions * | |
583 | partitions_read_disk(const char *, daddr_t disk_size, bool no_mbr); | 603 | partitions_read_disk(const char *, daddr_t disk_size, | |
604 | size_t bytes_per_sector, bool no_mbr); | |||
584 | 605 | |||
585 | /* | 606 | /* | |
586 | * Generic part info adaption, may be overriden by individual partitionin | 607 | * Generic part info adaption, may be overriden by individual partitionin | |
587 | * schemes | 608 | * schemes | |
588 | */ | 609 | */ | |
589 | bool generic_adapt_foreign_part_info( | 610 | bool generic_adapt_foreign_part_info( | |
590 | const struct disk_partitions *myself, struct disk_part_info *dest, | 611 | const struct disk_partitions *myself, struct disk_part_info *dest, | |
591 | const struct disk_partitioning_scheme *src_scheme, | 612 | const struct disk_partitioning_scheme *src_scheme, | |
592 | const struct disk_part_info *src); | 613 | const struct disk_part_info *src); | |
593 | 614 | |||
594 | /* | 615 | /* | |
595 | * One time initialization and clenaup | 616 | * One time initialization and clenaup | |
596 | */ | 617 | */ |
--- src/usr.sbin/sysinst/partman.c 2020/01/15 19:08:24 1.48
+++ src/usr.sbin/sysinst/partman.c 2020/01/27 21:21:22 1.49
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: partman.c,v 1.48 2020/01/15 19:08:24 martin Exp $ */ | 1 | /* $NetBSD: partman.c,v 1.49 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2012 Eugene Lozovoy | 4 | * Copyright 2012 Eugene Lozovoy | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -235,39 +235,39 @@ enum { /* LVM submenu (logical volumes) | @@ -235,39 +235,39 @@ enum { /* LVM submenu (logical volumes) | |||
235 | PMLV_MENU_STRIPES, PMLV_MENU_STRIPESIZE, PMLV_MENU_ZERO, | 235 | PMLV_MENU_STRIPES, PMLV_MENU_STRIPESIZE, PMLV_MENU_ZERO, | |
236 | PMLV_MENU_REMOVE, PMLV_MENU_END | 236 | PMLV_MENU_REMOVE, PMLV_MENU_END | |
237 | }; | 237 | }; | |
238 | 238 | |||
239 | struct part_entry pm_dev_list(int); | 239 | struct part_entry pm_dev_list(int); | |
240 | static int pm_raid_disk_add(menudesc *, void *); | 240 | static int pm_raid_disk_add(menudesc *, void *); | |
241 | static int pm_raid_disk_del(menudesc *, void *); | 241 | static int pm_raid_disk_del(menudesc *, void *); | |
242 | static int pm_cgd_disk_set(struct cgd_desc *, struct part_entry *); | 242 | static int pm_cgd_disk_set(struct cgd_desc *, struct part_entry *); | |
243 | static int pm_mount(struct pm_devs *, int); | 243 | static int pm_mount(struct pm_devs *, int); | |
244 | static int pm_upddevlist(menudesc *, void *); | 244 | static int pm_upddevlist(menudesc *, void *); | |
245 | static void pm_select(struct pm_devs *); | 245 | static void pm_select(struct pm_devs *); | |
246 | 246 | |||
247 | static void | 247 | static void | |
248 | pm_edit_size_value(msg prompt_msg, daddr_t cylsec, daddr_t *size) | 248 | pm_edit_size_value(msg prompt_msg, daddr_t bps, daddr_t cylsec, daddr_t *size) | |
249 | { | 249 | { | |
250 | 250 | |||
251 | char answer[16], dflt[16]; | 251 | char answer[16], dflt[16]; | |
252 | daddr_t new_size_val, mult; | 252 | daddr_t new_size_val, mult; | |
253 | 253 | |||
254 | snprintf(dflt, sizeof dflt, "%" PRIu64 "%s", *size / sizemult, | 254 | snprintf(dflt, sizeof dflt, "%" PRIu64 "%s", *size / sizemult, | |
255 | multname); | 255 | multname); | |
256 | 256 | |||
257 | msg_prompt_win(prompt_msg, -1, 18, 0, 0, dflt, answer, sizeof answer); | 257 | msg_prompt_win(prompt_msg, -1, 18, 0, 0, dflt, answer, sizeof answer); | |
258 | 258 | |||
259 | mult = sizemult; | 259 | mult = sizemult; | |
260 | new_size_val = parse_disk_pos(answer, &mult, cylsec, NULL); | 260 | new_size_val = parse_disk_pos(answer, &mult, bps, cylsec, NULL); | |
261 | 261 | |||
262 | if (new_size_val > 0) | 262 | if (new_size_val > 0) | |
263 | *size = new_size_val * mult; | 263 | *size = new_size_val * mult; | |
264 | } | 264 | } | |
265 | 265 | |||
266 | static const char * | 266 | static const char * | |
267 | pm_get_mount(struct pm_devs *p, part_id id) | 267 | pm_get_mount(struct pm_devs *p, part_id id) | |
268 | { | 268 | { | |
269 | 269 | |||
270 | if (p->mounted == NULL) | 270 | if (p->mounted == NULL) | |
271 | return NULL; | 271 | return NULL; | |
272 | if (id >= p->parts->num_part) | 272 | if (id >= p->parts->num_part) | |
273 | return NULL; | 273 | return NULL; | |
@@ -1047,27 +1047,28 @@ pm_vnd_set_value(menudesc *m, void *arg) | @@ -1047,27 +1047,28 @@ pm_vnd_set_value(menudesc *m, void *arg) | |||
1047 | } | 1047 | } | |
1048 | if (dev_ptr->filepath[strlen(dev_ptr->filepath) - 1] | 1048 | if (dev_ptr->filepath[strlen(dev_ptr->filepath) - 1] | |
1049 | == '/') | 1049 | == '/') | |
1050 | dev_ptr->filepath[strlen(dev_ptr->filepath) | 1050 | dev_ptr->filepath[strlen(dev_ptr->filepath) | |
1051 | - 1] = '\0'; | 1051 | - 1] = '\0'; | |
1052 | return 0; | 1052 | return 0; | |
1053 | case PMV_MENU_EXIST: | 1053 | case PMV_MENU_EXIST: | |
1054 | dev_ptr->is_exist = !dev_ptr->is_exist; | 1054 | dev_ptr->is_exist = !dev_ptr->is_exist; | |
1055 | return 0; | 1055 | return 0; | |
1056 | case PMV_MENU_SIZE: | 1056 | case PMV_MENU_SIZE: | |
1057 | if (dev_ptr->is_exist) | 1057 | if (dev_ptr->is_exist) | |
1058 | return 0; | 1058 | return 0; | |
1059 | 1059 | |||
1060 | pm_edit_size_value(MSG_vnd_size_ask, pm->dlcylsize, | 1060 | pm_edit_size_value(MSG_vnd_size_ask, | |
1061 | pm->sectorsize, pm->dlcylsize, | |||
1061 | &dev_ptr->size); | 1062 | &dev_ptr->size); | |
1062 | 1063 | |||
1063 | break; | 1064 | break; | |
1064 | case PMV_MENU_RO: | 1065 | case PMV_MENU_RO: | |
1065 | dev_ptr->readonly = !dev_ptr->readonly; | 1066 | dev_ptr->readonly = !dev_ptr->readonly; | |
1066 | return 0; | 1067 | return 0; | |
1067 | case PMV_MENU_MGEOM: | 1068 | case PMV_MENU_MGEOM: | |
1068 | if (dev_ptr->is_exist) | 1069 | if (dev_ptr->is_exist) | |
1069 | return 0; | 1070 | return 0; | |
1070 | dev_ptr->manual_geom = !dev_ptr->manual_geom; | 1071 | dev_ptr->manual_geom = !dev_ptr->manual_geom; | |
1071 | return 0; | 1072 | return 0; | |
1072 | case PMV_MENU_SECSIZE: | 1073 | case PMV_MENU_SECSIZE: | |
1073 | if (!dev_ptr->manual_geom || dev_ptr->is_exist) | 1074 | if (!dev_ptr->manual_geom || dev_ptr->is_exist) | |
@@ -1871,27 +1872,28 @@ pm_lvmlv_set_value(menudesc *m, void *ar | @@ -1871,27 +1872,28 @@ pm_lvmlv_set_value(menudesc *m, void *ar | |||
1871 | { | 1872 | { | |
1872 | char buf[STRSIZE]; | 1873 | char buf[STRSIZE]; | |
1873 | const char *msg_to_show = NULL; | 1874 | const char *msg_to_show = NULL; | |
1874 | int *out_var = NULL; | 1875 | int *out_var = NULL; | |
1875 | lv_t *dev_ptr = arg; | 1876 | lv_t *dev_ptr = arg; | |
1876 | 1877 | |||
1877 | switch (m->cursel) { | 1878 | switch (m->cursel) { | |
1878 | case PMLV_MENU_NAME: | 1879 | case PMLV_MENU_NAME: | |
1879 | msg_prompt_win(MSG_lvmlv_name_ask, -1, 18, 0, 0, | 1880 | msg_prompt_win(MSG_lvmlv_name_ask, -1, 18, 0, 0, | |
1880 | dev_ptr->name, dev_ptr->name, SSTRSIZE); | 1881 | dev_ptr->name, dev_ptr->name, SSTRSIZE); | |
1881 | return 0; | 1882 | return 0; | |
1882 | case PMLV_MENU_SIZE: | 1883 | case PMLV_MENU_SIZE: | |
1883 | pm_edit_size_value(MSG_lvmlv_size_ask, | 1884 | pm_edit_size_value(MSG_lvmlv_size_ask, | |
1884 | pm->dlcylsize, &dev_ptr->size); /* XXX cylsize? */ | 1885 | pm->sectorsize, pm->dlcylsize, | |
1886 | &dev_ptr->size); /* XXX cylsize? */ | |||
1885 | break; | 1887 | break; | |
1886 | case PMLV_MENU_READONLY: | 1888 | case PMLV_MENU_READONLY: | |
1887 | dev_ptr->readonly = !dev_ptr->readonly; | 1889 | dev_ptr->readonly = !dev_ptr->readonly; | |
1888 | return 0; | 1890 | return 0; | |
1889 | case PMLV_MENU_CONTIGUOUS: | 1891 | case PMLV_MENU_CONTIGUOUS: | |
1890 | dev_ptr->contiguous = !dev_ptr->contiguous; | 1892 | dev_ptr->contiguous = !dev_ptr->contiguous; | |
1891 | return 0; | 1893 | return 0; | |
1892 | case PMLV_MENU_EXTENTS: | 1894 | case PMLV_MENU_EXTENTS: | |
1893 | msg_prompt_win(MSG_lvmlv_extnum_ask, -1, 18, 0, 0, | 1895 | msg_prompt_win(MSG_lvmlv_extnum_ask, -1, 18, 0, 0, | |
1894 | dev_ptr->extents, dev_ptr->extents, SSTRSIZE); | 1896 | dev_ptr->extents, dev_ptr->extents, SSTRSIZE); | |
1895 | return 0; | 1897 | return 0; | |
1896 | case PMLV_MENU_MINOR: | 1898 | case PMLV_MENU_MINOR: | |
1897 | msg_to_show = MSG_lvmlv_minor_ask; | 1899 | msg_to_show = MSG_lvmlv_minor_ask; | |
@@ -3220,28 +3222,28 @@ bool | @@ -3220,28 +3222,28 @@ bool | |||
3220 | pm_force_parts(struct pm_devs *my_pm) | 3222 | pm_force_parts(struct pm_devs *my_pm) | |
3221 | { | 3223 | { | |
3222 | if (my_pm == NULL) | 3224 | if (my_pm == NULL) | |
3223 | return false; | 3225 | return false; | |
3224 | if (my_pm->parts != NULL) | 3226 | if (my_pm->parts != NULL) | |
3225 | return true; | 3227 | return true; | |
3226 | 3228 | |||
3227 | const struct disk_partitioning_scheme *ps = | 3229 | const struct disk_partitioning_scheme *ps = | |
3228 | select_part_scheme(my_pm, NULL, false, NULL); | 3230 | select_part_scheme(my_pm, NULL, false, NULL); | |
3229 | if (ps == NULL) | 3231 | if (ps == NULL) | |
3230 | return false; | 3232 | return false; | |
3231 | 3233 | |||
3232 | struct disk_partitions *parts = | 3234 | struct disk_partitions *parts = | |
3233 | (*ps->create_new_for_disk)(my_pm->diskdev, 0, my_pm->dlsize, | 3235 | (*ps->create_new_for_disk)(my_pm->diskdev, 0, | |
3234 | my_pm->dlsize, false, NULL); | 3236 | my_pm->dlsize, false, NULL); | |
3235 | if (parts == NULL) | 3237 | if (parts == NULL) | |
3236 | return false; | 3238 | return false; | |
3237 | 3239 | |||
3238 | my_pm->parts = parts; | 3240 | my_pm->parts = parts; | |
3239 | if (pm->dlsize > ps->size_limit) | 3241 | if (pm->dlsize > ps->size_limit) | |
3240 | pm->dlsize = ps->size_limit; | 3242 | pm->dlsize = ps->size_limit; | |
3241 | 3243 | |||
3242 | return true; | 3244 | return true; | |
3243 | } | 3245 | } | |
3244 | 3246 | |||
3245 | void | 3247 | void | |
3246 | pm_edit_partitions(struct part_entry *pe) | 3248 | pm_edit_partitions(struct part_entry *pe) | |
3247 | { | 3249 | { |
--- src/usr.sbin/sysinst/sizemultname.c 2019/06/12 06:20:18 1.3
+++ src/usr.sbin/sysinst/sizemultname.c 2020/01/27 21:21:22 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sizemultname.c,v 1.3 2019/06/12 06:20:18 martin Exp $ */ | 1 | /* $NetBSD: sizemultname.c,v 1.4 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -39,46 +39,45 @@ | @@ -39,46 +39,45 @@ | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/sysctl.h> | 40 | #include <sys/sysctl.h> | |
41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> | |
42 | #include <curses.h> | 42 | #include <curses.h> | |
43 | #include <errno.h> | 43 | #include <errno.h> | |
44 | #include <fts.h> | 44 | #include <fts.h> | |
45 | #include <util.h> | 45 | #include <util.h> | |
46 | #include "defs.h" | 46 | #include "defs.h" | |
47 | #include "md.h" | 47 | #include "md.h" | |
48 | #include "msg_defs.h" | 48 | #include "msg_defs.h" | |
49 | #include "menu_defs.h" | 49 | #include "menu_defs.h" | |
50 | 50 | |||
51 | void | 51 | void | |
52 | set_sizemult(uint secs) | 52 | set_sizemult(daddr_t unit, uint bps) | |
53 | { | 53 | { | |
54 | if (secs == 0) | 54 | if (unit == 0 || bps == 0) | |
55 | return; | 55 | return; | |
56 | 56 | |||
57 | sizemult = secs; | 57 | sizemult = unit/bps; | |
58 | 58 | |||
59 | if (secs == 1) | 59 | if (sizemult == 1) | |
60 | multname = msg_string(MSG_secname); | 60 | multname = msg_string(MSG_secname); | |
61 | else if (secs == MEG/512) | 61 | else if (unit == MEG) | |
62 | multname = msg_string(MSG_megname); | 62 | multname = msg_string(MSG_megname); | |
63 | else if (secs == GIG/512) | 63 | else if (unit == GIG) | |
64 | multname = msg_string(MSG_gigname); | 64 | multname = msg_string(MSG_gigname); | |
65 | else | 65 | else | |
66 | multname = msg_string(MSG_cylname); | 66 | multname = msg_string(MSG_cylname); | |
67 | } | 67 | } | |
68 | 68 | |||
69 | /* | 69 | /* | |
70 | * Only first call sets it | 70 | * Only first call sets it | |
71 | */ | 71 | */ | |
72 | void | 72 | void | |
73 | set_default_sizemult(uint secs) | 73 | set_default_sizemult(const char *disk, daddr_t unit, uint bps) | |
74 | { | 74 | { | |
75 | static bool default_done; | 75 | static char last_dev[40]; | |
76 | 76 | |||
77 | if (default_done) | 77 | if (strcmp(disk, last_dev) == 0) | |
78 | return; | 78 | return; | |
79 | 79 | |||
80 | default_done = true; | 80 | strlcpy(last_dev, disk, sizeof last_dev); | |
81 | set_sizemult(secs); | 81 | set_sizemult(unit, bps); | |
82 | } | 82 | } | |
83 | 83 | |||
84 |
--- src/usr.sbin/sysinst/arch/arc/md.c 2020/01/09 13:22:30 1.11
+++ src/usr.sbin/sysinst/arch/arc/md.c 2020/01/27 21:21:22 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.11 2020/01/09 13:22:30 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.12 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -69,27 +69,27 @@ md_get_info(struct install_partition_des | @@ -69,27 +69,27 @@ md_get_info(struct install_partition_des | |||
69 | if (pm->no_mbr || pm->no_part) | 69 | if (pm->no_mbr || pm->no_part) | |
70 | return true; | 70 | return true; | |
71 | 71 | |||
72 | if (pm->parts == NULL) { | 72 | if (pm->parts == NULL) { | |
73 | 73 | |||
74 | const struct disk_partitioning_scheme *ps = | 74 | const struct disk_partitioning_scheme *ps = | |
75 | select_part_scheme(pm, NULL, true, NULL); | 75 | select_part_scheme(pm, NULL, true, NULL); | |
76 | 76 | |||
77 | if (!ps) | 77 | if (!ps) | |
78 | return false; | 78 | return false; | |
79 | 79 | |||
80 | struct disk_partitions *parts = | 80 | struct disk_partitions *parts = | |
81 | (*ps->create_new_for_disk)(pm->diskdev, | 81 | (*ps->create_new_for_disk)(pm->diskdev, | |
82 | 0, pm->dlsize, pm->dlsize, true, NULL); | 82 | 0, pm->dlsize, true, NULL); | |
83 | if (!parts) | 83 | if (!parts) | |
84 | return false; | 84 | return false; | |
85 | 85 | |||
86 | pm->parts = parts; | 86 | pm->parts = parts; | |
87 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 87 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
88 | pm->dlsize = ps->size_limit; | 88 | pm->dlsize = ps->size_limit; | |
89 | } | 89 | } | |
90 | 90 | |||
91 | return set_bios_geom_with_mbr_guess(pm->parts); | 91 | return set_bios_geom_with_mbr_guess(pm->parts); | |
92 | } | 92 | } | |
93 | 93 | |||
94 | /* | 94 | /* | |
95 | * md back-end code for menu-driven BSD disklabel editor. | 95 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/bebox/md.c 2020/01/09 13:22:31 1.7
+++ src/usr.sbin/sysinst/arch/bebox/md.c 2020/01/27 21:21:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | @@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | |||
62 | if (pm->no_mbr || pm->no_part) | 62 | if (pm->no_mbr || pm->no_part) | |
63 | return true; | 63 | return true; | |
64 | 64 | |||
65 | if (pm->parts == NULL) { | 65 | if (pm->parts == NULL) { | |
66 | 66 | |||
67 | const struct disk_partitioning_scheme *ps = | 67 | const struct disk_partitioning_scheme *ps = | |
68 | select_part_scheme(pm, NULL, true, NULL); | 68 | select_part_scheme(pm, NULL, true, NULL); | |
69 | 69 | |||
70 | if (!ps) | 70 | if (!ps) | |
71 | return false; | 71 | return false; | |
72 | 72 | |||
73 | struct disk_partitions *parts = | 73 | struct disk_partitions *parts = | |
74 | (*ps->create_new_for_disk)(pm->diskdev, | 74 | (*ps->create_new_for_disk)(pm->diskdev, | |
75 | 0, pm->dlsize, pm->dlsize, true, NULL); | 75 | 0, pm->dlsize, true, NULL); | |
76 | if (!parts) | 76 | if (!parts) | |
77 | return false; | 77 | return false; | |
78 | 78 | |||
79 | pm->parts = parts; | 79 | pm->parts = parts; | |
80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
81 | pm->dlsize = ps->size_limit; | 81 | pm->dlsize = ps->size_limit; | |
82 | } | 82 | } | |
83 | 83 | |||
84 | return set_bios_geom_with_mbr_guess(pm->parts); | 84 | return set_bios_geom_with_mbr_guess(pm->parts); | |
85 | } | 85 | } | |
86 | 86 | |||
87 | /* | 87 | /* | |
88 | * md back-end code for menu-driven BSD disklabel editor. | 88 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/cobalt/md.c 2020/01/09 13:22:31 1.11
+++ src/usr.sbin/sysinst/arch/cobalt/md.c 2020/01/27 21:21:22 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.11 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.12 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -69,27 +69,27 @@ md_get_info(struct install_partition_des | @@ -69,27 +69,27 @@ md_get_info(struct install_partition_des | |||
69 | if (pm->no_mbr || pm->no_part) | 69 | if (pm->no_mbr || pm->no_part) | |
70 | return true; | 70 | return true; | |
71 | 71 | |||
72 | if (pm->parts == NULL) { | 72 | if (pm->parts == NULL) { | |
73 | 73 | |||
74 | const struct disk_partitioning_scheme *ps = | 74 | const struct disk_partitioning_scheme *ps = | |
75 | select_part_scheme(pm, NULL, true, NULL); | 75 | select_part_scheme(pm, NULL, true, NULL); | |
76 | 76 | |||
77 | if (!ps) | 77 | if (!ps) | |
78 | return false; | 78 | return false; | |
79 | 79 | |||
80 | struct disk_partitions *parts = | 80 | struct disk_partitions *parts = | |
81 | (*ps->create_new_for_disk)(pm->diskdev, | 81 | (*ps->create_new_for_disk)(pm->diskdev, | |
82 | 0, pm->dlsize, pm->dlsize, true, NULL); | 82 | 0, pm->dlsize, true, NULL); | |
83 | if (!parts) | 83 | if (!parts) | |
84 | return false; | 84 | return false; | |
85 | 85 | |||
86 | pm->parts = parts; | 86 | pm->parts = parts; | |
87 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 87 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
88 | pm->dlsize = ps->size_limit; | 88 | pm->dlsize = ps->size_limit; | |
89 | } | 89 | } | |
90 | 90 | |||
91 | return set_bios_geom_with_mbr_guess(pm->parts); | 91 | return set_bios_geom_with_mbr_guess(pm->parts); | |
92 | } | 92 | } | |
93 | 93 | |||
94 | /* | 94 | /* | |
95 | * md back-end code for menu-driven BSD disklabel editor. | 95 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/evbarm/md.c 2020/01/20 21:26:35 1.13
+++ src/usr.sbin/sysinst/arch/evbarm/md.c 2020/01/27 21:21:22 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.13 2020/01/20 21:26:35 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.14 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -97,27 +97,27 @@ md_get_info(struct install_partition_des | @@ -97,27 +97,27 @@ md_get_info(struct install_partition_des | |||
97 | if (pm->no_mbr || pm->no_part) | 97 | if (pm->no_mbr || pm->no_part) | |
98 | return true; | 98 | return true; | |
99 | 99 | |||
100 | if (pm->parts == NULL) { | 100 | if (pm->parts == NULL) { | |
101 | 101 | |||
102 | const struct disk_partitioning_scheme *ps = | 102 | const struct disk_partitioning_scheme *ps = | |
103 | select_part_scheme(pm, NULL, true, NULL); | 103 | select_part_scheme(pm, NULL, true, NULL); | |
104 | 104 | |||
105 | if (!ps) | 105 | if (!ps) | |
106 | return false; | 106 | return false; | |
107 | 107 | |||
108 | struct disk_partitions *parts = | 108 | struct disk_partitions *parts = | |
109 | (*ps->create_new_for_disk)(pm->diskdev, | 109 | (*ps->create_new_for_disk)(pm->diskdev, | |
110 | 0, pm->dlsize, pm->dlsize, true, NULL); | 110 | 0, pm->dlsize, true, NULL); | |
111 | if (!parts) | 111 | if (!parts) | |
112 | return false; | 112 | return false; | |
113 | 113 | |||
114 | pm->parts = parts; | 114 | pm->parts = parts; | |
115 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 115 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
116 | pm->dlsize = ps->size_limit; | 116 | pm->dlsize = ps->size_limit; | |
117 | } | 117 | } | |
118 | 118 | |||
119 | return edit_outer_parts(pm->parts); | 119 | return edit_outer_parts(pm->parts); | |
120 | } | 120 | } | |
121 | 121 | |||
122 | /* | 122 | /* | |
123 | * md back-end code for menu-driven BSD disklabel editor. | 123 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/evbmips/md.c 2020/01/09 13:22:31 1.7
+++ src/usr.sbin/sysinst/arch/evbmips/md.c 2020/01/27 21:21:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997,2002 Piermont Information Systems Inc. | 4 | * Copyright 1997,2002 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | @@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | |||
62 | if (pm->no_mbr || pm->no_part) | 62 | if (pm->no_mbr || pm->no_part) | |
63 | return true; | 63 | return true; | |
64 | 64 | |||
65 | if (pm->parts == NULL) { | 65 | if (pm->parts == NULL) { | |
66 | 66 | |||
67 | const struct disk_partitioning_scheme *ps = | 67 | const struct disk_partitioning_scheme *ps = | |
68 | select_part_scheme(pm, NULL, true, NULL); | 68 | select_part_scheme(pm, NULL, true, NULL); | |
69 | 69 | |||
70 | if (!ps) | 70 | if (!ps) | |
71 | return false; | 71 | return false; | |
72 | 72 | |||
73 | struct disk_partitions *parts = | 73 | struct disk_partitions *parts = | |
74 | (*ps->create_new_for_disk)(pm->diskdev, | 74 | (*ps->create_new_for_disk)(pm->diskdev, | |
75 | 0, pm->dlsize, pm->dlsize, true, NULL); | 75 | 0, pm->dlsize, true, NULL); | |
76 | if (!parts) | 76 | if (!parts) | |
77 | return false; | 77 | return false; | |
78 | 78 | |||
79 | pm->parts = parts; | 79 | pm->parts = parts; | |
80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
81 | pm->dlsize = ps->size_limit; | 81 | pm->dlsize = ps->size_limit; | |
82 | } | 82 | } | |
83 | 83 | |||
84 | return set_bios_geom_with_mbr_guess(pm->parts); | 84 | return set_bios_geom_with_mbr_guess(pm->parts); | |
85 | } | 85 | } | |
86 | 86 | |||
87 | /* | 87 | /* | |
88 | * md back-end code for menu-driven BSD disklabel editor. | 88 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/evbppc/md.c 2020/01/09 13:22:31 1.7
+++ src/usr.sbin/sysinst/arch/evbppc/md.c 2020/01/27 21:21:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997,2002 Piermont Information Systems Inc. | 4 | * Copyright 1997,2002 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | @@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | |||
62 | if (pm->no_mbr || pm->no_part) | 62 | if (pm->no_mbr || pm->no_part) | |
63 | return true; | 63 | return true; | |
64 | 64 | |||
65 | if (pm->parts == NULL) { | 65 | if (pm->parts == NULL) { | |
66 | 66 | |||
67 | const struct disk_partitioning_scheme *ps = | 67 | const struct disk_partitioning_scheme *ps = | |
68 | select_part_scheme(pm, NULL, true, NULL); | 68 | select_part_scheme(pm, NULL, true, NULL); | |
69 | 69 | |||
70 | if (!ps) | 70 | if (!ps) | |
71 | return false; | 71 | return false; | |
72 | 72 | |||
73 | struct disk_partitions *parts = | 73 | struct disk_partitions *parts = | |
74 | (*ps->create_new_for_disk)(pm->diskdev, | 74 | (*ps->create_new_for_disk)(pm->diskdev, | |
75 | 0, pm->dlsize, pm->dlsize, true, NULL); | 75 | 0, pm->dlsize, true, NULL); | |
76 | if (!parts) | 76 | if (!parts) | |
77 | return false; | 77 | return false; | |
78 | 78 | |||
79 | pm->parts = parts; | 79 | pm->parts = parts; | |
80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
81 | pm->dlsize = ps->size_limit; | 81 | pm->dlsize = ps->size_limit; | |
82 | } | 82 | } | |
83 | 83 | |||
84 | return set_bios_geom_with_mbr_guess(pm->parts); | 84 | return set_bios_geom_with_mbr_guess(pm->parts); | |
85 | } | 85 | } | |
86 | 86 | |||
87 | /* | 87 | /* | |
88 | * md back-end code for menu-driven BSD disklabel editor. | 88 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/hpcarm/md.c 2020/01/09 13:22:31 1.7
+++ src/usr.sbin/sysinst/arch/hpcarm/md.c 2020/01/27 21:21:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -91,27 +91,27 @@ md_get_info(struct install_partition_des | @@ -91,27 +91,27 @@ md_get_info(struct install_partition_des | |||
91 | if (pm->no_mbr || pm->no_part) | 91 | if (pm->no_mbr || pm->no_part) | |
92 | return true; | 92 | return true; | |
93 | 93 | |||
94 | if (pm->parts == NULL) { | 94 | if (pm->parts == NULL) { | |
95 | 95 | |||
96 | const struct disk_partitioning_scheme *ps = | 96 | const struct disk_partitioning_scheme *ps = | |
97 | select_part_scheme(pm, NULL, true, NULL); | 97 | select_part_scheme(pm, NULL, true, NULL); | |
98 | 98 | |||
99 | if (!ps) | 99 | if (!ps) | |
100 | return false; | 100 | return false; | |
101 | 101 | |||
102 | struct disk_partitions *parts = | 102 | struct disk_partitions *parts = | |
103 | (*ps->create_new_for_disk)(pm->diskdev, | 103 | (*ps->create_new_for_disk)(pm->diskdev, | |
104 | 0, pm->dlsize, pm->dlsize, true, NULL); | 104 | 0, pm->dlsize, true, NULL); | |
105 | if (!parts) | 105 | if (!parts) | |
106 | return false; | 106 | return false; | |
107 | 107 | |||
108 | pm->parts = parts; | 108 | pm->parts = parts; | |
109 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 109 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
110 | pm->dlsize = ps->size_limit; | 110 | pm->dlsize = ps->size_limit; | |
111 | } | 111 | } | |
112 | 112 | |||
113 | return set_bios_geom_with_mbr_guess(pm->parts); | 113 | return set_bios_geom_with_mbr_guess(pm->parts); | |
114 | } | 114 | } | |
115 | 115 | |||
116 | /* | 116 | /* | |
117 | * md back-end code for menu-driven BSD disklabel editor. | 117 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/hpcmips/md.c 2020/01/09 13:22:31 1.7
+++ src/usr.sbin/sysinst/arch/hpcmips/md.c 2020/01/27 21:21:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:22 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -65,27 +65,27 @@ md_get_info(struct install_partition_des | @@ -65,27 +65,27 @@ md_get_info(struct install_partition_des | |||
65 | if (pm->no_mbr || pm->no_part) | 65 | if (pm->no_mbr || pm->no_part) | |
66 | return true; | 66 | return true; | |
67 | 67 | |||
68 | if (pm->parts == NULL) { | 68 | if (pm->parts == NULL) { | |
69 | 69 | |||
70 | const struct disk_partitioning_scheme *ps = | 70 | const struct disk_partitioning_scheme *ps = | |
71 | select_part_scheme(pm, NULL, true, NULL); | 71 | select_part_scheme(pm, NULL, true, NULL); | |
72 | 72 | |||
73 | if (!ps) | 73 | if (!ps) | |
74 | return false; | 74 | return false; | |
75 | 75 | |||
76 | struct disk_partitions *parts = | 76 | struct disk_partitions *parts = | |
77 | (*ps->create_new_for_disk)(pm->diskdev, | 77 | (*ps->create_new_for_disk)(pm->diskdev, | |
78 | 0, pm->dlsize, pm->dlsize, true, NULL); | 78 | 0, pm->dlsize, true, NULL); | |
79 | if (!parts) | 79 | if (!parts) | |
80 | return false; | 80 | return false; | |
81 | 81 | |||
82 | pm->parts = parts; | 82 | pm->parts = parts; | |
83 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 83 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
84 | pm->dlsize = ps->size_limit; | 84 | pm->dlsize = ps->size_limit; | |
85 | } | 85 | } | |
86 | 86 | |||
87 | return set_bios_geom_with_mbr_guess(pm->parts); | 87 | return set_bios_geom_with_mbr_guess(pm->parts); | |
88 | } | 88 | } | |
89 | 89 | |||
90 | /* | 90 | /* | |
91 | * md back-end code for menu-driven BSD disklabel editor. | 91 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/hpcsh/md.c 2020/01/09 13:22:31 1.8
+++ src/usr.sbin/sysinst/arch/hpcsh/md.c 2020/01/27 21:21:23 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.8 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.9 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -66,27 +66,27 @@ md_get_info(struct install_partition_des | @@ -66,27 +66,27 @@ md_get_info(struct install_partition_des | |||
66 | if (pm->no_mbr || pm->no_part) | 66 | if (pm->no_mbr || pm->no_part) | |
67 | return true; | 67 | return true; | |
68 | 68 | |||
69 | if (pm->parts == NULL) { | 69 | if (pm->parts == NULL) { | |
70 | 70 | |||
71 | const struct disk_partitioning_scheme *ps = | 71 | const struct disk_partitioning_scheme *ps = | |
72 | select_part_scheme(pm, NULL, true, NULL); | 72 | select_part_scheme(pm, NULL, true, NULL); | |
73 | 73 | |||
74 | if (!ps) | 74 | if (!ps) | |
75 | return false; | 75 | return false; | |
76 | 76 | |||
77 | struct disk_partitions *parts = | 77 | struct disk_partitions *parts = | |
78 | (*ps->create_new_for_disk)(pm->diskdev, | 78 | (*ps->create_new_for_disk)(pm->diskdev, | |
79 | 0, pm->dlsize, pm->dlsize, true, NULL); | 79 | 0, pm->dlsize, true, NULL); | |
80 | if (!parts) | 80 | if (!parts) | |
81 | return false; | 81 | return false; | |
82 | 82 | |||
83 | pm->parts = parts; | 83 | pm->parts = parts; | |
84 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 84 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
85 | pm->dlsize = ps->size_limit; | 85 | pm->dlsize = ps->size_limit; | |
86 | } | 86 | } | |
87 | 87 | |||
88 | return set_bios_geom_with_mbr_guess(pm->parts); | 88 | return set_bios_geom_with_mbr_guess(pm->parts); | |
89 | } | 89 | } | |
90 | 90 | |||
91 | /* | 91 | /* | |
92 | * md back-end code for menu-driven BSD disklabel editor. | 92 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/i386/md.c 2020/01/09 13:22:31 1.28
+++ src/usr.sbin/sysinst/arch/i386/md.c 2020/01/27 21:21:23 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.28 2020/01/09 13:22:31 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.29 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -112,41 +112,41 @@ md_get_info(struct install_partition_des | @@ -112,41 +112,41 @@ md_get_info(struct install_partition_des | |||
112 | if (pm->no_mbr || pm->no_part) | 112 | if (pm->no_mbr || pm->no_part) | |
113 | return true; | 113 | return true; | |
114 | 114 | |||
115 | if (pm->parts == NULL) { | 115 | if (pm->parts == NULL) { | |
116 | 116 | |||
117 | const struct disk_partitioning_scheme *ps = | 117 | const struct disk_partitioning_scheme *ps = | |
118 | select_part_scheme(pm, NULL, true, NULL); | 118 | select_part_scheme(pm, NULL, true, NULL); | |
119 | 119 | |||
120 | if (!ps) | 120 | if (!ps) | |
121 | return false; | 121 | return false; | |
122 | 122 | |||
123 | struct disk_partitions *parts = | 123 | struct disk_partitions *parts = | |
124 | (*ps->create_new_for_disk)(pm->diskdev, | 124 | (*ps->create_new_for_disk)(pm->diskdev, | |
125 | 0, pm->dlsize, pm->dlsize, true, NULL); | 125 | 0, pm->dlsize, true, NULL); | |
126 | if (!parts) | 126 | if (!parts) | |
127 | return false; | 127 | return false; | |
128 | 128 | |||
129 | pm->parts = parts; | 129 | pm->parts = parts; | |
130 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 130 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
131 | pm->dlsize = ps->size_limit; | 131 | pm->dlsize = ps->size_limit; | |
132 | } | 132 | } | |
133 | 133 | |||
134 | if (get_bios_info(pm->diskdev, pm->parts, &bcyl, &bhead, &bsec) | 134 | if (get_bios_info(pm->diskdev, pm->parts, &bcyl, &bhead, &bsec) | |
135 | && pm->parts->pscheme->change_disk_geom != NULL) | 135 | && pm->parts->pscheme->change_disk_geom != NULL) | |
136 | pm->parts->pscheme->change_disk_geom(pm->parts, | 136 | pm->parts->pscheme->change_disk_geom(pm->parts, | |
137 | bcyl, bhead, bsec); | 137 | bcyl, bhead, bsec); | |
138 | else | 138 | else | |
139 | set_default_sizemult(MEG/512); | 139 | set_default_sizemult(pm->diskdev, MEG, pm->sectorsize); | |
140 | 140 | |||
141 | /* | 141 | /* | |
142 | * If the selected scheme does not need two-stage partitioning | 142 | * If the selected scheme does not need two-stage partitioning | |
143 | * (like GPT), do not bother to edit the outer partitions. | 143 | * (like GPT), do not bother to edit the outer partitions. | |
144 | */ | 144 | */ | |
145 | if (pm->parts->pscheme->secondary_partitions == NULL || | 145 | if (pm->parts->pscheme->secondary_partitions == NULL || | |
146 | pm->parts->pscheme->secondary_scheme == NULL) | 146 | pm->parts->pscheme->secondary_scheme == NULL) | |
147 | return true; | 147 | return true; | |
148 | 148 | |||
149 | if (pm->no_mbr || pm->no_part) | 149 | if (pm->no_mbr || pm->no_part) | |
150 | return true; | 150 | return true; | |
151 | 151 | |||
152 | return edit_outer_parts(pm->parts); | 152 | return edit_outer_parts(pm->parts); |
--- src/usr.sbin/sysinst/arch/landisk/md.c 2020/01/09 13:22:32 1.12
+++ src/usr.sbin/sysinst/arch/landisk/md.c 2020/01/27 21:21:23 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.12 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.13 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997,2002 Piermont Information Systems Inc. | 4 | * Copyright 1997,2002 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | @@ -62,27 +62,27 @@ md_get_info(struct install_partition_des | |||
62 | if (pm->no_mbr || pm->no_part) | 62 | if (pm->no_mbr || pm->no_part) | |
63 | return true; | 63 | return true; | |
64 | 64 | |||
65 | if (pm->parts == NULL) { | 65 | if (pm->parts == NULL) { | |
66 | 66 | |||
67 | const struct disk_partitioning_scheme *ps = | 67 | const struct disk_partitioning_scheme *ps = | |
68 | select_part_scheme(pm, NULL, true, NULL); | 68 | select_part_scheme(pm, NULL, true, NULL); | |
69 | 69 | |||
70 | if (!ps) | 70 | if (!ps) | |
71 | return false; | 71 | return false; | |
72 | 72 | |||
73 | struct disk_partitions *parts = | 73 | struct disk_partitions *parts = | |
74 | (*ps->create_new_for_disk)(pm->diskdev, | 74 | (*ps->create_new_for_disk)(pm->diskdev, | |
75 | 0, pm->dlsize, pm->dlsize, true, NULL); | 75 | 0, pm->dlsize, true, NULL); | |
76 | if (!parts) | 76 | if (!parts) | |
77 | return false; | 77 | return false; | |
78 | 78 | |||
79 | pm->parts = parts; | 79 | pm->parts = parts; | |
80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 80 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
81 | pm->dlsize = ps->size_limit; | 81 | pm->dlsize = ps->size_limit; | |
82 | } | 82 | } | |
83 | 83 | |||
84 | return set_bios_geom_with_mbr_guess(pm->parts); | 84 | return set_bios_geom_with_mbr_guess(pm->parts); | |
85 | } | 85 | } | |
86 | 86 | |||
87 | /* | 87 | /* | |
88 | * md back-end code for menu-driven BSD disklabel editor. | 88 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/ofppc/md.c 2020/01/09 13:22:32 1.9
+++ src/usr.sbin/sysinst/arch/ofppc/md.c 2020/01/27 21:21:23 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.9 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.10 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -83,27 +83,27 @@ md_get_info(struct install_partition_des | @@ -83,27 +83,27 @@ md_get_info(struct install_partition_des | |||
83 | if (pm->no_mbr || pm->no_part) | 83 | if (pm->no_mbr || pm->no_part) | |
84 | return true; | 84 | return true; | |
85 | 85 | |||
86 | if (pm->parts == NULL) { | 86 | if (pm->parts == NULL) { | |
87 | 87 | |||
88 | const struct disk_partitioning_scheme *ps = | 88 | const struct disk_partitioning_scheme *ps = | |
89 | select_part_scheme(pm, NULL, true, NULL); | 89 | select_part_scheme(pm, NULL, true, NULL); | |
90 | 90 | |||
91 | if (!ps) | 91 | if (!ps) | |
92 | return false; | 92 | return false; | |
93 | 93 | |||
94 | struct disk_partitions *parts = | 94 | struct disk_partitions *parts = | |
95 | (*ps->create_new_for_disk)(pm->diskdev, | 95 | (*ps->create_new_for_disk)(pm->diskdev, | |
96 | 0, pm->dlsize, pm->dlsize, true, NULL); | 96 | 0, pm->dlsize, true, NULL); | |
97 | if (!parts) | 97 | if (!parts) | |
98 | return false; | 98 | return false; | |
99 | 99 | |||
100 | pm->parts = parts; | 100 | pm->parts = parts; | |
101 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 101 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
102 | pm->dlsize = ps->size_limit; | 102 | pm->dlsize = ps->size_limit; | |
103 | } | 103 | } | |
104 | 104 | |||
105 | return set_bios_geom_with_mbr_guess(pm->parts); | 105 | return set_bios_geom_with_mbr_guess(pm->parts); | |
106 | } | 106 | } | |
107 | 107 | |||
108 | /* | 108 | /* | |
109 | * md back-end code for menu-driven BSD disklabel editor. | 109 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/playstation2/md.c 2020/01/09 13:22:32 1.7
+++ src/usr.sbin/sysinst/arch/playstation2/md.c 2020/01/27 21:21:23 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -67,44 +67,44 @@ md_get_info(struct install_partition_des | @@ -67,44 +67,44 @@ md_get_info(struct install_partition_des | |||
67 | if (pm->no_mbr || pm->no_part) | 67 | if (pm->no_mbr || pm->no_part) | |
68 | return true; | 68 | return true; | |
69 | 69 | |||
70 | if (pm->parts == NULL) { | 70 | if (pm->parts == NULL) { | |
71 | 71 | |||
72 | const struct disk_partitioning_scheme *ps = | 72 | const struct disk_partitioning_scheme *ps = | |
73 | select_part_scheme(pm, NULL, true, NULL); | 73 | select_part_scheme(pm, NULL, true, NULL); | |
74 | 74 | |||
75 | if (!ps) | 75 | if (!ps) | |
76 | return false; | 76 | return false; | |
77 | 77 | |||
78 | struct disk_partitions *parts = | 78 | struct disk_partitions *parts = | |
79 | (*ps->create_new_for_disk)(pm->diskdev, | 79 | (*ps->create_new_for_disk)(pm->diskdev, | |
80 | 0, pm->dlsize, pm->dlsize, true, NULL); | 80 | 0, pm->dlsize, true, NULL); | |
81 | if (!parts) | 81 | if (!parts) | |
82 | return false; | 82 | return false; | |
83 | 83 | |||
84 | pm->parts = parts; | 84 | pm->parts = parts; | |
85 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 85 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
86 | pm->dlsize = ps->size_limit; | 86 | pm->dlsize = ps->size_limit; | |
87 | } | 87 | } | |
88 | 88 | |||
89 | msg_fmt_display(MSG_nobiosgeom, "%d%d%d", | 89 | msg_fmt_display(MSG_nobiosgeom, "%d%d%d", | |
90 | pm->dlcyl, pm->dlhead, pm->dlsec); | 90 | pm->dlcyl, pm->dlhead, pm->dlsec); | |
91 | 91 | |||
92 | if (guess_biosgeom_from_parts(pm->parts, &cyl, &head, &sec) >= 0 | 92 | if (guess_biosgeom_from_parts(pm->parts, &cyl, &head, &sec) >= 0 | |
93 | && pm->parts->pscheme->change_disk_geom != NULL) | 93 | && pm->parts->pscheme->change_disk_geom != NULL) | |
94 | pm->parts->pscheme->change_disk_geom(pm->parts, | 94 | pm->parts->pscheme->change_disk_geom(pm->parts, | |
95 | cyl, head, sec); | 95 | cyl, head, sec); | |
96 | else | 96 | else | |
97 | set_default_sizemult(MEG/512); | 97 | set_default_sizemult(pm->diskdev, MEG, pm->sectorsize); | |
98 | 98 | |||
99 | /* | 99 | /* | |
100 | * If the selected scheme does not need two-stage partitioning | 100 | * If the selected scheme does not need two-stage partitioning | |
101 | * (like GPT), do not bother to edit the outer partitions. | 101 | * (like GPT), do not bother to edit the outer partitions. | |
102 | */ | 102 | */ | |
103 | if (pm->parts->pscheme->secondary_partitions == NULL || | 103 | if (pm->parts->pscheme->secondary_partitions == NULL || | |
104 | pm->parts->pscheme->secondary_scheme == NULL) | 104 | pm->parts->pscheme->secondary_scheme == NULL) | |
105 | return true; | 105 | return true; | |
106 | 106 | |||
107 | if (pm->no_mbr || pm->no_part) | 107 | if (pm->no_mbr || pm->no_part) | |
108 | return true; | 108 | return true; | |
109 | 109 | |||
110 | return edit_outer_parts(pm->parts); | 110 | return edit_outer_parts(pm->parts); |
--- src/usr.sbin/sysinst/arch/prep/md.c 2020/01/09 13:22:32 1.11
+++ src/usr.sbin/sysinst/arch/prep/md.c 2020/01/27 21:21:23 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.11 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.12 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -67,27 +67,27 @@ md_get_info(struct install_partition_des | @@ -67,27 +67,27 @@ md_get_info(struct install_partition_des | |||
67 | if (pm->no_mbr || pm->no_part) | 67 | if (pm->no_mbr || pm->no_part) | |
68 | return true; | 68 | return true; | |
69 | 69 | |||
70 | if (pm->parts == NULL) { | 70 | if (pm->parts == NULL) { | |
71 | 71 | |||
72 | const struct disk_partitioning_scheme *ps = | 72 | const struct disk_partitioning_scheme *ps = | |
73 | select_part_scheme(pm, NULL, true, NULL); | 73 | select_part_scheme(pm, NULL, true, NULL); | |
74 | 74 | |||
75 | if (!ps) | 75 | if (!ps) | |
76 | return false; | 76 | return false; | |
77 | 77 | |||
78 | struct disk_partitions *parts = | 78 | struct disk_partitions *parts = | |
79 | (*ps->create_new_for_disk)(pm->diskdev, | 79 | (*ps->create_new_for_disk)(pm->diskdev, | |
80 | 0, pm->dlsize, pm->dlsize, true, NULL); | 80 | 0, pm->dlsize, true, NULL); | |
81 | if (!parts) | 81 | if (!parts) | |
82 | return false; | 82 | return false; | |
83 | 83 | |||
84 | pm->parts = parts; | 84 | pm->parts = parts; | |
85 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 85 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
86 | pm->dlsize = ps->size_limit; | 86 | pm->dlsize = ps->size_limit; | |
87 | } | 87 | } | |
88 | 88 | |||
89 | return set_bios_geom_with_mbr_guess(pm->parts); | 89 | return set_bios_geom_with_mbr_guess(pm->parts); | |
90 | } | 90 | } | |
91 | 91 | |||
92 | /* | 92 | /* | |
93 | * md back-end code for menu-driven BSD disklabel editor. | 93 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/sandpoint/md.c 2020/01/09 13:22:32 1.7
+++ src/usr.sbin/sysinst/arch/sandpoint/md.c 2020/01/27 21:21:23 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -96,27 +96,27 @@ md_get_info(struct install_partition_des | @@ -96,27 +96,27 @@ md_get_info(struct install_partition_des | |||
96 | if (pm->no_mbr || pm->no_part) | 96 | if (pm->no_mbr || pm->no_part) | |
97 | return true; | 97 | return true; | |
98 | 98 | |||
99 | if (pm->parts == NULL) { | 99 | if (pm->parts == NULL) { | |
100 | 100 | |||
101 | const struct disk_partitioning_scheme *ps = | 101 | const struct disk_partitioning_scheme *ps = | |
102 | select_part_scheme(pm, NULL, true, NULL); | 102 | select_part_scheme(pm, NULL, true, NULL); | |
103 | 103 | |||
104 | if (!ps) | 104 | if (!ps) | |
105 | return false; | 105 | return false; | |
106 | 106 | |||
107 | struct disk_partitions *parts = | 107 | struct disk_partitions *parts = | |
108 | (*ps->create_new_for_disk)(pm->diskdev, | 108 | (*ps->create_new_for_disk)(pm->diskdev, | |
109 | 0, pm->dlsize, pm->dlsize, true, NULL); | 109 | 0, pm->dlsize, true, NULL); | |
110 | if (!parts) | 110 | if (!parts) | |
111 | return false; | 111 | return false; | |
112 | 112 | |||
113 | pm->parts = parts; | 113 | pm->parts = parts; | |
114 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 114 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
115 | pm->dlsize = ps->size_limit; | 115 | pm->dlsize = ps->size_limit; | |
116 | } | 116 | } | |
117 | 117 | |||
118 | return set_bios_geom_with_mbr_guess(pm->parts); | 118 | return set_bios_geom_with_mbr_guess(pm->parts); | |
119 | } | 119 | } | |
120 | 120 | |||
121 | /* | 121 | /* | |
122 | * md back-end code for menu-driven BSD disklabel editor. | 122 | * md back-end code for menu-driven BSD disklabel editor. |
--- src/usr.sbin/sysinst/arch/zaurus/md.c 2020/01/09 13:22:32 1.7
+++ src/usr.sbin/sysinst/arch/zaurus/md.c 2020/01/27 21:21:23 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md.c,v 1.7 2020/01/09 13:22:32 martin Exp $ */ | 1 | /* $NetBSD: md.c,v 1.8 2020/01/27 21:21:23 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 1997 Piermont Information Systems Inc. | 4 | * Copyright 1997 Piermont Information Systems Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Based on code written by Philip A. Nelson for Piermont Information | 7 | * Based on code written by Philip A. Nelson for Piermont Information | |
8 | * Systems Inc. | 8 | * Systems Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -76,27 +76,27 @@ md_get_info(struct install_partition_des | @@ -76,27 +76,27 @@ md_get_info(struct install_partition_des | |||
76 | if (pm->no_mbr || pm->no_part) | 76 | if (pm->no_mbr || pm->no_part) | |
77 | return true; | 77 | return true; | |
78 | 78 | |||
79 | if (pm->parts == NULL) { | 79 | if (pm->parts == NULL) { | |
80 | 80 | |||
81 | const struct disk_partitioning_scheme *ps = | 81 | const struct disk_partitioning_scheme *ps = | |
82 | select_part_scheme(pm, NULL, true, NULL); | 82 | select_part_scheme(pm, NULL, true, NULL); | |
83 | 83 | |||
84 | if (!ps) | 84 | if (!ps) | |
85 | return false; | 85 | return false; | |
86 | 86 | |||
87 | struct disk_partitions *parts = | 87 | struct disk_partitions *parts = | |
88 | (*ps->create_new_for_disk)(pm->diskdev, | 88 | (*ps->create_new_for_disk)(pm->diskdev, | |
89 | 0, pm->dlsize, pm->dlsize, true, NULL); | 89 | 0, pm->dlsize, true, NULL); | |
90 | if (!parts) | 90 | if (!parts) | |
91 | return false; | 91 | return false; | |
92 | 92 | |||
93 | pm->parts = parts; | 93 | pm->parts = parts; | |
94 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | 94 | if (ps->size_limit > 0 && pm->dlsize > ps->size_limit) | |
95 | pm->dlsize = ps->size_limit; | 95 | pm->dlsize = ps->size_limit; | |
96 | } | 96 | } | |
97 | 97 | |||
98 | return set_bios_geom_with_mbr_guess(pm->parts); | 98 | return set_bios_geom_with_mbr_guess(pm->parts); | |
99 | } | 99 | } | |
100 | 100 | |||
101 | bool | 101 | bool | |
102 | md_make_bsd_partitions(struct install_partition_desc *install) | 102 | md_make_bsd_partitions(struct install_partition_desc *install) |