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.73 2006/03/10 13:51:06 martinea Exp $
38 static am_host_t *hostlist;
41 static char *upcase P((char *st));
42 static int parse_diskline P((disklist_t *, const char *, FILE *, int *, char **));
43 static void parserror P((const char *, int, const char *, ...))
44 __attribute__ ((format (printf, 3, 4)));
48 read_diskfile(filename, lst)
59 lst->head = lst->tail = NULL;
62 if ((diskf = fopen(filename, "r")) == NULL) {
63 error("could not open disklist file \"%s\": %s",
64 filename, strerror(errno));
67 while ((line = agets(diskf)) != NULL) {
69 if (parse_diskline(lst, filename, diskf, &line_num, &line) < 0) {
87 for (p = hostlist; p != NULL; p = p->next) {
88 if(strcasecmp(p->hostname, hostname) == 0) return p;
94 lookup_disk(hostname, diskname)
95 const char *hostname, *diskname;
100 host = lookup_host(hostname);
104 for (disk = host->disks; disk != NULL; disk = disk->hostnext) {
105 if (strcmp(disk->name, diskname) == 0)
111 void enqueue_disk(list, disk) /* put disk on end of queue */
115 if(list->tail == NULL) list->head = disk;
116 else list->tail->next = disk;
117 disk->prev = list->tail;
123 void headqueue_disk(list, disk) /* put disk on head of queue */
127 if(list->head == NULL) list->tail = disk;
128 else list->head->prev = disk;
129 disk->next = list->head;
135 void insert_disk(list, disk, cmp) /* insert in sorted order */
138 int (*cmp) P((disk_t *a, disk_t *b));
146 if(cmp(disk, ptr) < 0) break;
153 if(prev == NULL) list->head = disk;
154 else prev->next = disk;
155 if(ptr == NULL) list->tail = disk;
156 else ptr->prev = disk;
159 disk_t *add_disk(list, hostname, diskname)
167 disk = alloc(sizeof(disk_t));
169 disk->tape_splitsize = 0;
170 disk->split_diskbuffer = NULL;
171 disk->fallback_splitsize = 0;
172 disk->name = stralloc(diskname);
173 disk->device = stralloc(diskname);
176 disk->compress = COMP_NONE;
177 disk->encrypt = ENCRYPT_NONE;
181 host = lookup_host(hostname);
183 host = alloc(sizeof(am_host_t));
184 host->next = hostlist;
187 host->hostname = stralloc(hostname);
189 host->inprogress = 0;
194 host->features = NULL;
196 enqueue_disk(list, disk);
199 disk->hostnext = host->disks;
205 int find_disk(list, disk)
208 /* check if disk is present in list. Return true if so, false otherwise. */
212 for( t = list->head; t && t != disk; t = t->next );
217 void sort_disk(in, out, cmp) /* sort a whole queue */
220 int (*cmp) P((disk_t *a, disk_t *b));
225 tmp = in; /* just in case in == out */
227 out->head = (disk_t *)0;
228 out->tail = (disk_t *)0;
230 while((disk = dequeue_disk(tmp)))
231 insert_disk(out, disk, cmp);
234 disk_t *dequeue_disk(list) /* remove disk from front of queue */
239 if(list->head == NULL) return NULL;
242 list->head = disk->next;
244 if(list->head == NULL) list->tail = NULL;
245 else list->head->prev = NULL;
247 disk->prev = disk->next = NULL; /* for debugging */
251 void remove_disk(list, disk)
255 if(disk->prev == NULL) list->head = disk->next;
256 else disk->prev->next = disk->next;
258 if(disk->next == NULL) list->tail = disk->prev;
259 else disk->next->prev = disk->prev;
261 disk->prev = disk->next = NULL;
264 void free_disklist(disklist_t* dl) {
265 while (dl->head != NULL) {
266 free(dequeue_disk(dl));
270 static char *upcase(st)
276 if(islower((int)*s)) *s = toupper((int)*s);
284 parse_diskline(lst, filename, diskf, line_num_p, line_p)
286 const char *filename;
294 interface_t *netif = 0;
295 char *hostname = NULL;
296 char *diskname, *diskdevice;
299 char *line = *line_p;
300 int line_num = *line_num_p;
302 assert(filename != NULL);
303 assert(line_num > 0);
304 assert(line != NULL);
308 skip_whitespace(s, ch);
309 if(ch == '\0' || ch == '#')
313 skip_non_whitespace(s, ch);
315 host = lookup_host(fp);
317 hostname = stralloc(fp);
318 malloc_mark(hostname);
320 hostname = host->hostname;
323 skip_whitespace(s, ch);
324 if(ch == '\0' || ch == '#') {
325 parserror(filename, line_num, "disk device name expected");
326 if (host == NULL) amfree(hostname);
330 skip_non_whitespace(s, ch);
332 diskname = stralloc(fp);
334 skip_whitespace(s, ch);
335 if(ch == '\0' || ch == '#') {
336 parserror(filename, line_num, "disk dumptype expected");
337 if(host == NULL) amfree(hostname);
342 skip_non_whitespace(s, ch);
346 diskdevice = stralloc(fp);
347 if(fp[0] != '{' && (dtype = lookup_dumptype(upcase(fp))) == NULL) {
348 skip_whitespace(s, ch);
349 if(ch == '\0' || ch == '#') {
350 parserror(filename, line_num, "disk dumptype expected");
351 if(host == NULL) amfree(hostname);
357 skip_non_whitespace(s, ch);
364 /* check for duplicate disk */
365 if(host && (disk = lookup_disk(hostname, diskname)) != NULL) {
366 parserror(filename, line_num,
367 "duplicate disk record, previous on line %d", disk->line);
370 disk = alloc(sizeof(disk_t));
372 disk->line = line_num;
373 disk->name = diskname;
374 disk->device = diskdevice;
375 malloc_mark(disk->name);
378 disk->inprogress = 0;
384 skip_whitespace(s, ch);
385 if (ch != '\0' && ch != '#') {
386 parserror(filename, line_num,
387 "expected line break after `{\', ignoring rest of line");
390 if (strchr(s-1, '}') &&
391 (strchr(s-1, '#') == NULL ||
392 strchr(s-1, '}') < strchr(s-1, '#'))) {
393 if(host == NULL) amfree(hostname);
395 amfree(disk->device);
406 dtype = read_dumptype(vstralloc("custom(", hostname,
407 ":", disk->name, ")", 0),
408 diskf, (char*)filename, line_num_p);
410 *line_p = line = agets(diskf);
411 line_num = *line_num_p; /* no incr, read_dumptype did it already */
413 if (dtype == NULL || dup) {
414 if(host == NULL) amfree(hostname);
416 amfree(disk->device);
427 *line_p = line = stralloc("");
430 } else if((dtype = lookup_dumptype(upcase(fp))) == NULL) {
431 parserror(filename, line_num, "undefined dumptype `%s'", fp);
432 if(host == NULL) amfree(hostname);
434 amfree(disk->device);
445 if (host == NULL) amfree(hostname);
451 disk->dtype_name = dtype->name;
452 disk->program = dtype->program;
453 disk->exclude_file = duplicate_sl(dtype->exclude_file);
454 disk->exclude_list = duplicate_sl(dtype->exclude_list);
455 disk->include_file = duplicate_sl(dtype->include_file);
456 disk->include_list = duplicate_sl(dtype->include_list);
457 disk->exclude_optional = dtype->exclude_optional;
458 disk->include_optional = dtype->include_optional;
459 disk->priority = dtype->priority;
460 disk->dumpcycle = dtype->dumpcycle;
461 disk->frequency = dtype->frequency;
462 disk->security_driver = dtype->security_driver;
463 disk->maxdumps = dtype->maxdumps;
464 disk->tape_splitsize = dtype->tape_splitsize;
465 disk->split_diskbuffer = dtype->split_diskbuffer;
466 disk->fallback_splitsize = dtype->fallback_splitsize;
467 disk->maxpromoteday = dtype->maxpromoteday;
468 disk->bumppercent = dtype->bumppercent;
469 disk->bumpsize = dtype->bumpsize;
470 disk->bumpdays = dtype->bumpdays;
471 disk->bumpmult = dtype->bumpmult;
472 disk->start_t = dtype->start_t;
473 disk->strategy = dtype->strategy;
474 disk->estimate = dtype->estimate;
475 disk->compress = dtype->compress;
476 disk->srvcompprog = dtype->srvcompprog;
477 disk->clntcompprog = dtype->clntcompprog;
478 disk->encrypt = dtype->encrypt;
479 disk->srv_decrypt_opt = dtype->srv_decrypt_opt;
480 disk->clnt_decrypt_opt = dtype->clnt_decrypt_opt;
481 disk->srv_encrypt = dtype->srv_encrypt;
482 disk->clnt_encrypt = dtype->clnt_encrypt;
483 disk->comprate[0] = dtype->comprate[0];
484 disk->comprate[1] = dtype->comprate[1];
485 disk->record = dtype->record;
486 disk->skip_incr = dtype->skip_incr;
487 disk->skip_full = dtype->skip_full;
488 disk->no_hold = dtype->no_hold;
489 disk->kencrypt = dtype->kencrypt;
490 disk->index = dtype->index;
493 skip_whitespace(s, ch);
495 if(ch && ch != '#') { /* get optional spindle number */
498 skip_non_whitespace(s, ch);
501 if (*fp1 == '-') fp1++;
502 for(;*fp1!='\0';fp1++) {
503 if(!isdigit((int)*fp1)) {
508 parserror(filename, line_num, "non-integer spindle `%s'", fp);
509 if(host == NULL) amfree(hostname);
514 disk->spindle = atoi(fp);
518 skip_whitespace(s, ch);
520 if(ch && ch != '#') { /* get optional network interface */
521 skip_non_whitespace(s, ch);
523 if((netif = lookup_interface(upcase(fp))) == NULL) {
524 parserror(filename, line_num,
525 "undefined network interface `%s'", fp);
526 if(host == NULL) amfree(hostname);
532 netif = lookup_interface("");
535 skip_whitespace(s, ch);
536 if(ch && ch != '#') { /* now we have garbage, ignore it */
537 parserror(filename, line_num, "end of line expected");
540 if(dtype->ignore || dtype->strategy == DS_SKIP) {
541 if(host == NULL) amfree(hostname);
547 /* success, add disk to lists */
549 if(host == NULL) { /* new host */
550 host = alloc(sizeof(am_host_t));
552 host->next = hostlist;
555 host->hostname = hostname;
558 host->inprogress = 0;
559 host->maxdumps = 1; /* will be overwritten */
563 host->features = NULL;
568 enqueue_disk(lst, disk);
571 disk->hostnext = host->disks;
573 host->maxdumps = disk->maxdumps;
579 printf_arglist_function2(static void parserror, const char *, filename,
580 int, line_num, const char *, format)
584 /* print error message */
586 fprintf(stderr, "\"%s\", line %d: ", filename, line_num);
587 arglist_start(argp, format);
588 vfprintf(stderr, format, argp);
594 void dump_queue(st, q, npr, f)
597 int npr; /* we print first npr disks on queue, plus last two */
604 fprintf(f, "%s QUEUE: empty\n", st);
607 fprintf(f, "%s QUEUE:\n", st);
608 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
609 if(pos < npr) fprintf(f, "%3d: %-10s %-4s\n",
610 pos, d->host->hostname, d->name);
613 if(pos > npr+2) fprintf(f, " ...\n");
616 fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
619 fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
623 char *optionstr(dp, their_features, fdout)
625 am_feature_t * their_features;
628 char *auth_opt = NULL;
629 char *kencrypt_opt = "";
630 char *compress_opt = "";
631 char *encrypt_opt = "";
632 char *decrypt_opt ="";
633 char *record_opt = "";
634 char *index_opt = "";
635 char *exclude_file = NULL;
636 char *exclude_list = NULL;
637 char *include_file = NULL;
638 char *include_list = NULL;
648 && am_has_feature(dp->host->features, fe_options_auth)) {
649 auth_opt = vstralloc("auth=", dp->security_driver, ";", NULL);
650 } else if(strcasecmp(dp->security_driver, "bsd") == 0) {
651 if(am_has_feature(dp->host->features, fe_options_bsd_auth))
652 auth_opt = stralloc("bsd-auth;");
655 "WARNING: %s:%s does not support auth or bsd-auth\n",
656 dp->host->hostname, dp->name);
658 } else if(strcasecmp(dp->security_driver, "krb4") == 0) {
659 if(am_has_feature(dp->host->features, fe_options_krb4_auth))
660 auth_opt = stralloc("krb4-auth;");
663 "WARNING: %s:%s does not support auth or krb4-auth\n",
664 dp->host->hostname, dp->name);
667 if(am_has_feature(dp->host->features, fe_options_kencrypt)) {
668 kencrypt_opt = "kencrypt;";
672 "WARNING: %s:%s does not support kencrypt\n",
673 dp->host->hostname, dp->name);
678 switch(dp->compress) {
680 if(am_has_feature(their_features, fe_options_compress_fast)) {
681 compress_opt = "compress-fast;";
685 "WARNING: %s:%s does not support fast compression\n",
686 dp->host->hostname, dp->name);
690 if(am_has_feature(their_features, fe_options_compress_best)) {
691 compress_opt = "compress-best;";
695 "WARNING: %s:%s does not support best compression\n",
696 dp->host->hostname, dp->name);
700 if(am_has_feature(their_features, fe_options_compress_cust)) {
701 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
702 if (BSTRNCMP(compress_opt, "comp-cust=;") == 0){
705 "WARNING: %s:%s client custom compression with no compression program specified\n",
706 dp->host->hostname, dp->name);
712 "WARNING: %s:%s does not support client custom compression\n",
713 dp->host->hostname, dp->name);
717 if(am_has_feature(their_features, fe_options_srvcomp_fast)) {
718 compress_opt = "srvcomp-fast;";
722 if(am_has_feature(their_features, fe_options_srvcomp_best)) {
723 compress_opt = "srvcomp-best;";
727 if(am_has_feature(their_features, fe_options_srvcomp_cust)) {
728 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
729 if (BSTRNCMP(compress_opt, "srvcomp-cust=;") == 0){
732 "WARNING: %s:%s server custom compression with no compression program specified\n",
733 dp->host->hostname, dp->name);
739 "WARNING: %s:%s does not support server custom compression\n",
740 dp->host->hostname, dp->name);
745 switch(dp->encrypt) {
747 if(am_has_feature(their_features, fe_options_encrypt_cust)) {
748 encrypt_opt = vstralloc("encrypt-cust=", dp->clnt_encrypt, ";", NULL);
749 if (BSTRNCMP(encrypt_opt, "encrypt-cust=;") == 0) {
752 "WARNING: %s:%s encrypt client with no encryption program specified\n",
753 dp->host->hostname, dp->name);
756 if(dp->clnt_decrypt_opt) {
757 if(am_has_feature(their_features, fe_options_client_decrypt_option)) {
758 decrypt_opt = vstralloc("client-decrypt-option=", dp->clnt_decrypt_opt, ";", NULL);
762 "WARNING: %s:%s does not support client decrypt option\n",
763 dp->host->hostname, dp->name);
769 "WARNING: %s:%s does not support client data encryption\n",
770 dp->host->hostname, dp->name);
773 case ENCRYPT_SERV_CUST:
774 if(am_has_feature(their_features, fe_options_encrypt_serv_cust)) {
775 encrypt_opt = vstralloc("encrypt-serv-cust=", dp->srv_encrypt, ";", NULL);
776 if (BSTRNCMP(encrypt_opt, "encrypt-serv-cust=;") == 0){
779 "WARNING: %s:%s encrypt server with no encryption program specified\n",
780 dp->host->hostname, dp->name);
783 if(dp->srv_decrypt_opt) {
784 if(am_has_feature(their_features, fe_options_server_decrypt_option)) {
785 decrypt_opt = vstralloc("server-decrypt-option=", dp->srv_decrypt_opt, ";", NULL);
789 "WARNING: %s:%s does not support server decrypt option\n",
790 dp->host->hostname, dp->name);
796 "WARNING: %s:%s does not support server data encryption\n",
797 dp->host->hostname, dp->name);
803 if(am_has_feature(their_features, fe_options_no_record)) {
804 record_opt = "no-record;";
807 fprintf(fdout, "WARNING: %s:%s does not support no record\n",
808 dp->host->hostname, dp->name);
813 if(am_has_feature(their_features, fe_options_index)) {
814 index_opt = "index;";
817 fprintf(fdout, "WARNING: %s:%s does not support index\n",
818 dp->host->hostname, dp->name);
822 if(dp->kencrypt) kencrypt_opt = "kencrypt;";
825 exclude_file = stralloc("");
827 if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
828 nb_exclude_file = dp->exclude_file->nb_element;
829 if(am_has_feature(their_features, fe_options_exclude_file)) {
830 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
831 dp->exclude_file->nb_element == 1) {
832 for(excl = dp->exclude_file->first; excl != NULL;
834 exc = newvstralloc( exc, "exclude-file=", excl->name,
836 strappend(exclude_file, exc);
839 exc = newvstralloc(exc, "exclude-file=",
840 dp->exclude_file->last->name, ";", NULL);
841 strappend(exclude_file, exc);
844 "WARNING: %s:%s does not support multiple exclude\n",
845 dp->host->hostname, dp->name);
849 fprintf(fdout, "WARNING: %s:%s does not support exclude file\n",
850 dp->host->hostname, dp->name);
853 exclude_list = stralloc("");
854 if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
855 if(am_has_feature(their_features, fe_options_exclude_list)) {
856 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
857 (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {
858 for(excl = dp->exclude_list->first; excl != NULL;
860 exc = newvstralloc( exc, "exclude-list=", excl->name,
862 strappend(exclude_list, exc);
865 exc = newvstralloc(exc, "exclude-list=",
866 dp->exclude_list->last->name, ";", NULL);
867 strappend(exclude_list, exc);
870 "WARNING: %s:%s does not support multiple exclude\n",
871 dp->host->hostname, dp->name);
875 fprintf(fdout, "WARNING: %s:%s does not support exclude list\n",
876 dp->host->hostname, dp->name);
880 include_file = stralloc("");
882 if(dp->include_file != NULL && dp->include_file->nb_element > 0) {
883 nb_include_file = dp->include_file->nb_element;
884 if(am_has_feature(their_features, fe_options_include_file)) {
885 if(am_has_feature(their_features, fe_options_multiple_include) ||
886 dp->include_file->nb_element == 1) {
887 for(excl = dp->include_file->first; excl != NULL;
889 exc = newvstralloc( exc, "include-file=", excl->name,
891 strappend(include_file, exc);
894 exc = newvstralloc(exc, "include-file=",
895 dp->include_file->last->name, ";", NULL);
896 strappend(include_file, exc);
899 "WARNING: %s:%s does not support multiple include\n",
900 dp->host->hostname, dp->name);
904 fprintf(fdout, "WARNING: %s:%s does not support include file\n",
905 dp->host->hostname, dp->name);
908 include_list = stralloc("");
909 if(dp->include_list != NULL && dp->include_list->nb_element > 0) {
910 if(am_has_feature(their_features, fe_options_include_list)) {
911 if(am_has_feature(their_features, fe_options_multiple_include) ||
912 (dp->include_list->nb_element == 1 && nb_include_file == 0)) {
913 for(excl = dp->include_list->first; excl != NULL;
915 exc = newvstralloc( exc, "include-list=", excl->name,
917 strappend(include_list, exc);
920 exc = newvstralloc(exc, "include-list=",
921 dp->include_list->last->name, ";", NULL);
922 strappend(include_list, exc);
925 "WARNING: %s:%s does not support multiple include\n",
926 dp->host->hostname, dp->name);
930 fprintf(fdout, "WARNING: %s:%s does not support include list\n",
931 dp->host->hostname, dp->name);
935 if(dp->exclude_optional) {
936 if(am_has_feature(their_features, fe_options_optional_exclude)) {
937 excl_opt = "exclude-optional;";
941 "WARNING: %s:%s does not support optional exclude\n",
942 dp->host->hostname, dp->name);
945 if(dp->include_optional) {
946 if(am_has_feature(their_features, fe_options_optional_include)) {
947 incl_opt = "include-optional;";
951 "WARNING: %s:%s does not support optional include\n",
952 dp->host->hostname, dp->name);
956 result = vstralloc(";",
972 amfree(exclude_list);
973 amfree(exclude_file);
974 amfree(include_file);
975 amfree(include_list);
982 void match_disklist(disklist_t *origqp, int sargc, char **sargv)
984 char *prevhost = NULL;
994 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1000 for(i=0;i<sargc;i++) {
1002 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1003 if(match_host(sargv[i], dp->host->hostname))
1007 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1008 if(prevhost != NULL &&
1009 match_host(prevhost, dp->host->hostname) &&
1010 (match_disk(sargv[i], dp->name) ||
1011 (dp->device && match_disk(sargv[i], dp->device)))) {
1013 error("Argument %s match a host and a disk",sargv[i]);
1016 if(dp->todo == -1) {
1025 if(match_a_host == 1) {
1026 if(prev_match == 1) { /* all disk of the previous host */
1027 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1028 if(match_host(prevhost,dp->host->hostname))
1033 prevhost = sargv[i];
1038 /*error("%s match nothing",sargv[i]);*/
1043 if(prev_match == 1) { /* all disk of the previous host */
1044 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1045 if(match_host(prevhost,dp->host->hostname))
1051 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1060 static void dump_disk P((const disk_t *));
1061 static void dump_disklist P((const disklist_t *));
1062 int main P((int, char *[]));
1068 printf(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n",
1069 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
1070 dp->name == NULL? "(null)": dp->name,
1076 const disklist_t *lst;
1078 const disk_t *dp, *prev;
1079 const am_host_t *hp;
1081 if(hostlist == NULL) {
1082 printf("DISKLIST not read in\n");
1086 printf("DISKLIST BY HOSTNAME:\n");
1088 for(hp = hostlist; hp != NULL; hp = hp->next) {
1089 printf("HOST %s INTERFACE %s\n",
1091 (hp->netif == NULL||hp->netif->name == NULL) ? "(null)"
1093 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
1099 printf("DISKLIST IN FILE ORDER:\n");
1102 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
1104 /* check pointers */
1105 if(dp->prev != prev) printf("*** prev pointer mismatch!\n");
1106 if(dp->next == NULL && lst->tail != dp) printf("tail mismatch!\n");
1116 char *conf_diskfile;
1119 unsigned long malloc_hist_1, malloc_size_1;
1120 unsigned long malloc_hist_2, malloc_size_2;
1124 set_pname("diskfile");
1126 /* Don't die when child closes pipe */
1127 signal(SIGPIPE, SIG_IGN);
1129 malloc_size_1 = malloc_inuse(&malloc_hist_1);
1132 config_name = argv[1];
1133 if (strchr(config_name, '/') != NULL) {
1134 config_dir = stralloc2(argv[1], "/");
1135 config_name = strrchr(config_name, '/') + 1;
1137 config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
1140 config_dir = stralloc("");
1142 conffile = stralloc2(config_dir, CONFFILE_NAME);
1143 if((result = read_conffile(conffile)) == 0) {
1144 conf_diskfile = getconf_str(CNF_DISKFILE);
1145 if (*conf_diskfile == '/') {
1146 conf_diskfile = stralloc(conf_diskfile);
1148 conf_diskfile = stralloc2(config_dir, conf_diskfile);
1150 result = read_diskfile(conf_diskfile, &lst);
1152 dump_disklist(&lst);
1154 amfree(conf_diskfile);
1159 malloc_size_2 = malloc_inuse(&malloc_hist_2);
1161 if(malloc_size_1 != malloc_size_2) {
1162 malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);