#!/usr/bin/perl 
#  $Id: create_loopback_file.in,v 1.1.1.1 1998/02/21 11:40:04 fawcett Exp $
#
#  CREATE_LOOPBACK_FILE: Create an empty temporary file for use with
#  the loopback device.
#

package main;
use lib "/etc/yard", "/usr/share/yard";
require "Config.pl";
BEGIN { require "yard_utils.pl" } # Defines info() and error() for compiler

if (-e $CFG::device) {
    if (-b _ or -c _) {
	error "$CFG::device is the name of an existing device.\n";
    } elsif (-f _) {
	info 0, "Deleting existing file $CFG::device\n";
	unlink($CFG::device);
    }
}

print "Creating $CFG::fs_size K file on $CFG::device to be used as root filesystem\n";

sys("dd if=/dev/zero bs=1k of=$CFG::device count=$CFG::fs_size");

print "Done.\n";
