2003-01-13 00:49:50 +03:00
|
|
|
/* $NetBSD: disks.c,v 1.49 2003/01/12 21:49:50 christos 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
|
|
|
|
* 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
|
|
|
|
* 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)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* 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-01-10 23:00:27 +03:00
|
|
|
static void foundffs (struct data *list, size_t num);
|
1997-11-05 10:28:20 +03:00
|
|
|
static int do_fsck(const char *diskpart);
|
2000-12-22 13:12:12 +03:00
|
|
|
static int fsck_root (void);
|
1999-04-09 14:24:38 +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 part, const char *mountpoint);
|
|
|
|
static int fsck_num(const char *mp);
|
1997-10-01 09:04:24 +04:00
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
static int fsck_with_error_menu(const char *diskpart);
|
|
|
|
static int target_mount_with_error_menu(const char *opt, char *diskpart,
|
|
|
|
const char *mntpt);
|
|
|
|
|
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
|
|
|
{
|
1997-10-29 04:06:42 +03:00
|
|
|
char **xd = disk_names;
|
1997-10-15 08:35:17 +04:00
|
|
|
char d_name[SSTRSIZE];
|
|
|
|
struct disklabel l;
|
|
|
|
int i;
|
1997-10-07 08:01:29 +04:00
|
|
|
|
1997-10-15 08:35:17 +04:00
|
|
|
while (*xd != NULL) {
|
1998-10-31 06:54:44 +03:00
|
|
|
for (i=0; i< MAX_DISKS; i++) {
|
1999-03-31 04:44:48 +04:00
|
|
|
snprintf(d_name, SSTRSIZE, "%s%d", *xd, i);
|
|
|
|
if (get_geom(d_name, &l) && numdisks < MAX_DISKS) {
|
1999-03-14 17:19:05 +03:00
|
|
|
strncpy (disks[numdisks].dd_name,
|
1997-10-15 08:35:17 +04:00
|
|
|
d_name, SSTRSIZE);
|
|
|
|
strncat (disknames, d_name,
|
|
|
|
SSTRSIZE-1-strlen(disknames));
|
|
|
|
strncat (disknames, " ",
|
|
|
|
SSTRSIZE-1-strlen(disknames));
|
1999-03-14 17:19:05 +03:00
|
|
|
disks[numdisks].dd_cyl = l.d_ncylinders;
|
|
|
|
disks[numdisks].dd_head = l.d_ntracks;
|
|
|
|
disks[numdisks].dd_sec = l.d_nsectors;
|
|
|
|
disks[numdisks].dd_secsize = l.d_secsize;
|
|
|
|
disks[numdisks].dd_totsec = l.d_secperunit;
|
1997-10-15 08:35:17 +04:00
|
|
|
numdisks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xd++;
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
|
|
|
}
|
1997-10-15 08:35:17 +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;
|
1997-10-07 08:01:29 +04:00
|
|
|
char defname[STRSIZE];
|
|
|
|
int i;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/* initialize */
|
|
|
|
disknames[0] = 0;
|
|
|
|
numdisks = 0;
|
|
|
|
|
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);
|
|
|
|
process_menu(MENU_ok);
|
1999-01-21 11:02:17 +03:00
|
|
|
/*endwin();*/
|
1997-09-27 03:02:53 +04:00
|
|
|
return -1;
|
|
|
|
} else if (numdisks == 1) {
|
|
|
|
/* One disk found! */
|
|
|
|
/* Remove that space we added. */
|
|
|
|
disknames[strlen(disknames)-1] = 0;
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_display(MSG_onedisk, disknames, doingwhat);
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
strcpy(diskdev, disknames);
|
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, " ");
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_prompt(MSG_askdisk, defname, diskdev, 10, disknames);
|
1997-09-27 03:02:53 +04:00
|
|
|
tp = diskdev;
|
|
|
|
strsep(&tp, " ");
|
|
|
|
diskdev[strlen(diskdev)+1] = 0;
|
|
|
|
diskdev[strlen(diskdev)] = ' ';
|
1997-10-29 04:06:42 +03:00
|
|
|
while (!ISDISKSTART(*diskdev) ||
|
1997-09-27 03:02:53 +04:00
|
|
|
strstr(disknames, diskdev) == NULL) {
|
1999-03-31 04:44:48 +04:00
|
|
|
msg_prompt(MSG_badname, defname, diskdev, 10,
|
1997-09-27 03:02:53 +04:00
|
|
|
disknames);
|
|
|
|
tp = diskdev;
|
|
|
|
strsep(&tp, " ");
|
|
|
|
diskdev[strlen(diskdev)+1] = 0;
|
|
|
|
diskdev[strlen(diskdev)] = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove that space we added. */
|
|
|
|
diskdev[strlen(diskdev)-1] = 0;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
1999-07-04 12:01:39 +04:00
|
|
|
msg_table_add(MSG_fspart_row_start,
|
2002-08-12 06:22:52 +04:00
|
|
|
'a'+i, 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,
|
1999-03-31 04:44:48 +04:00
|
|
|
bsdlabel[i].pi_bsize,
|
|
|
|
bsdlabel[i].pi_fsize,
|
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
|
|
|
preservemount[i] ? "Yes" : "No",
|
1997-09-27 03:02:53 +04:00
|
|
|
fsmount[i]);
|
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,
|
|
|
|
fsmount[i]);
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* Sun ports should use DISKLABEL_CMD "/sbin/disklabel -w"
|
|
|
|
* 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
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* point defined, or is marked preserve, don't touch it!
|
1997-11-03 03:04:53 +03: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)) {
|
|
|
|
error = do_flfs_newfs(partname, i, fsmount[i]);
|
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. */
|
1999-04-09 14:24:38 +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;
|
|
|
|
|
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 (*mountpoint && !preservemount[partno])
|
|
|
|
error = run_prog(RUN_DISPLAY, MSG_cmdfail, "%s /dev/r%s",
|
|
|
|
bsdlabel[partno].pi_fstype == FS_BSDFFS ?
|
|
|
|
"/sbin/newfs" : "/sbin/newfs_lfs", partname);
|
|
|
|
else
|
|
|
|
error = 0;
|
1999-04-09 14:24:38 +04:00
|
|
|
if (*mountpoint && 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);
|
- 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
|
|
|
process_menu (MENU_ok);
|
|
|
|
}
|
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");
|
1999-04-09 14:24:38 +04:00
|
|
|
process_menu(MENU_ok);
|
- 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;
|
|
|
|
#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
|
|
|
for (i = 0; i < getmaxpartitions(); i++)
|
2002-06-30 08:02:47 +04:00
|
|
|
if (bsdlabel[i].pi_fstype == FS_BSDFFS) {
|
|
|
|
char *s = "#";
|
|
|
|
|
|
|
|
if (*fsmount[i] != '\0')
|
|
|
|
s++;
|
|
|
|
scripting_fprintf(f, "%s/dev/%s%c %s ffs rw 1 %d\n", s,
|
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
|
|
|
diskdev, 'a'+i, fsmount[i],
|
|
|
|
fsck_num(fsmount[i]));
|
2002-06-30 08:02:47 +04:00
|
|
|
} else if (bsdlabel[i].pi_fstype == 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
|
|
|
char *s = "#";
|
|
|
|
|
|
|
|
/* If there is no LFS, just comment it out. */
|
2002-06-30 08:02:47 +04:00
|
|
|
if (!check_lfs_progs() && *fsmount[i] != '\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
|
|
|
s++;
|
|
|
|
scripting_fprintf(f, "%s/dev/%s%c %s lfs rw 1 %d\n", s,
|
|
|
|
diskdev, 'a'+i, fsmount[i],
|
|
|
|
fsck_num(fsmount[i]));
|
2002-06-30 08:02:47 +04:00
|
|
|
} else if (bsdlabel[i].pi_fstype == FS_MSDOS) {
|
|
|
|
char *s = "#";
|
|
|
|
|
|
|
|
if (*fsmount[i] != '\0')
|
|
|
|
s++;
|
|
|
|
scripting_fprintf(f, "%s/dev/%s%c %s msdos rw 0 0\n", s,
|
1997-09-27 03:02:53 +04:00
|
|
|
diskdev, 'a'+i, fsmount[i]);
|
2002-06-30 08:02:47 +04:00
|
|
|
} else if (bsdlabel[i].pi_fstype == FS_SWAP) {
|
2003-01-10 23:00:27 +03:00
|
|
|
if (swap_dev == -1)
|
|
|
|
swap_dev = 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
|
|
|
scripting_fprintf(f, "/dev/%s%c none swap sw 0 0\n", diskdev, 'a'+i);
|
1999-01-21 11:02:17 +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
|
|
|
if (layout_tmp) {
|
2003-01-10 23:00:27 +03:00
|
|
|
if (swap_dev != -1)
|
|
|
|
scripting_fprintf(f, "/dev/%s%c /tmp mfs rw\n", diskdev, 'a'+swap_dev);
|
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
|
|
|
|
scripting_fprintf(f, "swap /tmp mfs rw\n");
|
1999-01-21 11:02:17 +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
|
|
|
scripting_fprintf(script, "/kern /kern kernfs rw\n");
|
|
|
|
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
|
1997-11-13 06:06:44 +03:00
|
|
|
/* We added /kern to fstab, make mountpoint. */
|
|
|
|
make_target_dir("/kern");
|
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-10-07 08:01:29 +04:00
|
|
|
static int
|
1999-03-31 04:44:48 +04:00
|
|
|
inode_kind(char *dev)
|
1997-10-07 08:01:29 +04:00
|
|
|
{
|
1999-03-31 04:44:48 +04:00
|
|
|
union {
|
|
|
|
struct fs fs;
|
|
|
|
char pad[SBSIZE];
|
|
|
|
} fs;
|
1997-10-07 08:01:29 +04:00
|
|
|
int fd;
|
|
|
|
|
1999-03-31 04:44:48 +04:00
|
|
|
fd = open(dev, O_RDONLY, 0);
|
1997-10-07 08:01:29 +04:00
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
1999-03-31 04:44:48 +04:00
|
|
|
if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1) {
|
|
|
|
close(fd);
|
1997-10-07 08:01:29 +04:00
|
|
|
return -1;
|
1999-03-31 04:44:48 +04:00
|
|
|
}
|
2003-01-10 23:00:27 +03:00
|
|
|
if (read(fd, &fs, SBSIZE) != SBSIZE) {
|
1999-03-31 04:44:48 +04:00
|
|
|
close(fd);
|
1997-10-22 19:28:33 +04:00
|
|
|
return -2;
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
1999-03-31 04:44:48 +04:00
|
|
|
close(fd);
|
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 (fs_is_lfs(&fs.fs))
|
|
|
|
return -4;
|
1997-10-07 08:01:29 +04:00
|
|
|
if (fs.fs.fs_magic != FS_MAGIC)
|
1997-10-22 19:28:33 +04:00
|
|
|
return -3;
|
1997-10-07 08:01:29 +04:00
|
|
|
if (fs.fs.fs_inodefmt < FS_44INODEFMT)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
|
|
|
* Do an fsck. For now, assume ffs filesystems.
|
|
|
|
* Returns zero if the fsck completed with no errors.
|
|
|
|
* Returns a negative numbe to indicate a bad inode type,
|
|
|
|
* and a positive non-zero value if exec'ing fsck returns an error.
|
|
|
|
* If the filesystem is an out-of-date version, prompt the user
|
|
|
|
* whether to upgrade the filesystem level.
|
|
|
|
*
|
|
|
|
*/
|
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];
|
1997-10-07 08:01:29 +04:00
|
|
|
int inodetype;
|
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
|
|
|
char *upgr = "", *prog = "/sbin/fsck_ffs";
|
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);
|
|
|
|
inodetype = inode_kind (rraw);
|
1997-10-07 08:01:29 +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
|
|
|
if (inodetype == -4) {
|
|
|
|
if (check_lfs_progs() == 0)
|
|
|
|
return EOPNOTSUPP; /* XXX */
|
|
|
|
prog = "/sbin/fsck_lfs";
|
|
|
|
} else if (inodetype < 0) {
|
1997-10-07 08:01:29 +04:00
|
|
|
/* error */
|
1997-10-22 19:28:33 +04:00
|
|
|
return inodetype;
|
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 if (inodetype == 0) {
|
1997-10-07 08:01:29 +04:00
|
|
|
/* Ask to upgrade */
|
2003-01-10 23:00:27 +03:00
|
|
|
msg_display(MSG_upgrinode, rraw);
|
1999-03-31 04:44:48 +04:00
|
|
|
process_menu(MENU_yesno);
|
1997-10-07 08:01:29 +04:00
|
|
|
if (yesno)
|
2000-10-31 19:02:06 +03:00
|
|
|
upgr = "-c 3 ";
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
1997-10-01 09:04:24 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
/*endwin();*/
|
2000-05-20 04:45:45 +04:00
|
|
|
#ifndef DEBUG_SETS
|
2003-01-10 23:00:27 +03:00
|
|
|
err = run_prog(RUN_DISPLAY, NULL, "%s %s%s", prog, upgr, rraw);
|
1997-12-05 17:00:59 +03:00
|
|
|
#else
|
2003-01-10 23:00:27 +03:00
|
|
|
err = run_prog(RUN_DISPLAY, NULL, "%s -f %s%s", prog, upgr, rraw);
|
1997-12-05 17:00:59 +03: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);
|
|
|
|
process_menu(MENU_ok);
|
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.
|
|
|
|
*/
|
|
|
|
int target_mount_with_error_menu(const char *opt,
|
|
|
|
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, "");
|
1997-10-07 08:01:29 +04:00
|
|
|
process_menu (MENU_ok);
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mount /dev/<diskdev>a on target's "".
|
|
|
|
* If we pass "" as mount-on, Prefixing will DTRT.
|
|
|
|
* for now, use no options.
|
|
|
|
* XXX consider -o remount in case target root is
|
|
|
|
* current root, still readonly from single-user?
|
|
|
|
*/
|
|
|
|
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();
|
|
|
|
if (error != 0 && error != EBUSY) {
|
1997-11-03 05:38:41 +03:00
|
|
|
return 0;
|
1997-11-05 10:28:20 +03:00
|
|
|
}
|
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. */
|
1997-12-05 17:00:59 +03:00
|
|
|
if (target_dir_exists_p("/etc") == 0 ||
|
|
|
|
target_file_exists_p("/etc/fstab") == 0) {
|
1997-11-05 10:28:20 +03:00
|
|
|
msg_display(MSG_noetcfstab, diskdev);
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
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);
|
|
|
|
process_menu(MENU_ok);
|
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
|
1997-11-05 10:28:20 +03:00
|
|
|
if (target_mount_with_error_menu("", dev[i], mnt[i]) != 0) {
|
1997-10-07 08:01:29 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2001-01-15 02:45:16 +03:00
|
|
|
|
|
|
|
/* XXX
|
|
|
|
* these belong in bsddisklabel.c but until that is common across all sysinst
|
|
|
|
* ports, they need to be here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
show_cur_filesystems()
|
|
|
|
{
|
|
|
|
|
|
|
|
msg_display(MSG_cur_fs);
|
|
|
|
msg_table_add(MSG_cur_fs_header);
|
|
|
|
msg_table_add(MSG_cur_fs_row, "/ ", "[X] (always)");
|
|
|
|
msg_table_add(MSG_cur_fs_row, "swap ", layout_swap ? "[X]" : "");
|
|
|
|
msg_table_add(MSG_cur_fs_row, "/usr ", layout_usr ? "[X]" : "");
|
|
|
|
msg_table_add(MSG_cur_fs_row, "/var ", layout_var ? "[X]" : "");
|
|
|
|
msg_table_add(MSG_cur_fs_row, "/home", layout_home ? "[X]" : "");
|
|
|
|
msg_table_add(MSG_cur_fs_row, "/tmp ", layout_tmp ? "[X] (mfs)" : " (mfs)");
|
|
|
|
}
|
|
|
|
|
|
|
|
int layout_swap, layout_usr, layout_tmp, layout_var, layout_home;
|
|
|
|
|