Updates for diskwatcher

This commit is contained in:
Michiel Broek
2004-03-21 12:55:45 +00:00
parent f55ff6280f
commit f10a39a9e7
17 changed files with 67 additions and 82 deletions

View File

@@ -471,20 +471,30 @@ unsigned long sequencer()
*/
int enoughspace(unsigned long needed)
{
char *buf, *res;
int rc = 3;
char *buf, *res;
int rc = 3, cnt;
unsigned long avail = 0L;
buf = calloc(SS_BUFSIZE, sizeof(char));
sprintf(buf, "DSPC:1,%ld;", needed);
if (socket_send(buf) == 0) {
free(buf);
buf = socket_receive();
res = strtok(buf, ",");
res = strtok(NULL, ";");
rc = atoi(res);
sprintf(buf, "%s", socket_receive());
res = strtok(buf, ":");
cnt = atoi(strtok(NULL, ","));
if (cnt == 1) {
rc = atoi(strtok(NULL, ";"));
} else if (cnt == 2) {
rc = atoi(strtok(NULL, ","));
avail = atol(strtok(NULL, ";"));
if (rc == 0)
Syslog('+', "Only %ld MBytes diskspace, need %ld MBytes", avail, needed);
} else {
Syslog('-', "Error in enoughspace()");
}
}
free(buf);
return rc;
}