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: diskfile.c,v 1.95.2.12 2007/01/26 14:33:24 martinea Exp $
38 static am_host_t *hostlist;
41 static char *upcase(char *st);
42 static int parse_diskline(disklist_t *, const char *, FILE *, int *, char **);
43 static void disk_parserror(const char *, int, const char *, ...)
44 __attribute__ ((format (printf, 3, 4)));
58 lst->head = lst->tail = NULL;
61 if ((diskf = fopen(filename, "r")) == NULL) {
66 while ((line = agets(diskf)) != NULL) {
68 if (line[0] != '\0') {
69 if (parse_diskline(lst, filename, diskf, &line_num, &line) < 0) {
88 for (p = hostlist; p != NULL; p = p->next) {
89 if(strcasecmp(p->hostname, hostname) == 0) return p;
102 host = lookup_host(hostname);
106 for (disk = host->disks; disk != NULL; disk = disk->hostnext) {
107 if (strcmp(disk->name, diskname) == 0)
115 * put disk on end of queue
123 if(list->tail == NULL) list->head = disk;
124 else list->tail->next = disk;
125 disk->prev = list->tail;
133 * put disk on head of queue
141 if(list->head == NULL) list->tail = disk;
142 else list->head->prev = disk;
143 disk->next = list->head;
151 * insert in sorted order
158 int (*cmp)(disk_t *a, disk_t *b))
166 if(cmp(disk, ptr) < 0) break;
173 if(prev == NULL) list->head = disk;
174 else prev->next = disk;
175 if(ptr == NULL) list->tail = disk;
176 else ptr->prev = disk;
188 disk = alloc(SIZEOF(disk_t));
190 disk->tape_splitsize = (off_t)0;
191 disk->split_diskbuffer = NULL;
192 disk->fallback_splitsize = (off_t)0;
193 disk->name = stralloc(diskname);
194 disk->device = stralloc(diskname);
197 disk->compress = COMP_NONE;
198 disk->encrypt = ENCRYPT_NONE;
202 disk->exclude_list = NULL;
203 disk->exclude_file = NULL;
204 disk->include_list = NULL;
205 disk->include_file = NULL;
207 host = lookup_host(hostname);
209 host = alloc(SIZEOF(am_host_t));
210 host->next = hostlist;
213 host->hostname = stralloc(hostname);
215 host->inprogress = 0;
220 host->features = NULL;
222 enqueue_disk(list, disk);
225 disk->hostnext = host->disks;
233 * check if disk is present in list. Return true if so, false otherwise.
244 while ((t != NULL) && (t != disk)) {
259 int (*cmp)(disk_t *a, disk_t *b))
264 tmp = in; /* just in case in == out */
266 out->head = (disk_t *)0;
267 out->tail = (disk_t *)0;
269 while((disk = dequeue_disk(tmp)))
270 insert_disk(out, disk, cmp);
275 * remove disk from front of queue
284 if(list->head == NULL) return NULL;
287 list->head = disk->next;
289 if(list->head == NULL) list->tail = NULL;
290 else list->head->prev = NULL;
292 disk->prev = disk->next = NULL; /* for debugging */
301 if(disk->prev == NULL) list->head = disk->next;
302 else disk->prev->next = disk->next;
304 if(disk->next == NULL) list->tail = disk->prev;
305 else disk->next->prev = disk->prev;
307 disk->prev = disk->next = NULL;
315 am_host_t *host, *hostnext;
317 while (dl->head != NULL) {
318 dp = dequeue_disk(dl);
320 free_sl(dp->exclude_file);
321 free_sl(dp->exclude_list);
322 free_sl(dp->include_file);
323 free_sl(dp->include_list);
327 for(host=hostlist; host != NULL; host = hostnext) {
328 amfree(host->hostname);
329 am_release_feature_set(host->features);
330 host->features = NULL;
331 hostnext = host->next;
344 if(islower((int)*s)) *s = (char)toupper((int)*s);
351 /* return 0 on success */
352 /* return -1 on error */
356 const char *filename,
359 /*@keep@*/ char ** line_p)
364 interface_t *netif = 0;
365 char *hostname = NULL;
366 char *diskname, *diskdevice;
370 char *line = *line_p;
371 int line_num = *line_num_p;
378 assert(filename != NULL);
379 assert(line_num > 0);
380 assert(line != NULL);
384 skip_whitespace(s, ch);
385 if(ch == '\0' || ch == '#')
389 skip_non_whitespace(s, ch);
391 host = lookup_host(fp);
393 hostname = stralloc(fp);
394 malloc_mark(hostname);
396 hostname = stralloc(host->hostname);
397 if (strcmp(host->hostname, fp) != 0) {
398 disk_parserror(filename, line_num, "Same host with different case: \"%s\" and \"%s\".", host->hostname, fp);
403 shost = sanitise_filename(hostname);
404 for (p = hostlist; p != NULL; p = p->next) {
405 char *shostp = sanitise_filename(p->hostname);
406 if (!strcmp(hostname, p->hostname) &&
407 strcmp(shost, shostp)) {
408 disk_parserror(filename, line_num, "Two host are mapping to the same name: \"%s\" and \"%s\"", p->hostname, hostname);
411 else if (strcasecmp(hostname, p->hostname) &&
412 match_host(hostname, p->hostname) &&
413 match_host(p->hostname, hostname)) {
414 disk_parserror(filename, line_num, "Duplicate host name: \"%s\" and \"%s\"", p->hostname, hostname);
421 skip_whitespace(s, ch);
422 if(ch == '\0' || ch == '#') {
423 disk_parserror(filename, line_num, "disk device name expected");
429 skip_quoted_string(s, ch);
431 diskname = unquote_string(fp);
433 skip_whitespace(s, ch);
434 if(ch == '\0' || ch == '#') {
435 disk_parserror(filename, line_num, "disk dumptype expected");
441 skip_quoted_string(s, ch);
448 dumptype = unquote_string(fp);
449 if ((dtype = lookup_dumptype(dumptype)) == NULL) {
450 diskdevice = dumptype;
451 skip_whitespace(s, ch);
452 if(ch == '\0' || ch == '#') {
453 disk_parserror(filename, line_num,
454 "disk dumptype '%s' not found", dumptype);
462 skip_quoted_string(s, ch);
465 dumptype = unquote_string(fp);
470 /* check for duplicate disk */
473 if ((disk = lookup_disk(hostname, diskname)) != NULL) {
478 if (match_disk(diskname, disk->name) &&
479 match_disk(disk->name, diskname)) {
482 disk = disk->hostnext;
485 while (dup == 0 && disk != NULL);
488 disk_parserror(filename, line_num,
489 "duplicate disk record, previous on line %d",
494 disk = alloc(SIZEOF(disk_t));
496 disk->line = line_num;
497 disk->name = diskname;
498 disk->device = diskdevice;
499 malloc_mark(disk->name);
502 disk->inprogress = 0;
506 sdisk = sanitise_filename(diskname);
507 for (dp = host->disks; dp != NULL; dp = dp->next) {
508 char *sdiskp = sanitise_filename(dp->name);
509 if (strcmp(diskname, dp->name) != 0 &&
510 strcmp(sdisk, sdiskp) == 0) {
511 disk_parserror(filename, line_num,
512 "Two disk are mapping to the same name: \"%s\" and \"%s\""
513 ", you must use different diskname",
525 skip_whitespace(s, ch);
526 if (ch != '\0' && ch != '#') {
527 disk_parserror(filename, line_num,
528 "expected line break after `{\', ignoring rest of line");
531 if (strchr(s-1, '}') &&
532 (strchr(s-1, '#') == NULL ||
533 strchr(s-1, '}') < strchr(s-1, '#'))) {
534 disk_parserror(filename, line_num,"'}' on same line than '{'");
537 amfree(disk->device);
548 dtype = read_dumptype(vstralloc("custom(", hostname,
549 ":", disk->name, ")", NULL),
550 diskf, (char*)filename, line_num_p);
551 if (dtype == NULL || dup) {
552 disk_parserror(filename, line_num,
553 "read of custom dumptype failed");
556 amfree(disk->device);
566 *line_p = line = agets(diskf);
567 line_num = *line_num_p; /* no incr, read_dumptype did it already */
570 *line_p = line = stralloc("");
574 if((dtype = lookup_dumptype(dumptype)) == NULL) {
575 char *qdt = quote_string(dumptype);
577 disk_parserror(filename, line_num, "undefined dumptype `%s'", qdt);
582 amfree(disk->device);
600 disk->dtype_name = dtype->name;
601 disk->program = dumptype_get_program(dtype);
602 disk->exclude_list = duplicate_sl(dumptype_get_exclude(dtype).sl_list);
603 disk->exclude_file = duplicate_sl(dumptype_get_exclude(dtype).sl_file);
604 disk->exclude_optional = dumptype_get_exclude(dtype).optional;
605 disk->include_list = duplicate_sl(dumptype_get_include(dtype).sl_list);
606 disk->include_file = duplicate_sl(dumptype_get_include(dtype).sl_file);
607 disk->include_optional = dumptype_get_include(dtype).optional;
608 disk->priority = dumptype_get_priority(dtype);
609 disk->dumpcycle = dumptype_get_dumpcycle(dtype);
610 /* disk->frequency = dumptype_get_frequency(dtype);*/
611 disk->security_driver = dumptype_get_security_driver(dtype);
612 disk->maxdumps = dumptype_get_maxdumps(dtype);
613 disk->tape_splitsize = dumptype_get_tape_splitsize(dtype);
614 disk->split_diskbuffer = dumptype_get_split_diskbuffer(dtype);
615 disk->fallback_splitsize = dumptype_get_fallback_splitsize(dtype);
616 disk->maxpromoteday = dumptype_get_maxpromoteday(dtype);
617 disk->bumppercent = dumptype_get_bumppercent(dtype);
618 disk->bumpsize = dumptype_get_bumpsize(dtype);
619 disk->bumpdays = dumptype_get_bumpdays(dtype);
620 disk->bumpmult = dumptype_get_bumpmult(dtype);
621 disk->starttime = dumptype_get_starttime(dtype);
623 if (disk->starttime > 0) {
626 stm = localtime(&st);
627 disk->start_t -= stm->tm_sec + 60 * stm->tm_min + 3600 * stm->tm_hour;
628 disk->start_t += disk->starttime / 100 * 3600 +
629 disk->starttime % 100 * 60;
630 if ((disk->start_t - st) < -43200)
631 disk->start_t += 86400;
633 disk->strategy = dumptype_get_strategy(dtype);
634 disk->estimate = dumptype_get_estimate(dtype);
635 disk->compress = dumptype_get_compress(dtype);
636 disk->srvcompprog = dumptype_get_srvcompprog(dtype);
637 disk->clntcompprog = dumptype_get_clntcompprog(dtype);
638 disk->encrypt = dumptype_get_encrypt(dtype);
639 disk->srv_decrypt_opt = dumptype_get_srv_decrypt_opt(dtype);
640 disk->clnt_decrypt_opt = dumptype_get_clnt_decrypt_opt(dtype);
641 disk->srv_encrypt = dumptype_get_srv_encrypt(dtype);
642 disk->clnt_encrypt = dumptype_get_clnt_encrypt(dtype);
643 disk->amandad_path = dumptype_get_amandad_path(dtype);
644 disk->client_username = dumptype_get_client_username(dtype);
645 disk->ssh_keys = dumptype_get_ssh_keys(dtype);
646 disk->comprate[0] = dumptype_get_comprate(dtype)[0];
647 disk->comprate[1] = dumptype_get_comprate(dtype)[1];
650 * Boolean parameters with no value (Appears here as value 2) defaults
651 * to TRUE for backward compatibility and for logical consistency.
653 disk->record = dumptype_get_record(dtype) != 0;
654 disk->skip_incr = dumptype_get_skip_incr(dtype) != 0;
655 disk->skip_full = dumptype_get_skip_full(dtype) != 0;
656 disk->to_holdingdisk = dumptype_get_to_holdingdisk(dtype);
657 disk->kencrypt = dumptype_get_kencrypt(dtype) != 0;
658 disk->index = dumptype_get_index(dtype) != 0;
662 skip_whitespace(s, ch);
664 if(ch && ch != '#') { /* get optional spindle number */
668 skip_non_whitespace(s, ch);
671 if (*fp1 == '-') fp1++;
672 for(;*fp1!='\0';fp1++) {
673 if(!isdigit((int)*fp1)) {
678 disk_parserror(filename, line_num, "non-integer spindle `%s'", fp);
684 disk->spindle = atoi(fp);
688 skip_whitespace(s, ch);
690 if(ch && ch != '#') { /* get optional network interface */
691 skip_non_whitespace(s, ch);
693 if((netif = lookup_interface(upcase(fp))) == NULL) {
694 disk_parserror(filename, line_num,
695 "undefined network interface `%s'", fp);
702 netif = lookup_interface("default");
705 skip_whitespace(s, ch);
706 if(ch && ch != '#') { /* now we have garbage, ignore it */
707 disk_parserror(filename, line_num, "end of line expected");
710 if(dumptype_get_ignore(dtype) || dumptype_get_strategy(dtype) == DS_SKIP) {
717 /* success, add disk to lists */
719 if(host == NULL) { /* new host */
720 host = alloc(SIZEOF(am_host_t));
722 host->next = hostlist;
725 host->hostname = hostname;
728 host->inprogress = 0;
729 host->maxdumps = 1; /* will be overwritten */
733 host->features = NULL;
740 enqueue_disk(lst, disk);
743 disk->hostnext = host->disks;
745 host->maxdumps = disk->maxdumps;
751 printf_arglist_function2(void disk_parserror, const char *, filename,
752 int, line_num, const char *, format)
756 /* print error message */
758 fprintf(stderr, "\"%s\", line %d: ", filename, line_num);
759 arglist_start(argp, format);
760 vfprintf(stderr, format, argp);
770 int npr, /* we print first npr disks on queue, plus last two */
778 fprintf(f, "%s QUEUE: empty\n", st);
781 fprintf(f, "%s QUEUE:\n", st);
782 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
783 qname = quote_string(d->name);
784 if(pos < npr) fprintf(f, "%3d: %-10s %-4s\n",
785 pos, d->host->hostname, qname);
789 if(pos > npr+2) fprintf(f, " ...\n");
792 fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
795 fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
802 am_feature_t * their_features,
805 char *auth_opt = NULL;
806 char *kencrypt_opt = "";
807 char *compress_opt = "";
808 char *encrypt_opt = stralloc("");
809 char *decrypt_opt = stralloc("");
810 char *record_opt = "";
811 char *index_opt = "";
812 char *exclude_file = NULL;
813 char *exclude_list = NULL;
814 char *include_file = NULL;
815 char *include_list = NULL;
828 assert(dp->host != NULL);
830 qdpname = quote_string(dp->name);
831 if(am_has_feature(dp->host->features, fe_options_auth)) {
832 auth_opt = vstralloc("auth=", dp->security_driver, ";", NULL);
833 } else if(strcasecmp(dp->security_driver, "bsd") == 0) {
834 if(am_has_feature(dp->host->features, fe_options_bsd_auth))
835 auth_opt = stralloc("bsd-auth;");
838 "WARNING: %s:%s does not support auth or bsd-auth\n",
839 dp->host->hostname, qdpname);
841 } else if(strcasecmp(dp->security_driver, "krb4") == 0) {
842 if(am_has_feature(dp->host->features, fe_options_krb4_auth))
843 auth_opt = stralloc("krb4-auth;");
846 "WARNING: %s:%s does not support auth or krb4-auth\n",
847 dp->host->hostname, qdpname);
850 if(am_has_feature(dp->host->features, fe_options_kencrypt)) {
851 kencrypt_opt = "kencrypt;";
855 "WARNING: %s:%s does not support kencrypt\n",
856 dp->host->hostname, qdpname);
861 switch(dp->compress) {
863 if(am_has_feature(their_features, fe_options_compress_fast)) {
864 compress_opt = "compress-fast;";
868 "WARNING: %s:%s does not support fast compression\n",
869 dp->host->hostname, qdpname);
873 if(am_has_feature(their_features, fe_options_compress_best)) {
874 compress_opt = "compress-best;";
878 "WARNING: %s:%s does not support best compression\n",
879 dp->host->hostname, qdpname);
883 if(am_has_feature(their_features, fe_options_compress_cust)) {
884 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
885 if (BSTRNCMP(compress_opt, "comp-cust=;") == 0){
888 "ERROR: %s:%s client custom compression with no compression program specified\n",
889 dp->host->hostname, qdpname);
896 "WARNING: %s:%s does not support client custom compression\n",
897 dp->host->hostname, qdpname);
901 if(am_has_feature(their_features, fe_options_srvcomp_fast)) {
902 compress_opt = "srvcomp-fast;";
906 if(am_has_feature(their_features, fe_options_srvcomp_best)) {
907 compress_opt = "srvcomp-best;";
911 if(am_has_feature(their_features, fe_options_srvcomp_cust)) {
912 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
913 if (BSTRNCMP(compress_opt, "srvcomp-cust=;") == 0){
916 "ERROR: %s:%s server custom compression with no compression program specified\n",
917 dp->host->hostname, qdpname);
924 "WARNING: %s:%s does not support server custom compression\n",
925 dp->host->hostname, qdpname);
930 switch(dp->encrypt) {
932 if(am_has_feature(their_features, fe_options_encrypt_cust)) {
933 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",
934 dp->clnt_encrypt, ";", NULL);
935 if (BSTRNCMP(encrypt_opt, "encrypt-cust=;") == 0) {
938 "ERROR: %s:%s encrypt client with no encryption program specified\n",
939 dp->host->hostname, qdpname);
943 if ( dp->compress == COMP_SERV_FAST ||
944 dp->compress == COMP_SERV_BEST ||
945 dp->compress == COMP_SERV_CUST ) {
948 "ERROR: %s:Client encryption with server compression is not supported. See amanda.conf(5) for detail.\n", dp->host->hostname);
952 if(dp->clnt_decrypt_opt) {
953 if(am_has_feature(their_features, fe_options_client_decrypt_option)) {
954 decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",
955 dp->clnt_decrypt_opt, ";", NULL);
959 "WARNING: %s:%s does not support client decrypt option\n",
960 dp->host->hostname, qdpname);
966 "WARNING: %s:%s does not support client data encryption\n",
967 dp->host->hostname, qdpname);
970 case ENCRYPT_SERV_CUST:
971 if(am_has_feature(their_features, fe_options_encrypt_serv_cust)) {
972 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",
973 dp->srv_encrypt, ";", NULL);
974 if (BSTRNCMP(encrypt_opt, "encrypt-serv-cust=;") == 0){
977 "ERROR: %s:%s encrypt server with no encryption program specified\n",
978 dp->host->hostname, qdpname);
982 if(dp->srv_decrypt_opt) {
983 if(am_has_feature(their_features, fe_options_server_decrypt_option)) {
984 decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",
985 dp->srv_decrypt_opt, ";", NULL);
989 "WARNING: %s:%s does not support server decrypt option\n",
990 dp->host->hostname, qdpname);
996 "WARNING: %s:%s does not support server data encryption\n",
997 dp->host->hostname, qdpname);
1003 if(am_has_feature(their_features, fe_options_no_record)) {
1004 record_opt = "no-record;";
1007 fprintf(fdout, "WARNING: %s:%s does not support no record\n",
1008 dp->host->hostname, qdpname);
1013 if(am_has_feature(their_features, fe_options_index)) {
1014 index_opt = "index;";
1017 fprintf(fdout, "WARNING: %s:%s does not support index\n",
1018 dp->host->hostname, qdpname);
1022 if(dp->kencrypt) kencrypt_opt = "kencrypt;";
1025 exclude_file = stralloc("");
1026 nb_exclude_file = 0;
1027 if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1028 nb_exclude_file = dp->exclude_file->nb_element;
1029 if(am_has_feature(their_features, fe_options_exclude_file)) {
1030 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1031 dp->exclude_file->nb_element == 1) {
1032 for(excl = dp->exclude_file->first; excl != NULL;
1033 excl = excl->next) {
1034 qname = quote_string(excl->name);
1035 exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);
1036 strappend(exclude_file, exc);
1040 qname = quote_string(dp->exclude_file->last->name);
1041 exc = newvstralloc(exc, "exclude-file=", qname, ";", NULL);
1042 strappend(exclude_file, exc);
1045 "WARNING: %s:%s does not support multiple exclude\n",
1046 dp->host->hostname, qdpname);
1051 fprintf(fdout, "WARNING: %s:%s does not support exclude file\n",
1052 dp->host->hostname, qdpname);
1055 exclude_list = stralloc("");
1056 if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1057 if(am_has_feature(their_features, fe_options_exclude_list)) {
1058 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1059 (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {
1060 for(excl = dp->exclude_list->first; excl != NULL;
1061 excl = excl->next) {
1062 qname = quote_string(excl->name);
1063 exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);
1064 strappend(exclude_list, exc);
1068 qname = quote_string(dp->exclude_list->last->name);
1069 exc = newvstralloc(exc, "exclude-list=", qname, ";", NULL);
1070 strappend(exclude_list, exc);
1073 "WARNING: %s:%s does not support multiple exclude\n",
1074 dp->host->hostname, qdpname);
1079 fprintf(fdout, "WARNING: %s:%s does not support exclude list\n",
1080 dp->host->hostname, qdpname);
1084 include_file = stralloc("");
1085 nb_include_file = 0;
1086 if(dp->include_file != NULL && dp->include_file->nb_element > 0) {
1087 nb_include_file = dp->include_file->nb_element;
1088 if(am_has_feature(their_features, fe_options_include_file)) {
1089 if(am_has_feature(their_features, fe_options_multiple_include) ||
1090 dp->include_file->nb_element == 1) {
1091 for(excl = dp->include_file->first; excl != NULL;
1092 excl = excl->next) {
1093 qname = quote_string(excl->name);
1094 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1095 strappend(include_file, exc);
1099 qname = quote_string(dp->include_file->last->name);
1100 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1101 strappend(include_file, exc);
1104 "WARNING: %s:%s does not support multiple include\n",
1105 dp->host->hostname, qdpname);
1110 fprintf(fdout, "WARNING: %s:%s does not support include file\n",
1111 dp->host->hostname, qdpname);
1114 include_list = stralloc("");
1115 if(dp->include_list != NULL && dp->include_list->nb_element > 0) {
1116 if(am_has_feature(their_features, fe_options_include_list)) {
1117 if(am_has_feature(their_features, fe_options_multiple_include) ||
1118 (dp->include_list->nb_element == 1 && nb_include_file == 0)) {
1119 for(excl = dp->include_list->first; excl != NULL;
1120 excl = excl->next) {
1121 qname = quote_string(excl->name);
1122 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1123 strappend(include_list, exc);
1127 qname = quote_string(dp->include_list->last->name);
1128 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1129 strappend(include_list, exc);
1132 "WARNING: %s:%s does not support multiple include\n",
1133 dp->host->hostname, qdpname);
1138 fprintf(fdout, "WARNING: %s:%s does not support include list\n",
1139 dp->host->hostname, qdpname);
1143 if(dp->exclude_optional) {
1144 if(am_has_feature(their_features, fe_options_optional_exclude)) {
1145 excl_opt = "exclude-optional;";
1149 "WARNING: %s:%s does not support optional exclude\n",
1150 dp->host->hostname, qdpname);
1153 if(dp->include_optional) {
1154 if(am_has_feature(their_features, fe_options_optional_include)) {
1155 incl_opt = "include-optional;";
1159 "WARNING: %s:%s does not support optional include\n",
1160 dp->host->hostname, qdpname);
1164 result = vstralloc(";",
1181 amfree(exclude_list);
1182 amfree(exclude_file);
1183 amfree(include_file);
1184 amfree(include_list);
1186 amfree(decrypt_opt);
1187 amfree(encrypt_opt);
1189 /* result contains at least 'auth=...' */
1205 char *prevhost = NULL;
1206 char *errstr = NULL;
1216 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1222 for(i=0;i<sargc;i++) {
1224 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1225 if(match_host(sargv[i], dp->host->hostname))
1229 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1230 if(prevhost != NULL &&
1231 match_host(prevhost, dp->host->hostname) &&
1232 (match_disk(sargv[i], dp->name) ||
1233 (dp->device && match_disk(sargv[i], dp->device)))) {
1235 error("Argument %s match a host and a disk",sargv[i]);
1239 if(dp->todo == -1) {
1248 if(match_a_host == 1) {
1249 if(prev_match == 1) { /* all disk of the previous host */
1250 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1251 if(match_host(prevhost,dp->host->hostname))
1256 prevhost = sargv[i];
1260 vstrextend(&errstr, "Argument '", sargv[i], "' match neither a host nor a disk.\n", NULL);
1265 if(prev_match == 1) { /* all disk of the previous host */
1266 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1267 if(match_host(prevhost,dp->host->hostname))
1273 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1284 static void dump_disk(const disk_t *);
1285 static void dump_disklist(const disklist_t *);
1286 int main(int, char *[]);
1292 printf(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n",
1293 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
1294 dp->name == NULL? "(null)": dp->name,
1300 const disklist_t * lst)
1302 const disk_t *dp, *prev;
1303 const am_host_t *hp;
1305 if(hostlist == NULL) {
1306 printf("DISKLIST not read in\n");
1310 printf("DISKLIST BY HOSTNAME:\n");
1312 for(hp = hostlist; hp != NULL; hp = hp->next) {
1313 printf("HOST %s INTERFACE %s\n",
1315 (hp->netif == NULL||hp->netif->name == NULL) ? "(null)"
1317 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
1323 printf("DISKLIST IN FILE ORDER:\n");
1326 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
1328 /* check pointers */
1329 if(dp->prev != prev) printf("*** prev pointer mismatch!\n");
1330 if(dp->next == NULL && lst->tail != dp) printf("tail mismatch!\n");
1340 char *conf_diskfile;
1343 unsigned long malloc_hist_1, malloc_size_1;
1344 unsigned long malloc_hist_2, malloc_size_2;
1348 set_pname("diskfile");
1350 dbopen(DBG_SUBDIR_SERVER);
1352 /* Don't die when child closes pipe */
1353 signal(SIGPIPE, SIG_IGN);
1355 malloc_size_1 = malloc_inuse(&malloc_hist_1);
1358 config_name = argv[1];
1359 if (strchr(config_name, '/') != NULL) {
1360 config_dir = stralloc2(argv[1], "/");
1361 config_name = strrchr(config_name, '/') + 1;
1363 config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
1366 config_dir = stralloc("");
1368 conffile = stralloc2(config_dir, CONFFILE_NAME);
1369 if((result = read_conffile(conffile)) == 0) {
1370 conf_diskfile = getconf_str(CNF_DISKFILE);
1371 if (*conf_diskfile == '/') {
1372 conf_diskfile = stralloc(conf_diskfile);
1374 conf_diskfile = stralloc2(config_dir, conf_diskfile);
1376 result = read_diskfile(conf_diskfile, &lst);
1378 dump_disklist(&lst);
1380 amfree(conf_diskfile);
1385 malloc_size_2 = malloc_inuse(&malloc_hist_2);
1387 if(malloc_size_1 != malloc_size_2) {
1388 malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);