summaryrefslogtreecommitdiffstats
path: root/utils/pintos-set-cmdline
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /utils/pintos-set-cmdline
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-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-cmdline42
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
3use strict;
4use Fcntl 'SEEK_SET';
5
6# Read Pintos.pm from the same directory as this program.
7BEGIN { my $self = $0; $self =~ s%/+[^/]*$%%; require "$self/Pintos.pm"; }
8
9# Get command-line arguments.
10usage (0) if @ARGV == 1 && $ARGV[0] eq '--help';
11usage (1) if @ARGV < 2 || $ARGV[1] ne '--';
12my ($disk, undef, @kernel_args) = @ARGV;
13
14# Open disk.
15my ($handle);
16open ($handle, '+<', $disk) or die "$disk: open: $!\n";
17
18# Check that it's a partitioned disk with a Pintos loader.
19my ($buffer) = read_fully ($handle, $disk, 512);
20unpack ("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.
24our ($LOADER_SIZE);
25sysseek ($handle, $LOADER_SIZE, SEEK_SET) == $LOADER_SIZE
26 or die "$disk: seek: $!\n";
27write_fully ($handle, $disk, make_kernel_command_line (@kernel_args));
28
29# Close disk.
30close ($handle) or die "$disk: close: $!\n";
31
32exit 0;
33
34sub usage {
35 print <<'EOF';
36pintos-set-cmdline, a utility for changing the command line in Pintos disks
37Usage: pintos-set-cmdline DISK -- [ARGUMENT...]
38where DISK is a bootable disk containing a Pintos loader
39 and each ARGUMENT is inserted into the command line written to DISK.
40EOF
41 exit ($_[0]);
42}