Add more target_wrapper functions, to do
* renames of files from one pathname within the target to another (e.g., mv_within_target_or_die("/etc", "/etc.old"); * check to see if a partition name like "sd0a" is the current root * Duplicate a file from the current root into the target root (for copying /netbsd from RAMdisk into the target). A no-op if the root is the install target). Start using these where appropriate. Change net.c to avoid losing any information when updating network config files: where possible, do appends to files that might have more info than we got from the user (e.g., /etc/hosts.) Where possible, add comment saying file was created/modified by sysinst.
This commit is contained in:
parent
d0f1a6dc73
commit
17aa1054d7
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.13 1997/11/02 09:41:57 jonathan Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.14 1997/11/02 23:43:11 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -253,3 +253,6 @@ void trunc_target_file __P((const char *path));
|
|||
int target_chdir __P(( const char *path));
|
||||
void target_chdir_or_die __P((const char *dir));
|
||||
int target_already_root __P((void));
|
||||
int is_active_rootpart __P((const char *partname));
|
||||
void dup_file_into_target __P((const char *filename));
|
||||
void mv_within_target_or_die __P((const char *from, const char *to));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: net.c,v 1.12 1997/11/02 08:20:44 jonathan Exp $ */
|
||||
/* $NetBSD: net.c,v 1.13 1997/11/02 23:43:12 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -263,22 +263,43 @@ get_via_nfs(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the network config info the user entered via menus into the
|
||||
* config files in the target disk. Be careful not to lose any
|
||||
* information we don't immediately add back, in case the install
|
||||
* target is the currently-active root.
|
||||
*/
|
||||
void
|
||||
mnt_net_config(void)
|
||||
{
|
||||
char ans [5] = "y";
|
||||
char ifconfig_fn [STRSIZE];
|
||||
char buf[STRSIZE];
|
||||
|
||||
if (network_up) {
|
||||
msg_prompt (MSG_mntnetconfig, ans, ans, 5);
|
||||
if (*ans == 'y') {
|
||||
if (!target_already_root()) {
|
||||
run_prog ("/bin/cp /etc/resolv.conf /mnt/etc");
|
||||
}
|
||||
|
||||
sprintf_to_target_file (
|
||||
"/etc/hosts", "%s %s", net_ip, net_host);
|
||||
/* If not running in target, copy resolv.conf there. */
|
||||
dup_file_into_target("/etc/resolv");
|
||||
#define APPEND append_to_target_file
|
||||
/*
|
||||
* Add IPaddr/hostname to /etc/hosts.
|
||||
* Be careful not to clobber any existing contents.
|
||||
* Relies on ordered seach of /etc/hosts. XXX YP?
|
||||
*/
|
||||
APPEND("/etc/hosts", "#");
|
||||
APPEND("/etc/hosts", "#Added by NetBSD sysinst");
|
||||
APPEND("/etc/hosts", "#");
|
||||
snprintf(buf, STRSIZE,
|
||||
"%s %s", net_ip, net_host);
|
||||
APPEND("/etc/hosts", buf);
|
||||
snprintf(buf, STRSIZE,
|
||||
"%s %s.%s", net_ip, net_host, net_domain);
|
||||
APPEND("/etc/hosts", buf);
|
||||
APPEND("/etc/hosts", "127.0.0.1 localhost");
|
||||
|
||||
/* Write IPaddr and netmask to /etc/ifconfig.if[0-9] */
|
||||
snprintf (ifconfig_fn, STRSIZE,
|
||||
"/etc/ifconfig.%s", net_dev);
|
||||
sprintf_to_target_file (
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: target.c,v 1.2 1997/11/02 08:30:39 jonathan Exp $ */
|
||||
/* $NetBSD: target.c,v 1.3 1997/11/02 23:43:13 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Jonathan Stone
|
||||
|
@ -79,9 +79,17 @@ const char* target_prefix(void)
|
|||
/* Is the root we're running from is the root we're trying to upgrade? */
|
||||
int target_already_root()
|
||||
{
|
||||
/* FIXME */
|
||||
return(strcmp(target_prefix(), "/mnt") == 0);
|
||||
}
|
||||
|
||||
/* Is this partname (e.g., "sd0a") mounted as root? */
|
||||
int is_active_rootpart(const char *partname)
|
||||
{
|
||||
/* FIXME -- compare to kernel's sysctl string with current root. */
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Make a directory, with a prefix like "/mnt" or possibly just "". */
|
||||
static void
|
||||
|
@ -192,3 +200,25 @@ int target_chdir(const char *dir)
|
|||
{
|
||||
return(do_target_chdir(dir, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicate a file from the current root to the same pathname
|
||||
* in the target system. Pathname must be an absolute pathname.
|
||||
* If we're running in the target, do nothing.
|
||||
*/
|
||||
void dup_file_into_target(const char *filename)
|
||||
{
|
||||
if (!target_already_root()) {
|
||||
run_prog ("/bin/cp %s %s/%s",
|
||||
filename, target_prefix(), filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Do a mv where both pathnames are within the target filesystem. */
|
||||
void mv_within_target_or_die(const char *from, const char *to)
|
||||
{
|
||||
run_prog_or_die("mv %s/%s",
|
||||
target_prefix(), from,
|
||||
target_prefix(), to);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: upgrade.c,v 1.6 1997/11/02 09:42:00 jonathan Exp $ */
|
||||
/* $NetBSD: upgrade.c,v 1.7 1997/11/02 23:43:14 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -64,7 +64,7 @@ void do_upgrade(void)
|
|||
return;
|
||||
|
||||
/* Move /mnt/etc /mnt/etc.old so old stuff isn't overwritten. */
|
||||
run_prog ("/bin/mv /mnt/etc /mnt/etc.old");
|
||||
mv_within_target_or_die ("/etc", "/etc.old");
|
||||
|
||||
/* Do any md updating of the file systems ... e.g. bootblocks,
|
||||
copy file systems ... */
|
||||
|
|
Loading…
Reference in New Issue