Commit 80e987b9 authored by Ryan Jackson's avatar Ryan Jackson

Finally committed all of my Linux MFS stuff. It's not done yet, but enough is...

Finally committed all of my Linux MFS stuff.  It's not done yet, but enough is there that I need to get it into version control before I lose it.

This includes:
- Build tree for a Linux frisbee MFS (the source tarballs are in ops:/share/linux/mfs/source)
- Patch for pxelinux to add bootinfo support
- Patch for grub to support our magic config sector
parent e718002d
--- grub-0.97/stage2/builtins.c.orig 2005-02-15 14:58:23.000000000 -0700
+++ grub-0.97/stage2/builtins.c 2008-10-17 13:31:46.000000000 -0600
@@ -49,6 +49,15 @@
# include <md5.h>
#endif
+#ifdef SUPPORT_EMULAB
+# include "testbed_boot.h"
+/* FIXME this may be too low; use 0xff? */
+#define MAX_BIOS_DRIVE 0x90
+
+/* FIXME this should be good enough */
+#define DEVNAME_SIZE 32
+#endif /* SUPPORT_EMULAB */
+
/* The type of kernel loaded. */
kernel_t kernel_type;
/* The boot device. */
@@ -103,6 +112,23 @@
grub_timeout = -1;
}
+#ifdef SUPPORT_EMULAB
+#define CRCPOLY 0xedb88320UL
+unsigned long crc32(unsigned long crc, unsigned char const *p, int len);
+
+unsigned long crc32(unsigned long crc, unsigned char const *p, int len)
+{
+ int i;
+ while (len--) {
+ crc ^= *p++;
+ for (i = 0; i < 8; i++) {
+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY : 0);
+ }
+ }
+ return crc;
+}
+#endif /* SUPPORT_EMULAB */
+
/* Check a password for correctness. Returns 0 if password was
correct, and a value != 0 for error, similarly to strcmp. */
int
@@ -3612,6 +3638,188 @@
{"delete", 0, 0x7f, 0, 0x53}
};
+#ifdef SUPPORT_EMULAB
+static int
+gettbboot(int drive, tbboot_t *tbhdr)
+{
+ unsigned long oldcrc, newcrc;
+
+ if (!rawread(drive, TBBOOT_SECTOR, 0, sizeof(tbboot_t),
+ (void *)tbhdr)) {
+ return 1;
+ }
+
+ if (tbhdr->magic1 != TBBOOT_MAGIC1 ||
+ tbhdr->magic2 != TBBOOT_MAGIC2) {
+
+ return 1;
+ }
+
+ printf("BIOS drive 0x%x\n", drive);
+ printf(" version: %d\n", tbhdr->version);
+ printf(" bootdisk: %x\n", tbhdr->bootdisk);
+ printf(" bootfromdisk: %d\n", tbhdr->bootfromdisk);
+ printf(" bootfromcdrom: %d\n", tbhdr->bootfromcdrom);
+ printf(" checksum: %x\n", tbhdr->checksum);
+
+ oldcrc = tbhdr->checksum;
+ tbhdr->checksum = 0;
+ newcrc = crc32(~0, (void *) tbhdr, sizeof(tbboot_t));
+ newcrc ^= 0xffffffffUL;
+
+ if (newcrc != oldcrc) {
+ printf("gettbboot: bad checksum number on 0x%x: %x %x", drive, oldcrc, newcrc);
+ return 1;
+ }
+
+ if (tbhdr->version != TBBOOT_VERSION) {
+ printf("gettbboot: version mismatch on device '0x%x': %d vs %d",
+ drive, tbhdr->version, TBBOOT_VERSION);
+#if 0
+ delay(2000000);
+#endif
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+tbboot_func(char *arg, int flags)
+{
+ int biosdev, slice;
+ char buffer[512];
+ tbboot_t *tbhdr = (tbboot_t *)buffer;
+ int config_biosdev;
+ struct geometry geometry;
+ char diskdev[DEVNAME_SIZE];
+ unsigned long newcrc;
+
+ memset(buffer, 0, sizeof(buffer));
+
+ errnum = 0;
+ if (*arg) {
+ if (!set_device(arg))
+ return 1;
+
+ if (current_drive < 0x80) {
+ grub_printf("invalid device for testbed boot\n");
+ errnum = ERR_BOOT_FAILURE;
+ return 1;
+ }
+
+ biosdev = current_drive;
+
+ if (gettbboot(biosdev, tbhdr) != 0) {
+ grub_printf("no biosdev found for testbed boot");
+ errnum = ERR_BOOT_FAILURE;
+ return 1;
+ }
+ }
+ else {
+ for (biosdev = 0x80; biosdev < MAX_BIOS_DRIVE; biosdev++) {
+ if (gettbboot(biosdev, tbhdr) == 0)
+ break;
+ }
+
+ if (biosdev == MAX_BIOS_DRIVE) {
+ errnum = ERR_BOOT_FAILURE;
+ grub_printf("no biosdev found for testbed boot");
+ }
+ }
+
+ if (errnum) {
+ grub_printf("Falling back to MFS...\n");
+ errnum = ERR_BOOT_FAILURE;
+ return 1;
+ }
+
+ /* Save the device number where we found our config sector. */
+ config_biosdev = biosdev;
+
+ /* If bootdisk == 0xfe, boot from the specified partition
+ * on the boot device.
+ * If bootdisk == 0xff, boot from the device on which our
+ * magic sector was found
+ * Else, boot from the specifed device.
+ */
+ if (tbhdr->bootdisk < 0xfe) {
+ biosdev = tbhdr->bootdisk;
+ if (get_diskinfo(biosdev, &geometry) != 0) {
+ grub_printf("no such bios device 0x%x for testbed boot\n",
+ biosdev);
+ tbhdr->bootfromcdrom = 1;
+ }
+ }
+ else if (tbhdr->bootdisk == 0xfe) {
+ printf("requested booting from boot device (0x%x)\n",
+ saved_drive);
+ if (saved_drive < 0x80) {
+ grub_printf("invalid device '0x%x' for testbed boot\n",
+ saved_drive);
+ tbhdr->bootfromcdrom = 1;
+ }
+ }
+ else {
+ slice = tbhdr->bootfromdisk;
+ if (slice == 255) {
+ slice = 0;
+ sprintf(diskdev, "(hd%d)", biosdev - 0x80);
+ } else {
+ sprintf(diskdev, "(hd%d,%d)", biosdev - 0x80, slice);
+ }
+ }
+
+ /*
+ * Check boot direction. Its an error for them to be equal,
+ * so boot to the cdrom and leave things as they are.
+ */
+ if (tbhdr->bootfromcdrom ||
+ tbhdr->bootfromcdrom == tbhdr->bootfromdisk) {
+ if (tbhdr->bootfromcdrom == tbhdr->bootfromdisk)
+ grub_printf("Oops, bootfromdisk==bootfromcdrom==%d. "
+ "Falling back to MFS ...\n",
+ tbhdr->bootfromdisk);
+ else
+ grub_printf("Falling back to MFS ...\n");
+
+ errnum = ERR_BOOT_FAILURE;
+ return 1;
+ }
+
+ /*
+ * Only choice is bootfromdisk=$slice. Clear it and go.
+ */
+ tbhdr->bootfromdisk = 0;
+ tbhdr->bootfromcdrom = 1;
+ newcrc = crc32(~0, (void *) tbhdr, sizeof(*tbhdr));
+ newcrc ^= 0xffffffffUL;
+ tbhdr->checksum = newcrc;
+
+ grub_printf("Writing out new boot header ...\n");
+ if (rawwrite(config_biosdev, TBBOOT_SECTOR, (void *)tbhdr) == 0) {
+ return 1;
+ }
+
+ if (real_root_func(diskdev, 0) != 0) {
+ return 1;
+ }
+
+ /* Activate the chosen slice */
+ if (slice != 0 && !make_saved_active())
+ return 1;
+
+ grub_printf("Booting from %s...\n", diskdev);
+
+ if (chainloader_func("+1", 0) != 0) {
+ return 1;
+ }
+
+ /* Shouldn't ever get here */
+ return 1;
+}
+#endif /* SUPPORT_EMULAB */
+
static int
setkey_func (char *arg, int flags)
{
@@ -3757,6 +3965,17 @@
return 0;
}
+#ifdef SUPPORT_EMULAB
+static struct builtin builtin_tbboot =
+{
+ "testbed_boot",
+ tbboot_func,
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
+ "testbed_boot",
+ "testbed booting magic",
+};
+#endif /* SUPPORT_EMULAB */
+
static struct builtin builtin_setkey =
{
"setkey",
@@ -4864,6 +5083,9 @@
#endif /* SUPPORT_SERIAL */
&builtin_setkey,
&builtin_setup,
+#if defined(SUPPORT_EMULAB)
+ &builtin_tbboot,
+#endif /* SUPPORT_EMULAB */
#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
&builtin_terminal,
#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
SOURCE_PATH = $(PWD)/source
SCRIPTS_PATH = $(PWD)/scripts
TOOLCHAIN_BUILD_PATH = $(PWD)/toolchain_build
TARGET_BUILD_PATH = $(PWD)/build
TARGET_PATH = $(PWD)/target
TEMPLATE_PATH = $(PWD)/target_template
TARGET_INITRAMFS = $(PWD)/target.cpio.gz
FAKEROOT_ENVIRONMENT = $(PWD)/$(BUILD)_fs_fakeroot.env
TARGET_CC = i386-linux-uclibc-gcc
TARGET_CFLAGS = -Os -mtune=i386 -march=i386
TARGET_MODULES = uclibc-install-target zlib-install-target busybox-install dropbear-install linux-modules-install openssl-install-target kexec-install tmcc-install imagezip-install frisbee-install e2fsprogs-install
TARGET_FS_SIZE = 13568
BUILDROOT_PATH = $(PWD)/buildroot
BUILDROOT_VERSION = 20080705
BINUTILS_VERSION = 2.18
GCC_VERSION = 4.2.4
UCLIBC_VERSION = 0.9.29
OPENSSL_VERSION = 0.9.7m
OPENSSL_PATH = $(TARGET_BUILD_PATH)/openssl-$(OPENSSL_VERSION)
DROPBEAR_VERSION = 0.51
DROPBEAR_PATH = $(TARGET_BUILD_PATH)/dropbear-$(DROPBEAR_VERSION)
E2FSPROGS_VERSION = 1.41.1
E2FSPROGS_PATH = $(TARGET_BUILD_PATH)/e2fsprogs-$(E2FSPROGS_VERSION)
BUSYBOX_VERSION = 1.11.0
BUSYBOX_PATH = $(TARGET_BUILD_PATH)/busybox-$(BUSYBOX_VERSION)
ZLIB_VERSION = 1.2.3
ZLIB_PATH = $(TARGET_BUILD_PATH)/zlib-$(ZLIB_VERSION)
FAKEROOT_VERSION = 1.8.1
FAKEROOT_PATH = $(TOOLCHAIN_BUILD_PATH)/fakeroot-$(FAKEROOT_VERSION)
GENEXT2FS_VERSION = 1.4.1
GENEXT2FS_PATH = $(TOOLCHAIN_BUILD_PATH)/genext2fs-$(GENEXT2FS_VERSION)
LINUX_VERSION = 2.6.25.9
LINUX_PATH = $(BUILDROOT_PATH)/toolchain_build_i386/linux-$(LINUX_VERSION)
KEXEC_VERSION = 20080324
KEXEC_PATH = $(TARGET_BUILD_PATH)/kexec-tools-$(KEXEC_VERSION)
STAGING_DIR = $(BUILDROOT_PATH)/build_i386/staging_dir/
#HOSTMAKE=make
#HOSTAR=ar
#HOSTAS=as
#HOSTCC=gcc
#HOSTCXX=g++
#HOSTLD=ld
#HOST_CFLAGS=-g -O2
#TOOLCHAIN_PATH="$(STAGING_DIR)/bin:$(STAGING_DIR)/usr/bin:$(PATH)"
CROSS_COMPILER_PREFIX=i386-linux-uclibc-
STRIPCMD=$(STAGING_DIR)/usr/bin/$(CROSS_COMPILER_PREFIX)strip
#CC=$(STAGING_DIR)/usr/bin/i386-linux-uclibc-gcc -Os -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include --sysroot=$(STAGING_DIR)/ -isysroot $(STAGING_DIR) -mtune=i386 -march=i386
# Hack for building uClibc -- it can't handle parallel make processes.
#MAKE1:=$(HOSTMAKE) MAKE="$(firstword $(HOSTMAKE)) -j1"
HOSTCC=gcc
HOST_CONFIGURE_OPTS=PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
AR_FOR_BUILD="$(HOSTAR)" \
AS_FOR_BUILD="$(HOSTAS)" \
CC_FOR_BUILD="$(HOSTCC)" \
GCC_FOR_BUILD="$(HOSTCC)" \
CXX_FOR_BUILD="$(HOSTCXX)" \
LD_FOR_BUILD="$(HOSTLD)" \
CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
AR_FOR_TARGET=$(CROSS_COMPILER_PREFIX)ar \
AS_FOR_TARGET=$(CROSS_COMPILER_PREFIX)as \
LD_FOR_TARGET=$(CROSS_COMPILER_PREFIX)ld \
NM_FOR_TARGET=$(CROSS_COMPILER_PREFIX)nm \
RANLIB_FOR_TARGET=$(CROSS_COMPILER_PREFIX)ranlib \
STRIP_FOR_TARGET=$(CROSS_COMPILER_PREFIX)strip \
OBJCOPY_FOR_TARGET=$(CROSS_COMPILER_PREFIX)objcopy
modules := $(addprefix $(SOURCE_PATH)/, buildroot busybox zlib dropbear linux fakeroot openssl kexec-tools testbed e2fsprogs)
build-env: toolchain build-env-libraries build-tools
build-env-libraries: zlib-install-sysroot openssl-install-sysroot
include $(addsuffix /Rules.mk,$(modules))
.PHONY: all root clean root-template-install toolchain build-tools build-env devices \
root-base root-install
all: toolchain
toolchain: buildroot-build
$(TARGET_PATH)/lib/libc.so.0: toolchain
mkdir -p $(TARGET_PATH)/lib
cp -dpR $(BUILDROOT_PATH)/project_build_i386/uclibc/root/lib/* $(TARGET_PATH)/lib
uclibc-install-target: $(TARGET_PATH)/lib/libc.so.0
build-tools: fakeroot-install
$(FAKEROOT_ENVIRONMENT):
touch $@
#target-base:
# $(SCRIPTS_PATH)/mk_basic_fs.sh $(TARGET_PATH)
# #rm -f $(FAKEROOT_ENVIRONMENT)
target-install: target-template-install $(TARGET_MODULES)
devices: $(FAKEROOT_ENVIRONMENT)
rm -rf $(TARGET_PATH)/dev
$(STAGING_DIR)/usr/bin/fakeroot -s $(FAKEROOT_ENVIRONMENT) \
-i $(FAKEROOT_ENVIRONMENT) \
$(SCRIPTS_PATH)/makedevs.sh \
$(SCRIPTS_PATH)/devices $(TARGET_PATH)
permissions: $(FAKEROOT_ENVIRONMENT) devices target-install
$(STAGING_DIR)/usr/bin/fakeroot -s $(FAKEROOT_ENVIRONMENT) \
-i $(FAKEROOT_ENVIRONMENT) \
$(SCRIPTS_PATH)/fixperms.sh $(TARGET_PATH)
target-initramfs:
$(STAGING_DIR)/usr/bin/fakeroot -i $(FAKEROOT_ENVIRONMENT) \
$(SCRIPTS_PATH)/gen_initramfs.sh $(TARGET_PATH) $(TARGET_INITRAMFS)
target-template-install:
mkdir -p $(TARGET_PATH)
cp -dpR $(TEMPLATE_PATH)/* $(TARGET_PATH)
target: target-install devices permissions
build-env-clean:
rm -rf $(BUILDROOT_PATH) $(BUILD_TOOLS)
clean:
rm -rf $(TARGET_BUILD_PATH) $(TARGET_PATH) \
$(FAKEROOT_ENVIRONMENT) $(TARGET_FS)
This is the build tree for the Linux-based frisbee MFS.
In order to actually build anything, you'll need a whole bunch of source
tarballs. They can be found in ops:/share/linux/mfs/source. Just rsync
or scp that whole tree on top of the 'source' subdirectory in this tree.
This can probably only be compiled on a Linux machine.
To build, run "make build-env" to build the cross-compiling uClibc
toolchain. Then run "make target" to compile all of the source for the
initramfs.
Finally, run "make target-initramfs" to create a compressed cpio archive
suitable to use as an initramfs.
The kernel is compiled but not installed anywhere. You'll have to pull
it out of the build tree for now.
TODO
----
Lots of small things. I've tested the tmcc and frisbee functionality of
the image, but it's not really automated yet. The necessary scripts are
all there, but not yet tested.
BUGS
----
- There are no docs (except this, and it sucks).
- The build system needs some work:
- The kernel image isn't installed anywhere
- There are occasional problems building the toolchain. These are due
to weird bugs in the gcc build process that I haven't figured out a
good fix for.
- There are some minor dependency issues in building some of the
targets that cause other targets to be rebuilt unnecessarily.
- Documentation sucks.
- The hotplug scripts that work with mdev (busybox's stripped-down udev)
need to be cleaned up a bit.
# This file contains the list of device files that need to be created on the
# target filesystem. The format is as follows:
#
# name type major minor uid gid mode link_target
#
# You may create non-block or -char files by specifying 'd' for directories,
# 'p' for pipes 's' for sockets, 'l' for symlinks. The major and minor fields
# are ignored for these types. link_target is required for symlinks,
# optional for everything else.
atibm c 0xa 0x3 0 0 600
audio1 c 0xe 0x14 0 0 640 bpcd b 0x29 0x0 0 0 640
cdu535 b 0x18 0x0 0 0 640
console c 0x5 0x1 0 0 600
core l 0x0 0x0 0 0 777 /proc/kcore
fd l 0x0 0x0 0 0 777 /proc/self/fd
fd0 b 0x2 0x0 0 0 640
fd0u1040 b 0x2 0x54 0 0 640
fd0u1120 b 0x2 0x58 0 0 640
fd0u1440 b 0x2 0x1c 0 0 640
fd0u1600 b 0x2 0x7c 0 0 640
fd0u1680 b 0x2 0x2c 0 0 640
fd0u1722 b 0x2 0x3c 0 0 640
fd0u1743 b 0x2 0x4c 0 0 640
fd0u1760 b 0x2 0x60 0 0 640
fd0u1840 b 0x2 0x74 0 0 640
fd0u1920 b 0x2 0x64 0 0 640
fd0u360 b 0x2 0xc 0 0 640
fd0u720 b 0x2 0x10 0 0 640
fd0u800 b 0x2 0x78 0 0 640
fd0u820 b 0x2 0x34 0 0 640
fd0u830 b 0x2 0x44 0 0 640
full c 0x1 0x7 0 0 600
fwmonitor c 0x24 0x3 0 0 600
hda b 0x3 0x0 0 0 640
hda1 b 0x3 0x1 0 0 640
hda2 b 0x3 0x2 0 0 640
hda3 b 0x3 0x3 0 0 640
hda4 b 0x3 0x4 0 0 640
hda5 b 0x3 0x5 0 0 640
hda6 b 0x3 0x6 0 0 640
hda7 b 0x3 0x7 0 0 640
hda8 b 0x3 0x8 0 0 640
hda9 b 0x3 0x9 0 0 640
hdb b 0x3 0x40 0 0 644
hdb1 b 0x3 0x41 0 0 644
initctl p 0x0 0x0 0 0 600
initrd b 0x1 0xfa 0 0 640
inportbm c 0xa 0x2 0 0 600
jbm c 0xa 0x4 0 0 600
keypad c 0x47 0x0 0 0 644
kmem c 0x1 0x2 0 0 640
lmscd b 0x18 0x0 0 0 640
logibm c 0xa 0x0 0 0 600
mcd b 0x17 0x0 0 0 640
mcdx b 0x14 0x0 0 0 640
mem c 0x1 0x1 0 0 640
mixer c 0xe 0x0 0 0 640
mixer1 c 0xe 0x10 0 0 640
null c 0x1 0x3 0 0 644
par0 c 0x6 0x0 0 0 640
par1 c 0x6 0x1 0 0 640
par2 c 0x6 0x2 0 0 640
port c 0x1 0x4 0 0 640
ptmx c 0x5 0x2 0 0 644
pts d 0x0 0x0 0 0 755
random c 0x1 0x8 0 0 444
route c 0x24 0x0 0 0 600
rtc c 0xa 0x87 0 0 640
sda b 0x8 0x0 0 0 640
sda1 b 0x8 0x1 0 0 640
sda2 b 0x8 0x2 0 0 640
sda3 b 0x8 0x3 0 0 640
sda4 b 0x8 0x4 0 0 640
sda5 b 0x8 0x5 0 0 640
sda6 b 0x8 0x6 0 0 640
sda7 b 0x8 0x7 0 0 640
sda8 b 0x8 0x8 0 0 640
skip c 0x24 0x1 0 0 600
stderr l 0x0 0x0 0 0 777 fd/2
stdin l 0x0 0x0 0 0 777 fd/0
stdout l 0x0 0x0 0 0 777 fd/1
tprobe c 0x46 0x0 0 0 644
tty c 0x5 0x0 0 0 644
tty0 c 0x4 0x0 0 0 600
tty1 c 0x4 0x1 0 0 600
tty2 c 0x4 0x2 0 0 600
tty3 c 0x4 0x3 0 0 600
tty4 c 0x4 0x4 0 0 600
tty5 c 0x4 0x5 0 0 600
tty6 c 0x4 0x6 0 0 600
tty7 c 0x4 0x7 0 0 644
tty8 c 0x4 0x8 0 0 644
tty9 c 0x4 0x9 0 0 644
ttyS0 c 0x4 0x40 0 0 600
ttyS1 c 0x4 0x41 0 0 640
ttyS10 c 0x4 0x4a 0 0 644
ttyS11 c 0x4 0x4b 0 0 644
ttyS12 c 0x4 0x4c 0 0 644
ttyS13 c 0x4 0x4d 0 0 644
ttyS14 c 0x4 0x4e 0 0 644
ttyS15 c 0x4 0x4f 0 0 600
ttyS16 c 0x4 0x50 0 0 644
ttyS17 c 0x4 0x51 0 0 644
ttyS2 c 0x4 0x42 0 0 640
ttyS3 c 0x4 0x43 0 0 640
ttyS4 c 0x4 0x44 0 0 644
ttyS5 c 0x4 0x45 0 0 644
ttyS6 c 0x4 0x46 0 0 644
ttyS7 c 0x4 0x47 0 0 644
ttyS8 c 0x4 0x48 0 0 644
ttyS9 c 0x4 0x49 0 0 644
urandom c 0x1 0x9 0 0 444
zero c 0x1 0x5 0 0 644
i2c-0 c 0x59 0x0 0 0 664
#! /bin/sh
target_dir="$1"
if [ -z "$target_dir" ] || ! [ -d "$target_dir" ]; then
echo "${0##*/}: invalid target directory \"$target_dir\""
exit 1
fi
chmod 1777 "$target_dir/tmp"
chmod 1777 "$target_dir/var/tmp"
#! /bin/sh
TARGET="$1"
INITRAMFS="$2"
cd "$TARGET"
find . -print | cpio --quiet -H newc -o | gzip -c -9 > "$INITRAMFS"
#! /bin/sh
devices=$1
target_path=$2
if [ -z "$devices" ] || [ -z "$target_path" ]; then
echo "Usage ${0##*/} devices target_path"
exit 1
fi
if ! [ -f "$devices" ]; then
echo "${0##*/}: $devices: no such file or directory"
exit 2
fi
#if ! [ -d "$target_path" ]; then
# echo "${0##*/}: $target_path: no such file or directory"
# exit 3
#fi
mkdir -p "$target_path" || exit 1
mkdir -p "$target_path/dev"
#sed 's/# .*$//;/^[ ]*$/d' $devices | \
sed 's/#.*$//;/^[ \t]*$/d' $devices | \
while read name type major minor uid gid mode target; do
device="$target_path/dev/$name"
if [ "$type" = d ]; then
mkdir -p "$device"
elif [ -n "${device%/*}" ]; then
mkdir -p "${device%/*}"
fi
case $type in
b|c) mknod "$device" $type $major $minor ;;
p) mkfifo "$device" ;;
l) ln -s "$target" "$device" ;;
s) ;; # not supported yet
esac
chown $uid:$gid "$device"
chmod $mode "$device"
done
#! /bin/sh
target_dir="$1"
if [ -z "$target_dir" ] || ! [ -d "$target_dir" ]; then
echo "${0##*/}: invalid target directory \"$target_dir\""
exit 1
fi
standard_dirs="dev tmp proc sys mnt home root etc dev/pts dev/shm boot
var var/lock var/run var/log var/tmp"
for dir in $standard_dirs; do
mkdir -p "$target_dir/$dir"
done
#! /bin/sh
# A little script I whipped up to make it easy to
# patch source trees and have sane error handling
# -Erik
#
# (c) 2002 Erik Andersen <andersen@codepoet.org>
# Set directories from arguments, or use defaults.
targetdir=${1-.}
patchdir=${2-../kernel-patches}
shift 2
patchpattern=${@-*}
if [ ! -d "${targetdir}" ] ; then
echo "Aborting. '${targetdir}' is not a directory."
exit 1
fi
if [ ! -d "${patchdir}" ] ; then
echo "Aborting. '${patchdir}' is not a directory."
exit 1
fi
for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
case "$i" in
*.gz)
type="gzip"; uncomp="gunzip -dc"; ;;
*.bz)
type="bzip"; uncomp="bunzip -dc"; ;;
*.bz2)
type="bzip2"; uncomp="bunzip2 -dc"; ;;
*.zip)
type="zip"; uncomp="unzip -d"; ;;
*.Z)
type="compress"; uncomp="uncompress -c"; ;;
*)
type="plaintext"; uncomp="cat"; ;;
esac
echo ""
echo "Applying ${i} using ${type}: "
${uncomp} ${patchdir}/${i} | patch -p1 -E -d ${targetdir}
if [ $? != 0 ] ; then
echo "Patch failed! Please fix $i!"
exit 1
fi
done