summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework/rootfs')
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-framework/rootfs57
1 files changed, 57 insertions, 0 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
new file mode 100644
index 0000000000..5790d8cb8b
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
@@ -0,0 +1,57 @@
1#!/bin/sh
2# Copyright (C) 2011 O.S. Systems Software LTDA.
3# Licensed on MIT
4
5rootfs_enabled() {
6 return 0
7}
8
9rootfs_run() {
10 if [ -z "$ROOTFS_DIR" ]; then
11 return
12 fi
13 C=0
14 delay=${bootparam_rootdelay:-1}
15 timeout=${bootparam_roottimeout:-5}
16 while [ ! -d $ROOTFS_DIR/dev ]; do
17 if [ $(( $C * $delay )) -gt $timeout ]; then
18 fatal "root '$bootparam_root' doesn't exist or does not contain a /dev."
19 fi
20
21 if [ -n "$bootparam_root" ]; then
22 debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..."
23
24 if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then
25 root_uuid=`echo $bootparam_root | cut -c6-`
26 bootparam_root="/dev/disk/by-uuid/$root_uuid"
27 fi
28
29 if [ -e "$bootparam_root" ]; then
30 flags=""
31 if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
32 if [ -n "$bootparam_rootflags" ]; then
33 bootparam_rootflags="$bootparam_rootflags,"
34 fi
35 bootparam_rootflags="${bootparam_rootflags}ro"
36 fi
37 if [ -n "$bootparam_rootflags" ]; then
38 flags="$flags -o$bootparam_rootflags"
39 fi
40 if [ -n "$bootparam_rootfstype" ]; then
41 flags="$flags -t$bootparam_rootfstype"
42 fi
43 mount $flags $bootparam_root $ROOTFS_DIR
44 if [ -d $ROOTFS_DIR/dev ]; then
45 break
46 else
47 # It is unlikely to change, but keep trying anyway.
48 # Perhaps we pick a different device next time.
49 umount $ROOTFS_DIR
50 fi
51 fi
52 fi
53 debug "Sleeping for $delay second(s) to wait root to settle..."
54 sleep $delay
55 C=$(( $C + 1 ))
56 done
57}