2003-06-09 23:06:48 +04:00
|
|
|
/* $NetBSD: disks.c,v 1.57 2003/06/09 19:06:48 dsl Exp $ */
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997 Piermont Information Systems Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Philip A. Nelson for Piermont Information Systems Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1999-06-20 10:08:13 +04:00
|
|
|
* This product includes software developed for the NetBSD Project by
|
1997-09-27 03:02:53 +04:00
|
|
|
* Piermont Information Systems Inc.
|
|
|
|
* 4. The name of Piermont Information Systems Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2003-05-19 00:04:21 +04:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
1997-09-27 03:02:53 +04:00
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
2003-05-19 00:04:21 +04:00
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
1997-09-27 03:02:53 +04:00
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* disks.c -- routines to deal with finding disks and labeling disks. */
|
|
|
|
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
#include <errno.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1997-10-07 08:01:29 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
1997-11-03 03:04:53 +03:00
|
|
|
#include <util.h>
|
1997-10-07 08:01:29 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <ufs/ufs/dinode.h>
|
|
|
|
#include <ufs/ffs/fs.h>
|
2003-01-10 23:00:27 +03:00
|
|
|
#define FSTYPENAMES
|
2003-01-13 00:49:50 +03:00
|
|
|
#define static
|
2003-01-10 23:00:27 +03:00
|
|
|
#include <sys/disklabel.h>
|
2003-01-13 00:49:50 +03:00
|
|
|
#undef static
|
1997-10-07 08:01:29 +04:00
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
#include "defs.h"
|
1997-10-29 04:06:42 +03:00
|
|
|
#include "md.h"
|
1997-09-27 03:02:53 +04:00
|
|
|
#include "msg_defs.h"
|
|
|
|
#include "menu_defs.h"
|
|
|
|
#include "txtwalk.h"
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
|
1997-11-02 11:20:40 +03:00
|
|
|
|
1997-10-01 09:04:24 +04:00
|
|
|
/* Local prototypes */
|
1997-10-15 08:35:17 +04:00
|
|
|
static void get_disks (void);
|
2003-05-19 00:04:21 +04:00
|
|
|
static void foundffs(struct data *, size_t);
|
|
|
|
static int do_fsck(const char *);
|
|
|
|
static int fsck_root(void);
|
|
|
|
static int do_flfs_newfs(const char *, int, const char *);
|
|
|
|
static int fsck_num(const char *);
|
1997-10-01 09:04:24 +04:00
|
|
|
|
2003-05-19 00:04:21 +04:00
|
|
|
static int fsck_with_error_menu(const char *);
|
|
|
|
static int target_mount_with_error_menu(const char *, char *, const char *);
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2003-05-30 15:56:23 +04:00
|
|
|
#ifndef DISK_NAMES
|
|
|
|
#define DISK_NAMES "wd", "sd", "ld"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static char *disk_names[] = { DISK_NAMES, NULL };
|
1997-11-02 11:20:40 +03:00
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
static void
|
|
|
|
get_disks(void)
|
1997-10-15 08:35:17 +04:00
|
|
|
{
|
2003-05-19 00:04:21 +04:00
|
|
|
char **xd;
|
1997-10-15 08:35:17 +04:00
|
|
|
char d_name[SSTRSIZE];
|
|
|
|
struct disklabel l;
|
2003-05-19 00:04:21 +04:00
|
|
|
struct disk_desc *dd;
|
1997-10-15 08:35:17 +04:00
|
|
|
int i;
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2003-05-19 00:04:21 +04:00
|
|
|
/* initialize */
|
|
|
|
disknames[0] = 0;
|
|
|
|
numdisks = 0;
|
|
|
|
dd = disks;
|
|
|
|
|
|
|
|
for (xd = disk_names; *xd != NULL; xd++) {
|
|
|
|
for (i = 0; i < MAX_DISKS; i++) {
|
|
|
|
snprintf(d_name, sizeof d_name, "%s%d", *xd, i);
|
2003-05-30 15:56:23 +04:00
|
|
|
if (!get_geom(d_name, &l)) {
|
|
|
|
if (errno == ENOENT)
|
|
|
|
break;
|
2003-05-19 00:04:21 +04:00
|
|
|
continue;
|
2003-05-30 15:56:23 +04:00
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
strncpy(dd->dd_name, d_name, sizeof dd->dd_name);
|
|
|
|
strlcat(disknames, d_name, sizeof disknames);
|
|
|
|
strlcat(disknames, " ", sizeof disknames);
|
|
|
|
dd->dd_cyl = l.d_ncylinders;
|
|
|
|
dd->dd_head = l.d_ntracks;
|
|
|
|
dd->dd_sec = l.d_nsectors;
|
|
|
|
dd->dd_secsize = l.d_secsize;
|
|
|
|
dd->dd_totsec = l.d_secperunit;
|
|
|
|
dd++;
|
|
|
|
numdisks++;
|
|
|
|
if (numdisks >= MAX_DISKS)
|
|
|
|
return;
|
1997-10-15 08:35:17 +04:00
|
|
|
}
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
|
|
|
find_disks(void)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
char *tp;
|
2003-05-19 00:04:21 +04:00
|
|
|
const char *prompt;
|
1997-10-07 08:01:29 +04:00
|
|
|
char defname[STRSIZE];
|
|
|
|
int i;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1997-10-15 08:35:17 +04:00
|
|
|
/* Find disks. */
|
|
|
|
get_disks();
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
/* need a redraw here, kernel messages hose everything */
|
|
|
|
touchwin(stdscr);
|
|
|
|
refresh();
|
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
if (numdisks == 0) {
|
|
|
|
/* No disks found! */
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_display(MSG_nodisk);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1999-01-21 11:02:17 +03:00
|
|
|
/*endwin();*/
|
1997-09-27 03:02:53 +04:00
|
|
|
return -1;
|
2003-05-19 00:04:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numdisks == 1) {
|
1997-09-27 03:02:53 +04:00
|
|
|
/* One disk found! */
|
|
|
|
/* Remove that space we added. */
|
2003-05-19 00:04:21 +04:00
|
|
|
disknames[strlen(disknames) - 1] = 0;
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_display(MSG_onedisk, disknames, doingwhat);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
2003-05-19 00:04:21 +04:00
|
|
|
strlcpy(diskdev, disknames, sizeof diskdev);
|
1997-09-27 03:02:53 +04:00
|
|
|
} else {
|
|
|
|
/* Multiple disks found! */
|
1999-03-31 04:44:48 +04:00
|
|
|
strcpy(defname, disknames);
|
1997-09-27 03:02:53 +04:00
|
|
|
tp = defname;
|
|
|
|
strsep(&tp, " ");
|
2003-05-19 00:04:21 +04:00
|
|
|
prompt = MSG_askdisk;
|
|
|
|
do {
|
|
|
|
msg_prompt(prompt, defname, diskdev, 10, disknames);
|
|
|
|
prompt = MSG_badname;
|
1997-09-27 03:02:53 +04:00
|
|
|
tp = diskdev;
|
|
|
|
strsep(&tp, " ");
|
2003-05-19 00:04:21 +04:00
|
|
|
diskdev[strlen(diskdev) + 1] = 0;
|
1997-09-27 03:02:53 +04:00
|
|
|
diskdev[strlen(diskdev)] = ' ';
|
2003-05-19 00:04:21 +04:00
|
|
|
tp = strstr(disknames, diskdev);
|
|
|
|
} while (tp == NULL || (tp != disknames && tp[-1] != ' '));
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/* Remove that space we added. */
|
2003-05-19 00:04:21 +04:00
|
|
|
diskdev[strlen(diskdev) - 1] = 0;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
|
1997-10-07 08:01:29 +04:00
|
|
|
/* Set disk. */
|
1999-03-31 04:44:48 +04:00
|
|
|
for (i = 0; i < numdisks; i++)
|
1999-03-14 17:19:05 +03:00
|
|
|
if (strcmp(diskdev, disks[i].dd_name) == 0)
|
1997-10-07 08:01:29 +04:00
|
|
|
disk = &disks[i];
|
|
|
|
|
1999-03-14 17:19:05 +03:00
|
|
|
sectorsize = disk->dd_secsize;
|
|
|
|
if (disk->dd_totsec == 0)
|
|
|
|
disk->dd_totsec = disk->dd_cyl * disk->dd_head * disk->dd_sec;
|
1999-03-31 04:44:48 +04:00
|
|
|
dlcyl = disk->dd_cyl;
|
|
|
|
dlhead = disk->dd_head;
|
|
|
|
dlsec = disk->dd_sec;
|
|
|
|
dlsize = disk->dd_totsec;
|
|
|
|
dlcylsize = dlhead * dlsec;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
return numdisks;
|
|
|
|
}
|
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
void
|
|
|
|
fmt_fspart(char *buf, size_t len, int ptn)
|
|
|
|
{
|
|
|
|
int poffset, psize, pend;
|
|
|
|
int l;
|
|
|
|
const char *desc;
|
|
|
|
|
|
|
|
poffset = bsdlabel[ptn].pi_offset / sizemult;
|
|
|
|
psize = bsdlabel[ptn].pi_size / sizemult;
|
|
|
|
if (psize == 0)
|
|
|
|
pend = 0;
|
|
|
|
else
|
|
|
|
pend = (bsdlabel[ptn].pi_offset +
|
|
|
|
bsdlabel[ptn].pi_size) / sizemult - 1;
|
|
|
|
|
|
|
|
desc = fstypenames[bsdlabel[ptn].pi_fstype];
|
|
|
|
#ifdef PART_BOOT
|
|
|
|
if (ptn == PART_BOOT)
|
|
|
|
desc = msg_string(MSG_Boot_partition_cant_change);
|
|
|
|
#endif
|
|
|
|
if (ptn == getrawpartition())
|
|
|
|
desc = msg_string(MSG_Whole_disk_cant_change);
|
|
|
|
else {
|
|
|
|
if (ptn == C)
|
|
|
|
desc = msg_string(MSG_NetBSD_partition_cant_change);
|
|
|
|
}
|
|
|
|
|
|
|
|
l = snprintf(buf, len, msg_string(MSG_fspart_row_start),
|
|
|
|
poffset, pend, psize, desc);
|
|
|
|
buf += l;
|
|
|
|
len -= l;
|
|
|
|
if (len <= 0)
|
|
|
|
return;
|
|
|
|
if (PI_ISBSDFS(&bsdlabel[ptn]))
|
|
|
|
snprintf(buf, len, msg_string(MSG_fspart_row_end_bsd),
|
|
|
|
bsdlabel[ptn].pi_bsize,
|
|
|
|
bsdlabel[ptn].pi_fsize,
|
|
|
|
bsdlabel[ptn].pi_newfs ? "No" : "Yes",
|
|
|
|
bsdlabel[ptn].pi_mount);
|
|
|
|
else if (bsdlabel[ptn].pi_fstype == FS_MSDOS)
|
|
|
|
snprintf(buf, len, msg_string(MSG_fspart_row_end_msdos),
|
|
|
|
bsdlabel[ptn].pi_mount);
|
|
|
|
else
|
|
|
|
snprintf(buf, len, msg_string(MSG_fspart_row_end_other));
|
|
|
|
}
|
1997-09-27 03:02:53 +04:00
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
void
|
|
|
|
disp_cur_fspart(int disp, int showall)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int start, stop;
|
1998-12-17 01:35:26 +03:00
|
|
|
int poffset, psize, pend;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
if (disp < 0) {
|
|
|
|
start = 0;
|
1997-11-03 03:04:53 +03:00
|
|
|
stop = getmaxpartitions();
|
1997-09-27 03:02:53 +04:00
|
|
|
} else {
|
|
|
|
start = disp;
|
|
|
|
stop = disp+1;
|
|
|
|
}
|
|
|
|
|
1999-07-04 12:01:39 +04:00
|
|
|
msg_table_add (MSG_fspart_header);
|
1999-03-31 04:44:48 +04:00
|
|
|
for (i = start; i < stop; i++) {
|
|
|
|
if (showall || bsdlabel[i].pi_size > 0) {
|
|
|
|
poffset = bsdlabel[i].pi_offset / sizemult;
|
|
|
|
psize = bsdlabel[i].pi_size / sizemult;
|
1998-12-17 01:35:26 +03:00
|
|
|
if (psize == 0)
|
|
|
|
pend = 0;
|
|
|
|
else
|
1999-03-31 04:44:48 +04:00
|
|
|
pend = (bsdlabel[i].pi_offset +
|
|
|
|
bsdlabel[i].pi_size) / sizemult - 1;
|
2003-06-09 23:06:48 +04:00
|
|
|
msg_table_add("%c: ", 'a' + i);
|
1999-07-04 12:01:39 +04:00
|
|
|
msg_table_add(MSG_fspart_row_start,
|
2003-06-09 23:06:48 +04:00
|
|
|
poffset, pend, psize,
|
1999-03-31 04:44:48 +04:00
|
|
|
fstypenames[bsdlabel[i].pi_fstype]);
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
if (PI_ISBSDFS(&bsdlabel[i]))
|
1999-07-04 12:01:39 +04:00
|
|
|
msg_table_add(MSG_fspart_row_end_bsd,
|
2003-06-05 00:05:12 +04:00
|
|
|
bsdlabel[i].pi_bsize,
|
|
|
|
bsdlabel[i].pi_fsize,
|
|
|
|
bsdlabel[i].pi_newfs ? "No" : "Yes",
|
|
|
|
bsdlabel[i].pi_mount);
|
1999-03-31 04:44:48 +04:00
|
|
|
else if (bsdlabel[i].pi_fstype == FS_MSDOS)
|
1999-07-04 12:01:39 +04:00
|
|
|
msg_table_add(MSG_fspart_row_end_msdos,
|
2003-06-05 00:05:12 +04:00
|
|
|
bsdlabel[i].pi_mount);
|
1999-07-04 12:01:39 +04:00
|
|
|
else
|
|
|
|
msg_table_add(MSG_fspart_row_end_other);
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-05 01:52:11 +04:00
|
|
|
msg_display_add(MSG_newline);
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
1997-11-09 07:14:10 +03:00
|
|
|
/*
|
|
|
|
* Label a disk using an MD-specific string DISKLABEL_CMD for
|
|
|
|
* to invoke disklabel.
|
|
|
|
* if MD code does not define DISKLABEL_CMD, this is a no-op.
|
|
|
|
*
|
|
|
|
* i386 port uses "/sbin/disklabel -w -r", just like i386
|
|
|
|
* miniroot scripts, though this may leave a bogus incore label.
|
|
|
|
*
|
2003-05-19 00:04:21 +04:00
|
|
|
* Sun ports should use DISKLABEL_CMD "/sbin/disklabel -w"
|
1997-11-09 07:14:10 +03:00
|
|
|
* to get incore to ondisk inode translation for the Sun proms.
|
|
|
|
*/
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
|
|
|
write_disklabel (void)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
1997-11-09 07:14:10 +03:00
|
|
|
|
|
|
|
#ifdef DISKLABEL_CMD
|
1997-09-27 03:02:53 +04:00
|
|
|
/* disklabel the disk */
|
2000-10-12 03:47:55 +04:00
|
|
|
return run_prog(RUN_DISPLAY, MSG_cmdfail,
|
1999-04-09 14:24:38 +04:00
|
|
|
"%s %s %s", DISKLABEL_CMD, diskdev, bsddiskname);
|
2003-01-10 23:00:27 +03:00
|
|
|
#else
|
1999-04-09 14:24:38 +04:00
|
|
|
return 0;
|
2003-01-10 23:00:27 +03:00
|
|
|
#endif
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
|
|
|
make_filesystems(void)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
int i;
|
1997-11-03 03:04:53 +03:00
|
|
|
char partname[STRSIZE];
|
1999-04-09 14:24:38 +04:00
|
|
|
int error;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/* Making new file systems and mounting them*/
|
1999-03-31 04:44:48 +04:00
|
|
|
for (i = 0; i < getmaxpartitions(); i++) {
|
1997-11-03 03:04:53 +03:00
|
|
|
/*
|
2003-05-19 00:04:21 +04:00
|
|
|
* newfs and mount. For now, process only BSD filesystems.
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
* but if this is the mounted-on root, has no mount
|
2003-05-19 00:04:21 +04:00
|
|
|
* point defined, or is marked preserve, don't touch it!
|
1997-11-03 03:04:53 +03:00
|
|
|
*/
|
2003-05-19 00:04:21 +04:00
|
|
|
snprintf(partname, STRSIZE, "%s%c", diskdev, 'a' + i);
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
if (PI_ISBSDFS(&bsdlabel[i]) && !is_active_rootpart(partname)) {
|
2003-06-05 00:05:12 +04:00
|
|
|
error = do_flfs_newfs(partname, i, bsdlabel[i].pi_mount);
|
1999-04-09 14:24:38 +04:00
|
|
|
if (error)
|
|
|
|
return error;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
1997-11-03 03:04:53 +03:00
|
|
|
}
|
1999-04-09 14:24:38 +04:00
|
|
|
return 0;
|
1997-11-03 03:04:53 +03:00
|
|
|
}
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1997-11-03 03:04:53 +03:00
|
|
|
/* newfs and mount an ffs filesystem. */
|
2003-05-19 00:04:21 +04:00
|
|
|
static int
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
do_flfs_newfs(const char *partname, int partno, const char *mountpoint)
|
1997-11-03 03:04:53 +03:00
|
|
|
{
|
2003-01-10 23:00:27 +03:00
|
|
|
char dev_name[STRSIZE];
|
1999-04-09 14:24:38 +04:00
|
|
|
int error;
|
2003-06-09 23:06:48 +04:00
|
|
|
const char *newfs;
|
|
|
|
|
|
|
|
if (!*mountpoint)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (bsdlabel[partno].pi_newfs) {
|
|
|
|
switch (bsdlabel[partno].pi_fstype) {
|
|
|
|
case FS_BSDFFS:
|
|
|
|
newfs = "/sbin/newfs";
|
|
|
|
break;
|
|
|
|
case FS_BSDLFS:
|
|
|
|
newfs = "/sbin/newfs_lfs";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
error = run_prog(RUN_DISPLAY, MSG_cmdfail, "%s /dev/r%s",
|
2003-06-09 23:06:48 +04:00
|
|
|
newfs, partname);
|
|
|
|
} else
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
error = 0;
|
2003-06-09 23:06:48 +04:00
|
|
|
|
|
|
|
if (error == 0) {
|
2003-01-10 23:00:27 +03:00
|
|
|
snprintf(dev_name, sizeof(dev_name), "/dev/%s", partname);
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
if (partno > 0) /* XXX strcmp(mountpoint, "/") ? XXX */
|
1997-11-03 03:04:53 +03:00
|
|
|
make_target_dir(mountpoint);
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
error = target_mount(bsdlabel[partno].pi_fstype == FS_BSDFFS ?
|
2003-01-10 23:00:27 +03:00
|
|
|
"-v -o async" : "-v", dev_name, mountpoint);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
if (error) {
|
2003-01-10 23:00:27 +03:00
|
|
|
msg_display(MSG_mountfail, dev_name, mountpoint);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
}
|
1997-11-03 03:04:53 +03:00
|
|
|
}
|
1999-04-09 14:24:38 +04:00
|
|
|
return error;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
|
|
|
make_fstab(void)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
FILE *f;
|
2003-01-10 23:00:27 +03:00
|
|
|
int i, swap_dev = -1;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/* Create the fstab. */
|
1997-11-02 11:20:40 +03:00
|
|
|
make_target_dir("/etc");
|
1999-03-31 04:44:48 +04:00
|
|
|
f = target_fopen("/etc/fstab", "w");
|
1999-01-21 11:02:17 +03:00
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
(void)fprintf(logfp,
|
|
|
|
"Creating %s/etc/fstab.\n", target_prefix());
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
scripting_fprintf(NULL, "cat <<EOF >%s/etc/fstab\n", target_prefix());
|
1999-01-21 11:02:17 +03:00
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
if (f == NULL) {
|
|
|
|
#ifndef DEBUG
|
1999-04-09 14:24:38 +04:00
|
|
|
msg_display(MSG_createfstab);
|
1999-01-21 11:02:17 +03:00
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
(void)fprintf(logfp, "Failed to make /etc/fstab!\n");
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
return 1;
|
1997-09-27 03:02:53 +04:00
|
|
|
#else
|
|
|
|
f = stdout;
|
2003-05-19 00:04:21 +04:00
|
|
|
#endif
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
for (i = 0; i < getmaxpartitions(); i++) {
|
|
|
|
const char *s = "";
|
|
|
|
const char *mp = bsdlabel[i].pi_mount;
|
|
|
|
const char *fstype = "ffs";
|
|
|
|
|
|
|
|
if (!*mp) {
|
|
|
|
/*
|
|
|
|
* No mount point specified, comment out line and
|
|
|
|
* use /mnt as a placeholder for the mount point.
|
|
|
|
*/
|
|
|
|
s = "# ";
|
|
|
|
mp = "/mnt";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (bsdlabel[i].pi_fstype) {
|
|
|
|
case FS_BSDLFS:
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
/* If there is no LFS, just comment it out. */
|
2003-06-09 23:06:48 +04:00
|
|
|
if (check_lfs_progs())
|
|
|
|
s = "# ";
|
|
|
|
fstype = "lfs";
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case FS_BSDFFS:
|
|
|
|
scripting_fprintf(f, "%s/dev/%s%c %s %s rw 1 %d\n",
|
|
|
|
s, diskdev, 'a' + i, mp, fstype, fsck_num(mp));
|
|
|
|
break;
|
|
|
|
case FS_MSDOS:
|
|
|
|
scripting_fprintf(f, "%s/dev/%s%c %s msdos rw 0 0\n",
|
|
|
|
s, diskdev, 'a' + i, mp);
|
|
|
|
break;
|
|
|
|
case FS_SWAP:
|
2003-01-10 23:00:27 +03:00
|
|
|
if (swap_dev == -1)
|
|
|
|
swap_dev = i;
|
2003-05-19 00:04:21 +04:00
|
|
|
scripting_fprintf(f, "/dev/%s%c none swap sw 0 0\n",
|
|
|
|
diskdev, 'a' + i);
|
2003-06-09 23:06:48 +04:00
|
|
|
break;
|
1999-01-21 11:02:17 +03:00
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
}
|
|
|
|
|
2003-06-07 01:37:13 +04:00
|
|
|
if (tmp_mfs_size != 0) {
|
2003-01-10 23:00:27 +03:00
|
|
|
if (swap_dev != -1)
|
2003-06-07 01:37:13 +04:00
|
|
|
scripting_fprintf(f, "/dev/%s%c /tmp mfs rw,-s=%d\n",
|
|
|
|
diskdev, 'a' + swap_dev, tmp_mfs_size);
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
else
|
2003-06-07 01:37:13 +04:00
|
|
|
scripting_fprintf(f, "swap /tmp mfs rw,-s=%d\n,
|
|
|
|
tmp_mfs_size");
|
1999-01-21 11:02:17 +03:00
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
|
|
|
/* Add /kern to fstab and make mountpoint. */
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
scripting_fprintf(script, "/kern /kern kernfs rw\n");
|
2003-06-09 23:06:48 +04:00
|
|
|
make_target_dir("/kern");
|
|
|
|
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
scripting_fprintf(NULL, "EOF\n");
|
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
#ifndef DEBUG
|
|
|
|
fclose(f);
|
1999-01-21 11:02:17 +03:00
|
|
|
fflush(NULL);
|
1997-09-27 03:02:53 +04:00
|
|
|
#endif
|
1999-04-09 14:24:38 +04:00
|
|
|
return 0;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2002-06-30 07:57:46 +04:00
|
|
|
/* Return the appropriate fs_passno field, as specified by fstab(5) */
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
static int
|
|
|
|
fsck_num(const char *mp)
|
|
|
|
{
|
2002-06-30 07:57:46 +04:00
|
|
|
return (strcmp(mp, "/") == 0) ? 1 : 2;
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
}
|
|
|
|
|
1997-11-13 06:06:44 +03:00
|
|
|
|
1997-10-01 09:04:24 +04:00
|
|
|
/* Get information on the file systems mounted from the root filesystem.
|
|
|
|
* Offer to convert them into 4.4BSD inodes if they are not 4.4BSD
|
|
|
|
* inodes. Fsck them. Mount them.
|
|
|
|
*/
|
|
|
|
|
1997-10-07 08:01:29 +04:00
|
|
|
|
|
|
|
static struct lookfor fstabbuf[] = {
|
2000-11-14 16:27:49 +03:00
|
|
|
{"/dev/", "/dev/%s %s ffs %s", "c", NULL, 0, 0, foundffs},
|
|
|
|
{"/dev/", "/dev/%s %s ufs %s", "c", NULL, 0, 0, foundffs},
|
1997-10-01 09:04:24 +04:00
|
|
|
};
|
2003-01-10 23:00:27 +03:00
|
|
|
static size_t numfstabbuf = sizeof(fstabbuf) / sizeof(struct lookfor);
|
1997-10-07 08:01:29 +04:00
|
|
|
|
|
|
|
#define MAXDEVS 40
|
1997-10-01 09:04:24 +04:00
|
|
|
|
1997-10-07 08:01:29 +04:00
|
|
|
static char dev[MAXDEVS][SSTRSIZE];
|
|
|
|
static char mnt[MAXDEVS][STRSIZE];
|
|
|
|
static int devcnt = 0;
|
|
|
|
|
|
|
|
static void
|
2003-01-10 23:00:27 +03:00
|
|
|
/*ARGSUSED*/
|
|
|
|
foundffs(struct data *list, size_t num)
|
1997-10-01 09:04:24 +04:00
|
|
|
{
|
2000-11-14 16:27:49 +03:00
|
|
|
if (strcmp(list[1].u.s_val, "/") != 0 &&
|
|
|
|
strstr(list[2].u.s_val, "noauto") == NULL) {
|
1997-10-07 08:01:29 +04:00
|
|
|
strncpy(dev[devcnt], list[0].u.s_val, SSTRSIZE);
|
|
|
|
strncpy(mnt[devcnt], list[1].u.s_val, STRSIZE);
|
|
|
|
devcnt++;
|
|
|
|
}
|
1997-10-01 09:04:24 +04:00
|
|
|
}
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
2003-03-18 04:13:23 +03:00
|
|
|
* Run a check on the specified filesystem.
|
1997-11-05 10:28:20 +03:00
|
|
|
*/
|
1997-10-07 08:01:29 +04:00
|
|
|
static int
|
1997-11-05 10:28:20 +03:00
|
|
|
do_fsck(const char *diskpart)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
2003-01-10 23:00:27 +03:00
|
|
|
char rraw[SSTRSIZE];
|
2003-03-18 04:13:23 +03:00
|
|
|
char *prog = "/sbin/fsck";
|
1997-11-05 10:28:20 +03:00
|
|
|
int err;
|
1997-10-07 08:01:29 +04:00
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/* cons up raw partition name. */
|
2003-01-10 23:00:27 +03:00
|
|
|
snprintf (rraw, sizeof(rraw), "/dev/r%s", diskpart);
|
1997-10-01 09:04:24 +04:00
|
|
|
|
2000-05-20 04:45:45 +04:00
|
|
|
#ifndef DEBUG_SETS
|
2003-03-18 04:13:23 +03:00
|
|
|
err = run_prog(RUN_DISPLAY, NULL, "%s %s", prog, rraw);
|
1997-12-05 17:00:59 +03:00
|
|
|
#else
|
2003-03-18 04:13:23 +03:00
|
|
|
err = run_prog(RUN_DISPLAY, NULL, "%s -f %s", prog, rraw);
|
2003-05-19 00:04:21 +04:00
|
|
|
#endif
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
wrefresh(stdscr);
|
1997-11-05 10:28:20 +03:00
|
|
|
return err;
|
1997-10-01 09:04:24 +04:00
|
|
|
}
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
|
|
|
* Do an fsck. On failure, inform the user by showing a warning
|
|
|
|
* message and doing menu_ok() before proceeding.
|
|
|
|
* acknowledge the warning before continuing.
|
|
|
|
* Returns 0 on success, or nonzero return code from do_fsck() on failure.
|
|
|
|
*/
|
1997-10-01 09:04:24 +04:00
|
|
|
int
|
1997-11-05 10:28:20 +03:00
|
|
|
fsck_with_error_menu(const char *diskpart)
|
1997-11-03 05:38:41 +03:00
|
|
|
{
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
int error;
|
|
|
|
|
|
|
|
if ((error = do_fsck(diskpart)) != 0) {
|
1997-11-05 10:28:20 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, "sysinst: do_fsck() returned err %d\n", error);
|
|
|
|
#endif
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_display(MSG_badfs, diskpart, "", error);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
1997-11-05 10:28:20 +03:00
|
|
|
return error;
|
|
|
|
}
|
1997-10-01 09:04:24 +04:00
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do target_mount, but print a message and do menu_ok() before
|
|
|
|
* proceeding, to inform the user.
|
|
|
|
* returns 0 if the mount completed without indicating errors,
|
|
|
|
* and an nonzero error code from target_mount() otherwise.
|
|
|
|
*/
|
2003-05-19 00:04:21 +04:00
|
|
|
int target_mount_with_error_menu(const char *opt,
|
1997-11-05 10:28:20 +03:00
|
|
|
char *diskpart, const char *mntpoint)
|
|
|
|
{
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
int error;
|
2003-01-10 23:00:27 +03:00
|
|
|
char dev_name[STRSIZE];
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
snprintf(dev_name, sizeof(dev_name), "/dev/%s", diskpart);
|
1997-11-05 10:28:20 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, "sysinst: mount_with_error_menu: %s %s %s\n",
|
2003-01-10 23:00:27 +03:00
|
|
|
opt, dev_name, mntpoint);
|
1997-11-05 10:28:20 +03:00
|
|
|
#endif
|
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
if ((error = target_mount(opt, dev_name, mntpoint)) != 0) {
|
|
|
|
msg_display (MSG_badmount, dev_name, "");
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu (MENU_ok, NULL);
|
1997-11-05 10:28:20 +03:00
|
|
|
return error;
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("mount %s %s %s OK\n", opt, diskpart, mntpoint);
|
|
|
|
#endif
|
1997-11-03 05:38:41 +03:00
|
|
|
}
|
1997-11-05 10:28:20 +03:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fsck and mount the root partition.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
fsck_root()
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
char rootdev[STRSIZE];
|
|
|
|
|
|
|
|
/* cons up the root name: partition 'a' on the target diskdev.*/
|
|
|
|
snprintf(rootdev, STRSIZE, "%s%c", diskdev, 'a');
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("fsck_root: rootdev is %s\n", rootdev);
|
|
|
|
#endif
|
|
|
|
error = fsck_with_error_menu(rootdev);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if (target_already_root()) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-05-19 00:04:21 +04:00
|
|
|
/* Mount /dev/<diskdev>a on target's "".
|
|
|
|
* If we pass "" as mount-on, Prefixing will DTRT.
|
1997-11-05 10:28:20 +03:00
|
|
|
* for now, use no options.
|
|
|
|
* XXX consider -o remount in case target root is
|
2003-05-19 00:04:21 +04:00
|
|
|
* current root, still readonly from single-user?
|
1997-11-05 10:28:20 +03:00
|
|
|
*/
|
|
|
|
error = target_mount_with_error_menu("", rootdev, "");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("fsck_root: mount of %s returns %d\n", rootdev, error);
|
|
|
|
#endif
|
|
|
|
return (error);
|
1997-11-03 05:38:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-03-31 04:44:48 +04:00
|
|
|
fsck_disks(void)
|
1997-11-03 05:38:41 +03:00
|
|
|
{ char *fstab;
|
|
|
|
int fstabsize;
|
|
|
|
int i;
|
1997-11-05 10:28:20 +03:00
|
|
|
int error;
|
1997-11-03 05:38:41 +03:00
|
|
|
|
|
|
|
/* First the root device. */
|
|
|
|
if (!target_already_root()) {
|
1997-11-05 10:28:20 +03:00
|
|
|
error = fsck_root();
|
2003-05-19 00:04:21 +04:00
|
|
|
if (error != 0 && error != EBUSY)
|
1997-11-03 05:38:41 +03:00
|
|
|
return 0;
|
1997-10-01 09:04:24 +04:00
|
|
|
}
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/* Check the target /etc/fstab exists before trying to parse it. */
|
2003-05-19 00:04:21 +04:00
|
|
|
if (target_dir_exists_p("/etc") == 0 ||
|
1997-12-05 17:00:59 +03:00
|
|
|
target_file_exists_p("/etc/fstab") == 0) {
|
1997-11-05 10:28:20 +03:00
|
|
|
msg_display(MSG_noetcfstab, diskdev);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1997-11-05 10:28:20 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-03 05:38:41 +03:00
|
|
|
/* Get fstab entries from the target-root /etc/fstab. */
|
1999-03-31 04:44:48 +04:00
|
|
|
fstabsize = target_collect_file(T_FILE, &fstab, "/etc/fstab");
|
1997-10-01 09:04:24 +04:00
|
|
|
if (fstabsize < 0) {
|
|
|
|
/* error ! */
|
1997-11-05 10:28:20 +03:00
|
|
|
msg_display(MSG_badetcfstab, diskdev);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1997-10-01 09:04:24 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2003-01-10 23:00:27 +03:00
|
|
|
walk(fstab, (size_t)fstabsize, fstabbuf, numfstabbuf);
|
1997-10-01 09:04:24 +04:00
|
|
|
free(fstab);
|
|
|
|
|
1999-03-31 04:44:48 +04:00
|
|
|
for (i = 0; i < devcnt; i++) {
|
1997-11-05 10:28:20 +03:00
|
|
|
if (fsck_with_error_menu(dev[i]))
|
1997-10-07 08:01:29 +04:00
|
|
|
return 0;
|
1997-11-05 10:28:20 +03:00
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
#ifdef DEBUG
|
1997-11-05 10:28:20 +03:00
|
|
|
printf("sysinst: mount %s\n", dev[i]);
|
1997-12-05 17:00:59 +03:00
|
|
|
#endif
|
2003-05-19 00:04:21 +04:00
|
|
|
if (target_mount_with_error_menu("", dev[i], mnt[i]) != 0)
|
1997-10-07 08:01:29 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
|
1997-10-01 09:04:24 +04:00
|
|
|
return 1;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
2000-09-27 16:42:04 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
set_swap(dev, pp, enable)
|
|
|
|
const char *dev;
|
|
|
|
partinfo *pp;
|
2003-01-10 23:00:27 +03:00
|
|
|
int enable;
|
2000-09-27 16:42:04 +04:00
|
|
|
{
|
|
|
|
partinfo parts[16];
|
|
|
|
int i, maxpart;
|
|
|
|
|
|
|
|
if (pp == NULL) {
|
|
|
|
emptylabel(parts);
|
|
|
|
if (incorelabel(dev, parts) < 0)
|
|
|
|
return -1;
|
|
|
|
pp = parts;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxpart = getmaxpartitions();
|
|
|
|
|
|
|
|
for (i = 0; i < maxpart; i++) {
|
|
|
|
if (pp[i].pi_fstype == FS_SWAP) {
|
2000-10-12 03:47:55 +04:00
|
|
|
if (run_prog(0, NULL,
|
2000-09-27 16:42:04 +04:00
|
|
|
"/sbin/swapctl -%c /dev/%s%c",
|
|
|
|
enable ? 'a' : 'd', dev, 'a' + i) != 0)
|
|
|
|
return -1;
|
|
|
|
if (enable)
|
|
|
|
strcpy(swapdev, dev);
|
|
|
|
else
|
|
|
|
swapdev[0] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|