+ default:
+ error(_("Don't know how to send %s command to dumper"), cmdstr[cmd]);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Note: cmdline already has a '\n'.
+ */
+ if(dumper->down) {
+ g_printf(_("driver: send-cmd time %s ignored to down dumper %s: %s"),
+ walltime_str(curclock()), dumper->name, cmdline);
+ } else {
+ g_printf(_("driver: send-cmd time %s to %s: %s"),
+ walltime_str(curclock()), dumper->name, cmdline);
+ fflush(stdout);
+ if (fullwrite(dumper->fd, cmdline, strlen(cmdline)) < 0) {
+ g_printf(_("writing %s command: %s\n"), dumper->name, strerror(errno));
+ fflush(stdout);
+ amfree(cmdline);
+ return 0;
+ }
+ if (cmd == QUIT) aclose(dumper->fd);
+ }
+ amfree(cmdline);
+ return 1;
+}
+
+int
+chunker_cmd(
+ chunker_t *chunker,
+ cmd_t cmd,
+ disk_t *dp)
+{
+ char *cmdline = NULL;
+ char number[NUM_STR_SIZE];
+ char chunksize[NUM_STR_SIZE];
+ char use[NUM_STR_SIZE];
+ char *o;
+ int activehd=0;
+ assignedhd_t **h=NULL;
+ char *features;
+ char *qname;
+ char *qdest;
+
+ switch(cmd) {
+ case START:
+ cmdline = vstralloc(cmdstr[cmd], " ", (char *)dp, "\n", NULL);
+ break;
+ case PORT_WRITE:
+ if(dp && sched(dp) && sched(dp)->holdp) {
+ h = sched(dp)->holdp;
+ activehd = sched(dp)->activehd;
+ }
+
+ if (dp && h) {
+ qname = quote_string(dp->name);
+ qdest = quote_string(sched(dp)->destname);
+ h[activehd]->disk->allocated_dumpers++;
+ g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
+ g_snprintf(chunksize, SIZEOF(chunksize), "%lld",
+ (long long)holdingdisk_get_chunksize(h[0]->disk->hdisk));
+ g_snprintf(use, SIZEOF(use), "%lld",
+ (long long)h[0]->reserved);
+ features = am_feature_to_string(dp->host->features);
+ o = optionstr(dp, dp->host->features, NULL);
+ if ( o == NULL ) {
+ error(_("problem with option string, check the dumptype definition.\n"));
+ }
+ cmdline = vstralloc(cmdstr[cmd],
+ " ", disk2serial(dp),
+ " ", qdest,
+ " ", dp->host->hostname,
+ " ", features,
+ " ", qname,
+ " ", number,
+ " ", sched(dp)->dumpdate,
+ " ", chunksize,
+ " ", dp->program,
+ " ", use,
+ " |", o,
+ "\n", NULL);
+ amfree(features);
+ amfree(o);
+ amfree(qdest);
+ amfree(qname);
+ } else {
+ error(_("%s command without disk and holding disk.\n"),
+ cmdstr[cmd]);
+ /*NOTREACHED*/
+ }
+ break;