summaryrefslogtreecommitdiffstats
path: root/pintos-progos/utils/pintos-set-cmdline
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/utils/pintos-set-cmdline
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/utils/pintos-set-cmdline')
-rw-r--r--pintos-progos/utils/pintos-set-cmdline42
1 files changed, 42 insertions, 0 deletions
diff --git a/pintos-progos/utils/pintos-set-cmdline b/pintos-progos/utils/pintos-set-cmdline
new file mode 100644
index 0000000..8c8f702
--- /dev/null
+++ b/pintos-progos/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}