For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
This commit is contained in:
parent
20514c29be
commit
5bf641af07
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: boot2.c,v 1.38 2008/10/11 11:06:19 joerg Exp $ */
|
||||
/* $NetBSD: boot2.c,v 1.39 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -799,31 +799,11 @@ command_modules(char *arg)
|
|||
void
|
||||
command_load(char *arg)
|
||||
{
|
||||
boot_module_t *bm, *bmp;
|
||||
size_t len;
|
||||
char *str;
|
||||
|
||||
while (*arg == ' ' || *arg == '\t')
|
||||
++arg;
|
||||
|
||||
bm = alloc(sizeof(boot_module_t));
|
||||
len = strlen(arg) + 1;
|
||||
str = alloc(len);
|
||||
if (bm == NULL || str == NULL) {
|
||||
printf("couldn't allocate module\n");
|
||||
return;
|
||||
}
|
||||
memcpy(str, arg, len);
|
||||
bm->bm_path = str;
|
||||
bm->bm_next = NULL;
|
||||
if (boot_modules == NULL)
|
||||
boot_modules = bm;
|
||||
else {
|
||||
for (bmp = boot_modules; bmp->bm_next;
|
||||
bmp = bmp->bm_next)
|
||||
;
|
||||
bmp->bm_next = bm;
|
||||
}
|
||||
module_add(arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: version,v 1.8 2008/10/11 11:06:20 joerg Exp $
|
||||
$NetBSD: version,v 1.9 2008/11/19 12:36:41 ad Exp $
|
||||
|
||||
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
|
||||
file is important - make sure the entries are appended on end, last item
|
||||
|
@ -39,3 +39,4 @@ is taken as the current.
|
|||
5.0: Support for boot menu, modules.
|
||||
5.1: Change boot messages to replace build date with kernel version.
|
||||
5.2: Support for multiboot.
|
||||
5.3: Autoload kernel module for root file system.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec.c,v 1.33 2008/10/11 11:06:20 joerg Exp $ */
|
||||
/* $NetBSD: exec.c,v 1.34 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -135,6 +135,33 @@ static char module_base[64] = "/";
|
|||
|
||||
static void module_init(void);
|
||||
|
||||
void
|
||||
module_add(char *name)
|
||||
{
|
||||
boot_module_t *bm, *bmp;
|
||||
size_t len;
|
||||
char *str;
|
||||
|
||||
bm = alloc(sizeof(boot_module_t));
|
||||
len = strlen(name) + 1;
|
||||
str = alloc(len);
|
||||
if (bm == NULL || str == NULL) {
|
||||
printf("couldn't allocate module\n");
|
||||
return;
|
||||
}
|
||||
memcpy(str, name, len);
|
||||
bm->bm_path = str;
|
||||
bm->bm_next = NULL;
|
||||
if (boot_modules == NULL)
|
||||
boot_modules = bm;
|
||||
else {
|
||||
for (bmp = boot_modules; bmp->bm_next;
|
||||
bmp = bmp->bm_next)
|
||||
;
|
||||
bmp->bm_next = bm;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
common_load_kernel(const char *file, u_long *basemem, u_long *extmem,
|
||||
physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
|
||||
|
@ -184,6 +211,11 @@ common_load_kernel(const char *file, u_long *basemem, u_long *extmem,
|
|||
|
||||
close(fd);
|
||||
|
||||
/* Now we know the root fs type, load modules for it. */
|
||||
module_add(fsmod);
|
||||
if (fsmod2 != NULL && strcmp(fsmod, fsmod2) != 0)
|
||||
module_add(fsmod2);
|
||||
|
||||
/*
|
||||
* Gather some information for the kernel. Do this after the
|
||||
* "point of no return" to avoid memory leaks.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: libi386.h,v 1.26 2008/10/11 11:06:20 joerg Exp $ */
|
||||
/* $NetBSD: libi386.h,v 1.27 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -135,3 +135,5 @@ int dosopen(char *);
|
|||
int dosread(int, char *, int);
|
||||
int dosseek(int, int, int);
|
||||
extern int doserrno; /* in dos_file.S */
|
||||
|
||||
void module_add(char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd9660.c,v 1.23 2007/11/24 13:20:54 isaki Exp $ */
|
||||
/* $NetBSD: cd9660.c,v 1.24 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Wolfgang Solfrank.
|
||||
|
@ -277,6 +277,7 @@ cd9660_open(const char *path, struct open_file *f)
|
|||
fp->bno = isonum_733(dp->extent);
|
||||
fp->size = isonum_733(dp->size);
|
||||
dealloc(buf, buf_size);
|
||||
fsmod = "cd9660";
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dosfs.c,v 1.14 2008/03/25 21:23:50 christos Exp $ */
|
||||
/* $NetBSD: dosfs.c,v 1.15 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1998 Robert Nordier
|
||||
|
@ -261,6 +261,7 @@ dosfs_open(const char *path, struct open_file *fd)
|
|||
fs->links++;
|
||||
f->de = *de;
|
||||
fd->f_fsdata = (void *)f;
|
||||
fsmod = "msdosfs";
|
||||
|
||||
out:
|
||||
return err;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ext2fs.c,v 1.4 2007/12/02 06:47:43 tsutsui Exp $ */
|
||||
/* $NetBSD: ext2fs.c,v 1.5 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Manuel Bouyer.
|
||||
|
@ -691,6 +691,10 @@ ext2fs_open(const char *path, struct open_file *f)
|
|||
out:
|
||||
if (rc)
|
||||
ext2fs_close(f);
|
||||
else {
|
||||
fsmod = "ext2fs";
|
||||
fsmod2 = "ffs";
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffsv1.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: ffsv1.c,v 1.4 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
#define LIBSA_FFSv1
|
||||
|
||||
|
@ -12,4 +12,6 @@
|
|||
#define ufs_dinode ufs1_dinode
|
||||
#define indp_t int32_t
|
||||
|
||||
#define FSMOD "ffs"
|
||||
|
||||
#include "ufs.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffsv2.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: ffsv2.c,v 1.4 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
#define LIBSA_FFSv2
|
||||
|
||||
|
@ -12,4 +12,6 @@
|
|||
#define ufs_dinode ufs2_dinode
|
||||
#define indp_t int64_t
|
||||
|
||||
#define FSMOD "ffs"
|
||||
|
||||
#include "ufs.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: globals.c,v 1.7 2003/03/27 12:28:58 drochner Exp $ */
|
||||
/* $NetBSD: globals.c,v 1.8 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* globals.c:
|
||||
|
@ -19,6 +19,8 @@ u_char bcea[6] = BA; /* broadcast ethernet address */
|
|||
char rootpath[FNAME_SIZE]; /* root mount path */
|
||||
char bootfile[FNAME_SIZE]; /* bootp says to boot this */
|
||||
char hostname[FNAME_SIZE]; /* our hostname */
|
||||
char *fsmod = "ffs"; /* guessed file system module name */
|
||||
char *fsmod2; /* a requisite module */
|
||||
struct in_addr myip; /* my ip address */
|
||||
struct in_addr rootip; /* root ip address */
|
||||
struct in_addr gateip; /* swap ip address */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfsv1.c,v 1.2 2003/04/11 11:27:06 dsl Exp $ */
|
||||
/* $NetBSD: lfsv1.c,v 1.3 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
#define LIBSA_LFS
|
||||
#define REQUIRED_LFS_VERSION 1
|
||||
|
@ -16,4 +16,7 @@
|
|||
#define FSBTODB(fs, daddr) (daddr) /* LFSv1 uses sectors for addresses */
|
||||
#define INOPBx(fs) INOPB(fs)
|
||||
|
||||
#define FSMOD "lfs"
|
||||
#define FSMOD2 "ffs"
|
||||
|
||||
#include "lib/libsa/ufs.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfsv2.c,v 1.2 2003/04/11 11:27:06 dsl Exp $ */
|
||||
/* $NetBSD: lfsv2.c,v 1.3 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
#define LIBSA_LFS
|
||||
#define REQUIRED_LFS_VERSION 2
|
||||
|
@ -19,4 +19,7 @@
|
|||
#define INOPBx(fs) INOPB(fs)
|
||||
#endif
|
||||
|
||||
#define FSMOD "lfs"
|
||||
#define FSMOD2 "ffs"
|
||||
|
||||
#include "lib/libsa/ufs.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfs.c,v 1.43 2008/03/25 21:23:50 christos Exp $ */
|
||||
/* $NetBSD: nfs.c,v 1.44 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -520,6 +520,7 @@ out:
|
|||
#endif
|
||||
if (!error) {
|
||||
f->f_fsdata = (void *)currfd;
|
||||
fsmod = "nfs";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: stand.h,v 1.64 2008/03/25 21:23:51 christos Exp $ */
|
||||
/* $NetBSD: stand.h,v 1.65 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -100,6 +100,9 @@ struct open_file;
|
|||
* This structure is used to define file system operations in a file system
|
||||
* independent way.
|
||||
*/
|
||||
extern char *fsmod;
|
||||
extern char *fsmod2;
|
||||
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
struct fs_ops {
|
||||
int (*open)(const char *, struct open_file *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tftp.c,v 1.26 2008/05/11 11:29:12 chris Exp $ */
|
||||
/* $NetBSD: tftp.c,v 1.27 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -270,6 +270,7 @@ tftp_open(const char *path, struct open_file *f)
|
|||
return res;
|
||||
}
|
||||
f->f_fsdata = (void *)tftpfile;
|
||||
fsmod = "nfs";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs.c,v 1.53 2008/01/02 11:48:58 ad Exp $ */
|
||||
/* $NetBSD: ufs.c,v 1.54 2008/11/19 12:36:41 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -739,6 +739,14 @@ ufs_open(const char *path, struct open_file *f)
|
|||
out:
|
||||
if (rc)
|
||||
ufs_close(f);
|
||||
else {
|
||||
#ifdef FSMOD
|
||||
fsmod = FSMOD;
|
||||
#endif
|
||||
#ifdef FSMOD2
|
||||
fsmod2 = FSMOD2;
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue