Replace newroot with a call to mount, will make type autodetect easier
This commit is contained in:
parent
3b386ad39f
commit
c7859a538c
5 changed files with 14 additions and 47 deletions
|
@ -1,4 +1,4 @@
|
|||
PROG= newroot
|
||||
SCRIPTS= newroot.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
newroot.c
|
||||
|
||||
Replace the current root with a new one
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "Usage: newroot [-i] <block-special>\n");
|
||||
fprintf(stderr, "-i: copy mfs binary from boot image to memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int r;
|
||||
char *dev;
|
||||
int mountflags;
|
||||
|
||||
r = 0;
|
||||
mountflags = 0; /* !read-only */
|
||||
|
||||
if (argc != 2 && argc != 3) usage();
|
||||
if(argc == 2) {
|
||||
dev = argv[1];
|
||||
} else if(argc == 3) {
|
||||
/* -i flag was supposedly entered. Verify.*/
|
||||
if(strcmp(argv[1], "-i") != 0) usage();
|
||||
mountflags |= MS_REUSE;
|
||||
dev = argv[2];
|
||||
}
|
||||
|
||||
r = mount(dev, "/", mountflags, NULL, NULL);
|
||||
if (r != 0) {
|
||||
fprintf(stderr, "newroot: mount failed: %s\n",strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
5
commands/newroot/newroot.sh
Normal file
5
commands/newroot/newroot.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Actually, newroot is just like mounting on the root
|
||||
exec mount "$*" /
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Makefile for ramdisk image
|
||||
|
||||
PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk newroot \
|
||||
PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk mount newroot \
|
||||
pci sh service sysenv mfs
|
||||
EXTRA=system.conf passwd rs.single
|
||||
|
||||
|
@ -67,6 +67,12 @@ loadramdisk: ../../commands/loadramdisk/loadramdisk
|
|||
../../commands/loadramdisk/loadramdisk:
|
||||
$(MAKE) -C ../../commands/loadramdisk
|
||||
|
||||
mount: ../../commands/mount/mount
|
||||
install -s ../../commands/$@/$@ $@
|
||||
|
||||
../../commands/mount/mount:
|
||||
$(MAKE) -C ../../commands/mount
|
||||
|
||||
newroot: ../../commands/newroot/newroot
|
||||
install -s ../../commands/$@/$@ $@
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ d--755 0 0
|
|||
cdprobe ---755 0 0 cdprobe
|
||||
dev2name ---755 0 0 dev2name
|
||||
loadramdisk ---755 0 0 loadramdisk
|
||||
mount ---755 0 0 mount
|
||||
newroot ---755 0 0 newroot
|
||||
sh ---755 0 0 sh
|
||||
service ---755 0 0 service
|
||||
|
|
Loading…
Reference in a new issue