-
Notifications
You must be signed in to change notification settings - Fork 4
/
donboot.pl
executable file
·44 lines (37 loc) · 1020 Bytes
/
donboot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl -w
use strict;
# Beeb Utilities to manipulate MMB and SSD files
# Copyright (C) 2012 Stephen Harris
#
# See file "COPYING" for GPLv2 licensing
use FindBin;
use lib "$FindBin::Bin";
use BeebUtils;
@ARGV=BeebUtils::init(@ARGV);
my ($disktable,%boot)=BeebUtils::load_onboot();
my %disk=BeebUtils::load_dcat(\$disktable);
if (!@ARGV)
{
foreach (0..3)
{
my $d=$boot{$_};
my $t="<empty>";
if ($disk{$d}{Formatted})
{
my $L=$disk{$d}{ReadOnly}?" (L)":"";
$t="$disk{$d}{DiskTitle}$L";
}
print "$_: $d - $t\n";
}
exit;
}
my $force=0;
if ($ARGV[0] eq '-y') { $force=1; shift @ARGV; }
my $drive=shift @ARGV;
my $disk=shift @ARGV;
die "Syntax: $BeebUtils::PROG [-y] drive disk_number\n" unless defined($disk);
die "Invalid drive\n" unless $drive=~/^[0123]$/;
die "Invalid disk\n" unless $disk=~/^\d+$/;
die "Disk $disk not formatted. Use -y flag to foce\n" unless $disk{$disk}{Formatted} || $force;
$boot{$drive}=$disk;
BeebUtils::save_onboot(\$disktable,%boot);