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
This commit is contained in:
parent
d3dd65ab60
commit
62fad4a13f
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user