Commit 34c6e5b9 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add option to add files to the archive by hand.

parent 73256bef
...@@ -12,13 +12,15 @@ use Getopt::Std; ...@@ -12,13 +12,15 @@ use Getopt::Std;
# #
sub usage() sub usage()
{ {
print STDOUT print STDERR
"Usage: archive_control [-f] <commit> <pid> <eid>\n"; "Usage: archive_control [-f] commit <pid> <eid>\n".
" archive_control [-f] [-a] addfile <pid> <eid> [files ...]\n";
exit(-1); exit(-1);
} }
my $optlist = "df"; my $optlist = "dfa";
my $debug = 0; my $debug = 0;
my $force = 0; my $force = 0;
my $exact = 0;
my $dbuid; my $dbuid;
# #
...@@ -66,23 +68,26 @@ if (! UNIX2DBUID($UID, \$dbuid)) { ...@@ -66,23 +68,26 @@ if (! UNIX2DBUID($UID, \$dbuid)) {
if (! getopts($optlist, \%options)) { if (! getopts($optlist, \%options)) {
usage(); usage();
} }
if (@ARGV != 3) { if (@ARGV < 3) {
usage(); usage();
} }
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 1;
} }
if (defined($options{"a"})) {
$exact = 1;
}
if (defined($options{"f"})) { if (defined($options{"f"})) {
$force = 1; $force = 1;
} }
my $action = $ARGV[0]; my $action = shift(@ARGV);
my $pid = $ARGV[1]; my $pid = shift(@ARGV);
my $eid = $ARGV[2]; my $eid = shift(@ARGV);
# #
# Untaint args. # Untaint args.
# #
if ($action =~ /^(commit)$/) { if ($action =~ /^(commit|addfile)$/) {
$action = $1; $action = $1;
} }
else { else {
...@@ -176,6 +181,20 @@ if ($action eq "commit") { ...@@ -176,6 +181,20 @@ if ($action eq "commit") {
fatal("Failed to commit experiment archive!"); fatal("Failed to commit experiment archive!");
} }
} }
elsif ($action eq "addfile") {
usage()
if (! @ARGV);
# The Archive library does a taint check on the pathnames.
while (@ARGV) {
my $pathname = shift(@ARGV);
if (libArchive::TBExperimentArchiveAddFile($pid, $eid,
$pathname, $exact) < 0) {
fatal("Failed to add '$pathname' to experiment archive!");
}
}
}
exit(0); exit(0);
sub fatal($) sub fatal($)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment