summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall
diff options
context:
space:
mode:
authorsimon <simon@FreeBSD.org>2006-07-15 12:23:56 +0000
committersimon <simon@FreeBSD.org>2006-07-15 12:23:56 +0000
commit0eacf9737caf2565dd819b5b0335a07ac729f328 (patch)
treefc1eb3e89eb516ab8f6f2bc2181f7c4f2cd8b19c /usr.sbin/sysinstall
parent8f169c00cb7fabb05b0febab6c26286eddd3da1a (diff)
downloadFreeBSD-src-0eacf9737caf2565dd819b5b0335a07ac729f328.zip
FreeBSD-src-0eacf9737caf2565dd819b5b0335a07ac729f328.tar.gz
Add FreeBSD version information to the menu title so it's possible to
see which release you are installing (really which FreeBSD version the installer is running, but that shouldn't matter in all normal cases). PR: bin/100309 Submitted by: Joao Barros <joao.barros@gmail.com> (original version) Idea from: FreeBSD ideas page MFC after: 1 week
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r--usr.sbin/sysinstall/install.c18
-rw-r--r--usr.sbin/sysinstall/main.c12
-rw-r--r--usr.sbin/sysinstall/misc.c24
-rw-r--r--usr.sbin/sysinstall/sysinstall.h1
4 files changed, 40 insertions, 15 deletions
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
index 3ff7d8e..f45a74c 100644
--- a/usr.sbin/sysinstall/install.c
+++ b/usr.sbin/sysinstall/install.c
@@ -1182,20 +1182,6 @@ installFilesystems(dialogMenuItem *self)
return DITEM_SUCCESS | DITEM_RESTORE;
}
-static char *
-getRelname(void)
-{
- static char buf[64];
- size_t sz = (sizeof buf) - 1;
-
- if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) {
- buf[sz] = '\0';
- return buf;
- }
- else
- return "<unknown>";
-}
-
/* Initialize various user-settable values to their defaults */
int
installVarDefaults(dialogMenuItem *self)
@@ -1203,7 +1189,9 @@ installVarDefaults(dialogMenuItem *self)
char *cp, ncpus[10];
/* Set default startup options */
- variable_set2(VAR_RELNAME, getRelname(), 0);
+ cp = getsysctlbyname("kern.osrelease");
+ variable_set2(VAR_RELNAME, cp, 0);
+ free(cp);
variable_set2(VAR_CPIO_VERBOSITY, "high", 0);
variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE, 0);
variable_set2(VAR_INSTALL_ROOT, "/", 0);
diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c
index ca31125..7af8d44 100644
--- a/usr.sbin/sysinstall/main.c
+++ b/usr.sbin/sysinstall/main.c
@@ -51,6 +51,7 @@ int
main(int argc, char **argv)
{
int choice, scroll, curr, max, status;
+ char titlestr[80], *arch, *osrel, *ostype;
/* Record name to be able to restart */
StartName = argv[0];
@@ -162,6 +163,17 @@ main(int argc, char **argv)
if (RunningAsInit)
configCountry(NULL);
+ /* Add FreeBSD version info to the menu title */
+ arch = getsysctlbyname("hw.machine_arch");
+ osrel = getsysctlbyname("kern.osrelease");
+ ostype = getsysctlbyname("kern.ostype");
+ snprintf(titlestr, sizeof(titlestr), "%s/%s %s - %s", ostype, arch,
+ osrel, MenuInitial.title);
+ free(arch);
+ free(osrel);
+ free(ostype);
+ MenuInitial.title = titlestr;
+
/* Begin user dialog at outer menu */
dialog_clear();
while (1) {
diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c
index 07cbc81..c978b76 100644
--- a/usr.sbin/sysinstall/misc.c
+++ b/usr.sbin/sysinstall/misc.c
@@ -46,6 +46,7 @@
#include <sys/reboot.h>
#include <sys/disklabel.h>
#include <fs/msdosfs/msdosfsmount.h>
+#include <sys/sysctl.h>
/* Quick check to see if a file is readable */
Boolean
@@ -527,3 +528,26 @@ restorescr(WINDOW *w)
delwin(w);
}
+/*
+ * Get a sysctl variable as a string or "<unknown>" if sysctl fails.
+ * Caller must free returned string.
+ */
+char *
+getsysctlbyname(const char *sysctlname)
+{
+ char *buf;
+ size_t sz, buf_sz = 0;
+ const char unk_str[] = "<unknown>";
+
+ sysctlbyname(sysctlname, NULL, &buf_sz, NULL, 0);
+ buf_sz = MAX(sizeof(unk_str), buf_sz) + 1;
+ sz = buf_sz - 1;
+ buf = (char *)safe_malloc(buf_sz);
+
+ if (sysctlbyname(sysctlname, buf, &sz, NULL, 0) != -1)
+ buf[sz] = '\0';
+ else
+ strlcpy(buf, unk_str, buf_sz);
+
+ return buf;
+}
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
index afc1ab5..4ec2bcf 100644
--- a/usr.sbin/sysinstall/sysinstall.h
+++ b/usr.sbin/sysinstall/sysinstall.h
@@ -784,6 +784,7 @@ extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj,
extern WINDOW *savescr(void);
extern void restorescr(WINDOW *w);
extern char *sstrncpy(char *dst, const char *src, int size);
+extern char *getsysctlbyname(const char *sysctlname);
/* modules.c */
extern void driverFloppyCheck(void);
OpenPOWER on IntegriCloud