diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /utils/pintos-set-cmdline | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'utils/pintos-set-cmdline')
| -rw-r--r-- | utils/pintos-set-cmdline | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/pintos-set-cmdline b/utils/pintos-set-cmdline new file mode 100644 index 0000000..8c8f702 --- /dev/null +++ b/utils/pintos-set-cmdline | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #! /usr/bin/perl -w | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Fcntl 'SEEK_SET'; | ||
| 5 | |||
| 6 | # Read Pintos.pm from the same directory as this program. | ||
| 7 | BEGIN { my $self = $0; $self =~ s%/+[^/]*$%%; require "$self/Pintos.pm"; } | ||
| 8 | |||
| 9 | # Get command-line arguments. | ||
| 10 | usage (0) if @ARGV == 1 && $ARGV[0] eq '--help'; | ||
| 11 | usage (1) if @ARGV < 2 || $ARGV[1] ne '--'; | ||
| 12 | my ($disk, undef, @kernel_args) = @ARGV; | ||
| 13 | |||
| 14 | # Open disk. | ||
| 15 | my ($handle); | ||
| 16 | open ($handle, '+<', $disk) or die "$disk: open: $!\n"; | ||
| 17 | |||
| 18 | # Check that it's a partitioned disk with a Pintos loader. | ||
| 19 | my ($buffer) = read_fully ($handle, $disk, 512); | ||
| 20 | unpack ("x510 v", $buffer) == 0xaa55 or die "$disk: not a partitioned disk\n"; | ||
| 21 | $buffer =~ /Pintos/ or die "$disk: does not contain Pintos loader\n"; | ||
| 22 | |||
| 23 | # Write the command line. | ||
| 24 | our ($LOADER_SIZE); | ||
| 25 | sysseek ($handle, $LOADER_SIZE, SEEK_SET) == $LOADER_SIZE | ||
| 26 | or die "$disk: seek: $!\n"; | ||
| 27 | write_fully ($handle, $disk, make_kernel_command_line (@kernel_args)); | ||
| 28 | |||
| 29 | # Close disk. | ||
| 30 | close ($handle) or die "$disk: close: $!\n"; | ||
| 31 | |||
| 32 | exit 0; | ||
| 33 | |||
| 34 | sub usage { | ||
| 35 | print <<'EOF'; | ||
| 36 | pintos-set-cmdline, a utility for changing the command line in Pintos disks | ||
| 37 | Usage: pintos-set-cmdline DISK -- [ARGUMENT...] | ||
| 38 | where DISK is a bootable disk containing a Pintos loader | ||
| 39 | and each ARGUMENT is inserted into the command line written to DISK. | ||
| 40 | EOF | ||
| 41 | exit ($_[0]); | ||
| 42 | } | ||
