Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst Do not offer to upgared the "current system...



details:   https://anonhg.NetBSD.org/src/rev/4e0c3337a225
branches:  trunk
changeset: 965008:4e0c3337a225
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Aug 27 14:11:00 2019 +0000

description:
Do not offer to upgared the "current system" if we are running off a CD
(i.e. / is mounted read-only)

diffstat:

 usr.sbin/sysinst/defs.h    |   3 ++-
 usr.sbin/sysinst/upgrade.c |   6 +++---
 usr.sbin/sysinst/util.c    |  13 ++++++++++++-
 3 files changed, 17 insertions(+), 5 deletions(-)

diffs (71 lines):

diff -r 1cbdefe1cdcc -r 4e0c3337a225 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Aug 27 12:45:04 2019 +0000
+++ b/usr.sbin/sysinst/defs.h   Tue Aug 27 14:11:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.43 2019/08/07 10:08:04 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.44 2019/08/27 14:11:00 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -712,6 +712,7 @@
 bool   md_parts_use_wholedisk(struct disk_partitions*);
 
 /* from util.c */
+bool   root_is_read_only(void);
 void   get_ptn_alignment(const struct disk_partitions *parts, daddr_t *align, daddr_t *p0off);
 char*  str_arg_subst(const char *, size_t, const char **);
 void   msg_display_subst(const char *, size_t, ...);
diff -r 1cbdefe1cdcc -r 4e0c3337a225 usr.sbin/sysinst/upgrade.c
--- a/usr.sbin/sysinst/upgrade.c        Tue Aug 27 12:45:04 2019 +0000
+++ b/usr.sbin/sysinst/upgrade.c        Tue Aug 27 14:11:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: upgrade.c,v 1.12 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: upgrade.c,v 1.13 2019/08/27 14:11:00 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -64,7 +64,7 @@
 
        get_ramsize();
 
-       if (find_disks(msg_string(MSG_upgrade), true) < 0)
+       if (find_disks(msg_string(MSG_upgrade), !root_is_read_only()) < 0)
                return;
 
        if (pm->parts == NULL && !pm->cur_system) {
@@ -208,7 +208,7 @@
        if (!ask_noyes(NULL))
                return;
 
-       if (find_disks(msg_string(MSG_reinstall), true) < 0)
+       if (find_disks(msg_string(MSG_reinstall), !root_is_read_only()) < 0)
                return;
 
        if (!pm->cur_system) {
diff -r 1cbdefe1cdcc -r 4e0c3337a225 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Tue Aug 27 12:45:04 2019 +0000
+++ b/usr.sbin/sysinst/util.c   Tue Aug 27 14:11:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.31 2019/08/17 18:03:12 martin Exp $ */
+/*     $NetBSD: util.c,v 1.32 2019/08/27 14:11:00 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -537,6 +537,17 @@
        return 0;
 }
 
+bool
+root_is_read_only(void)
+{
+       struct statvfs sb;
+
+       if (statvfs("/", &sb) == 0)
+               return sb.f_flag & ST_RDONLY;
+
+       return false;
+}
+
 /*
  * Get from a CDROM distribution.
  * Also used on "installation using bootable install media"



Home | Main Index | Thread Index | Old Index