X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Futils%2Fpintos;h=94132052b30e4b22feba396b0f58b8b57b928a2c;hb=73a641b917fca65bab31677f27ab76b7bb280f3b;hp=0d7b8bca2476fa7946ccf288dcabdfeb089e4ac6;hpb=fd24c2387f5cf1b802e885c7430ba1f1bb852e13;p=pintos-anon diff --git a/src/utils/pintos b/src/utils/pintos index 0d7b8bc..9413205 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -46,18 +46,18 @@ sub parse_command_line { while ((my $arg = shift (@kernel_args)) ne '--') { push (@ARGV, $arg); } - GetOptions ("sim=s" => sub { set_sim (@_) }, + GetOptions ("sim=s" => sub { set_sim ($_[1]) }, "bochs" => sub { set_sim ("bochs") }, "qemu" => sub { set_sim ("qemu") }, "player" => sub { set_sim ("player") }, - "debug=s" => sub { set_debug (@_) }, + "debug=s" => sub { set_debug ($_[1]) }, "no-debug" => sub { set_debug ("none") }, "monitor" => sub { set_debug ("monitor") }, "gdb" => sub { set_debug ("gdb") }, "m|memory=i" => \$mem, - "j|jitter=i" => sub { set_jitter (@_) }, + "j|jitter=i" => sub { set_jitter ($_[1]) }, "r|realtime" => sub { set_realtime () }, "T|timeout=i" => \$timeout, @@ -268,7 +268,15 @@ sub finish_scratch_disk { } # Read each file. - get_scratch_file (defined ($_->[1]) ? $_->[1] : $_->[0]) foreach @gets; + # If reading fails, delete that file and all subsequent files. + my ($ok) = 1; + foreach my $get (@gets) { + my ($name) = defined ($get->[1]) ? $get->[1] : $get->[0]; + $ok &&= get_scratch_file ($name); + if (!$ok) { + die "$name: unlink: $!\n" if !unlink ($name) && !$!{ENOENT}; + } + } } # put_scratch_file($file). @@ -303,6 +311,7 @@ sub put_scratch_file { # get_scratch_file($file). # # Copies from the scratch disk to $file. +# Returns 1 if successful, 0 on failure. sub get_scratch_file { my ($get_file_name) = @_; my ($disk_handle, $disk_file_name) = open_disk ($disks{SCRATCH}); @@ -313,12 +322,13 @@ sub get_scratch_file { # the file size. my ($metadata) = read_fully ($disk_handle, $disk_file_name, 512); my ($signature, $size) = unpack ("a4 V", $metadata); - die "bad signature reading scratch disk--did Pintos run correctly?\n" - if $signature ne "GET\0"; + (print STDERR "bad signature on scratch disk--did Pintos run fail?\n"), + return 0 + if $signature ne "GET\0"; # Copy file data. my ($get_handle); - sysopen ($get_handle, $get_file_name, O_WRONLY | O_CREAT | O_EXCL, 0666) + sysopen ($get_handle, $get_file_name, O_WRONLY | O_CREAT, 0666) or die "$get_file_name: create: $!\n"; copy_file ($disk_handle, $disk_file_name, $get_handle, $get_file_name, $size); @@ -327,6 +337,8 @@ sub get_scratch_file { # Skip forward in disk up to beginning of next sector. read_fully ($disk_handle, $disk_file_name, 512 - $size % 512) if $size % 512; + + return 1; } # Prepares the arguments to pass to the Pintos kernel, @@ -398,7 +410,7 @@ panic: action=fatal EOF print BOCHSRC "gdbstub: enabled=1\n" if $debug eq 'gdb'; print BOCHSRC "clock: sync=", $realtime ? 'realtime' : 'none', - " time0=0\n"; + ", time0=0\n"; print_bochs_disk_line ("ata0-master", 0); print_bochs_disk_line ("ata0-slave", 1); if (defined ($disks_by_iface[2]{FILE_NAME})