2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: driverio.c,v 1.92 2006/08/24 01:57:16 paddy_s Exp $
30 * I/O-related functions for driver program
35 #include "server_util.h"
40 #include "timestamp.h"
42 #define GLOBAL /* the global variables defined here */
47 static const char *childstr(int);
56 for(dumper = dmptable; dumper < dmptable + MAX_DUMPERS; dumper++) {
66 static char buf[NUM_STR_SIZE + 32];
72 for (dumper = dmptable; dumper < dmptable + MAX_DUMPERS; dumper++) {
74 return (dumper->name);
75 if (dumper->chunker && dumper->chunker->fd == fd)
76 return (dumper->chunker->name);
78 g_snprintf(buf, SIZEOF(buf), _("unknown child (fd %d)"), fd);
86 int taper_parallel_write,
91 char **config_options;
94 /* always allocate the tapetable */
95 tapetable = calloc(sizeof(taper_t), taper_parallel_write+1);
97 for (taper = tapetable, i = 0; i < taper_parallel_write; taper++, i++) {
98 taper->name = g_strdup_printf("worker%d", i);
99 taper->sendresult = 0;
100 taper->input_error = NULL;
101 taper->tape_error = NULL;
103 taper->dumper = NULL;
105 taper->first_label = NULL;
106 taper->first_fileno = 0;
107 taper->state = TAPER_STATE_DEFAULT;
111 /* jump right to degraded mode if there's no taper */
113 taper->tape_error = g_strdup("no taper started (--no-taper)");
114 taper->result = BOGUS;
118 /* don't start the taper if we're not supposed to */
122 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
123 error(_("taper pipe: %s"), strerror(errno));
126 if(fd[0] < 0 || fd[0] >= (int)FD_SETSIZE) {
127 error(_("taper socketpair 0: descriptor %d out of range (0 .. %d)\n"),
128 fd[0], (int)FD_SETSIZE-1);
131 if(fd[1] < 0 || fd[1] >= (int)FD_SETSIZE) {
132 error(_("taper socketpair 1: descriptor %d out of range (0 .. %d)\n"),
133 fd[1], (int)FD_SETSIZE-1);
137 switch(taper_pid = fork()) {
139 error(_("fork taper: %s"), strerror(errno));
142 case 0: /* child process */
144 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1)
145 error(_("taper dup2: %s"), strerror(errno));
146 config_options = get_config_options(2);
147 config_options[0] = "taper";
148 config_options[1] = get_config_name();
150 execve(taper_program, config_options, safe_env());
151 error("exec %s: %s", taper_program, strerror(errno));
154 default: /* parent process */
157 taper_ev_read = NULL;
162 startup_dump_process(
164 char *dumper_program)
167 char **config_options;
169 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
170 error(_("%s pipe: %s"), dumper->name, strerror(errno));
174 switch(dumper->pid = fork()) {
176 error(_("fork %s: %s"), dumper->name, strerror(errno));
179 case 0: /* child process */
181 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1)
182 error(_("%s dup2: %s"), dumper->name, strerror(errno));
183 config_options = get_config_options(2);
184 config_options[0] = dumper->name ? dumper->name : "dumper",
185 config_options[1] = get_config_name();
187 execve(dumper_program, config_options, safe_env());
188 error(_("exec %s (%s): %s"), dumper_program,
189 dumper->name, strerror(errno));
192 default: /* parent process */
195 dumper->ev_read = NULL;
196 dumper->busy = dumper->down = 0;
198 g_fprintf(stderr,_("driver: started %s pid %u\n"),
199 dumper->name, (unsigned)dumper->pid);
205 startup_dump_processes(
206 char *dumper_program,
212 char number[NUM_STR_SIZE];
214 for(dumper = dmptable, i = 0; i < inparallel; dumper++, i++) {
215 g_snprintf(number, SIZEOF(number), "%d", i);
216 dumper->name = stralloc2("dumper", number);
217 dumper->chunker = &chktable[i];
218 chktable[i].name = stralloc2("chunker", number);
219 chktable[i].dumper = dumper;
222 startup_dump_process(dumper, dumper_program);
223 dumper_cmd(dumper, START, NULL, (void *)timestamp);
228 startup_chunk_process(
230 char *chunker_program)
233 char **config_options;
235 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
236 error(_("%s pipe: %s"), chunker->name, strerror(errno));
240 switch(chunker->pid = fork()) {
242 error(_("fork %s: %s"), chunker->name, strerror(errno));
245 case 0: /* child process */
247 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1) {
248 error(_("%s dup2: %s"), chunker->name, strerror(errno));
251 config_options = get_config_options(2);
252 config_options[0] = chunker->name ? chunker->name : "chunker",
253 config_options[1] = get_config_name();
255 execve(chunker_program, config_options, safe_env());
256 error(_("exec %s (%s): %s"), chunker_program,
257 chunker->name, strerror(errno));
260 default: /* parent process */
264 chunker->ev_read = NULL;
265 g_fprintf(stderr,_("driver: started %s pid %u\n"),
266 chunker->name, (unsigned)chunker->pid);
281 if((line = areads(fd)) == NULL) {
283 g_fprintf(stderr, _("reading result from %s: %s"), childstr(fd), strerror(errno));
286 *result_argc = 0; /* EOF */
288 *result_argv = split_quoted_strings(line);
289 *result_argc = g_strv_length(*result_argv);
293 g_printf(_("driver: result time %s from %s:"),
294 walltime_str(curclock()),
297 g_printf(" %s", line);
300 g_printf(" (eof)\n");
306 if(*result_argc < 1) return BOGUS;
308 for(t = (cmd_t)(BOGUS+1); t < LAST_TOK; t++)
309 if(strcmp((*result_argv)[0], cmdstr[t]) == 0) return t;
316 taper_splitting_args(
319 GString *args = NULL;
321 dumptype_t *dt = dp->config;
324 tt = lookup_tapetype(getconf_str(CNF_TAPETYPE));
325 g_assert(tt != NULL);
327 args = g_string_new("");
329 /* old dumptype-based parameters, using empty strings when not seen */
330 if (dt) { /* 'dt' may be NULL for flushes */
331 if (dumptype_seen(dt, DUMPTYPE_TAPE_SPLITSIZE)) {
332 g_string_append_printf(args, "%ju ",
333 (uintmax_t)dumptype_get_tape_splitsize(dt)*1024);
335 g_string_append(args, "\"\" ");
338 q = quote_string(dumptype_seen(dt, DUMPTYPE_SPLIT_DISKBUFFER)?
339 dumptype_get_split_diskbuffer(dt) : "");
340 g_string_append_printf(args, "%s ", q);
343 if (dumptype_seen(dt, DUMPTYPE_FALLBACK_SPLITSIZE)) {
344 g_string_append_printf(args, "%ju ",
345 (uintmax_t)dumptype_get_fallback_splitsize(dt)*1024);
347 g_string_append(args, "\"\" ");
350 if (dumptype_seen(dt, DUMPTYPE_ALLOW_SPLIT)) {
351 g_string_append_printf(args, "%d ",
352 (int)dumptype_get_allow_split(dt));
354 g_string_append(args, "\"\" ");
357 g_string_append(args, "\"\" \"\" \"\" \"\" ");
360 /* new tapetype-based parameters */
361 if (tapetype_seen(tt, TAPETYPE_PART_SIZE)) {
362 g_string_append_printf(args, "%ju ",
363 (uintmax_t)tapetype_get_part_size(tt)*1024);
365 g_string_append(args, "\"\" ");
369 if (tapetype_seen(tt, TAPETYPE_PART_CACHE_TYPE)) {
370 switch (tapetype_get_part_cache_type(tt)) {
372 case PART_CACHE_TYPE_NONE:
376 case PART_CACHE_TYPE_MEMORY:
380 case PART_CACHE_TYPE_DISK:
386 g_string_append_printf(args, "%s ", q);
389 q = quote_string(tapetype_seen(tt, TAPETYPE_PART_CACHE_DIR)?
390 tapetype_get_part_cache_dir(tt) : "");
391 g_string_append_printf(args, "%s ", q);
394 if (tapetype_seen(tt, TAPETYPE_PART_CACHE_MAX_SIZE)) {
395 g_string_append_printf(args, "%ju ",
396 (uintmax_t)tapetype_get_part_cache_max_size(tt)*1024);
398 g_string_append(args, "\"\" ");
402 return g_string_free(args, FALSE);
413 char *cmdline = NULL;
414 char number[NUM_STR_SIZE];
415 char orig_kb[NUM_STR_SIZE];
426 cmdline = vstralloc(cmdstr[cmd],
433 cmdline = g_strjoin(NULL, cmdstr[cmd],
434 " ", sched(dp)->taper->name,
439 qname = quote_string(dp->name);
440 qdest = quote_string(destname);
441 g_snprintf(number, SIZEOF(number), "%d", level);
442 if (sched(dp)->origsize >= 0)
443 origsize = sched(dp)->origsize;
446 g_snprintf(orig_kb, SIZEOF(orig_kb), "%ju", origsize);
447 splitargs = taper_splitting_args(dp);
448 cmdline = vstralloc(cmdstr[cmd],
449 " ", sched(dp)->taper->name,
450 " ", disk2serial(dp),
452 " ", dp->host->hostname,
466 qname = quote_string(dp->name);
467 g_snprintf(number, SIZEOF(number), "%d", level);
468 data_path = data_path_to_string(dp->data_path);
471 If we haven't been given a place to buffer split dumps to disk,
472 make the argument something besides and empty string so's taper
475 splitargs = taper_splitting_args(dp);
476 cmdline = vstralloc(cmdstr[cmd],
477 " ", sched(dp)->taper->name,
478 " ", disk2serial(dp),
479 " ", dp->host->hostname,
489 case DONE: /* handle */
491 if (sched(dp)->origsize >= 0)
492 origsize = sched(dp)->origsize;
495 g_snprintf(number, SIZEOF(number), "%ju", origsize);
496 cmdline = vstralloc(cmdstr[cmd],
497 " ", sched(dp)->taper->name,
498 " ", disk2serial(dp),
502 case FAILED: /* handle */
504 cmdline = vstralloc(cmdstr[cmd],
505 " ", sched(dp)->taper->name,
506 " ", disk2serial(dp),
511 q = quote_string(destname); /* reason why no new tape */
512 cmdline = vstralloc(cmdstr[cmd],
513 " ", sched(dp)->taper->name,
514 " ", disk2serial(dp),
521 cmdline = vstralloc(cmdstr[cmd],
522 " ", sched(dp)->taper->name,
523 " ", disk2serial(dp),
528 cmdline = vstralloc(cmdstr[cmd],
529 " ", sched(dp)->taper->name,
530 " ", disk2serial(dp),
533 case TAKE_SCRIBE_FROM:
535 cmdline = vstralloc(cmdstr[cmd],
536 " ", sched(dp)->taper->name,
537 " ", disk2serial(dp),
538 " ", destname, /* name of worker */
542 cmdline = stralloc2(cmdstr[cmd], "\n");
545 error(_("Don't know how to send %s command to taper"), cmdstr[cmd]);
550 * Note: cmdline already has a '\n'.
552 g_printf(_("driver: send-cmd time %s to taper: %s"),
553 walltime_str(curclock()), cmdline);
555 if ((full_write(taper_fd, cmdline, strlen(cmdline))) < strlen(cmdline)) {
556 g_printf(_("writing taper command '%s' failed: %s\n"),
557 cmdline, strerror(errno));
562 if(cmd == QUIT) aclose(taper_fd);
574 char *cmdline = NULL;
575 char number[NUM_STR_SIZE];
576 char numberport[NUM_STR_SIZE];
577 char maxwarnings[NUM_STR_SIZE];
586 cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
589 if(dp && dp->device) {
597 application_t *application = NULL;
601 char *qclient_username;
606 if (dp->application != NULL) {
607 application = lookup_application(dp->application);
608 g_assert(application != NULL);
611 device = quote_string((dp->device) ? dp->device : "NODEVICE");
612 qname = quote_string(dp->name);
613 g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
614 g_snprintf(numberport, SIZEOF(numberport), "%d", dumper->output_port);
615 g_snprintf(maxwarnings, SIZEOF(maxwarnings), "%d", dp->max_warnings);
616 features = am_feature_to_string(dp->host->features);
617 if (am_has_feature(dp->host->features, fe_req_xml)) {
618 o = xml_optionstr(dp, 1);
620 d_prop = xml_dumptype_properties(dp);
621 vstrextend(&o, d_prop, NULL);
626 xml_app = xml_application(dp, application,
628 vstrextend(&o, xml_app, NULL);
631 oo = quote_string(o);
638 g_assert(dp->program);
639 if (0 == strcmp(dp->program, "APPLICATION")) {
640 g_assert(application != NULL);
641 plugin = application_get_plugin(application);
643 plugin = dp->program;
645 qplugin = quote_string(plugin);
646 qamandad_path = quote_string(dp->amandad_path);
647 qclient_username = quote_string(dp->client_username);
648 qclient_port = quote_string(dp->client_port);
649 qssh_keys = quote_string(dp->ssh_keys);
650 dbprintf("security_driver %s\n", dp->auth);
652 cmdline = vstralloc(cmdstr[cmd],
653 " ", disk2serial(dp),
655 " ", dp->host->hostname,
660 " ", sched(dp)->dumpdate,
663 " ", qclient_username,
667 " ", data_path_to_string(dp->data_path),
668 " ", dp->dataport_list,
673 amfree(qamandad_path);
674 amfree(qclient_username);
675 amfree(qclient_port);
682 error(_("PORT-DUMP without disk pointer\n"));
688 qmesg = quote_string(mesg);
689 cmdline = vstralloc(cmdstr[cmd], " ", qmesg, "\n", NULL );
693 error(_("Don't know how to send %s command to dumper"), cmdstr[cmd]);
698 * Note: cmdline already has a '\n'.
701 g_printf(_("driver: send-cmd time %s ignored to down dumper %s: %s"),
702 walltime_str(curclock()), dumper->name, cmdline);
704 g_printf(_("driver: send-cmd time %s to %s: %s"),
705 walltime_str(curclock()), dumper->name, cmdline);
707 if (full_write(dumper->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
708 g_printf(_("writing %s command: %s\n"), dumper->name, strerror(errno));
713 if (cmd == QUIT) aclose(dumper->fd);
726 char *cmdline = NULL;
727 char number[NUM_STR_SIZE];
728 char chunksize[NUM_STR_SIZE];
729 char use[NUM_STR_SIZE];
732 assignedhd_t **h=NULL;
739 cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
742 if(dp && sched(dp) && sched(dp)->holdp) {
743 h = sched(dp)->holdp;
744 activehd = sched(dp)->activehd;
748 qname = quote_string(dp->name);
749 qdest = quote_string(sched(dp)->destname);
750 h[activehd]->disk->allocated_dumpers++;
751 g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
752 g_snprintf(chunksize, SIZEOF(chunksize), "%lld",
753 (long long)holdingdisk_get_chunksize(h[0]->disk->hdisk));
754 g_snprintf(use, SIZEOF(use), "%lld",
755 (long long)h[0]->reserved);
756 features = am_feature_to_string(dp->host->features);
758 cmdline = vstralloc(cmdstr[cmd],
759 " ", disk2serial(dp),
761 " ", dp->host->hostname,
765 " ", sched(dp)->dumpdate,
776 error(_("%s command without disk and holding disk.\n"),
782 if(dp && sched(dp) && sched(dp)->holdp) {
783 h = sched(dp)->holdp;
784 activehd = sched(dp)->activehd;
788 qname = quote_string(dp->name);
789 qdest = quote_string(h[activehd]->destname);
790 h[activehd]->disk->allocated_dumpers++;
791 g_snprintf(chunksize, SIZEOF(chunksize), "%lld",
792 (long long)holdingdisk_get_chunksize(h[activehd]->disk->hdisk));
793 g_snprintf(use, SIZEOF(use), "%lld",
794 (long long)(h[activehd]->reserved - h[activehd]->used));
795 cmdline = vstralloc(cmdstr[cmd],
796 " ", disk2serial(dp),
804 cmdline = stralloc2(cmdstr[cmd], "\n");
810 char *q = quote_string(mesg);
811 cmdline = vstralloc(cmdstr[cmd], " ", q, "\n", NULL);
818 cmdline = vstralloc(cmdstr[cmd],
819 " ", disk2serial(dp),
822 cmdline = vstralloc(cmdstr[cmd], "\n", NULL);
826 error(_("Don't know how to send %s command to chunker"), cmdstr[cmd]);
831 * Note: cmdline already has a '\n'.
833 g_printf(_("driver: send-cmd time %s to %s: %s"),
834 walltime_str(curclock()), chunker->name, cmdline);
836 if (full_write(chunker->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
837 g_printf(_("writing %s command: %s\n"), chunker->name, strerror(errno));
842 if (cmd == QUIT) aclose(chunker->fd);
847 #define MAX_SERIAL MAX_DUMPERS*2 /* one for each dumper and taper */
854 } stable[MAX_SERIAL];
863 rc = sscanf(str, "%d-%ld", &s, &gen);
865 error(_("error [serial2disk \"%s\" parse error]"), str);
867 } else if (s < 0 || s >= MAX_SERIAL) {
868 error(_("error [serial out of range 0..%d: %d]"), MAX_SERIAL, s);
871 if(gen != stable[s].gen)
872 g_printf(_("driver: serial2disk error time %s serial gen mismatch %s\n"),
873 walltime_str(curclock()), str);
884 rc = sscanf(str, _("%d-%ld"), &s, &gen);
885 if(!(rc == 2 && s >= 0 && s < MAX_SERIAL)) {
886 /* nuke self to get core dump for Brett */
887 g_fprintf(stderr, _("driver: free_serial: str \"%s\" rc %d s %d\n"),
893 if(gen != stable[s].gen)
894 g_printf(_("driver: free_serial error time %s serial gen mismatch %s\n"),
895 walltime_str(curclock()),str);
907 for(s = 0; s < MAX_SERIAL; s++) {
908 if(stable[s].dp == dp) {
915 g_printf(_("driver: error time %s serial not found for disk %s\n"),
916 walltime_str(curclock()), dp->name);
921 check_unfree_serial(void)
925 /* find used serial number */
926 for(s = 0; s < MAX_SERIAL; s++) {
927 if(stable[s].gen != 0 || stable[s].dp != NULL) {
928 g_printf(_("driver: error time %s bug: serial in use: %02d-%05ld\n"),
929 walltime_str(curclock()), s, stable[s].gen);
938 static char str[NUM_STR_SIZE];
940 for(s = 0; s < MAX_SERIAL; s++) {
941 if(stable[s].dp == dp) {
942 g_snprintf(str, SIZEOF(str), "%02d-%05ld", s, stable[s].gen);
947 /* find unused serial number */
948 for(s = 0; s < MAX_SERIAL; s++)
949 if(stable[s].gen == 0 && stable[s].dp == NULL)
951 if(s >= MAX_SERIAL) {
952 g_printf(_("driver: error time %s bug: out of serial numbers\n"),
953 walltime_str(curclock()));
957 stable[s].gen = generation++;
960 g_snprintf(str, SIZEOF(str), "%02d-%05ld", s, stable[s].gen);
977 level = sched(dp)->level;
979 conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));
980 if (open_infofile(conf_infofile)) {
981 error(_("could not open info db \"%s\""), conf_infofile);
984 amfree(conf_infofile);
986 get_info(dp->host->hostname, dp->name, &info);
988 /* Clean up information about this and higher-level dumps. This
989 assumes that update_info_dumper() is always run before
990 update_info_taper(). */
991 for (i = level; i < DUMP_LEVELS; ++i) {
993 infp->size = (off_t)-1;
994 infp->csize = (off_t)-1;
995 infp->secs = (time_t)-1;
996 infp->date = (time_t)-1;
997 infp->label[0] = '\0';
1001 /* now store information about this dump */
1002 infp = &info.inf[level];
1003 infp->size = origsize;
1004 infp->csize = dumpsize;
1005 infp->secs = dumptime;
1006 if (sched(dp)->timestamp == 0) {
1009 infp->date = get_time_from_timestamp(sched(dp)->datestamp);
1012 if(level == 0) perfp = &info.full;
1013 else perfp = &info.incr;
1015 /* Update the stats, but only if the new values are meaningful */
1016 if(dp->compress != COMP_NONE && origsize > (off_t)0) {
1017 newperf(perfp->comp, (double)dumpsize/(double)origsize);
1019 if(dumptime > (time_t)0) {
1020 if((off_t)dumptime >= dumpsize)
1021 newperf(perfp->rate, 1);
1023 newperf(perfp->rate, (double)dumpsize/(double)dumptime);
1026 if(origsize >= (off_t)0 && getconf_int(CNF_RESERVE)<100) {
1027 info.command = NO_COMMAND;
1030 if (origsize >= (off_t)0 && level == info.last_level) {
1031 info.consecutive_runs++;
1032 } else if (origsize >= (off_t)0) {
1033 info.last_level = level;
1034 info.consecutive_runs = 1;
1037 if(origsize >= (off_t)0 && dumpsize >= (off_t)0) {
1038 for(i=NB_HISTORY-1;i>0;i--) {
1039 info.history[i] = info.history[i-1];
1042 info.history[0].level = level;
1043 info.history[0].size = origsize;
1044 info.history[0].csize = dumpsize;
1045 if (sched(dp)->timestamp == 0) {
1046 info.history[0].date = 0;
1048 info.history[0].date = get_time_from_timestamp(sched(dp)->datestamp);
1050 info.history[0].secs = dumptime;
1053 if (put_info(dp->host->hostname, dp->name, &info)) {
1054 int save_errno = errno;
1055 g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
1056 dp->host->hostname, dp->name, strerror(save_errno));
1057 log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
1058 dp->host->hostname, dp->name, strerror(save_errno));
1059 error(_("infofile update failed (%s,'%s'): %s\n"),
1060 dp->host->hostname, dp->name, strerror(save_errno));
1078 rc = open_infofile(getconf_str(CNF_INFOFILE));
1080 error(_("could not open infofile %s: %s (%d)"), getconf_str(CNF_INFOFILE),
1081 strerror(errno), rc);
1085 get_info(dp->host->hostname, dp->name, &info);
1087 infp = &info.inf[level];
1088 /* XXX - should we record these two if no-record? */
1089 strncpy(infp->label, label, SIZEOF(infp->label)-1);
1090 infp->label[SIZEOF(infp->label)-1] = '\0';
1091 infp->filenum = filenum;
1093 info.command = NO_COMMAND;
1095 if (put_info(dp->host->hostname, dp->name, &info)) {
1096 int save_errno = errno;
1097 g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
1098 dp->host->hostname, dp->name, strerror(save_errno));
1099 log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
1100 dp->host->hostname, dp->name, strerror(save_errno));
1101 error(_("infofile update failed (%s,'%s'): %s\n"),
1102 dp->host->hostname, dp->name, strerror(save_errno));
1108 /* Free an array of pointers to assignedhd_t after freeing the
1109 * assignedhd_t themselves. The array must be NULL-terminated.
1111 void free_assignedhd(
1116 if( !ahd ) { return; }
1118 for( i = 0; ahd[i]; i++ ) {
1119 amfree(ahd[i]->destname);