1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libe2access/host/mkfs Tue Dec 28 01:37:59 2021 +0100
1.3 @@ -0,0 +1,47 @@
1.4 +#!/bin/sh
1.5 +
1.6 +# Make a filesystem image.
1.7 +#
1.8 +# Copyright (C) 2019, 2021 Paul Boddie <paul@boddie.org.uk>
1.9 +#
1.10 +# This program is free software; you can redistribute it and/or
1.11 +# modify it under the terms of the GNU General Public License as
1.12 +# published by the Free Software Foundation; either version 2 of
1.13 +# the License, or (at your option) any later version.
1.14 +#
1.15 +# This program is distributed in the hope that it will be useful,
1.16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 +# GNU General Public License for more details.
1.19 +#
1.20 +# You should have received a copy of the GNU General Public License
1.21 +# along with this program; if not, write to the Free Software
1.22 +# Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.23 +# Boston, MA 02110-1301, USA
1.24 +
1.25 +TARGET=$1
1.26 +
1.27 +if [ -e "$TARGET" ] ; then
1.28 + echo "File already exists: $TARGET" 1>&2
1.29 + exit 1
1.30 +fi
1.31 +
1.32 +if [ ! "$TARGET" ] ; then
1.33 + echo "Creating temporary file." 1>&2
1.34 + TARGET=`mktemp`
1.35 +fi
1.36 +
1.37 +SIZE=${2:-2000}
1.38 +
1.39 +# Make a filesystem.
1.40 +
1.41 + dd if=/dev/zero of="$TARGET" bs=1024 count=1 seek="$SIZE" \
1.42 +> /dev/null 2>&1
1.43 +
1.44 +if ! `/sbin/mkfs.ext2 -q "$TARGET"` ; then
1.45 + exit 1
1.46 +fi
1.47 +
1.48 +echo "$TARGET"
1.49 +
1.50 +# vim: tabstop=4 expandtab shiftwidth=4