Commit 956943a7 authored by Leigh Stoller's avatar Leigh Stoller

Add topomap function to spit back the topomap.gz from /usr/tesbed/expwork

To be used as a backup for NFS.
parent 1f6d5468
......@@ -234,6 +234,7 @@ COMMAND_PROTOTYPE(dolocalize);
COMMAND_PROTOTYPE(dobooterrno);
COMMAND_PROTOTYPE(dobootlog);
COMMAND_PROTOTYPE(dobattery);
COMMAND_PROTOTYPE(dotopomap);
/*
* The fullconfig slot determines what routines get called when pushing
......@@ -314,6 +315,7 @@ struct command {
{ "booterrno", FULLCONFIG_NONE, 0, dobooterrno},
{ "bootlog", FULLCONFIG_NONE, 0, dobootlog},
{ "battery", FULLCONFIG_NONE, F_REMUDP|F_MINLOG, dobattery},
{ "topomap", FULLCONFIG_NONE, F_MINLOG|F_ALLOCATED, dotopomap},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -5785,3 +5787,40 @@ COMMAND_PROTOTYPE(dobattery)
return 0;
}
/*
* Spit back the topomap. This is a backup for when NFS fails.
* We send back the gzipped version.
*/
COMMAND_PROTOTYPE(dotopomap)
{
FILE *fp;
char buf[MYBUFSIZE];
int cc;
/*
* Open up the file on boss and spit it back.
*/
sprintf(buf, "%s/expwork/%s/%s/topomap.gz", TBROOT,
reqp->pid, reqp->eid);
if ((fp = fopen(buf, "r")) == NULL) {
errorc("DOTOPOMAP: Could not open topomap for %s:",
reqp->nodeid);
return 1;
}
while (1) {
cc = fread(buf, sizeof(char), sizeof(buf), fp);
if (cc == 0) {
if (ferror(fp)) {
fclose(fp);
return 1;
}
break;
}
client_writeback(sock, buf, cc, tcp);
}
fclose(fp);
return 0;
}
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