Do not offer to upgared the "current system" if we are running off a CD (i.e. / is mounted read-only)diff -r1.43 -r1.44 src/usr.sbin/sysinst/defs.h
(martin)
--- src/usr.sbin/sysinst/defs.h 2019/08/07 10:08:04 1.43
+++ src/usr.sbin/sysinst/defs.h 2019/08/27 14:11:00 1.44
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: defs.h,v 1.43 2019/08/07 10:08:04 martin Exp $ */ | 1 | /* $NetBSD: defs.h,v 1.44 2019/08/27 14:11:00 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 | |
@@ -702,26 +702,27 @@ const struct disk_partitioning_scheme *s | @@ -702,26 +702,27 @@ const struct disk_partitioning_scheme *s | |||
702 | const char *title); | 702 | const char *title); | |
703 | bool edit_outer_parts(struct disk_partitions*); | 703 | bool edit_outer_parts(struct disk_partitions*); | |
704 | bool parts_use_wholedisk(struct disk_partitions*, | 704 | bool parts_use_wholedisk(struct disk_partitions*, | |
705 | size_t add_ext_parts, const struct disk_part_info *ext_parts); | 705 | size_t add_ext_parts, const struct disk_part_info *ext_parts); | |
706 | 706 | |||
707 | /* | 707 | /* | |
708 | * Machine dependent partitioning function, only used when | 708 | * Machine dependent partitioning function, only used when | |
709 | * innern/outer partitioning schemes are in use - this sets | 709 | * innern/outer partitioning schemes are in use - this sets | |
710 | * up the outer scheme for maximum NetBSD usage. | 710 | * up the outer scheme for maximum NetBSD usage. | |
711 | */ | 711 | */ | |
712 | bool md_parts_use_wholedisk(struct disk_partitions*); | 712 | bool md_parts_use_wholedisk(struct disk_partitions*); | |
713 | 713 | |||
714 | /* from util.c */ | 714 | /* from util.c */ | |
715 | bool root_is_read_only(void); | |||
715 | void get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off); | 716 | void get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off); | |
716 | char* str_arg_subst(const char *, size_t, const char **); | 717 | char* str_arg_subst(const char *, size_t, const char **); | |
717 | void msg_display_subst(const char *, size_t, ...); | 718 | void msg_display_subst(const char *, size_t, ...); | |
718 | void msg_display_add_subst(const char *, size_t, ...); | 719 | void msg_display_add_subst(const char *, size_t, ...); | |
719 | int ask_yesno(const char *); | 720 | int ask_yesno(const char *); | |
720 | int ask_noyes(const char *); | 721 | int ask_noyes(const char *); | |
721 | void hit_enter_to_continue(const char *msg, const char *title); | 722 | void hit_enter_to_continue(const char *msg, const char *title); | |
722 | /* | 723 | /* | |
723 | * return value: | 724 | * return value: | |
724 | * 0 -> abort | 725 | * 0 -> abort | |
725 | * 1 -> re-edit | 726 | * 1 -> re-edit | |
726 | * 2 -> continue installation | 727 | * 2 -> continue installation | |
727 | */ | 728 | */ |
--- src/usr.sbin/sysinst/upgrade.c 2019/07/23 18:13:40 1.12
+++ src/usr.sbin/sysinst/upgrade.c 2019/08/27 14:11:00 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: upgrade.c,v 1.12 2019/07/23 18:13:40 martin Exp $ */ | 1 | /* $NetBSD: upgrade.c,v 1.13 2019/08/27 14:11:00 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 | |
@@ -54,27 +54,27 @@ static int merge_X(const char *); | @@ -54,27 +54,27 @@ static int merge_X(const char *); | |||
54 | void | 54 | void | |
55 | do_upgrade(void) | 55 | do_upgrade(void) | |
56 | { | 56 | { | |
57 | struct install_partition_desc install = {}; | 57 | struct install_partition_desc install = {}; | |
58 | int retcode = 0; | 58 | int retcode = 0; | |
59 | partman_go = 0; | 59 | partman_go = 0; | |
60 | 60 | |||
61 | msg_display(MSG_upgradeusure); | 61 | msg_display(MSG_upgradeusure); | |
62 | if (!ask_noyes(NULL)) | 62 | if (!ask_noyes(NULL)) | |
63 | return; | 63 | return; | |
64 | 64 | |||
65 | get_ramsize(); | 65 | get_ramsize(); | |
66 | 66 | |||
67 | if (find_disks(msg_string(MSG_upgrade), true) < 0) | 67 | if (find_disks(msg_string(MSG_upgrade), !root_is_read_only()) < 0) | |
68 | return; | 68 | return; | |
69 | 69 | |||
70 | if (pm->parts == NULL && !pm->cur_system) { | 70 | if (pm->parts == NULL && !pm->cur_system) { | |
71 | hit_enter_to_continue(MSG_noroot, NULL); | 71 | hit_enter_to_continue(MSG_noroot, NULL); | |
72 | return; | 72 | return; | |
73 | } | 73 | } | |
74 | 74 | |||
75 | if (!pm->cur_system) { | 75 | if (!pm->cur_system) { | |
76 | if (pm->parts->pscheme->pre_update_verify) { | 76 | if (pm->parts->pscheme->pre_update_verify) { | |
77 | if (pm->parts->pscheme->pre_update_verify(pm->parts)) | 77 | if (pm->parts->pscheme->pre_update_verify(pm->parts)) | |
78 | pm->parts->pscheme->write_to_disk(pm->parts); | 78 | pm->parts->pscheme->write_to_disk(pm->parts); | |
79 | } | 79 | } | |
80 | 80 | |||
@@ -198,27 +198,27 @@ merge_X(const char *xroot) | @@ -198,27 +198,27 @@ merge_X(const char *xroot) | |||
198 | */ | 198 | */ | |
199 | void | 199 | void | |
200 | do_reinstall_sets() | 200 | do_reinstall_sets() | |
201 | { | 201 | { | |
202 | struct install_partition_desc install = {}; | 202 | struct install_partition_desc install = {}; | |
203 | int retcode = 0; | 203 | int retcode = 0; | |
204 | partman_go = 0; | 204 | partman_go = 0; | |
205 | 205 | |||
206 | unwind_mounts(); | 206 | unwind_mounts(); | |
207 | msg_display(MSG_reinstallusure); | 207 | msg_display(MSG_reinstallusure); | |
208 | if (!ask_noyes(NULL)) | 208 | if (!ask_noyes(NULL)) | |
209 | return; | 209 | return; | |
210 | 210 | |||
211 | if (find_disks(msg_string(MSG_reinstall), true) < 0) | 211 | if (find_disks(msg_string(MSG_reinstall), !root_is_read_only()) < 0) | |
212 | return; | 212 | return; | |
213 | 213 | |||
214 | if (!pm->cur_system) { | 214 | if (!pm->cur_system) { | |
215 | if (pm->parts == NULL) { | 215 | if (pm->parts == NULL) { | |
216 | hit_enter_to_continue(MSG_noroot, NULL); | 216 | hit_enter_to_continue(MSG_noroot, NULL); | |
217 | return; | 217 | return; | |
218 | } | 218 | } | |
219 | 219 | |||
220 | install_desc_from_parts(&install, pm->parts); | 220 | install_desc_from_parts(&install, pm->parts); | |
221 | } else { | 221 | } else { | |
222 | install.cur_system = true; | 222 | install.cur_system = true; | |
223 | } | 223 | } | |
224 | 224 |
--- src/usr.sbin/sysinst/util.c 2019/08/17 18:03:12 1.31
+++ src/usr.sbin/sysinst/util.c 2019/08/27 14:11:00 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: util.c,v 1.31 2019/08/17 18:03:12 martin Exp $ */ | 1 | /* $NetBSD: util.c,v 1.32 2019/08/27 14:11:00 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 | |
@@ -527,26 +527,37 @@ boot_media_still_needed(void) | @@ -527,26 +527,37 @@ boot_media_still_needed(void) | |||
527 | struct statvfs sb; | 527 | struct statvfs sb; | |
528 | 528 | |||
529 | if (statvfs("/", &sb) == 0) { | 529 | if (statvfs("/", &sb) == 0) { | |
530 | if (!(sb.f_flag & ST_LOCAL)) | 530 | if (!(sb.f_flag & ST_LOCAL)) | |
531 | return -1; | 531 | return -1; | |
532 | if (strcmp(sb.f_fstypename, MOUNT_CD9660) == 0 | 532 | if (strcmp(sb.f_fstypename, MOUNT_CD9660) == 0 | |
533 | || strcmp(sb.f_fstypename, MOUNT_UDF) == 0) | 533 | || strcmp(sb.f_fstypename, MOUNT_UDF) == 0) | |
534 | return 1; | 534 | return 1; | |
535 | } | 535 | } | |
536 | 536 | |||
537 | return 0; | 537 | return 0; | |
538 | } | 538 | } | |
539 | 539 | |||
540 | bool | |||
541 | root_is_read_only(void) | |||
542 | { | |||
543 | struct statvfs sb; | |||
544 | ||||
545 | if (statvfs("/", &sb) == 0) | |||
546 | return sb.f_flag & ST_RDONLY; | |||
547 | ||||
548 | return false; | |||
549 | } | |||
550 | ||||
540 | /* | 551 | /* | |
541 | * Get from a CDROM distribution. | 552 | * Get from a CDROM distribution. | |
542 | * Also used on "installation using bootable install media" | 553 | * Also used on "installation using bootable install media" | |
543 | * as the default option in the "distmedium" menu. | 554 | * as the default option in the "distmedium" menu. | |
544 | */ | 555 | */ | |
545 | int | 556 | int | |
546 | get_via_cdrom(void) | 557 | get_via_cdrom(void) | |
547 | { | 558 | { | |
548 | menu_ent cd_menu[MAX_CD_INFOS]; | 559 | menu_ent cd_menu[MAX_CD_INFOS]; | |
549 | struct stat sb; | 560 | struct stat sb; | |
550 | int rv, num_cds, menu_cd, i, selected_cd = 0; | 561 | int rv, num_cds, menu_cd, i, selected_cd = 0; | |
551 | bool silent = false; | 562 | bool silent = false; | |
552 | int mib[2]; | 563 | int mib[2]; |