From patchwork Sat Dec 7 23:26:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaro Koskinen X-Patchwork-Id: 298737 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9BADE2C00E3 for ; Sun, 8 Dec 2013 10:27:37 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755706Ab3LGX1e (ORCPT ); Sat, 7 Dec 2013 18:27:34 -0500 Received: from filtteri1.pp.htv.fi ([213.243.153.184]:49762 "EHLO filtteri1.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755895Ab3LGX12 (ORCPT ); Sat, 7 Dec 2013 18:27:28 -0500 Received: from localhost (localhost [127.0.0.1]) by filtteri1.pp.htv.fi (Postfix) with ESMTP id 60F6121B9BC; Sun, 8 Dec 2013 01:27:25 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp4.welho.com ([213.243.153.38]) by localhost (filtteri1.pp.htv.fi [213.243.153.184]) (amavisd-new, port 10024) with ESMTP id yQvL9H9jQhgt; Sun, 8 Dec 2013 01:27:20 +0200 (EET) Received: from blackmetal.bb.dnainternet.fi (91-145-91-118.bb.dnainternet.fi [91.145.91.118]) by smtp4.welho.com (Postfix) with ESMTP id B37FA5BC01A; Sun, 8 Dec 2013 01:27:20 +0200 (EET) From: Aaro Koskinen To: sparclinux@vger.kernel.org Cc: Aaro Koskinen Subject: [PATCH 05/10] tilo: make root image optional Date: Sun, 8 Dec 2013 01:26:54 +0200 Message-Id: <1386458819-6590-6-git-send-email-aaro.koskinen@iki.fi> X-Mailer: git-send-email 1.8.4.4 In-Reply-To: <1386458819-6590-1-git-send-email-aaro.koskinen@iki.fi> References: <1386458819-6590-1-git-send-email-aaro.koskinen@iki.fi> Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org Make root image optional. Signed-off-by: Aaro Koskinen --- tilo/maketilo.c | 35 ++++++++++++++++++++--------------- tilo/tilo.sh | 11 +++++++---- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/tilo/maketilo.c b/tilo/maketilo.c index 0a14a96149dc..30eaef4c2868 100644 --- a/tilo/maketilo.c +++ b/tilo/maketilo.c @@ -56,7 +56,7 @@ int root_tweak (char *s) int main (int argc, char **argv) { int i,len,rootlen; - FILE *f, *g; + FILE *f, *g = NULL; struct ImageInfo *ii; char *sun4_kernel_start; @@ -112,26 +112,26 @@ int main (int argc, char **argv) if (!sun4_kernel) { /*fprintf (stderr, "WARNING: Kernel for Sun4 not specified\n");*/ - } else if (!sun4_size || !sun4_root) { + } else if (!sun4_size || (!sun4_root && root_image)) { fprintf (stderr, "WARNING: Original size and root address must be specified for Sun4\n"); return -1; } if (!sun4c_kernel) { fprintf (stderr, "WARNING: Kernel for Sun4c/m/d not specified\n"); - } else if (!sun4c_size || !sun4c_root) { + } else if (!sun4c_size || (!sun4c_root && root_image)) { fprintf (stderr, "ERROR: Original size and root address must be specified for Sun4c\n"); return -1; } if (!sun4u_kernel) { fprintf (stderr, "WARNING: Kernel for Sun4u not specified\n"); - } else if (!sun4u_size || !sun4u_root) { + } else if (!sun4u_size || (!sun4u_root && root_image)) { fprintf (stderr, "ERROR: Original size and root address must be specified for Sun4u\n"); return -1; } - if (!root_image) { + if (!root_image && (sun4_root || sun4c_root || sun4u_root)) { fprintf (stderr, "ERROR: Root image not specified\n"); return -1; } @@ -141,16 +141,19 @@ int main (int argc, char **argv) return -1; } - g = fopen (root_image, "rb"); - if (!g) { - fprintf (stderr, "Can't load %s\n", root_image); - return -1; + if (root_image) { + g = fopen (root_image, "rb"); + if (!g) { + fprintf (stderr, "Can't load %s\n", root_image); + return -1; + } + fseek (g, 0, SEEK_END); + rootlen = ftell (g); + fseek (g, 0, SEEK_SET); + } else { + rootlen = 0; } - fseek (g, 0, SEEK_END); - rootlen = ftell (g); - fseek (g, 0, SEEK_SET); - if (rootlen + sun4_size + 0x4000 + 0x10000 >= 0x330000 || rootlen + sun4c_size + 0x4000 + 0x10000 >= 0x330000 || rootlen + sun4u_size + 0x4000 + 0x10000 >= 0x330000) { @@ -215,8 +218,10 @@ int main (int argc, char **argv) root_image_start = sun4u_kernel_start + len; - fread (root_image_start, 1, rootlen, g); - fclose (g); + if (root_image) { + fread (root_image_start, 1, rootlen, g); + fclose (g); + } output_end = root_image_start + rootlen; diff --git a/tilo/tilo.sh b/tilo/tilo.sh index 782a0305646b..8cf4d7674439 100755 --- a/tilo/tilo.sh +++ b/tilo/tilo.sh @@ -57,9 +57,11 @@ do_image () { echo " packed size = $PSIZE" echo " root address = $ROOTA" if [ -n "$sun4u" ]; then - tilo_args="$tilo_args sun4u=$KERNEL.gz size4u=$SIZE root4u=$ROOTA" + tilo_args="$tilo_args sun4u=$KERNEL.gz size4u=$SIZE" + root_addr="$root_addr root4u=$ROOTA" else - tilo_args="$tilo_args sun4c=$KERNEL.gz size4c=$SIZE root4c=$ROOTA" + tilo_args="$tilo_args sun4c=$KERNEL.gz size4c=$SIZE" + root_addr="$root_addr root4c=$ROOTA" fi } @@ -80,7 +82,7 @@ do_root () { fi ROOT_SIZE=`ls -l $rootimg | awk '{print$5}'` echo Root image packed size = $ROOT_SIZE - tilo_args="$tilo_args root=$rootimg" + root_img="root=$rootimg" } while [ $# != 0 ]; do @@ -112,7 +114,8 @@ if [ -z "$sun4u" -a -z "$sun4c" ]; then exit 1 fi -`echo $0 | sed 's/tilo\.sh$/maketilo/'` $tilo_args out=$output +[ -n "$root_img" ] && root_img="$root_img $root_addr" +`echo $0 | sed 's/tilo\.sh$/maketilo/'` $tilo_args $root_img out=$output rm -f $to_remove