All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: OpenBMC Patches <openbmc-patches@stwcx.xyz>, openbmc@lists.ozlabs.org
Subject: Re: [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments
Date: Tue, 09 Feb 2016 11:16:35 +1030	[thread overview]
Message-ID: <1454978795.3153.7.camel@aj.id.au> (raw)
In-Reply-To: <1454803221-12014-4-git-send-email-openbmc-patches@stwcx.xyz>

On Sat, 2016-02-06 at 18:00 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Create variables for all mount parameters and paths related to
> the read-only and read-write mounts, including fs type, full
> device name, and options.  Reorder mount arguments to always
> place options last.
> 
> Also add variables for update save directory and real init.
> 
> This allows easy testing of a file systems by changing a few
> parameters including making the rofs an image in ram.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../obmc-phosphor-initfs/files/obmc-init.sh        | 22 ++++++++++--
> ---
>  .../obmc-phosphor-initfs/files/obmc-update.sh      | 32 ++++++++++++
> ----------
>  2 files changed, 33 insertions(+), 21 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index f0d8522..0109925 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -1,12 +1,13 @@
>  #!/bin/sh
>  
> +fslist="proc sys dev run"
>  rodir=run/initramfs/ro
>  rwdir=run/initramfs/rw
>  upper=$rwdir/cow
>  work=$rwdir/work
>  
>  cd /
> -mkdir -p sys proc dev run
> +mkdir -p $fslist
>  mount dev dev -tdevtmpfs
>  mount sys sys -tsysfs
>  mount proc proc -tproc
> @@ -39,13 +40,20 @@ fi
>  rofs=$(findmtd rofs)
>  rwfs=$(findmtd rwfs)
>  
> +rodev=/dev/mtdblock${rofs#mtd}
> +rwdev=/dev/mtdblock${rwfs#mtd}
> +
>  rofst=squashfs
>  rwfst=ext4
> +roopts=ro
> +rwopts=rw
> +
> +init=/sbin/init
>  
>  echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
>  
>  if grep -w debug-init-sh /proc/cmdline ||
> -	! mount -o rw /dev/mtdblock${rwfs#mtd} $rwdir -t $rwfst
> +	! mount $rwdev $rwdir -t $rwfst -o $rwopts
>  then
>  	echo Please mount the rw file system on $rwdir from this
> shell
>  	while ! sulogin && ! test -f /takeover
> @@ -61,7 +69,7 @@ then
>  	exec /bin/sh
>  fi
>  
> -mount -o ro /dev/mtdblock${rofs#mtd} $rodir -t $rofst
> +mount $rodev $rodir -t $rofst -o $roopts
>  
>  rm -rf $work
>  mkdir -p $upper
> @@ -69,17 +77,17 @@ mkdir -p $work
>  
>  mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work
> cow /root
>  
> -if ! chroot /root /bin/sh -c "test -x /sbin/init -a -s /sbin/init"
> +if ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
>  then
>  	echo "Change Root test failed!  Invoking emergency shell."
>  	PS1=rescue#\  sulogin
>  fi
>  
> -for f in sys dev proc run
> +for f in $fslist
>  do
>  	mount --move $f root/$f
>  done
>  
> -# switch_root /root /sbin/init
> -exec chroot /root /sbin/init
> +# switch_root /root $init
> +exec chroot /root $init
>  
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh b/meta-phosphor/common/recipes
> -phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index f83b1ad..ec4a769 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor
> -initfs/files/obmc-update.sh
> @@ -35,30 +35,35 @@ findmtd() {
>  	echo $m
>  }
>  
> -rofs=$(findmtd rofs)
>  rwfs=$(findmtd rwfs)
>  
> -rofst=squahsfs
> +rwdev=/dev/mtdblock${rwfs#mtd}
>  rwfst=ext4
> +rwopts=rw
> +rorwopts=ro${rwopts#rw}
> +
> +rwdir=rw
> +upper=$rwdir/cow
> +save=save/${upper##*/}
>  
>  if test -n "$rwfs" && test -s whitelist
>  then
>  
> -	mkdir -p rw
> -	mount /dev/mtdblock${rwfs#mtd} rw -oro -t $rwfst
> +	mkdir -p $rwdir
> +	mount $rwdev $rwdir -t $rwfst -o $rorwopts
>  
>  	while read f
>  	do
> -		if ! test -e rw/cow/$f
> +		if ! test -e $upper/$f
>  		then
>  			continue
>  		fi
> -		d="save/cow/$f"
> +		d="$save/$f"
>  		mkdir -p "${d%/*}"
> -		cp -rp rw/cow/$f "${d%/*}/"
> +		cp -rp $upper/$f "${d%/*}/"
>  	done < whitelist
>  
> -	umount rw
> +	umount $rwdir
>  fi
>  
>  image=/run/initramfs/image-
> @@ -67,7 +72,7 @@ do
>  	m=$(findmtd ${f#$image})
>  	if test -z "$m"
>  	then
> -		echo 1>&2  "Unable to find mtd partiton for $f"
> +		echo 1>&2  "Unable to find mtd partiton for
> ${f##*/}."
>  		exec /bin/sh
>  	fi
>  done
> @@ -80,12 +85,11 @@ do
>  	flashcp -v $f /dev/$m
>  done
>  
> -
> -if test -d save/cow
> +if test -d $save
>  then
> -	mount /dev/mtdblock${rwfs#mtd} rw -o rw -t $rwfst
> -	cp -rp save/cow/. rw/cow/
> -	umount rw
> +	mount $rwdev rw -t $rwfst -o rw

Shouldn't this be as below in line with the stated aim of the patch
(use of variables for mount parameters)?

	mount $rwdev $rwdir -t $rwfst -o $rwopts

> +	cp -rp $save/. $upper/
> +	umount $rwdir
>  fi
>  
>  # Execute the command systemd told us to ...

  parent reply	other threads:[~2016-02-09  0:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07  0:00 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
2016-02-07  0:00 ` [PATCH openbmc 1/7] obmc-initfs: minor updates OpenBMC Patches
2016-02-08 16:25   ` Brad Bishop
2016-02-09  0:55   ` Andrew Jeffery
2016-02-07  0:00 ` [PATCH openbmc 2/7] obmc-initfs: look for images in /run/initramfs/image- OpenBMC Patches
2016-02-08 16:25   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches
2016-02-08 16:37   ` Brad Bishop
2016-02-09  0:46   ` Andrew Jeffery [this message]
2016-02-07  0:00 ` [PATCH openbmc 4/7] obmc-initfs: factor debug and takeover OpenBMC Patches
2016-02-08 16:58   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 5/7] obmc-initfs: run fsck on read/write file system OpenBMC Patches
2016-02-08 17:03   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 6/7] obmc-initfs: run update as a sub-script OpenBMC Patches
2016-02-08 17:05   ` Brad Bishop
2016-02-07  0:00 ` [PATCH openbmc 7/7] obmc-initfs: shutdown when rofs is a loop mounted image in /run OpenBMC Patches
2016-02-08 17:07   ` Brad Bishop
  -- strict thread matches above, loose matches on Subject: below --
2016-02-06  0:20 [PATCH openbmc 0/7] initfs: check and auto-repair read/write file system OpenBMC Patches
2016-02-06  0:20 ` [PATCH openbmc 3/7] obmc-initfs: use varables for paths and mount arguments OpenBMC Patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454978795.3153.7.camel@aj.id.au \
    --to=andrew@aj.id.au \
    --cc=openbmc-patches@stwcx.xyz \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.