From: Evgeniy Ivanov Date: Sat, 4 Feb 2012 10:21:30 +0000 (+0400) Subject: Adjust boot from NetBSD. X-Git-Tag: v3.2.0~77 X-Git-Url: http://zhaoyanbai.com/repos/man.named-checkzone.html?a=commitdiff_plain;h=602233213ee33c044f1e3eac6953a80ed899c566;p=minix.git Adjust boot from NetBSD. - Add load_mods command to boot2 (load_mods /dir/mod*). - Rename resulting binary to boot_monitor. - Change default banner when used in MINIX. --- diff --git a/man/man8/boot.8 b/man/man8/boot.8 index e61c32469..1da348daa 100644 --- a/man/man8/boot.8 +++ b/man/man8/boot.8 @@ -458,6 +458,8 @@ PCI domain IDs are currently ignored. See .Xr pciback 4 . .El +.It Ic load_mods Va mods_path_pattern +Load modules specified by pattern like /some_path/mod*. .It Ic ls Op Pa path Print a directory listing of .Pa path , diff --git a/sys/arch/i386/stand/boot/biosboot/Makefile b/sys/arch/i386/stand/boot/biosboot/Makefile index 96780c17b..843d4b9f0 100644 --- a/sys/arch/i386/stand/boot/biosboot/Makefile +++ b/sys/arch/i386/stand/boot/biosboot/Makefile @@ -1,5 +1,5 @@ # $NetBSD: Makefile,v 1.3 2005/12/11 12:17:48 christos Exp $ -PROG= boot +PROG= boot_monitor .include <../Makefile.boot> diff --git a/sys/arch/i386/stand/boot/boot2.c b/sys/arch/i386/stand/boot/boot2.c index 6356bcba4..695f6215c 100644 --- a/sys/arch/i386/stand/boot/boot2.c +++ b/sys/arch/i386/stand/boot/boot2.c @@ -122,6 +122,7 @@ void command_dev(char *); void command_consdev(char *); void command_modules(char *); void command_multiboot(char *); +void command_load_mods(char *); const struct bootblk_command commands[] = { { "help", command_help }, @@ -133,6 +134,7 @@ const struct bootblk_command commands[] = { { "consdev", command_consdev }, { "modules", command_modules }, { "load", module_add }, + { "load_mods", command_load_mods }, { "multiboot", command_multiboot }, { "vesa", command_vesa }, { "splash", splash_add }, @@ -261,11 +263,18 @@ print_banner(void) printf("%s\n", bootconf.banner[n]); } else { #endif /* !SMALL */ +#ifndef __minix printf("\n" ">> %s, Revision %s (from NetBSD %s)\n" ">> Memory: %d/%d k\n", bootprog_name, bootprog_rev, bootprog_kernrev, getbasemem(), getextmem()); +#else + printf("\n" + "--- Welcome to MINIX 3. This is the boot monitor. ---\n" + "Memory: %d/%d k\n", + getbasemem(), getextmem()); +#endif #ifndef SMALL } @@ -396,6 +405,7 @@ command_help(char *arg) "vesa {modenum|on|off|enabled|disabled|list}\n" "modules {on|off|enabled|disabled}\n" "load {path_to_module}\n" + "load_mods {path_to_modules}, pattern might be used\n" "multiboot [xdNx:][filename] []\n" "userconf {command}\n" "rndseed {path_to_rndseed_file}\n" @@ -409,7 +419,17 @@ command_ls(char *arg) const char *save = default_filename; default_filename = "/"; - ls(arg); + ls(arg, NULL); + default_filename = save; +} + +void +command_load_mods(char *arg) +{ + const char *save = default_filename; + + default_filename = "/"; + ls(arg, module_add); default_filename = save; } diff --git a/sys/lib/libsa/cd9660.c b/sys/lib/libsa/cd9660.c index fa1418042..1333c8c43 100644 --- a/sys/lib/libsa/cd9660.c +++ b/sys/lib/libsa/cd9660.c @@ -399,7 +399,8 @@ cd9660_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -cd9660_ls(struct open_file *f, const char *pattern) +cd9660_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by cd9660\n"); return; diff --git a/sys/lib/libsa/dosfs.c b/sys/lib/libsa/dosfs.c index 82ddfbdf9..383c5a96c 100644 --- a/sys/lib/libsa/dosfs.c +++ b/sys/lib/libsa/dosfs.c @@ -407,7 +407,8 @@ dosfs_stat(struct open_file *fd, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -dosfs_ls(struct open_file *f, const char *pattern) +dosfs_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by dosfs\n"); return; diff --git a/sys/lib/libsa/ext2fs.c b/sys/lib/libsa/ext2fs.c index dc3b49f96..53f94795d 100644 --- a/sys/lib/libsa/ext2fs.c +++ b/sys/lib/libsa/ext2fs.c @@ -858,7 +858,8 @@ ext2fs_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -ext2fs_ls(struct open_file *f, const char *pattern) +ext2fs_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { struct file *fp = (struct file *)f->f_fsdata; size_t block_size = fp->f_fs->e2fs_bsize; diff --git a/sys/lib/libsa/ls.c b/sys/lib/libsa/ls.c index 0f64a284a..b2169d15a 100644 --- a/sys/lib/libsa/ls.c +++ b/sys/lib/libsa/ls.c @@ -89,13 +89,13 @@ #include void -ls(const char *path) +ls(const char *path, void (*funcp)(char* arg)) { int fd; struct stat sb; size_t size; const char *fname = 0; - char *p; + char *p = NULL; struct open_file *f; if ((fd = open(path, 0)) < 0 @@ -115,7 +115,6 @@ ls(const char *path) memcpy(p, path, size); p[size] = 0; fd = open(p, 0); - dealloc(p, size + 1); } else { fd = open("", 0); fname = path; @@ -153,10 +152,12 @@ ls(const char *path) #endif if (FS_LS(f->f_ops) != NULL) - FS_LS(f->f_ops)(f, fname); + FS_LS(f->f_ops)(f, fname, funcp, p); else printf("no ls support for this file system\n"); out: + if (p != NULL) + dealloc(p, size + 1); close(fd); } diff --git a/sys/lib/libsa/minixfs3.c b/sys/lib/libsa/minixfs3.c index a72217302..15396df81 100644 --- a/sys/lib/libsa/minixfs3.c +++ b/sys/lib/libsa/minixfs3.c @@ -861,7 +861,8 @@ minixfs3_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -minixfs3_ls(struct open_file *f, const char *pattern) +minixfs3_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { struct file *fp = (struct file *)f->f_fsdata; struct mfs_sblock *fs = fp->f_fs; @@ -927,8 +928,24 @@ minixfs3_ls(struct open_file *f, const char *pattern) entry_t *p_names = names; do { n = p_names; - printf("%d: %s\n", - n->e_ino, n->e_name); + if (funcp) { + /* Call handler for each file instead of + * printing. Used by load_mods command. + */ + char namebuf[MAXPATHLEN+1]; + namebuf[0] = '\0'; + if (path != pattern) { + strcpy(namebuf, path); + namebuf[strlen(path)] = '/'; + namebuf[strlen(path) + 1] = '\0'; + } + strcat(namebuf, n->e_name); + + funcp(namebuf); + } else { + printf("%d: %s\n", + n->e_ino, n->e_name); + } p_names = n->e_next; } while (p_names); } else { diff --git a/sys/lib/libsa/nfs.c b/sys/lib/libsa/nfs.c index 6fadec026..9f2b5d7f6 100644 --- a/sys/lib/libsa/nfs.c +++ b/sys/lib/libsa/nfs.c @@ -658,7 +658,8 @@ nfs_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -nfs_ls(struct open_file *f, const char *pattern) +nfs_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by nfs\n"); return; diff --git a/sys/lib/libsa/nullfs.c b/sys/lib/libsa/nullfs.c index 558de6011..10c6673d4 100644 --- a/sys/lib/libsa/nullfs.c +++ b/sys/lib/libsa/nullfs.c @@ -116,7 +116,8 @@ null_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -null_ls(struct open_file *f, const char *pattern) +null_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by nullfs\n"); return; diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index a9d57200b..0e1ae7379 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -100,7 +100,8 @@ struct open_file; #if defined(LIBSA_ENABLE_LS_OP) #define FS_DEF(fs) \ FS_DEF_BASE(fs);\ - extern __compactcall void __CONCAT(fs,_ls)(struct open_file *, const char *) + extern __compactcall void __CONCAT(fs,_ls)(struct open_file *, const char *,\ + void (*)(char* arg), char*) #else #define FS_DEF(fs) FS_DEF_BASE(fs) #endif @@ -122,7 +123,8 @@ struct fs_ops { __compactcall off_t (*seek)(struct open_file *, off_t, int); __compactcall int (*stat)(struct open_file *, struct stat *); #if defined(LIBSA_ENABLE_LS_OP) - __compactcall void (*ls)(struct open_file *, const char *); + __compactcall void (*ls)(struct open_file *, const char *, + void (*)(char* arg), char*); #endif }; @@ -286,7 +288,7 @@ int ioctl(int, u_long, char *); int stat(const char *, struct stat *); int fstat(int, struct stat *); #if defined(LIBSA_ENABLE_LS_OP) -void ls(const char *); +void ls(const char *, void (*funcp)(char* arg)); #endif typedef int cmp_t(const void *, const void *); diff --git a/sys/lib/libsa/tftp.c b/sys/lib/libsa/tftp.c index f6a025d44..8d508cdaa 100644 --- a/sys/lib/libsa/tftp.c +++ b/sys/lib/libsa/tftp.c @@ -431,7 +431,8 @@ tftp_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -tftp_ls(struct open_file *f, const char *pattern) +tftp_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by tftp\n"); return; diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index 63be30be6..f491c9821 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -914,7 +914,8 @@ ufs_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -ufs_ls(struct open_file *f, const char *pattern) +ufs_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { struct file *fp = (struct file *)f->f_fsdata; char *buf; diff --git a/sys/lib/libsa/ustarfs.c b/sys/lib/libsa/ustarfs.c index 6dbe842f0..9349d909e 100644 --- a/sys/lib/libsa/ustarfs.c +++ b/sys/lib/libsa/ustarfs.c @@ -540,7 +540,8 @@ ustarfs_stat(struct open_file *f, struct stat *sb) #if defined(LIBSA_ENABLE_LS_OP) __compactcall void -ustarfs_ls(struct open_file *f, const char *pattern) +ustarfs_ls(struct open_file *f, const char *pattern, + void (*funcp)(char* arg), char* path) { printf("Currently ls command is unsupported by ustarfs\n"); return;