2003-07-25 12:26:21 +04:00
|
|
|
/* $NetBSD: disks.c,v 1.65 2003/07/25 08:26:21 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>
|
2003-06-16 14:42:47 +04:00
|
|
|
#include <sys/swap.h>
|
1997-10-07 08:01:29 +04:00
|
|
|
#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"
|
|
|
|
|
2003-07-11 19:28:58 +04:00
|
|
|
/* Disk descriptions */
|
|
|
|
#define MAX_DISKS 15
|
|
|
|
struct disk_desc {
|
|
|
|
char dd_name[SSTRSIZE];
|
|
|
|
struct disk_geom {
|
|
|
|
int dg_cyl;
|
|
|
|
int dg_head;
|
|
|
|
int dg_sec;
|
|
|
|
int dg_secsize;
|
|
|
|
int dg_totsec;
|
|
|
|
} dg;
|
|
|
|
};
|
|
|
|
#define dd_cyl dg.dg_cyl
|
|
|
|
#define dd_head dg.dg_head
|
|
|
|
#define dd_sec dg.dg_sec
|
|
|
|
#define dd_secsize dg.dg_secsize
|
|
|
|
#define dd_totsec dg.dg_totsec
|
1997-11-02 11:20:40 +03:00
|
|
|
|
1997-10-01 09:04:24 +04:00
|
|
|
/* Local prototypes */
|
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
|
|
|
|
|
2003-07-25 12:26:21 +04:00
|
|
|
static const char *disk_names[] = { DISK_NAMES, "vnd", NULL };
|
1997-11-02 11:20:40 +03:00
|
|
|
|
2003-07-11 19:28:58 +04:00
|
|
|
static int
|
|
|
|
get_disks(struct disk_desc *dd)
|
1997-10-15 08:35:17 +04:00
|
|
|
{
|
2003-07-25 12:26:21 +04:00
|
|
|
const char **xd;
|
1997-10-15 08:35:17 +04:00
|
|
|
char d_name[SSTRSIZE];
|
|
|
|
struct disklabel l;
|
|
|
|
int i;
|
2003-07-11 19:28:58 +04:00
|
|
|
int numdisks;
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2003-05-19 00:04:21 +04:00
|
|
|
/* initialize */
|
|
|
|
numdisks = 0;
|
|
|
|
|
|
|
|
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-07-11 19:28:58 +04:00
|
|
|
strlcpy(dd->dd_name, d_name, sizeof dd->dd_name);
|
2003-05-19 00:04:21 +04:00
|
|
|
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)
|
2003-07-11 19:28:58 +04:00
|
|
|
return numdisks;
|
1997-10-15 08:35:17 +04:00
|
|
|
}
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
2003-07-11 19:28:58 +04:00
|
|
|
return numdisks;
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
|
2003-07-11 19:28:58 +04:00
|
|
|
static int
|
|
|
|
set_dsk_select(menudesc *m, menu_ent *opt, void *arg)
|
|
|
|
{
|
|
|
|
*(int *)arg = m->cursel;
|
|
|
|
return 1;
|
|
|
|
}
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
2003-06-28 02:20:14 +04:00
|
|
|
find_disks(const char *doingwhat)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
2003-07-11 19:28:58 +04:00
|
|
|
struct disk_desc disks[MAX_DISKS];
|
|
|
|
menu_ent dsk_menu[nelem(disks)];
|
|
|
|
struct disk_desc *disk;
|
|
|
|
int i;
|
|
|
|
int numdisks;
|
|
|
|
int selected_disk = 0;
|
|
|
|
int menu_no;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1997-10-15 08:35:17 +04:00
|
|
|
/* Find disks. */
|
2003-07-11 19:28:58 +04:00
|
|
|
numdisks = get_disks(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! */
|
2003-07-11 19:28:58 +04:00
|
|
|
msg_display(MSG_onedisk, disks[0].dd_name, doingwhat);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1997-09-27 03:02:53 +04:00
|
|
|
} else {
|
|
|
|
/* Multiple disks found! */
|
2003-07-11 19:28:58 +04:00
|
|
|
for (i = 0; i < numdisks; i++) {
|
|
|
|
dsk_menu[i].opt_name = disks[i].dd_name;
|
|
|
|
dsk_menu[i].opt_menu = OPT_NOMENU;
|
|
|
|
dsk_menu[i].opt_flags = OPT_EXIT;
|
|
|
|
dsk_menu[i].opt_action = set_dsk_select;
|
|
|
|
}
|
|
|
|
menu_no = new_menu(MSG_Available_disks,
|
|
|
|
dsk_menu, numdisks, -1, 4, 0, 0,
|
|
|
|
MC_SCROLL | MC_NOEXITOPT,
|
|
|
|
NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (menu_no == -1)
|
|
|
|
return -1;
|
|
|
|
msg_display(MSG_ask_disk);
|
|
|
|
process_menu(menu_no, &selected_disk);
|
|
|
|
free_menu(menu_no);
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
2003-05-19 00:04:21 +04:00
|
|
|
|
2003-07-11 19:28:58 +04:00
|
|
|
disk = disks + selected_disk;
|
|
|
|
strlcpy(diskdev, disk->dd_name, sizeof diskdev);
|
1997-10-07 08:01:29 +04:00
|
|
|
|
1999-03-14 17:19:05 +03:00
|
|
|
sectorsize = disk->dd_secsize;
|
1999-03-31 04:44:48 +04:00
|
|
|
dlcyl = disk->dd_cyl;
|
|
|
|
dlhead = disk->dd_head;
|
|
|
|
dlsec = disk->dd_sec;
|
|
|
|
dlsize = disk->dd_totsec;
|
2003-07-11 19:28:58 +04:00
|
|
|
if (dlsize == 0)
|
|
|
|
dlsize = disk->dd_cyl * disk->dd_head * disk->dd_sec;
|
1999-03-31 04:44:48 +04:00
|
|
|
dlcylsize = dlhead * dlsec;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
/* Get existing/default label */
|
|
|
|
incorelabel(diskdev, oldlabel);
|
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
return numdisks;
|
|
|
|
}
|
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
void
|
2003-07-07 16:30:19 +04:00
|
|
|
fmt_fspart(menudesc *m, int ptn, void *arg)
|
2003-06-09 23:06:48 +04:00
|
|
|
{
|
|
|
|
int poffset, psize, pend;
|
|
|
|
const char *desc;
|
2003-07-07 16:30:19 +04:00
|
|
|
static const char *Yes, *No;
|
|
|
|
|
|
|
|
if (Yes == NULL) {
|
|
|
|
Yes = msg_string(MSG_Yes);
|
|
|
|
No = msg_string(MSG_No);
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
wprintw(m->mw, msg_string(MSG_fspart_row),
|
|
|
|
poffset, pend, psize, desc,
|
|
|
|
PI_ISBSDFS(&bsdlabel[ptn]) ?
|
|
|
|
bsdlabel[ptn].pi_flags & PIF_NEWFS ? Yes : No : "",
|
|
|
|
bsdlabel[ptn].pi_mount[0] == '/' ?
|
|
|
|
bsdlabel[ptn].pi_flags & PIF_MOUNT ? Yes : No : "",
|
|
|
|
bsdlabel[ptn].pi_mount);
|
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
|
2003-06-17 00:10:02 +04:00
|
|
|
* to invoke disklabel.
|
1997-11-09 07:14:10 +03:00
|
|
|
* if MD code does not define DISKLABEL_CMD, this is a no-op.
|
|
|
|
*
|
2003-06-17 00:10:02 +04:00
|
|
|
* i386 port uses "/sbin/disklabel -w -r", just like i386
|
1997-11-09 07:14:10 +03:00
|
|
|
* miniroot scripts, though this may leave a bogus incore label.
|
|
|
|
*
|
2003-06-17 00:10:02 +04:00
|
|
|
* Sun ports should use DISKLABEL_CMD "/sbin/disklabel -w"
|
|
|
|
* to get incore to ondisk inode translation for the Sun proms.
|
1997-11-09 07:14:10 +03:00
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
ptn_sort(const void *a, const void *b)
|
|
|
|
{
|
2003-07-25 12:26:21 +04:00
|
|
|
return strcmp(bsdlabel[*(const int *)a].pi_mount,
|
|
|
|
bsdlabel[*(const int *)b].pi_mount);
|
2003-07-07 16:30:19 +04:00
|
|
|
}
|
|
|
|
|
2000-12-06 07:53:37 +03:00
|
|
|
int
|
|
|
|
make_filesystems(void)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
int i;
|
2003-07-07 16:30:19 +04:00
|
|
|
int ptn;
|
|
|
|
int ptn_order[nelem(bsdlabel)];
|
1997-11-03 03:04:53 +03:00
|
|
|
char partname[STRSIZE];
|
1999-04-09 14:24:38 +04:00
|
|
|
int error;
|
2003-07-07 16:30:19 +04:00
|
|
|
int maxpart = getmaxpartitions();
|
1997-09-27 03:02:53 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (maxpart > nelem(bsdlabel))
|
|
|
|
maxpart = nelem(bsdlabel);
|
|
|
|
|
|
|
|
/* Making new file systems and mounting them */
|
|
|
|
|
|
|
|
/* sort to ensure /usr/local is mounted after /usr (etc) */
|
|
|
|
for (i = 0; i < maxpart; i++)
|
|
|
|
ptn_order[i] = i;
|
|
|
|
qsort(ptn_order, maxpart, sizeof ptn_order[0], ptn_sort);
|
|
|
|
|
|
|
|
for (i = 0; i < maxpart; 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-07-07 16:30:19 +04:00
|
|
|
ptn = ptn_order[i];
|
|
|
|
snprintf(partname, STRSIZE, "%s%c", diskdev, 'a' + ptn);
|
|
|
|
if (!PI_ISBSDFS(&bsdlabel[ptn]) || is_active_rootpart(partname))
|
|
|
|
continue;
|
|
|
|
error = do_flfs_newfs(partname, ptn, bsdlabel[ptn].pi_mount);
|
|
|
|
if (error)
|
|
|
|
return error;
|
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;
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (bsdlabel[partno].pi_flags & PIF_NEWFS) {
|
2003-06-09 23:06:48 +04:00
|
|
|
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
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (error == 0 && bsdlabel[partno].pi_flags & PIF_MOUNT) {
|
2003-01-10 23:00:27 +03:00
|
|
|
snprintf(dev_name, sizeof(dev_name), "/dev/%s", partname);
|
2003-07-07 16:30:19 +04: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-07-25 12:26:21 +04:00
|
|
|
const 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.
|
2003-06-17 00:10:02 +04:00
|
|
|
* returns 0 if the mount completed without indicating errors,
|
|
|
|
* and an nonzero error code from target_mount() otherwise.
|
1997-11-05 10:28:20 +03:00
|
|
|
*/
|
2003-07-07 16:30:19 +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
|
2003-06-17 00:10:02 +04:00
|
|
|
printf("mount %s %s %s OK\n", opt, diskpart, mntpoint);
|
1997-11-05 10:28:20 +03:00
|
|
|
#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
|
2003-06-16 23:42:13 +04:00
|
|
|
fsck_root(void)
|
1997-11-05 10:28:20 +03:00
|
|
|
{
|
2003-06-17 00:10:02 +04:00
|
|
|
int error;
|
1997-11-05 10:28:20 +03:00
|
|
|
char rootdev[STRSIZE];
|
|
|
|
|
2003-06-17 00:10:02 +04:00
|
|
|
/* cons up the root name: partition 'a' on the target diskdev.*/
|
2003-07-08 21:38:54 +04:00
|
|
|
snprintf(rootdev, STRSIZE, "%s%c", diskdev, 'a' + rootpart);
|
1997-11-05 10:28:20 +03:00
|
|
|
#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-06-17 00:10:02 +04:00
|
|
|
/* Mount /dev/<diskdev>a on target's "".
|
2003-05-19 00:04:21 +04:00
|
|
|
* 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-06-17 00:10:02 +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)
|
2003-06-16 23:42:13 +04:00
|
|
|
{
|
|
|
|
char *fstab;
|
1997-11-03 05:38:41 +03:00
|
|
|
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++) {
|
2003-06-17 00:10:02 +04: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
|
2003-07-25 12:26:21 +04:00
|
|
|
set_swap(const char *disk, partinfo *pp)
|
2000-09-27 16:42:04 +04:00
|
|
|
{
|
2003-07-07 16:30:19 +04:00
|
|
|
int i;
|
2003-06-16 14:42:47 +04:00
|
|
|
char *cp;
|
|
|
|
int rval;
|
2000-09-27 16:42:04 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (pp == NULL)
|
|
|
|
pp = oldlabel;
|
2000-09-27 16:42:04 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
for (i = 0; i < MAXPARTITIONS; i++) {
|
2003-06-16 14:42:47 +04:00
|
|
|
if (pp[i].pi_fstype != FS_SWAP)
|
|
|
|
continue;
|
2003-07-25 12:26:21 +04:00
|
|
|
asprintf(&cp, "/dev/%s%c", disk, 'a' + i);
|
2003-06-16 14:42:47 +04:00
|
|
|
rval = swapctl(SWAP_ON, cp, 0);
|
|
|
|
free(cp);
|
|
|
|
if (rval != 0)
|
|
|
|
return -1;
|
2000-09-27 16:42:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-16 14:42:47 +04:00
|
|
|
|
|
|
|
int
|
2003-07-25 12:26:21 +04:00
|
|
|
check_swap(const char *disk, int remove_swap)
|
2003-06-16 14:42:47 +04:00
|
|
|
{
|
|
|
|
struct swapent *swap;
|
|
|
|
char *cp;
|
|
|
|
int nswap;
|
|
|
|
int l;
|
|
|
|
int rval = 0;
|
|
|
|
|
|
|
|
nswap = swapctl(SWAP_NSWAP, 0, 0);
|
|
|
|
if (nswap <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
swap = malloc(nswap * sizeof *swap);
|
|
|
|
if (swap == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
nswap = swapctl(SWAP_STATS, swap, nswap);
|
|
|
|
if (nswap < 0)
|
|
|
|
goto bad_swap;
|
|
|
|
|
2003-07-25 12:26:21 +04:00
|
|
|
l = strlen(disk);
|
2003-06-16 14:42:47 +04:00
|
|
|
while (--nswap >= 0) {
|
|
|
|
/* Should we check the se_dev or se_path? */
|
|
|
|
cp = swap[nswap].se_path;
|
|
|
|
if (memcmp(cp, "/dev/", 5) != 0)
|
|
|
|
continue;
|
2003-07-25 12:26:21 +04:00
|
|
|
if (memcmp(cp + 5, disk, l) != 0)
|
2003-06-16 14:42:47 +04:00
|
|
|
continue;
|
|
|
|
if (!isalpha(*(unsigned char *)(cp + 5 + l)))
|
|
|
|
continue;
|
|
|
|
if (cp[5 + l + 1] != 0)
|
|
|
|
continue;
|
|
|
|
/* ok path looks like it is for this device */
|
2003-07-25 12:26:21 +04:00
|
|
|
if (!remove_swap) {
|
2003-06-16 14:42:47 +04:00
|
|
|
/* count active swap areas */
|
|
|
|
rval++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (swapctl(SWAP_OFF, cp, 0) == -1)
|
|
|
|
rval = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
free(swap);
|
|
|
|
return rval;
|
|
|
|
|
|
|
|
bad_swap:
|
|
|
|
rval = -1;
|
|
|
|
goto done;
|
|
|
|
}
|