summaryrefslogtreecommitdiffstats
path: root/sbin/sysinstall/stage3.c
blob: c08cccbdfdd46d430422eef3131e559da114d2b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
 * ----------------------------------------------------------------------------
 *
 * $Id: stage3.c,v 1.9.2.1 1994/11/21 03:12:18 phk Exp $
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <dialog.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <fstab.h>

#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>

#include "sysinstall.h"

void
stage3()
{
    char	pbuf[90],*p;
    int		mountflags;
    struct	fstab *fs;

    /*
     * Mount things in /etc/fstab we like.
     */

    mountflags = MNT_UPDATE;
    while((fs = getfsent()) != NULL) {
	p = fs->fs_spec;
	if (*p++ != '/') continue;
	if (*p++ != 'd') continue;
	if (*p++ != 'e') continue;
	if (*p++ != 'v') continue;
	if (*p++ != '/') continue;

	if (!strcmp(fs->fs_type, "sw")) {
	    if (swapon(fs->fs_spec) == -1)
		AskAbort("Unable to swap to %s - are you sure it's right?",
			 fs->fs_spec);
	    continue;
	}

	if (strcmp(fs->fs_vfstype, "ufs")) continue;

	if (!strcmp(fs->fs_type, "ro"))
	    mountflags |= MNT_RDONLY;
	else if (!strcmp(fs->fs_type, "rw"))
	    ;
	else
	    continue;
	strcpy(pbuf, "/dev/r");
	strcat(pbuf,p);
	TellEm("fsck -y %s",pbuf);
	if (exec(0, "/stand/fsck",
		 "/stand/fsck", "-y", pbuf, 0) == -1)
	    Fatal("exec(fsck) failed");

	MountUfs(p, fs->fs_file, 0, mountflags);
	mountflags = 0;
    }
    endfsent();
}
OpenPOWER on IntegriCloud