L4Re/departure

Annotated libe2access/host/mkfs

635:18f77ccd5ea8
8 months ago Paul Boddie Updated dataspace size type usage.
paul@226 1
#!/bin/sh
paul@226 2
paul@226 3
# Make a filesystem image.
paul@226 4
#
paul@226 5
# Copyright (C) 2019, 2021 Paul Boddie <paul@boddie.org.uk>
paul@226 6
#
paul@226 7
# This program is free software; you can redistribute it and/or
paul@226 8
# modify it under the terms of the GNU General Public License as
paul@226 9
# published by the Free Software Foundation; either version 2 of
paul@226 10
# the License, or (at your option) any later version.
paul@226 11
#
paul@226 12
# This program is distributed in the hope that it will be useful,
paul@226 13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@226 14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@226 15
# GNU General Public License for more details.
paul@226 16
#
paul@226 17
# You should have received a copy of the GNU General Public License
paul@226 18
# along with this program; if not, write to the Free Software
paul@226 19
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@226 20
# Boston, MA  02110-1301, USA
paul@226 21
paul@226 22
TARGET=$1
paul@226 23
paul@226 24
if [ -e "$TARGET" ] ; then
paul@226 25
    echo "File already exists: $TARGET" 1>&2
paul@226 26
    exit 1
paul@226 27
fi
paul@226 28
paul@226 29
if [ ! "$TARGET" ] ; then
paul@226 30
    echo "Creating temporary file." 1>&2
paul@226 31
    TARGET=`mktemp`
paul@226 32
fi
paul@226 33
paul@226 34
SIZE=${2:-2000}
paul@226 35
paul@226 36
# Make a filesystem.
paul@226 37
paul@226 38
  dd if=/dev/zero of="$TARGET" bs=1024 count=1 seek="$SIZE" \
paul@226 39
> /dev/null 2>&1
paul@226 40
paul@226 41
if ! `/sbin/mkfs.ext2 -q "$TARGET"` ; then
paul@226 42
    exit 1
paul@226 43
fi
paul@226 44
paul@226 45
echo "$TARGET"
paul@226 46
paul@226 47
# vim: tabstop=4 expandtab shiftwidth=4