1#!/bin/sh 2 3################################################################################ 4## ## 5## Copyright (c) International Business Machines Corp., 2005 ## 6## ## 7## This program is free software; you can redistribute it and#or modify ## 8## it under the terms of the GNU General Public License as published by ## 9## the Free Software Foundation; either version 2 of the License, or ## 10## (at your option) any later version. ## 11## ## 12## This program is distributed in the hope that it will be useful, but ## 13## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 14## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 15## for more details. ## 16## ## 17## You should have received a copy of the GNU General Public License ## 18## along with this program; if not, write to the Free Software ## 19## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 20## ## 21## ## 22################################################################################ 23# 24# File: 25# create_file 26# 27# Description: 28# Create a file in the specified size 29# 30# Arguments: 31# $1: filename 32# $2: filesize 33# 34# Returns: 35# 0: Success 36# 1: Fail 37# 38# Author: 39# Mitsuru Chinen <mitch@jp.ibm.com> 40# 41# History: 42# Oct 19 2005 - Created (Mitsuru Chinen) 43# 44#----------------------------------------------------------------------- 45#Uncomment line below for debug output. 46#trace_logic=${trace_logic:-"set -x"} 47$trace_logic 48 49# Check argument 50if [ $# -ne 2 ] ; then 51 echo "Usage: create_file filename filesize" >&2 52 exit 1 53fi 54filename=$1 55filesize=$2 56 57if [ $filesize -le 0 ]; then 58 echo "The filesize should be bigger than 0" >&2 59 exit 1 60fi 61 62echo -n "A" > $filename 2>/dev/null 63echo -n "Z" | dd of=$filename bs=1 seek=`expr $filesize - 1` >/dev/null 2>&1 64if [ $? -ne 0 ]; then 65 echo "Failed to create $filename" >&2 66 exit 1 67fi 68chmod 644 $filename 69 70exit 0 71