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 2006/07/26 15:17:37 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;
373 assert(filename != NULL);
374 assert(line_num > 0);
375 assert(line != NULL);
379 skip_whitespace(s, ch);
380 if(ch == '\0' || ch == '#')
384 skip_non_whitespace(s, ch);
386 host = lookup_host(fp);
388 hostname = stralloc(fp);
389 malloc_mark(hostname);
391 hostname = host->hostname;
394 skip_whitespace(s, ch);
395 if(ch == '\0' || ch == '#') {
396 disk_parserror(filename, line_num, "disk device name expected");
402 skip_quoted_string(s, ch);
404 diskname = unquote_string(fp);
406 skip_whitespace(s, ch);
407 if(ch == '\0' || ch == '#') {
408 disk_parserror(filename, line_num, "disk dumptype expected");
414 skip_quoted_string(s, ch);
420 dumptype = unquote_string(fp);
422 if ((dtype = lookup_dumptype(dumptype)) == NULL) {
423 diskdevice = dumptype;
424 skip_whitespace(s, ch);
425 if(ch == '\0' || ch == '#') {
426 disk_parserror(filename, line_num,
427 "disk dumptype '%s' not found", dumptype);
435 skip_quoted_string(s, ch);
437 dumptype = unquote_string(fp);
443 /* check for duplicate disk */
444 if(host && (disk = lookup_disk(hostname, diskname)) != NULL) {
445 disk_parserror(filename, line_num,
446 "duplicate disk record, previous on line %d", disk->line);
449 disk = alloc(SIZEOF(disk_t));
451 disk->line = line_num;
452 disk->name = diskname;
453 disk->device = diskdevice;
454 malloc_mark(disk->name);
457 disk->inprogress = 0;
463 skip_whitespace(s, ch);
464 if (ch != '\0' && ch != '#') {
465 disk_parserror(filename, line_num,
466 "expected line break after `{\', ignoring rest of line");
469 if (strchr(s-1, '}') &&
470 (strchr(s-1, '#') == NULL ||
471 strchr(s-1, '}') < strchr(s-1, '#'))) {
472 disk_parserror(filename, line_num,"'}' on same line than '{'");
475 amfree(disk->device);
486 dtype = read_dumptype(vstralloc("custom(", hostname,
487 ":", disk->name, ")", 0),
488 diskf, (char*)filename, line_num_p);
489 if (dtype == NULL || dup) {
490 disk_parserror(filename, line_num,
491 "read of custom dumptype failed");
494 amfree(disk->device);
504 *line_p = line = agets(diskf);
505 line_num = *line_num_p; /* no incr, read_dumptype did it already */
508 *line_p = line = stralloc("");
512 if((dtype = lookup_dumptype(dumptype)) == NULL) {
513 char *qdt = quote_string(dumptype);
515 disk_parserror(filename, line_num, "undefined dumptype `%s'", qdt);
520 amfree(disk->device);
538 disk->dtype_name = dtype->name;
539 disk->program = dumptype_get_program(dtype);
540 if(dumptype_get_exclude(dtype).type == 0) {
541 disk->exclude_list = duplicate_sl(dumptype_get_exclude(dtype).sl);
542 disk->exclude_file = NULL;
545 disk->exclude_file = duplicate_sl(dumptype_get_exclude(dtype).sl);
546 disk->exclude_list = NULL;
548 disk->exclude_optional = dumptype_get_exclude(dtype).optional;
549 if(dumptype_get_include(dtype).type == 0) {
550 disk->include_list = duplicate_sl(dumptype_get_include(dtype).sl);
551 disk->include_file = NULL;
554 disk->include_file = duplicate_sl(dumptype_get_include(dtype).sl);
555 disk->include_list = NULL;
557 disk->include_optional = dumptype_get_include(dtype).optional;
558 disk->priority = dumptype_get_priority(dtype);
559 disk->dumpcycle = dumptype_get_dumpcycle(dtype);
560 /* disk->frequency = dumptype_get_frequency(dtype);*/
561 disk->security_driver = dumptype_get_security_driver(dtype);
562 disk->maxdumps = dumptype_get_maxdumps(dtype);
563 disk->tape_splitsize = dumptype_get_tape_splitsize(dtype);
564 disk->split_diskbuffer = dumptype_get_split_diskbuffer(dtype);
565 disk->fallback_splitsize = dumptype_get_fallback_splitsize(dtype);
566 disk->maxpromoteday = dumptype_get_maxpromoteday(dtype);
567 disk->bumppercent = dumptype_get_bumppercent(dtype);
568 disk->bumpsize = dumptype_get_bumpsize(dtype);
569 disk->bumpdays = dumptype_get_bumpdays(dtype);
570 disk->bumpmult = dumptype_get_bumpmult(dtype);
571 disk->start_t = dumptype_get_start_t(dtype);
572 disk->strategy = dumptype_get_strategy(dtype);
573 disk->estimate = dumptype_get_estimate(dtype);
574 disk->compress = dumptype_get_compress(dtype);
575 disk->srvcompprog = dumptype_get_srvcompprog(dtype);
576 disk->clntcompprog = dumptype_get_clntcompprog(dtype);
577 disk->encrypt = dumptype_get_encrypt(dtype);
578 disk->srv_decrypt_opt = dumptype_get_srv_decrypt_opt(dtype);
579 disk->clnt_decrypt_opt = dumptype_get_clnt_decrypt_opt(dtype);
580 disk->srv_encrypt = dumptype_get_srv_encrypt(dtype);
581 disk->clnt_encrypt = dumptype_get_clnt_encrypt(dtype);
582 disk->amandad_path = dumptype_get_amandad_path(dtype);
583 disk->client_username = dumptype_get_client_username(dtype);
584 disk->ssh_keys = dumptype_get_ssh_keys(dtype);
585 disk->comprate[0] = dumptype_get_comprate(dtype)[0];
586 disk->comprate[1] = dumptype_get_comprate(dtype)[1];
589 * Boolean parameters with no value (Appears here as value 2) defaults
590 * to TRUE for backward compatibility and for logical consistency.
592 disk->record = dumptype_get_record(dtype) != 0;
593 disk->skip_incr = dumptype_get_skip_incr(dtype) != 0;
594 disk->skip_full = dumptype_get_skip_full(dtype) != 0;
595 disk->to_holdingdisk = dumptype_get_to_holdingdisk(dtype);
596 disk->kencrypt = dumptype_get_kencrypt(dtype) != 0;
597 disk->index = dumptype_get_index(dtype) != 0;
601 skip_whitespace(s, ch);
603 if(ch && ch != '#') { /* get optional spindle number */
607 skip_non_whitespace(s, ch);
610 if (*fp1 == '-') fp1++;
611 for(;*fp1!='\0';fp1++) {
612 if(!isdigit((int)*fp1)) {
617 disk_parserror(filename, line_num, "non-integer spindle `%s'", fp);
623 disk->spindle = atoi(fp);
627 skip_whitespace(s, ch);
629 if(ch && ch != '#') { /* get optional network interface */
630 skip_non_whitespace(s, ch);
632 if((netif = lookup_interface(upcase(fp))) == NULL) {
633 disk_parserror(filename, line_num,
634 "undefined network interface `%s'", fp);
641 netif = lookup_interface("default");
644 skip_whitespace(s, ch);
645 if(ch && ch != '#') { /* now we have garbage, ignore it */
646 disk_parserror(filename, line_num, "end of line expected");
649 if(dumptype_get_ignore(dtype) || dumptype_get_strategy(dtype) == DS_SKIP) {
656 /* success, add disk to lists */
658 if(host == NULL) { /* new host */
659 host = alloc(SIZEOF(am_host_t));
661 host->next = hostlist;
664 host->hostname = hostname;
667 host->inprogress = 0;
668 host->maxdumps = 1; /* will be overwritten */
672 host->features = NULL;
677 enqueue_disk(lst, disk);
680 disk->hostnext = host->disks;
682 host->maxdumps = disk->maxdumps;
688 printf_arglist_function2(void disk_parserror, const char *, filename,
689 int, line_num, const char *, format)
693 /* print error message */
695 fprintf(stderr, "\"%s\", line %d: ", filename, line_num);
696 arglist_start(argp, format);
697 vfprintf(stderr, format, argp);
707 int npr, /* we print first npr disks on queue, plus last two */
715 fprintf(f, "%s QUEUE: empty\n", st);
718 fprintf(f, "%s QUEUE:\n", st);
719 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
720 qname = quote_string(d->name);
721 if(pos < npr) fprintf(f, "%3d: %-10s %-4s\n",
722 pos, d->host->hostname, qname);
726 if(pos > npr+2) fprintf(f, " ...\n");
729 fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
732 fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
739 am_feature_t * their_features,
742 char *auth_opt = NULL;
743 char *kencrypt_opt = "";
744 char *compress_opt = "";
745 char *encrypt_opt = stralloc("");
746 char *decrypt_opt = stralloc("");
747 char *record_opt = "";
748 char *index_opt = "";
749 char *exclude_file = NULL;
750 char *exclude_list = NULL;
751 char *include_file = NULL;
752 char *include_list = NULL;
765 assert(dp->host != NULL);
767 qdpname = quote_string(dp->name);
768 if(am_has_feature(dp->host->features, fe_options_auth)) {
769 auth_opt = vstralloc("auth=", dp->security_driver, ";", NULL);
770 } else if(strcasecmp(dp->security_driver, "bsd") == 0) {
771 if(am_has_feature(dp->host->features, fe_options_bsd_auth))
772 auth_opt = stralloc("bsd-auth;");
775 "WARNING: %s:%s does not support auth or bsd-auth\n",
776 dp->host->hostname, qdpname);
778 } else if(strcasecmp(dp->security_driver, "krb4") == 0) {
779 if(am_has_feature(dp->host->features, fe_options_krb4_auth))
780 auth_opt = stralloc("krb4-auth;");
783 "WARNING: %s:%s does not support auth or krb4-auth\n",
784 dp->host->hostname, qdpname);
787 if(am_has_feature(dp->host->features, fe_options_kencrypt)) {
788 kencrypt_opt = "kencrypt;";
792 "WARNING: %s:%s does not support kencrypt\n",
793 dp->host->hostname, qdpname);
798 switch(dp->compress) {
800 if(am_has_feature(their_features, fe_options_compress_fast)) {
801 compress_opt = "compress-fast;";
805 "WARNING: %s:%s does not support fast compression\n",
806 dp->host->hostname, qdpname);
810 if(am_has_feature(their_features, fe_options_compress_best)) {
811 compress_opt = "compress-best;";
815 "WARNING: %s:%s does not support best compression\n",
816 dp->host->hostname, qdpname);
820 if(am_has_feature(their_features, fe_options_compress_cust)) {
821 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
822 if (BSTRNCMP(compress_opt, "comp-cust=;") == 0){
825 "ERROR: %s:%s client custom compression with no compression program specified\n",
826 dp->host->hostname, qdpname);
833 "WARNING: %s:%s does not support client custom compression\n",
834 dp->host->hostname, qdpname);
838 if(am_has_feature(their_features, fe_options_srvcomp_fast)) {
839 compress_opt = "srvcomp-fast;";
843 if(am_has_feature(their_features, fe_options_srvcomp_best)) {
844 compress_opt = "srvcomp-best;";
848 if(am_has_feature(their_features, fe_options_srvcomp_cust)) {
849 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
850 if (BSTRNCMP(compress_opt, "srvcomp-cust=;") == 0){
853 "ERROR: %s:%s server custom compression with no compression program specified\n",
854 dp->host->hostname, qdpname);
861 "WARNING: %s:%s does not support server custom compression\n",
862 dp->host->hostname, qdpname);
867 switch(dp->encrypt) {
869 if(am_has_feature(their_features, fe_options_encrypt_cust)) {
870 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",
871 dp->clnt_encrypt, ";", NULL);
872 if (BSTRNCMP(encrypt_opt, "encrypt-cust=;") == 0) {
875 "ERROR: %s:%s encrypt client with no encryption program specified\n",
876 dp->host->hostname, qdpname);
880 if ( dp->compress == COMP_SERV_FAST ||
881 dp->compress == COMP_SERV_BEST ||
882 dp->compress == COMP_SERV_CUST ) {
885 "ERROR: %s:Client encryption with server compression is not supported. See amanda.conf(5) for detail.\n", dp->host->hostname);
889 if(dp->clnt_decrypt_opt) {
890 if(am_has_feature(their_features, fe_options_client_decrypt_option)) {
891 decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",
892 dp->clnt_decrypt_opt, ";", NULL);
896 "WARNING: %s:%s does not support client decrypt option\n",
897 dp->host->hostname, qdpname);
903 "WARNING: %s:%s does not support client data encryption\n",
904 dp->host->hostname, qdpname);
907 case ENCRYPT_SERV_CUST:
908 if(am_has_feature(their_features, fe_options_encrypt_serv_cust)) {
909 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",
910 dp->srv_encrypt, ";", NULL);
911 if (BSTRNCMP(encrypt_opt, "encrypt-serv-cust=;") == 0){
914 "ERROR: %s:%s encrypt server with no encryption program specified\n",
915 dp->host->hostname, qdpname);
919 if(dp->srv_decrypt_opt) {
920 if(am_has_feature(their_features, fe_options_server_decrypt_option)) {
921 decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",
922 dp->srv_decrypt_opt, ";", NULL);
926 "WARNING: %s:%s does not support server decrypt option\n",
927 dp->host->hostname, qdpname);
933 "WARNING: %s:%s does not support server data encryption\n",
934 dp->host->hostname, qdpname);
940 if(am_has_feature(their_features, fe_options_no_record)) {
941 record_opt = "no-record;";
944 fprintf(fdout, "WARNING: %s:%s does not support no record\n",
945 dp->host->hostname, qdpname);
950 if(am_has_feature(their_features, fe_options_index)) {
951 index_opt = "index;";
954 fprintf(fdout, "WARNING: %s:%s does not support index\n",
955 dp->host->hostname, qdpname);
959 if(dp->kencrypt) kencrypt_opt = "kencrypt;";
962 exclude_file = stralloc("");
964 if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
965 nb_exclude_file = dp->exclude_file->nb_element;
966 if(am_has_feature(their_features, fe_options_exclude_file)) {
967 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
968 dp->exclude_file->nb_element == 1) {
969 for(excl = dp->exclude_file->first; excl != NULL;
971 qname = quote_string(excl->name);
972 exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);
973 strappend(exclude_file, exc);
977 qname = quote_string(dp->exclude_file->last->name);
978 exc = newvstralloc(exc, "exclude-file=", qname, ";", NULL);
979 strappend(exclude_file, exc);
982 "WARNING: %s:%s does not support multiple exclude\n",
983 dp->host->hostname, qdpname);
988 fprintf(fdout, "WARNING: %s:%s does not support exclude file\n",
989 dp->host->hostname, qdpname);
992 exclude_list = stralloc("");
993 if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
994 if(am_has_feature(their_features, fe_options_exclude_list)) {
995 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
996 (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {
997 for(excl = dp->exclude_list->first; excl != NULL;
999 qname = quote_string(excl->name);
1000 exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);
1001 strappend(exclude_list, exc);
1005 qname = quote_string(dp->exclude_list->last->name);
1006 exc = newvstralloc(exc, "exclude-list=", qname, ";", NULL);
1007 strappend(exclude_list, exc);
1010 "WARNING: %s:%s does not support multiple exclude\n",
1011 dp->host->hostname, qdpname);
1016 fprintf(fdout, "WARNING: %s:%s does not support exclude list\n",
1017 dp->host->hostname, qdpname);
1021 include_file = stralloc("");
1022 nb_include_file = 0;
1023 if(dp->include_file != NULL && dp->include_file->nb_element > 0) {
1024 nb_include_file = dp->include_file->nb_element;
1025 if(am_has_feature(their_features, fe_options_include_file)) {
1026 if(am_has_feature(their_features, fe_options_multiple_include) ||
1027 dp->include_file->nb_element == 1) {
1028 for(excl = dp->include_file->first; excl != NULL;
1029 excl = excl->next) {
1030 qname = quote_string(excl->name);
1031 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1032 strappend(include_file, exc);
1036 qname = quote_string(dp->include_file->last->name);
1037 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1038 strappend(include_file, exc);
1041 "WARNING: %s:%s does not support multiple include\n",
1042 dp->host->hostname, qdpname);
1047 fprintf(fdout, "WARNING: %s:%s does not support include file\n",
1048 dp->host->hostname, qdpname);
1051 include_list = stralloc("");
1052 if(dp->include_list != NULL && dp->include_list->nb_element > 0) {
1053 if(am_has_feature(their_features, fe_options_include_list)) {
1054 if(am_has_feature(their_features, fe_options_multiple_include) ||
1055 (dp->include_list->nb_element == 1 && nb_include_file == 0)) {
1056 for(excl = dp->include_list->first; excl != NULL;
1057 excl = excl->next) {
1058 qname = quote_string(excl->name);
1059 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1060 strappend(include_list, exc);
1064 qname = quote_string(dp->include_list->last->name);
1065 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1066 strappend(include_list, exc);
1069 "WARNING: %s:%s does not support multiple include\n",
1070 dp->host->hostname, qdpname);
1075 fprintf(fdout, "WARNING: %s:%s does not support include list\n",
1076 dp->host->hostname, qdpname);
1080 if(dp->exclude_optional) {
1081 if(am_has_feature(their_features, fe_options_optional_exclude)) {
1082 excl_opt = "exclude-optional;";
1086 "WARNING: %s:%s does not support optional exclude\n",
1087 dp->host->hostname, qdpname);
1090 if(dp->include_optional) {
1091 if(am_has_feature(their_features, fe_options_optional_include)) {
1092 incl_opt = "include-optional;";
1096 "WARNING: %s:%s does not support optional include\n",
1097 dp->host->hostname, qdpname);
1101 result = vstralloc(";",
1118 amfree(exclude_list);
1119 amfree(exclude_file);
1120 amfree(include_file);
1121 amfree(include_list);
1123 amfree(decrypt_opt);
1124 amfree(encrypt_opt);
1126 /* result contains at least 'auth=...' */
1142 char *prevhost = NULL;
1143 char *errstr = NULL;
1153 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1159 for(i=0;i<sargc;i++) {
1161 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1162 if(match_host(sargv[i], dp->host->hostname))
1166 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1167 if(prevhost != NULL &&
1168 match_host(prevhost, dp->host->hostname) &&
1169 (match_disk(sargv[i], dp->name) ||
1170 (dp->device && match_disk(sargv[i], dp->device)))) {
1172 error("Argument %s match a host and a disk",sargv[i]);
1176 if(dp->todo == -1) {
1185 if(match_a_host == 1) {
1186 if(prev_match == 1) { /* all disk of the previous host */
1187 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1188 if(match_host(prevhost,dp->host->hostname))
1193 prevhost = sargv[i];
1197 vstrextend(&errstr, "Argument '", sargv[i], "' match neither a host nor a disk.\n", NULL);
1202 if(prev_match == 1) { /* all disk of the previous host */
1203 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1204 if(match_host(prevhost,dp->host->hostname))
1210 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1221 static void dump_disk(const disk_t *);
1222 static void dump_disklist(const disklist_t *);
1223 int main(int, char *[]);
1229 printf(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n",
1230 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
1231 dp->name == NULL? "(null)": dp->name,
1237 const disklist_t * lst)
1239 const disk_t *dp, *prev;
1240 const am_host_t *hp;
1242 if(hostlist == NULL) {
1243 printf("DISKLIST not read in\n");
1247 printf("DISKLIST BY HOSTNAME:\n");
1249 for(hp = hostlist; hp != NULL; hp = hp->next) {
1250 printf("HOST %s INTERFACE %s\n",
1252 (hp->netif == NULL||hp->netif->name == NULL) ? "(null)"
1254 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
1260 printf("DISKLIST IN FILE ORDER:\n");
1263 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
1265 /* check pointers */
1266 if(dp->prev != prev) printf("*** prev pointer mismatch!\n");
1267 if(dp->next == NULL && lst->tail != dp) printf("tail mismatch!\n");
1277 char *conf_diskfile;
1280 unsigned long malloc_hist_1, malloc_size_1;
1281 unsigned long malloc_hist_2, malloc_size_2;
1285 set_pname("diskfile");
1287 dbopen(DBG_SUBDIR_SERVER);
1289 /* Don't die when child closes pipe */
1290 signal(SIGPIPE, SIG_IGN);
1292 malloc_size_1 = malloc_inuse(&malloc_hist_1);
1295 config_name = argv[1];
1296 if (strchr(config_name, '/') != NULL) {
1297 config_dir = stralloc2(argv[1], "/");
1298 config_name = strrchr(config_name, '/') + 1;
1300 config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
1303 config_dir = stralloc("");
1305 conffile = stralloc2(config_dir, CONFFILE_NAME);
1306 if((result = read_conffile(conffile)) == 0) {
1307 conf_diskfile = getconf_str(CNF_DISKFILE);
1308 if (*conf_diskfile == '/') {
1309 conf_diskfile = stralloc(conf_diskfile);
1311 conf_diskfile = stralloc2(config_dir, conf_diskfile);
1313 result = read_diskfile(conf_diskfile, &lst);
1315 dump_disklist(&lst);
1317 amfree(conf_diskfile);
1322 malloc_size_2 = malloc_inuse(&malloc_hist_2);
1324 if(malloc_size_1 != malloc_size_2) {
1325 malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);