diff options
Diffstat (limited to 'meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs')
-rwxr-xr-x | meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs new file mode 100755 index 0000000..c93c9c2 --- /dev/null +++ b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs | |||
@@ -0,0 +1,79 @@ | |||
1 | #!/bin/sh | ||
2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
3 | # Licensed on MIT | ||
4 | |||
5 | rootfs_enabled() { | ||
6 | return 0 | ||
7 | } | ||
8 | |||
9 | rootfs_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 [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then | ||
30 | root_uuid=`echo $bootparam_root | cut -c10-` | ||
31 | bootparam_root="/dev/disk/by-partuuid/$root_uuid" | ||
32 | fi | ||
33 | |||
34 | if [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then | ||
35 | root_label=`echo $bootparam_root | cut -c7-` | ||
36 | bootparam_root="/dev/disk/by-label/$root_label" | ||
37 | fi | ||
38 | |||
39 | if [ "${bootparam_root}" = "/dev/nfs" ]; then | ||
40 | bootparam_rootfstype="nfs" | ||
41 | bootparam_root=`echo $bootparam_nfsroot | cut -f1 -d","` | ||
42 | bootparam_nfsopts=`echo $bootparam_nfsroot | cut -f2- -d","` | ||
43 | fi | ||
44 | |||
45 | if [ -e "$bootparam_root" ] || [ "${bootparam_rootfstype}" = "nfs" ]; then | ||
46 | flags="" | ||
47 | if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then | ||
48 | if [ -n "$bootparam_rootflags" ]; then | ||
49 | bootparam_rootflags="$bootparam_rootflags," | ||
50 | fi | ||
51 | bootparam_rootflags="${bootparam_rootflags}ro" | ||
52 | fi | ||
53 | if [ -n "$bootparam_nfsopts" ]; then | ||
54 | if [ -n "$bootparam_rootflags" ]; then | ||
55 | bootparam_rootflags="$bootparam_rootflags," | ||
56 | fi | ||
57 | bootparam_rootflags="${bootparam_rootflags}${bootparam_nfsopts}" | ||
58 | fi | ||
59 | if [ -n "$bootparam_rootflags" ]; then | ||
60 | flags="$flags -o$bootparam_rootflags" | ||
61 | fi | ||
62 | if [ -n "$bootparam_rootfstype" ]; then | ||
63 | flags="$flags -t$bootparam_rootfstype" | ||
64 | fi | ||
65 | mount $flags $bootparam_root $ROOTFS_DIR | ||
66 | if [ -d $ROOTFS_DIR/dev ]; then | ||
67 | break | ||
68 | else | ||
69 | # It is unlikely to change, but keep trying anyway. | ||
70 | # Perhaps we pick a different device next time. | ||
71 | umount $ROOTFS_DIR | ||
72 | fi | ||
73 | fi | ||
74 | fi | ||
75 | debug "Sleeping for $delay second(s) to wait root to settle..." | ||
76 | sleep $delay | ||
77 | C=$(( $C + 1 )) | ||
78 | done | ||
79 | } | ||