2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Author: James da Silva, Systems Design and Analysis Group
25 * Computer Science Department
26 * University of Maryland at College Park
29 * $Id: driverio.c,v 1.92 2006/08/24 01:57:16 paddy_s Exp $
31 * I/O-related functions for driver program
36 #include "server_util.h"
41 #include "timestamp.h"
43 #define GLOBAL /* the global variables defined here */
48 static const char *childstr(int);
57 for(dumper = dmptable; dumper < dmptable + MAX_DUMPERS; dumper++) {
67 static char buf[NUM_STR_SIZE + 32];
73 for (dumper = dmptable; dumper < dmptable + MAX_DUMPERS; dumper++) {
75 return (dumper->name);
76 if (dumper->chunker && dumper->chunker->fd == fd)
77 return (dumper->chunker->name);
79 g_snprintf(buf, SIZEOF(buf), _("unknown child (fd %d)"), fd);
87 int taper_parallel_write,
92 char **config_options;
95 /* always allocate the tapetable */
96 tapetable = calloc(sizeof(taper_t), taper_parallel_write+1);
98 for (taper = tapetable, i = 0; i < taper_parallel_write; taper++, i++) {
99 taper->name = g_strdup_printf("worker%d", i);
100 taper->sendresult = 0;
101 taper->input_error = NULL;
102 taper->tape_error = NULL;
104 taper->dumper = NULL;
106 taper->first_label = NULL;
107 taper->first_fileno = 0;
108 taper->state = TAPER_STATE_DEFAULT;
112 /* jump right to degraded mode if there's no taper */
114 taper->tape_error = g_strdup("no taper started (--no-taper)");
115 taper->result = BOGUS;
119 /* don't start the taper if we're not supposed to */
123 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
124 error(_("taper pipe: %s"), strerror(errno));
127 if(fd[0] < 0 || fd[0] >= (int)FD_SETSIZE) {
128 error(_("taper socketpair 0: descriptor %d out of range (0 .. %d)\n"),
129 fd[0], (int)FD_SETSIZE-1);
132 if(fd[1] < 0 || fd[1] >= (int)FD_SETSIZE) {
133 error(_("taper socketpair 1: descriptor %d out of range (0 .. %d)\n"),
134 fd[1], (int)FD_SETSIZE-1);
138 switch(taper_pid = fork()) {
140 error(_("fork taper: %s"), strerror(errno));
143 case 0: /* child process */
145 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1)
146 error(_("taper dup2: %s"), strerror(errno));
147 config_options = get_config_options(2);
148 config_options[0] = "taper";
149 config_options[1] = get_config_name();
151 execve(taper_program, config_options, safe_env());
152 error("exec %s: %s", taper_program, strerror(errno));
155 default: /* parent process */
158 taper_ev_read = NULL;
163 startup_dump_process(
165 char *dumper_program)
168 char **config_options;
170 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
171 error(_("%s pipe: %s"), dumper->name, strerror(errno));
175 switch(dumper->pid = fork()) {
177 error(_("fork %s: %s"), dumper->name, strerror(errno));
180 case 0: /* child process */
182 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1)
183 error(_("%s dup2: %s"), dumper->name, strerror(errno));
184 config_options = get_config_options(2);
185 config_options[0] = dumper->name ? dumper->name : "dumper",
186 config_options[1] = get_config_name();
188 execve(dumper_program, config_options, safe_env());
189 error(_("exec %s (%s): %s"), dumper_program,
190 dumper->name, strerror(errno));
193 default: /* parent process */
196 dumper->ev_read = NULL;
197 dumper->busy = dumper->down = 0;
199 g_fprintf(stderr,_("driver: started %s pid %u\n"),
200 dumper->name, (unsigned)dumper->pid);
206 startup_dump_processes(
207 char *dumper_program,
213 char number[NUM_STR_SIZE];
215 for(dumper = dmptable, i = 0; i < inparallel; dumper++, i++) {
216 g_snprintf(number, SIZEOF(number), "%d", i);
217 dumper->name = stralloc2("dumper", number);
218 dumper->chunker = &chktable[i];
219 chktable[i].name = stralloc2("chunker", number);
220 chktable[i].dumper = dumper;
223 startup_dump_process(dumper, dumper_program);
224 dumper_cmd(dumper, START, NULL, (void *)timestamp);
229 startup_chunk_process(
231 char *chunker_program)
234 char **config_options;
236 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
237 error(_("%s pipe: %s"), chunker->name, strerror(errno));
241 switch(chunker->pid = fork()) {
243 error(_("fork %s: %s"), chunker->name, strerror(errno));
246 case 0: /* child process */
248 if(dup2(fd[1], 0) == -1 || dup2(fd[1], 1) == -1) {
249 error(_("%s dup2: %s"), chunker->name, strerror(errno));
252 config_options = get_config_options(2);
253 config_options[0] = chunker->name ? chunker->name : "chunker",
254 config_options[1] = get_config_name();
256 execve(chunker_program, config_options, safe_env());
257 error(_("exec %s (%s): %s"), chunker_program,
258 chunker->name, strerror(errno));
261 default: /* parent process */
265 chunker->ev_read = NULL;
266 g_fprintf(stderr,_("driver: started %s pid %u\n"),
267 chunker->name, (unsigned)chunker->pid);
282 if((line = areads(fd)) == NULL) {
284 g_fprintf(stderr, _("reading result from %s: %s"), childstr(fd), strerror(errno));
287 *result_argc = 0; /* EOF */
289 *result_argv = split_quoted_strings(line);
290 *result_argc = g_strv_length(*result_argv);
294 g_printf(_("driver: result time %s from %s:"),
295 walltime_str(curclock()),
298 g_printf(" %s", line);
301 g_printf(" (eof)\n");
307 if(*result_argc < 1) return BOGUS;
309 for(t = (cmd_t)(BOGUS+1); t < LAST_TOK; t++)
310 if(strcmp((*result_argv)[0], cmdstr[t]) == 0) return t;
317 taper_splitting_args(
320 GString *args = NULL;
322 dumptype_t *dt = dp->config;
325 tt = lookup_tapetype(getconf_str(CNF_TAPETYPE));
326 g_assert(tt != NULL);
328 args = g_string_new("");
330 /* old dumptype-based parameters, using empty strings when not seen */
331 if (dt) { /* 'dt' may be NULL for flushes */
332 if (dumptype_seen(dt, DUMPTYPE_TAPE_SPLITSIZE)) {
333 g_string_append_printf(args, "%ju ",
334 (uintmax_t)dumptype_get_tape_splitsize(dt)*1024);
336 g_string_append(args, "\"\" ");
339 q = quote_string(dumptype_seen(dt, DUMPTYPE_SPLIT_DISKBUFFER)?
340 dumptype_get_split_diskbuffer(dt) : "");
341 g_string_append_printf(args, "%s ", q);
344 if (dumptype_seen(dt, DUMPTYPE_FALLBACK_SPLITSIZE)) {
345 g_string_append_printf(args, "%ju ",
346 (uintmax_t)dumptype_get_fallback_splitsize(dt)*1024);
348 g_string_append(args, "\"\" ");
351 if (dumptype_seen(dt, DUMPTYPE_ALLOW_SPLIT)) {
352 g_string_append_printf(args, "%d ",
353 (int)dumptype_get_allow_split(dt));
355 g_string_append(args, "\"\" ");
358 g_string_append(args, "\"\" \"\" \"\" \"\" ");
361 /* new tapetype-based parameters */
362 if (tapetype_seen(tt, TAPETYPE_PART_SIZE)) {
363 g_string_append_printf(args, "%ju ",
364 (uintmax_t)tapetype_get_part_size(tt)*1024);
366 g_string_append(args, "\"\" ");
370 if (tapetype_seen(tt, TAPETYPE_PART_CACHE_TYPE)) {
371 switch (tapetype_get_part_cache_type(tt)) {
373 case PART_CACHE_TYPE_NONE:
377 case PART_CACHE_TYPE_MEMORY:
381 case PART_CACHE_TYPE_DISK:
387 g_string_append_printf(args, "%s ", q);
390 q = quote_string(tapetype_seen(tt, TAPETYPE_PART_CACHE_DIR)?
391 tapetype_get_part_cache_dir(tt) : "");
392 g_string_append_printf(args, "%s ", q);
395 if (tapetype_seen(tt, TAPETYPE_PART_CACHE_MAX_SIZE)) {
396 g_string_append_printf(args, "%ju ",
397 (uintmax_t)tapetype_get_part_cache_max_size(tt)*1024);
399 g_string_append(args, "\"\" ");
403 return g_string_free(args, FALSE);
414 char *cmdline = NULL;
415 char number[NUM_STR_SIZE];
416 char orig_kb[NUM_STR_SIZE];
427 cmdline = vstralloc(cmdstr[cmd],
434 cmdline = g_strjoin(NULL, cmdstr[cmd],
435 " ", sched(dp)->taper->name,
440 qname = quote_string(dp->name);
441 qdest = quote_string(destname);
442 g_snprintf(number, SIZEOF(number), "%d", level);
443 if (sched(dp)->origsize >= 0)
444 origsize = sched(dp)->origsize;
447 g_snprintf(orig_kb, SIZEOF(orig_kb), "%ju", origsize);
448 splitargs = taper_splitting_args(dp);
449 cmdline = vstralloc(cmdstr[cmd],
450 " ", sched(dp)->taper->name,
451 " ", disk2serial(dp),
453 " ", dp->host->hostname,
467 qname = quote_string(dp->name);
468 g_snprintf(number, SIZEOF(number), "%d", level);
469 data_path = data_path_to_string(dp->data_path);
472 If we haven't been given a place to buffer split dumps to disk,
473 make the argument something besides and empty string so's taper
476 splitargs = taper_splitting_args(dp);
477 cmdline = vstralloc(cmdstr[cmd],
478 " ", sched(dp)->taper->name,
479 " ", disk2serial(dp),
480 " ", dp->host->hostname,
490 case DONE: /* handle */
492 if (sched(dp)->origsize >= 0)
493 origsize = sched(dp)->origsize;
496 g_snprintf(number, SIZEOF(number), "%ju", origsize);
497 cmdline = vstralloc(cmdstr[cmd],
498 " ", sched(dp)->taper->name,
499 " ", disk2serial(dp),
503 case FAILED: /* handle */
505 cmdline = vstralloc(cmdstr[cmd],
506 " ", sched(dp)->taper->name,
507 " ", disk2serial(dp),
512 q = quote_string(destname); /* reason why no new tape */
513 cmdline = vstralloc(cmdstr[cmd],
514 " ", sched(dp)->taper->name,
515 " ", disk2serial(dp),
522 cmdline = vstralloc(cmdstr[cmd],
523 " ", sched(dp)->taper->name,
524 " ", disk2serial(dp),
529 cmdline = vstralloc(cmdstr[cmd],
530 " ", sched(dp)->taper->name,
531 " ", disk2serial(dp),
534 case TAKE_SCRIBE_FROM:
536 cmdline = vstralloc(cmdstr[cmd],
537 " ", sched(dp)->taper->name,
538 " ", disk2serial(dp),
539 " ", destname, /* name of worker */
543 cmdline = stralloc2(cmdstr[cmd], "\n");
546 error(_("Don't know how to send %s command to taper"), cmdstr[cmd]);
551 * Note: cmdline already has a '\n'.
553 g_printf(_("driver: send-cmd time %s to taper: %s"),
554 walltime_str(curclock()), cmdline);
556 if ((full_write(taper_fd, cmdline, strlen(cmdline))) < strlen(cmdline)) {
557 g_printf(_("writing taper command '%s' failed: %s\n"),
558 cmdline, strerror(errno));
563 if(cmd == QUIT) aclose(taper_fd);
575 char *cmdline = NULL;
576 char number[NUM_STR_SIZE];
577 char numberport[NUM_STR_SIZE];
578 char maxwarnings[NUM_STR_SIZE];
587 cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
590 if(dp && dp->device) {
598 application_t *application = NULL;
602 char *qclient_username;
607 if (dp->application != NULL) {
608 application = lookup_application(dp->application);
609 g_assert(application != NULL);
612 device = quote_string((dp->device) ? dp->device : "NODEVICE");
613 qname = quote_string(dp->name);
614 g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
615 g_snprintf(numberport, SIZEOF(numberport), "%d", dumper->output_port);
616 g_snprintf(maxwarnings, SIZEOF(maxwarnings), "%d", dp->max_warnings);
617 features = am_feature_to_string(dp->host->features);
618 if (am_has_feature(dp->host->features, fe_req_xml)) {
619 o = xml_optionstr(dp, 1);
621 d_prop = xml_dumptype_properties(dp);
622 vstrextend(&o, d_prop, NULL);
627 xml_app = xml_application(dp, application,
629 vstrextend(&o, xml_app, NULL);
632 oo = quote_string(o);
639 g_assert(dp->program);
640 if (0 == strcmp(dp->program, "APPLICATION")) {
641 g_assert(application != NULL);
642 plugin = application_get_plugin(application);
644 plugin = dp->program;
646 qplugin = quote_string(plugin);
647 qamandad_path = quote_string(dp->amandad_path);
648 qclient_username = quote_string(dp->client_username);
649 qclient_port = quote_string(dp->client_port);
650 qssh_keys = quote_string(dp->ssh_keys);
651 dbprintf("security_driver %s\n", dp->auth);
653 cmdline = vstralloc(cmdstr[cmd],
654 " ", disk2serial(dp),
656 " ", dp->host->hostname,
661 " ", sched(dp)->dumpdate,
664 " ", qclient_username,
668 " ", data_path_to_string(dp->data_path),
669 " ", dp->dataport_list,
674 amfree(qamandad_path);
675 amfree(qclient_username);
676 amfree(qclient_port);
683 error(_("PORT-DUMP without disk pointer\n"));
689 qmesg = quote_string(mesg);
690 cmdline = vstralloc(cmdstr[cmd], " ", qmesg, "\n", NULL );
694 error(_("Don't know how to send %s command to dumper"), cmdstr[cmd]);
699 * Note: cmdline already has a '\n'.
702 g_printf(_("driver: send-cmd time %s ignored to down dumper %s: %s"),
703 walltime_str(curclock()), dumper->name, cmdline);
705 g_printf(_("driver: send-cmd time %s to %s: %s"),
706 walltime_str(curclock()), dumper->name, cmdline);
708 if (full_write(dumper->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
709 g_printf(_("writing %s command: %s\n"), dumper->name, strerror(errno));
714 if (cmd == QUIT) aclose(dumper->fd);
727 char *cmdline = NULL;
728 char number[NUM_STR_SIZE];
729 char chunksize[NUM_STR_SIZE];
730 char use[NUM_STR_SIZE];
733 assignedhd_t **h=NULL;
740 cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
743 if(dp && sched(dp) && sched(dp)->holdp) {
744 h = sched(dp)->holdp;
745 activehd = sched(dp)->activehd;
749 qname = quote_string(dp->name);
750 qdest = quote_string(sched(dp)->destname);
751 h[activehd]->disk->allocated_dumpers++;
752 g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
753 g_snprintf(chunksize, SIZEOF(chunksize), "%lld",
754 (long long)holdingdisk_get_chunksize(h[0]->disk->hdisk));
755 g_snprintf(use, SIZEOF(use), "%lld",
756 (long long)h[0]->reserved);
757 features = am_feature_to_string(dp->host->features);
759 cmdline = vstralloc(cmdstr[cmd],
760 " ", disk2serial(dp),
762 " ", dp->host->hostname,
766 " ", sched(dp)->dumpdate,
777 error(_("%s command without disk and holding disk.\n"),
783 if(dp && sched(dp) && sched(dp)->holdp) {
784 h = sched(dp)->holdp;
785 activehd = sched(dp)->activehd;
789 qname = quote_string(dp->name);
790 qdest = quote_string(h[activehd]->destname);
791 h[activehd]->disk->allocated_dumpers++;
792 g_snprintf(chunksize, SIZEOF(chunksize), "%lld",
793 (long long)holdingdisk_get_chunksize(h[activehd]->disk->hdisk));
794 g_snprintf(use, SIZEOF(use), "%lld",
795 (long long)(h[activehd]->reserved - h[activehd]->used));
796 cmdline = vstralloc(cmdstr[cmd],
797 " ", disk2serial(dp),
805 cmdline = stralloc2(cmdstr[cmd], "\n");
811 char *q = quote_string(mesg);
812 cmdline = vstralloc(cmdstr[cmd], " ", q, "\n", NULL);
819 cmdline = vstralloc(cmdstr[cmd],
820 " ", disk2serial(dp),
823 cmdline = vstralloc(cmdstr[cmd], "\n", NULL);
827 error(_("Don't know how to send %s command to chunker"), cmdstr[cmd]);
832 * Note: cmdline already has a '\n'.
834 g_printf(_("driver: send-cmd time %s to %s: %s"),
835 walltime_str(curclock()), chunker->name, cmdline);
837 if (full_write(chunker->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
838 g_printf(_("writing %s command: %s\n"), chunker->name, strerror(errno));
843 if (cmd == QUIT) aclose(chunker->fd);
848 #define MAX_SERIAL MAX_DUMPERS*2 /* one for each dumper and taper */
855 } stable[MAX_SERIAL];
864 rc = sscanf(str, "%d-%ld", &s, &gen);
866 error(_("error [serial2disk \"%s\" parse error]"), str);
868 } else if (s < 0 || s >= MAX_SERIAL) {
869 error(_("error [serial out of range 0..%d: %d]"), MAX_SERIAL, s);
872 if(gen != stable[s].gen)
873 g_printf(_("driver: serial2disk error time %s serial gen mismatch %s\n"),
874 walltime_str(curclock()), str);
885 rc = sscanf(str, _("%d-%ld"), &s, &gen);
886 if(!(rc == 2 && s >= 0 && s < MAX_SERIAL)) {
887 /* nuke self to get core dump for Brett */
888 g_fprintf(stderr, _("driver: free_serial: str \"%s\" rc %d s %d\n"),
894 if(gen != stable[s].gen)
895 g_printf(_("driver: free_serial error time %s serial gen mismatch %s\n"),
896 walltime_str(curclock()),str);
908 for(s = 0; s < MAX_SERIAL; s++) {
909 if(stable[s].dp == dp) {
916 g_printf(_("driver: error time %s serial not found for disk %s\n"),
917 walltime_str(curclock()), dp->name);
922 check_unfree_serial(void)
926 /* find used serial number */
927 for(s = 0; s < MAX_SERIAL; s++) {
928 if(stable[s].gen != 0 || stable[s].dp != NULL) {
929 g_printf(_("driver: error time %s bug: serial in use: %02d-%05ld\n"),
930 walltime_str(curclock()), s, stable[s].gen);
939 static char str[NUM_STR_SIZE];
941 for(s = 0; s < MAX_SERIAL; s++) {
942 if(stable[s].dp == dp) {
943 g_snprintf(str, SIZEOF(str), "%02d-%05ld", s, stable[s].gen);
948 /* find unused serial number */
949 for(s = 0; s < MAX_SERIAL; s++)
950 if(stable[s].gen == 0 && stable[s].dp == NULL)
952 if(s >= MAX_SERIAL) {
953 g_printf(_("driver: error time %s bug: out of serial numbers\n"),
954 walltime_str(curclock()));
958 stable[s].gen = generation++;
961 g_snprintf(str, SIZEOF(str), "%02d-%05ld", s, stable[s].gen);
978 level = sched(dp)->level;
980 conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));
981 if (open_infofile(conf_infofile)) {
982 error(_("could not open info db \"%s\""), conf_infofile);
985 amfree(conf_infofile);
987 get_info(dp->host->hostname, dp->name, &info);
989 /* Clean up information about this and higher-level dumps. This
990 assumes that update_info_dumper() is always run before
991 update_info_taper(). */
992 for (i = level; i < DUMP_LEVELS; ++i) {
994 infp->size = (off_t)-1;
995 infp->csize = (off_t)-1;
996 infp->secs = (time_t)-1;
997 infp->date = (time_t)-1;
998 infp->label[0] = '\0';
1002 /* now store information about this dump */
1003 infp = &info.inf[level];
1004 infp->size = origsize;
1005 infp->csize = dumpsize;
1006 infp->secs = dumptime;
1007 if (sched(dp)->timestamp == 0) {
1010 infp->date = get_time_from_timestamp(sched(dp)->datestamp);
1013 if(level == 0) perfp = &info.full;
1014 else perfp = &info.incr;
1016 /* Update the stats, but only if the new values are meaningful */
1017 if(dp->compress != COMP_NONE && origsize > (off_t)0) {
1018 newperf(perfp->comp, (double)dumpsize/(double)origsize);
1020 if(dumptime > (time_t)0) {
1021 if((off_t)dumptime >= dumpsize)
1022 newperf(perfp->rate, 1);
1024 newperf(perfp->rate, (double)dumpsize/(double)dumptime);
1027 if(origsize >= (off_t)0 && getconf_int(CNF_RESERVE)<100) {
1028 info.command = NO_COMMAND;
1031 if (origsize >= (off_t)0 && level == info.last_level) {
1032 info.consecutive_runs++;
1033 } else if (origsize >= (off_t)0) {
1034 info.last_level = level;
1035 info.consecutive_runs = 1;
1038 if(origsize >= (off_t)0 && dumpsize >= (off_t)0) {
1039 for(i=NB_HISTORY-1;i>0;i--) {
1040 info.history[i] = info.history[i-1];
1043 info.history[0].level = level;
1044 info.history[0].size = origsize;
1045 info.history[0].csize = dumpsize;
1046 if (sched(dp)->timestamp == 0) {
1047 info.history[0].date = 0;
1049 info.history[0].date = get_time_from_timestamp(sched(dp)->datestamp);
1051 info.history[0].secs = dumptime;
1054 if (put_info(dp->host->hostname, dp->name, &info)) {
1055 int save_errno = errno;
1056 g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
1057 dp->host->hostname, dp->name, strerror(save_errno));
1058 log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
1059 dp->host->hostname, dp->name, strerror(save_errno));
1060 error(_("infofile update failed (%s,'%s'): %s\n"),
1061 dp->host->hostname, dp->name, strerror(save_errno));
1079 rc = open_infofile(getconf_str(CNF_INFOFILE));
1081 error(_("could not open infofile %s: %s (%d)"), getconf_str(CNF_INFOFILE),
1082 strerror(errno), rc);
1086 get_info(dp->host->hostname, dp->name, &info);
1088 infp = &info.inf[level];
1089 /* XXX - should we record these two if no-record? */
1090 strncpy(infp->label, label, SIZEOF(infp->label)-1);
1091 infp->label[SIZEOF(infp->label)-1] = '\0';
1092 infp->filenum = filenum;
1094 info.command = NO_COMMAND;
1096 if (put_info(dp->host->hostname, dp->name, &info)) {
1097 int save_errno = errno;
1098 g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
1099 dp->host->hostname, dp->name, strerror(save_errno));
1100 log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
1101 dp->host->hostname, dp->name, strerror(save_errno));
1102 error(_("infofile update failed (%s,'%s'): %s\n"),
1103 dp->host->hostname, dp->name, strerror(save_errno));
1109 /* Free an array of pointers to assignedhd_t after freeing the
1110 * assignedhd_t themselves. The array must be NULL-terminated.
1112 void free_assignedhd(
1117 if( !ahd ) { return; }
1119 for( i = 0; ahd[i]; i++ ) {
1120 amfree(ahd[i]->destname);