source: MondoRescue/branches/2.2.10/mondo/src/common/libmondo-files.c@ 2272

Last change on this file since 2272 was 2272, checked in by Bruno Cornec, 15 years ago

r3224@localhost: bruno | 2009-07-11 15:05:24 +0200
Replace sprintf by mr_asprintf in libmondo-files.c

  • Property svn:keywords set to Id
File size: 37.6 KB
Line 
1/* file manipulation
2 $Id: libmondo-files.c 2272 2009-07-12 00:05:33Z bruno $
3*/
4
5/**
6 * @file
7 * Functions to manipulate files.
8 */
9
10
11#include "my-stuff.h"
12#include "mr_mem.h"
13#include "mondostructures.h"
14#include "libmondo-files.h"
15
16#include "lib-common-externs.h"
17
18#include "libmondo-tools-EXT.h"
19#include "libmondo-gui-EXT.h"
20#include "libmondo-devices-EXT.h"
21#include "libmondo-fork-EXT.h"
22#include "libmondo-string-EXT.h"
23
24/*@unused@*/
25//static char cvsid[] = "$Id: libmondo-files.c 2272 2009-07-12 00:05:33Z bruno $";
26
27extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];
28
29extern int g_currentY;
30extern char *g_mondo_home;
31
32/* Reference to global bkpinfo */
33extern struct s_bkpinfo *bkpinfo;
34
35/**
36 * @addtogroup fileGroup
37 * @{
38 */
39/**
40 * Get an md5 checksum of the specified file.
41 * @param filename The file to checksum.
42 * @return The 32-character ASCII representation of the 128-bit checksum.
43 * @note The returned string points to static storage that will be overwritten with each call.
44 */
45char *calc_checksum_of_file(char *filename)
46{
47 /*@ buffers ***************************************************** */
48 static char output[MAX_STR_LEN];
49 char *command = NULL;
50 char *tmp = NULL;
51
52 /*@ pointers **************************************************** */
53 char *p;
54 FILE *fin;
55
56 /*@ initialize pointers ***************************************** */
57
58 p = output;
59
60 /*@************************************************************** */
61
62 assert_string_is_neither_NULL_nor_zerolength(filename);
63 if (does_file_exist(filename)) {
64 mr_asprintf(&command, "md5sum \"%s\"", filename);
65 fin = popen(command, "r");
66 if (fin) {
67 (void) fgets(output, MAX_STR_LEN, fin);
68 p = strchr(output, ' ');
69 paranoid_pclose(fin);
70 }
71 mr_free(command);
72 } else {
73 mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum",
74 filename);
75 log_it(tmp);
76 mr_free(tmp);
77 }
78 if (p) {
79 *p = '\0';
80 }
81 return (output);
82}
83
84
85/**
86 * Get a not-quite-unique representation of some of the file's @c stat properties.
87 * The returned string has the form <tt>size-mtime-ctime</tt>.
88 * @param curr_fname The file to generate the "checksum" for.
89 * @return The "checksum".
90 * @note The returned string points to static storage that will be overwritten with each call.
91 */
92char *calc_file_ugly_minichecksum(char *curr_fname)
93{
94
95 /*@ buffers ***************************************************** */
96 static char curr_cksum[1000];
97
98 /*@ pointers **************************************************** */
99
100 /*@ structures ************************************************** */
101 struct stat buf;
102
103 /*@ initialize data *************************************************** */
104 curr_cksum[0] = '\0';
105
106 /*@************************************************************** */
107
108 assert_string_is_neither_NULL_nor_zerolength(curr_fname);
109 if (lstat(curr_fname, &buf)) {
110 return (curr_cksum); // empty
111 }
112
113 sprintf(curr_cksum, "%ld-%ld-%ld", (long) (buf.st_size),
114 (long) (buf.st_mtime), (long) (buf.st_ctime));
115 return (curr_cksum);
116}
117
118
119
120/**
121 * Get the number of lines in @p filename.
122 * @param filename The file to count lines in.
123 * @return The number of lines in @p filename.
124 * @bug This function uses the shell and "wc -l"; it should probably be rewritten in C.
125 */
126long count_lines_in_file(char *filename)
127{
128
129 /*@ buffers ***************************************************** */
130 char *command = NULL;
131 char incoming[MAX_STR_LEN];
132 char *tmp = NULL;
133
134 /*@ long ******************************************************** */
135 long noof_lines = -1L;
136
137 /*@ pointers **************************************************** */
138 FILE *fin;
139
140 /*@ initialize [0] to null ******************************************** */
141 incoming[0] = '\0';
142
143 assert_string_is_neither_NULL_nor_zerolength(filename);
144 if (!does_file_exist(filename)) {
145 mr_asprintf(&tmp,
146 "%s does not exist, so I cannot found the number of lines in it",
147 filename);
148 log_it(tmp);
149 mr_free(tmp);
150 return (0);
151 }
152 mr_asprintf(&command, "cat %s | wc -l", filename);
153 if (!does_file_exist(filename)) {
154 mr_free(command);
155 return (-1);
156 }
157 fin = popen(command, "r");
158 mr_free(command);
159 if (fin) {
160 if (feof(fin)) {
161 noof_lines = 0;
162 } else {
163 (void) fgets(incoming, MAX_STR_LEN - 1, fin);
164 while (strlen(incoming) > 0
165 && incoming[strlen(incoming) - 1] < 32) {
166 incoming[strlen(incoming) - 1] = '\0';
167 }
168 noof_lines = atol(incoming);
169 }
170 paranoid_pclose(fin);
171 }
172 return (noof_lines);
173}
174
175
176/**
177 * Check for existence of given @p filename.
178 * @param filename The file to check for.
179 * @return TRUE if it exists, FALSE otherwise.
180 */
181bool does_file_exist(char *filename)
182{
183
184 /*@ structures ************************************************** */
185 struct stat buf;
186
187 /*@************************************************************** */
188
189 assert(filename != NULL);
190 // assert_string_is_neither_NULL_nor_zerolength(filename);
191 if (lstat(filename, &buf)) {
192 log_msg(20, "%s does not exist", filename);
193 return (FALSE);
194 } else {
195 log_msg(20, "%s exists", filename);
196 return (TRUE);
197 }
198}
199
200
201
202
203
204
205/**
206 * Modify @p inout (a file containing a list of files) to only contain files
207 * that exist.
208 * @param inout The filelist to operate on.
209 * @note The original file is renamed beforehand, so it will not be accessible
210 * while the modification is in progress.
211 */
212void exclude_nonexistent_files(char *inout)
213{
214 char *infname = NULL;
215 char *outfname = NULL;
216 char *tmp NULL;
217 char incoming[MAX_STR_LEN];
218
219 /*@ int ********************************************************* */
220 int i;
221
222 /*@ pointers **************************************************** */
223 FILE *fin, *fout;
224
225
226 /*@ end vars *********************************************************** */
227
228 assert_string_is_neither_NULL_nor_zerolength(inout);
229 mr_asprintf(&infname, "%s.in", inout);
230 mr_asprintf(&outfname, "%s", inout);
231 mr_asprintf(&tmp, "cp -f %s %s", inout, infname);
232 run_program_and_log_output(tmp, FALSE);
233 mr_free(tmp);
234
235 if (!(fin = fopen(infname, "r"))) {
236 log_OS_error("Unable to openin infname");
237 mr_free(infname);
238 return;
239 }
240 if (!(fout = fopen(outfname, "w"))) {
241 log_OS_error("Unable to openout outfname");
242 mr_free(outfname);
243 return;
244 }
245 mr_free(outfname);
246
247 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin);
248 fgets(incoming, MAX_STR_LEN, fin)) {
249 i = strlen(incoming) - 1;
250 if (i >= 0 && incoming[i] < 32) {
251 incoming[i] = '\0';
252 }
253 if (does_file_exist(incoming)) {
254 fprintf(fout, "%s\n", incoming);
255 } else {
256 mr_asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);
257 log_it(tmp);
258 mr_free(tmp);
259 }
260 }
261 paranoid_fclose(fout);
262 paranoid_fclose(fin);
263 unlink(infname);
264 mr_free(infname);
265}
266
267
268
269
270
271
272
273
274
275/**
276 * Attempt to find the user's kernel by calling Mindi.
277 * If Mindi can't find the kernel, ask user. If @p kernel is not empty,
278 * don't do anything.
279 * @param kernel Where to put the found kernel.
280 * @return 0 for success, 1 for failure.
281 */
282int figure_out_kernel_path_interactively_if_necessary(char *kernel)
283{
284 char *tmp = NULL;
285 char *command = NULL;;
286
287 if (!kernel[0]) {
288 strcpy(kernel,
289 call_program_and_get_last_line_of_output
290 ("mindi --findkernel 2> /dev/null"));
291 }
292 // If we didn't get anything back, check whether mindi raised a fatal error
293 if (!kernel[0]) {
294 mr_asprintf(&command, "%s", "grep 'Fatal error' /var/log/mindi.log");
295 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
296 if (strlen(tmp) > 1) {
297 popup_and_OK(tmp);
298 mr_free(tmp);
299 mr_free(command);
300 fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'.");
301 }
302 mr_free(tmp);
303 mr_free(command);
304 }
305 log_it("Calling Mindi with kernel path of '%s'", kernel);
306 while (!kernel[0]) {
307 if (!ask_me_yes_or_no
308 ("Kernel not found or invalid. Choose another?")) {
309 return (1);
310 }
311 if (!popup_and_get_string
312 ("Kernel path",
313 "What is the full path and filename of your kernel, please?",
314 kernel, MAX_STR_LEN / 4)) {
315 fatal_error
316 ("Kernel not found. Please specify with the '-k' flag.");
317 }
318 mr_asprintf(&tmp, "User says kernel is at %s", kernel);
319 log_it(tmp);
320 mr_free(tmp);
321 }
322 return (0);
323}
324
325
326
327
328
329
330/**
331 * Find location of specified executable in user's PATH.
332 * @param fname The basename of the executable to search for (e.g. @c afio).
333 * @return The full path to the executable, or "" if it does not exist, or NULL if @c file could not be found.
334 * @note The returned string points to static storage that will be overwritten with each call.
335 * @bug The checks with @c file and @c dirname seem pointless. If @c incoming is "", then you're calling
336 * <tt>dirname 2\>/dev/null</tt> or <tt>file 2\>/dev/null | cut -d':' -f1 2\>/dev/null</tt>, which basically amounts
337 * to nothing.
338 */
339char *find_home_of_exe(char *fname)
340{
341 /*@ buffers ********************* */
342 static char output[MAX_STR_LEN];
343 char *incoming;
344 char *command = NULL;
345
346 malloc_string(incoming);
347 incoming[0] = '\0';
348 /*@******************************* */
349
350 assert_string_is_neither_NULL_nor_zerolength(fname);
351 mr_asprintf(&command, "which %s 2> /dev/null", fname);
352 strcpy(incoming, call_program_and_get_last_line_of_output(command));
353 mr_free(command);
354 if (incoming[0] == '\0') {
355 if (system("which file > /dev/null 2> /dev/null")) {
356 paranoid_free(incoming);
357 output[0] = '\0';
358 return (NULL); // forget it :)
359 }
360 mr_asprintf(&command,
361 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
362 incoming);
363 strcpy(incoming,
364 call_program_and_get_last_line_of_output(command));
365 mr_free(command);
366 }
367 if (incoming[0] == '\0') // yes, it is == '\0' twice, not once :)
368 {
369 mr_asprintf(&command, "dirname %s 2> /dev/null", incoming);
370 strcpy(incoming,
371 call_program_and_get_last_line_of_output(command));
372 mr_free(command);
373 }
374 strcpy(output, incoming);
375 if (output[0] != '\0' && does_file_exist(output)) {
376 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname,
377 incoming);
378 } else {
379 output[0] = '\0';
380 log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
381 }
382 paranoid_free(incoming);
383 if (!output[0]) {
384 return (NULL);
385 } else {
386 return (output);
387 }
388}
389
390
391
392
393
394
395
396
397/**
398 * Get the last sequence of digits surrounded by non-digits in the first 32k of
399 * a file.
400 * @param logfile The file to look in.
401 * @return The number found, or 0 if none.
402 */
403int get_trackno_from_logfile(char *logfile)
404{
405
406 /*@ pointers ********************************************************* */
407 FILE *fin;
408
409 /*@ int ************************************************************** */
410 int trackno = 0;
411 size_t len = 0;
412
413 /*@ buffer ************************************************************ */
414 char datablock[32701];
415
416 assert_string_is_neither_NULL_nor_zerolength(logfile);
417 if (!(fin = fopen(logfile, "r"))) {
418 log_OS_error("Unable to open logfile");
419 fatal_error("Unable to open logfile to read trackno");
420 }
421 len = fread(datablock, 1, 32700, fin);
422 paranoid_fclose(fin);
423 if (len <= 0) {
424 return (0);
425 }
426 for (; len > 0 && !isdigit(datablock[len - 1]); len--);
427 datablock[len--] = '\0';
428 for (; len > 0 && isdigit(datablock[len - 1]); len--);
429 trackno = atoi(datablock + len);
430 return (trackno);
431}
432
433
434
435
436
437
438
439/**
440 * Get a percentage from the last line of @p filename. We look for the string
441 * "% done" on the last line and, if we find it, grab the number before the last % sign.
442 * @param filename The file to get the percentage from.
443 * @return The percentage found, or 0 for error.
444 */
445int grab_percentage_from_last_line_of_file(char *filename)
446{
447
448 /*@ buffers ***************************************************** */
449 char lastline[MAX_STR_LEN];
450 char *command = NULL;
451 /*@ pointers **************************************************** */
452 char *p;
453
454 /*@ int's ******************************************************* */
455 int i;
456
457 for (i = NOOF_ERR_LINES - 1;
458 i >= 0 && !strstr(err_log_lines[i], "% Done")
459 && !strstr(err_log_lines[i], "% done"); i--);
460 if (i < 0) {
461 mr_asprintf(&command,
462 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
463 filename, '%');
464 strcpy(lastline,
465 call_program_and_get_last_line_of_output(command));
466 mr_free(command);
467 if (!lastline[0]) {
468 return (0);
469 }
470 } else {
471 strcpy(lastline, err_log_lines[i]);
472 }
473
474 p = strrchr(lastline, '%');
475 if (p) {
476 *p = '\0';
477 }
478 if (!p) {
479 return (0);
480 }
481 *p = '\0';
482 for (p--; *p != ' ' && p != lastline; p--);
483 if (p != lastline) {
484 p++;
485 }
486 i = atoi(p);
487
488 return (i);
489}
490
491
492
493
494
495/**
496 * Return the last line of @p filename.
497 * @param filename The file to get the last line of.
498 * @return The last line of the file.
499 * @note The returned string points to static storage that will be overwritten with each call.
500 */
501char *last_line_of_file(char *filename)
502{
503 /*@ buffers ***************************************************** */
504 static char output[MAX_STR_LEN];
505 char *command = NULL
506 char *tmp = NULL;
507
508 /*@ pointers **************************************************** */
509 FILE *fin;
510
511 /*@ end vars **************************************************** */
512
513 if (!does_file_exist(filename)) {
514 mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)",
515 filename);
516 log_it(tmp);
517 mr_free(tmp);
518 output[0] = '\0';
519 return (output);
520 }
521 mr_asprintf(&command, "tail -n1 %s", filename);
522 fin = popen(command, "r");
523 mr_free(command);
524
525 (void) fgets(output, MAX_STR_LEN, fin);
526 paranoid_pclose(fin);
527 while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
528 output[strlen(output) - 1] = '\0';
529 }
530 return (output);
531}
532
533/**
534 * Get the length of @p filename in bytes.
535 * @param filename The file to get the length of.
536 * @return The length of the file, or -1 for error.
537 */
538off_t length_of_file(char *filename)
539{
540 /*@ pointers *************************************************** */
541 FILE *fin;
542
543 /*@ long long ************************************************* */
544 off_t length;
545
546 fin = fopen(filename, "r");
547 if (!fin) {
548 log_it("filename=%s", filename);
549 log_OS_error("Unable to openin filename");
550 return (-1);
551 }
552 fseeko(fin, 0, SEEK_END);
553 length = ftello(fin);
554 paranoid_fclose(fin);
555 return (length);
556}
557
558
559
560/**
561 * ?????
562 * @bug I don't know what this function does. However, it seems orphaned, so it should probably be removed.
563 */
564int
565make_checksum_list_file(char *filelist, char *cksumlist, char *comppath)
566{
567 /*@ pointers **************************************************** */
568 FILE *fin;
569 FILE *fout;
570
571 /*@ int ******************************************************* */
572 int percentage;
573 int i;
574 int counter = 0;
575
576 /*@ buffer ****************************************************** */
577 char stub_fname[1000];
578 char curr_fname[1000];
579 char curr_cksum[1000];
580 char *tmp = NULL;
581
582 /*@ long [long] ************************************************* */
583 off_t filelist_length;
584 off_t curr_pos;
585 long start_time;
586 long current_time;
587 long time_taken;
588 long time_remaining;
589
590 /*@ end vars *************************************************** */
591
592 start_time = get_time();
593 filelist_length = length_of_file(filelist);
594 log_it("filelist = %s; cksumlist = %s", filelist, cksumlist);
595
596 fin = fopen(filelist, "r");
597 if (fin == NULL) {
598 log_OS_error("Unable to fopen-in filelist");
599 log_to_screen("Can't open filelist");
600 return (1);
601 }
602 fout = fopen(cksumlist, "w");
603 if (fout == NULL) {
604 log_OS_error("Unable to openout cksumlist");
605 paranoid_fclose(fin);
606 log_to_screen("Can't open checksum list");
607 return (1);
608 }
609 for (fgets(stub_fname, 999, fin); !feof(fin);
610 fgets(stub_fname, 999, fin)) {
611 if (stub_fname[(i = strlen(stub_fname) - 1)] < 32) {
612 stub_fname[i] = '\0';
613 }
614 mr_asprintf(&tmp, "%s%s", comppath, stub_fname);
615 strcpy(curr_fname, tmp + 1);
616 mr_free(tmp);
617
618 strcpy(curr_cksum, calc_file_ugly_minichecksum(curr_fname));
619 fprintf(fout, "%s\t%s\n", curr_fname, curr_cksum);
620 if (counter++ > 12) {
621 current_time = get_time();
622 counter = 0;
623 curr_fname[37] = '\0';
624 curr_pos = ftello(fin) / 1024;
625 percentage = (int) (curr_pos * 100 / filelist_length);
626 time_taken = current_time - start_time;
627 if (percentage == 0) {
628 /* printf("%0d%% done \r",percentage); */
629 } else {
630 time_remaining =
631 time_taken * 100 / (long) (percentage) - time_taken;
632 mr_asprintf(&tmp,
633 "%02d%% done %02d:%02d taken %02d:%02d remaining %-37s\r",
634 percentage, (int) (time_taken / 60),
635 (int) (time_taken % 60),
636 (int) (time_remaining / 60),
637 (int) (time_remaining % 60), curr_fname);
638 log_to_screen(tmp);
639 mr_free(tmp);
640 }
641 sync();
642 }
643 }
644 paranoid_fclose(fout);
645 paranoid_fclose(fin);
646 log_it("Done.");
647 return (0);
648}
649
650
651/**
652 * Create the directory @p outdir_fname and all parent directories. Equivalent to <tt>mkdir -p</tt>.
653 * @param outdir_fname The directory to create.
654 * @return The return value of @c mkdir.
655 */
656int make_hole_for_dir(char *outdir_fname)
657{
658 char *tmp = NULL;
659 int res = 0;
660
661 assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
662 mr_asprintf(&tmp, "mkdir -p %s", outdir_fname);
663 res = system(tmp);
664 mr_free(tmp);
665 return (res);
666}
667
668
669/**
670 * Create the parent directories of @p outfile_fname.
671 * @param outfile_fname The file to make a "hole" for.
672 * @return 0, always.
673 * @bug Return value unnecessary.
674 */
675int make_hole_for_file(char *outfile_fname)
676{
677 /*@ buffer ****************************************************** */
678 char *command = NULL;
679
680 /*@ int ******************************************************** */
681 int res = 0;
682
683 /*@ end vars *************************************************** */
684
685 assert_string_is_neither_NULL_nor_zerolength(outfile_fname);
686 assert(!strstr(outfile_fname, MNT_CDROM));
687 assert(!strstr(outfile_fname, "/dev/cdrom"));
688 mr_asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
689 res += system(command);
690 mr_free(command);
691
692 mr_asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
693 res += system(command);
694 mr_free(command);
695
696 mr_asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
697 res += system(command);
698 mr_free(command);
699
700 unlink(outfile_fname);
701 return (0);
702}
703
704
705
706
707/**
708 * Get the number of lines in @p filelist_fname that contain the string @p wildcard.
709 * @param filelist_fname The file to search through.
710 * @param wildcard The string to search for. This is @e not a shell glob or a regular expression.
711 * @return The number of lines matched.
712 */
713long noof_lines_that_match_wildcard(char *filelist_fname, char *wildcard)
714{
715 /*@ long ******************************************************* */
716 long matches = 0;
717
718 /*@ pointers *************************************************** */
719 FILE *fin;
720
721 /*@ buffers **************************************************** */
722 char incoming[MAX_STR_LEN];
723
724 /*@ end vars *************************************************** */
725
726
727 fin = fopen(filelist_fname, "r");
728
729 if (!fin) {
730 log_OS_error("Unable to openin filelist_fname");
731 return (0);
732 }
733 (void) fgets(incoming, MAX_STR_LEN - 1, fin);
734 while (!feof(fin)) {
735 if (strstr(incoming, wildcard)) {
736 matches++;
737 }
738 (void) fgets(incoming, MAX_STR_LEN - 1, fin);
739 }
740 paranoid_fclose(fin);
741 return (matches);
742}
743
744
745
746/**
747 * Determine the size (in KB) of @p dev in the mountlist in <tt>tmpdir</tt>/mountlist.txt.
748 * @param tmpdir The tempdir where the mountlist is stored.
749 * @param dev The device to search for.
750 * @return The size of the partition in KB.
751 */
752long size_of_partition_in_mountlist_K(char *tmpdir, char *dev)
753{
754 char *command = NULL;
755 char *mountlist = NULL;
756 char sz_res[MAX_STR_LEN];
757 long file_len_K;
758
759 mr_asprintf(&mountlist, "%s/mountlist.txt", tmpdir);
760 mr_asprintf(&command,
761 "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'",
762 dev, tmpdir);
763 mr_free(mountlist);
764
765 log_it(command);
766 strcpy(sz_res, call_program_and_get_last_line_of_output(command));
767 file_len_K = atol(sz_res);
768 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
769 mr_free(command);
770
771 return (file_len_K);
772}
773
774/**
775 * Calculate the total size (in KB) of all the biggiefiles in this backup.
776 * @param bkpinfo The backup information structure. Only the @c bkpinfo->tmpdir field is used.
777 * @return The total size of all biggiefiles in KB.
778 */
779long size_of_all_biggiefiles_K()
780{
781 /*@ buffers ***************************************************** */
782 char *fname;
783 char *biggielist = NULL;
784 char *comment = NULL;
785 char *tmp = NULL;
786 char *command = NULL;
787
788 /*@ long ******************************************************** */
789 long scratchL = 0;
790 long file_len_K;
791
792 int res = 0;
793
794 /*@ pointers *************************************************** */
795 FILE *fin = NULL;
796
797 /*@ end vars *************************************************** */
798
799 malloc_string(fname);
800 log_it("Calculating size of all biggiefiles (in total)");
801 mr_asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
802 log_it("biggielist = %s", biggielist);
803 fin = fopen(biggielist, "r");
804 mr_free(biggielist);
805
806 if (!(fin)) {
807 log_OS_error("Cannot open biggielist. OK, so estimate is based on filesets only.");
808 } else {
809 log_msg(4, "Reading it...");
810 for (fgets(fname, MAX_STR_LEN, fin); !feof(fin);
811 fgets(fname, MAX_STR_LEN, fin)) {
812 if (fname[strlen(fname) - 1] <= 32) {
813 fname[strlen(fname) - 1] = '\0';
814 }
815 if (0 == strncmp(fname, "/dev/", 5)) {
816 if (is_dev_an_NTFS_dev(fname)) {
817 if ( !find_home_of_exe("ntfsresize")) {
818 fatal_error("ntfsresize not found");
819 }
820 mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
821 log_it("command = %s", command);
822 mr_asorintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
823 mr_free(command);
824
825 log_it("res of it = %s", tmp);
826 file_len_K = atoll(tmp) / 1024L;
827 mr_free(tmp);
828 } else {
829 file_len_K = get_phys_size_of_drive(fname) * 1024L;
830 }
831 } else {
832 /* BERLIOS: more than long here ??? */
833 file_len_K = (long) (length_of_file(fname) / 1024);
834 }
835 if (file_len_K > 0) {
836 scratchL += file_len_K;
837 log_msg(4, "%s --> %ld K", fname, file_len_K);
838 }
839 mr_asprintf(&comment,
840 "After adding %s, scratchL+%ld now equals %ld", fname,
841 file_len_K, scratchL);
842 log_msg(4, comment);
843 mr_free(comment);
844 if (feof(fin)) {
845 break;
846 }
847 }
848 }
849 log_it("Closing...");
850 paranoid_fclose(fin);
851 log_it("Finished calculating total size of all biggiefiles");
852 paranoid_free(fname);
853 return (scratchL);
854}
855
856/**
857 * Determine the amount of space (in KB) occupied by a mounted CD.
858 * This can also be used to find the space used for other directories.
859 * @param mountpt The mountpoint/directory to check.
860 * @return The amount of space occupied in KB.
861 */
862long long space_occupied_by_cd(char *mountpt)
863{
864 /*@ buffer ****************************************************** */
865 char tmp[MAX_STR_LEN];
866 char *command = NULL;
867 long long llres;
868 /*@ pointers **************************************************** */
869 char *p;
870 FILE *fin;
871
872 /*@ end vars *************************************************** */
873
874 mr_asprintf(&command, "du -sk %s", mountpt);
875 errno = 0;
876 fin = popen(command, "r");
877 if (errno) {
878 log_it("popen() FAILED: command=%s, mountpt=%s, fin=%d, errno=%d, strerror=%s", command, mountpt, fin, errno, strerror(errno));
879 llres = 0;
880 } else {
881 (void) fgets(tmp, MAX_STR_LEN, fin);
882 paranoid_pclose(fin);
883 p = strchr(tmp, '\t');
884 if (p) {
885 *p = '\0';
886 }
887 for (p = tmp, llres = 0; *p != '\0'; p++) {
888 llres *= 10;
889 llres += (int) (*p - '0');
890 }
891 }
892 mr_free(command);
893
894 return (llres);
895}
896
897
898/**
899 * Update a CRC checksum to include another character.
900 * @param crc The original CRC checksum.
901 * @param c The character to add.
902 * @return The new CRC checksum.
903 * @ingroup utilityGroup
904 */
905unsigned int updcrc(unsigned int crc, unsigned int c)
906{
907 unsigned int tmp;
908 tmp = (crc >> 8) ^ c;
909 crc = (crc << 8) ^ crctttab[tmp & 255];
910 return crc;
911}
912
913/**
914 * Update a reverse CRC checksum to include another character.
915 * @param crc The original CRC checksum.
916 * @param c The character to add.
917 * @return The new CRC checksum.
918 * @ingroup utilityGroup
919 */
920unsigned int updcrcr(unsigned int crc, unsigned int c)
921{
922 unsigned int tmp;
923 tmp = crc ^ c;
924 crc = (crc >> 8) ^ crc16tab[tmp & 0xff];
925 return crc;
926}
927
928
929
930
931/**
932 * Check for an executable on the user's system; write a message to the
933 * screen and the log if we can't find it.
934 * @param fname The executable basename to look for.
935 * @return 0 if it's found, nonzero if not.
936 */
937int whine_if_not_found(char *fname)
938{
939 /*@ buffers *** */
940 char *command = NULL;
941 char *errorstr = NULL;
942 int res = 0;
943
944 mr_asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);
945 res = system(command);
946 mr_free(command);
947
948 if (res) {
949 mr_asprintf(&errorstr, "Please install '%s'. I cannot find it on your system.", fname);
950 log_to_screen(errorstr);
951 mr_free(errorstr);
952 log_to_screen("There may be hyperlink at http://www.mondorescue.com which");
953 log_to_screen("will take you to the relevant (missing) package.");
954 return (1);
955 } else {
956 return (0);
957 }
958}
959
960
961
962
963
964
965/**
966 * Create a data file at @p fname containing @p contents.
967 * The data actually can be multiple lines, despite the name.
968 * @param fname The file to create.
969 * @param contents The data to put in it.
970 * @return 0 for success, 1 for failure.
971 */
972int write_one_liner_data_file(char *fname, char *contents)
973{
974 /*@ pointers *************************************************** */
975 FILE *fout;
976 int res = 0;
977
978 /*@ end vars *************************************************** */
979
980 assert_string_is_neither_NULL_nor_zerolength(fname);
981 if (!contents) {
982 log_it("%d: Warning - writing NULL to %s", __LINE__, fname);
983 }
984 if (!(fout = fopen(fname, "w"))) {
985 log_it("fname=%s");
986 log_OS_error("Unable to openout fname");
987 return (1);
988 }
989 fprintf(fout, "%s\n", contents);
990 paranoid_fclose(fout);
991 return (res);
992}
993
994
995
996/**
997 * Read @p fname into @p contents.
998 * @param fname The file to read.
999 * @param contents Where to put its contents.
1000 * @return 0 for success, nonzero for failure.
1001 */
1002int read_one_liner_data_file(char *fname, char *contents)
1003{
1004 /*@ pointers *************************************************** */
1005 FILE *fin;
1006 int res = 0;
1007 int i;
1008
1009 /*@ end vars *************************************************** */
1010
1011 assert_string_is_neither_NULL_nor_zerolength(fname);
1012 if (!contents) {
1013 log_it("%d: Warning - reading NULL from %s", __LINE__, fname);
1014 }
1015 if (!(fin = fopen(fname, "r"))) {
1016 log_it("fname=%s", fname);
1017 log_OS_error("Unable to openin fname");
1018 return (1);
1019 }
1020 fscanf(fin, "%s\n", contents);
1021 i = strlen(contents);
1022 if (i > 0 && contents[i - 1] < 32) {
1023 contents[i - 1] = '\0';
1024 }
1025 paranoid_fclose(fin);
1026 return (res);
1027}
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037/**
1038 * Copy the files that Mondo/Mindi need to run to the scratchdir or tempdir.
1039 * Currently this includes: copy Mondo's home directory to scratchdir, untar "mondo_home/payload.tgz"
1040 * if it exists, copy LAST-FILELIST-NUMBER to scratchdir, copy mondorestore
1041 * and post-nuke.tgz (if it exists) to tmpdir, and run "hostname > scratchdir/HOSTNAME".
1042 * @param bkpinfo The backup information structure. Fields used:
1043 * - @c bkpinfo->postnuke_tarball
1044 * - @c bkpinfo->scratchdir
1045 * - @c bkpinfo->tmpdir
1046 */
1047void copy_mondo_and_mindi_stuff_to_scratchdir()
1048{
1049 /*@ Char buffers ** */
1050 char *command = NULL;
1051 char tmp[MAX_STR_LEN];
1052 char old_pwd[MAX_STR_LEN];
1053 int res = 0;
1054
1055 mvaddstr_and_log_it(g_currentY, 0,
1056 "Copying Mondo's core files to the scratch directory");
1057
1058 log_msg(4, "g_mondo_home='%s'", g_mondo_home);
1059 if (strlen(g_mondo_home) < 2) {
1060 find_and_store_mondoarchives_home(g_mondo_home);
1061 }
1062 mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
1063 bkpinfo->scratchdir);
1064
1065 log_msg(4, "command = %s", command);
1066 res = run_program_and_log_output(command, 1);
1067 mr_free(command);
1068
1069 if (res) {
1070 fatal_error("Failed to copy Mondo's stuff to scratchdir");
1071 }
1072
1073 sprintf(tmp, "%s/payload.tgz", g_mondo_home);
1074 if (does_file_exist(tmp)) {
1075 log_it("Untarring payload %s to scratchdir %s", tmp,
1076 bkpinfo->scratchdir);
1077 (void) getcwd(old_pwd, MAX_STR_LEN - 1);
1078 chdir(bkpinfo->scratchdir);
1079 mr_asprintf(&command, "tar -zxvf %s", tmp);
1080 res = run_program_and_log_output(command, FALSE);
1081 mr_free(command);
1082
1083 if (res) {
1084 fatal_error("Failed to untar payload");
1085 }
1086 chdir(old_pwd);
1087 }
1088
1089 mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
1090 bkpinfo->scratchdir);
1091 res = run_program_and_log_output(command, FALSE);
1092 mr_free(command);
1093
1094 if (res) {
1095 fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
1096 }
1097
1098 strcpy(tmp,
1099 call_program_and_get_last_line_of_output("which mondorestore"));
1100 if (!tmp[0]) {
1101 fatal_error
1102 ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
1103 }
1104 mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
1105 res = run_program_and_log_output(command, FALSE);
1106 mr_free(command);
1107
1108 if (res) {
1109 fatal_error("Failed to copy mondorestore to tmpdir");
1110 }
1111
1112 mr_asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
1113 paranoid_system(command);
1114 mr_free(command);
1115
1116 if (bkpinfo->postnuke_tarball[0]) {
1117 mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz",
1118 bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
1119 res = run_program_and_log_output(command, FALSE);
1120 mr_free(command);
1121
1122 if (res) {
1123 fatal_error("Unable to copy post-nuke tarball to tmpdir");
1124 }
1125 }
1126
1127 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1128}
1129
1130
1131
1132
1133
1134/**
1135 * Store the client's NFS configuration in files to be restored at restore-time.
1136 * Assumes that @c bkpinfo->media_type = nfs, but does not check for this.
1137 * @param bkpinfo The backup information structure. Fields used:
1138 * - @c nfs_mount
1139 * - @c nfs_remote_dir
1140 * - @c tmpdir
1141 */
1142void store_nfs_config()
1143{
1144
1145 /*@ buffers ******** */
1146 char *nfs_dev = NULL;
1147 char *mac_addr = NULL;
1148 char *nfs_mount = NULL;
1149 char *nfs_client_ipaddr = NULL;
1150 char *nfs_client_netmask = NULL;
1151 char *nfs_client_broadcast = NULL;
1152 char *nfs_client_defgw = NULL;
1153 char *nfs_server_ipaddr = NULL;
1154 char *tmp = NULL;
1155 char *command = NULL
1156
1157 /*@ pointers ***** */
1158 char *p;
1159
1160 log_it("Storing NFS configuration");
1161 mr_asprintf(&tmp, "%s", bkpinfo->nfs_mount);
1162 p = strchr(tmp, ':');
1163 if (!p) {
1164 fatal_error
1165 ("NFS mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
1166 }
1167 *(p++) = '\0';
1168 mr_asprintf(&nfs_server_ipaddr, tmp);
1169 mr_asprintf(&nfs_mount, p);
1170 mr_free(tmp);
1171
1172 /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
1173 mr_asprintf(&command,
1174 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
1175 mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
1176 mr-free(command);
1177
1178 mr_asprintf(&command,
1179 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
1180 mr_asprintf(&nfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
1181 mr-free(command);
1182
1183 mr_asprintf(&command,
1184 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
1185 mr_asprintf(&nfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
1186 mr-free(command);
1187
1188 mr_asprintf(&command,
1189 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
1190 mr_asprintf(&nfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
1191 mr-free(command);
1192
1193 mr_asprintf(&command,
1194 "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
1195 mr_asprintf(&nfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
1196 mr-free(command);
1197
1198 if (strlen(nfs_dev) < 2) {
1199 fatal_error
1200 ("Unable to find ethN (eth0, eth1, ...) adapter via NFS mount you specified.");
1201 }
1202 /********
1203 * If the NFS device that found above is a bonded device,
1204 * we need to replace it with an ethN device or the
1205 * networking will not start during an NFS restore.
1206 *
1207 * If the NFS device in nfs_dev begins with the word "bond", or alb or aft
1208 * look for the corresponding slave ethN device and copy it to nfs_dev.
1209 * Using the common MAC address
1210 ********/
1211 if (!strncmp(nfs_dev, "bond", 4) || !strncmp(nfs_dev, "alb", 3) || !strncmp(nfs_dev, "aft", 3)) {
1212 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev);
1213 mr_asprintf(&command,
1214 "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
1215 mr_asprintf(&mac_addr, "%s", call_program_and_get_last_line_of_output(command));
1216 mr-free(command);
1217
1218 mr_asprintf(&command, "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr,nfs_dev);
1219 mr_free(mac_addr);
1220 mr_free(nfs_dev);
1221
1222 mr_asprintf(&nfs_dev, call_program_and_get_last_line_of_output(command));
1223 mr-free(command);
1224
1225 log_to_screen("Replacing it with %s\n", nfs_dev);
1226 }
1227
1228 mr_asprintf(tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
1229 write_one_liner_data_file(tmp, nfs_dev);
1230 mr_free(nfs_dev);
1231 mr_free(tmp);
1232
1233 mr_asprintf(tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
1234 write_one_liner_data_file(tmp, nfs_client_ipaddr);
1235 mr_free(nfs_client_ipaddr);
1236 mr_free(tmp);
1237
1238 mr_asprintf(tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
1239 write_one_liner_data_file(tmp, nfs_client_netmask);
1240 mr_free(nfs_client_netmask);
1241 mr_free(tmp);
1242
1243 mr_asprintf(tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
1244 write_one_liner_data_file(tmp, nfs_client_broadcast);
1245 mr_free(nfs_client_broadcast);
1246 mr_free(tmp);
1247
1248 mr_asprintf(tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
1249 write_one_liner_data_file(tmp, nfs_client_defgw);
1250 mr_free(nfs_client_defgw);
1251 mr_free(tmp);
1252
1253 mr_asprintf(tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
1254 write_one_liner_data_file(tmp, nfs_server_ipaddr);
1255 mr_free(tmp);
1256 mr_free(nfs_server_ipaddr);
1257
1258 mr_asprintf(tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
1259 write_one_liner_data_file(tmp, bkpinfo->nfs_mount);
1260 mr_free(tmp);
1261 mr_free(nfs_mount);
1262
1263 mr_asprintf(tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
1264 write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir);
1265 mr_free(tmp);
1266
1267 mr_asprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
1268 write_one_liner_data_file(tmp, bkpinfo->prefix);
1269 mr_free(tmp);
1270
1271 log_it("Finished storing NFS configuration");
1272}
1273
1274
1275
1276
1277
1278
1279/**
1280 * Determine the approximate number of media that the backup will take up,
1281 * and tell the user. The uncompressed size is estimated as size_of_all_biggiefiles_K()
1282 * plus (noof_sets x bkpinfo->optimal_set_size). The compression factor is estimated as
1283 * 2/3 for LZO and 1/2 for bzip2. The data is not saved anywhere. If there are any
1284 * "imagedevs", the estimate is not shown as it will be wildly inaccurate.
1285 * If there are more than 50 media estimated, the estimate will not be shown.
1286 * @param bkpinfo The backup information structure. Fields used:
1287 * - @c bkpinfo->backup_media_type
1288 * - @c bkpinfo->image_devs
1289 * - @c bkpinfo->media_size
1290 * - @c bkpinfo->optimal_set_size
1291 * - @c bkpinfo->use_lzo
1292 * @param noof_sets The number of filesets created.
1293 * @ingroup archiveGroup
1294 */
1295void
1296estimate_noof_media_required(long noof_sets)
1297{
1298 /*@ buffers *************** */
1299 char *tmp = NULL;
1300 char *mds = NULL;
1301
1302 /*@ long long ************* */
1303 long long scratchLL;
1304
1305 if (bkpinfo->media_size[1] <= 0) {
1306 log_to_screen("Number of media required: UNKNOWN");
1307 return;
1308 }
1309
1310 log_it("Estimating number of media required...");
1311 scratchLL =
1312 (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
1313 + (long long) (size_of_all_biggiefiles_K());
1314 scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
1315 scratchLL++;
1316 if (bkpinfo->use_lzo) {
1317 scratchLL = (scratchLL * 2) / 3;
1318 } else if (bkpinfo->use_gzip) {
1319 scratchLL = (scratchLL * 2) / 3;
1320 } else {
1321 scratchLL = scratchLL / 2;
1322 }
1323 if (!scratchLL) {
1324 scratchLL++;
1325 }
1326 if (scratchLL <= 1) {
1327 mds = media_descriptor_string(bkpinfo->backup_media_type);
1328 mr_asprintf(&tmp, "Your backup will probably occupy a single %s. Maybe two.", mds);
1329 mr_free(mds);
1330 } else if (scratchLL > 4) {
1331 mr_asprintf(&tmp,
1332 "Your backup will occupy one meeeeellion media! (maybe %s)",
1333 number_to_text((int) (scratchLL + 1)));
1334 } else {
1335 mr_asprintf(&tmp, "Your backup will occupy approximately %s media.",
1336 number_to_text((int) (scratchLL + 1)));
1337 }
1338 if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
1339 log_to_screen(tmp);
1340 }
1341 mr_free(tmp);
1342}
1343
1344
1345/**
1346 * Get the last suffix of @p instr.
1347 * If @p instr was "httpd.log.gz", we would return "gz".
1348 * @param instr The filename to get the suffix of.
1349 * @return The suffix (without a dot), or "" if none.
1350 * @note The returned string points to static storage that will be overwritten with each call.
1351 */
1352char *sz_last_suffix(char *instr)
1353{
1354 static char outstr[MAX_STR_LEN];
1355 char *p;
1356
1357 p = strrchr(instr, '.');
1358 if (!p) {
1359 outstr[0] = '\0';
1360 } else {
1361 strcpy(outstr, p);
1362 }
1363 return (outstr);
1364}
1365
1366
1367/**
1368 * Determine whether a file is compressed. This is done
1369 * by reading through the "do-not-compress-these" file distributed with Mondo.
1370 * @param filename The file to check.
1371 * @return TRUE if it's compressed, FALSE if not.
1372 */
1373bool is_this_file_compressed(char *filename)
1374{
1375 char do_not_compress_these[MAX_STR_LEN];
1376 char *tmp = NULL;
1377 char *p;
1378 char *q = NULL;
1379
1380 q = strrchr(filename, '.');
1381 if (q == NULL) {
1382 return (FALSE);
1383 }
1384
1385 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
1386 if (!does_file_exist(tmp)) {
1387 mr_free(tmp);
1388 return (FALSE);
1389 }
1390 /* BERLIOS: This is just plain WRONG !! */
1391 strcpy(do_not_compress_these,last_line_of_file(tmp));
1392 mr_free(tmp);
1393
1394 for (p = do_not_compress_these; p != NULL; p++) {
1395 mr_asprintf(&tmp, "%s", p);
1396 if (strchr(tmp, ' ')) {
1397 *(strchr(tmp, ' ')) = '\0';
1398 }
1399 if (!strcmp(q, tmp)) {
1400 mr_free(tmp);
1401 return (TRUE);
1402 }
1403 if (!(p = strchr(p, ' '))) {
1404 break;
1405 }
1406 mr_free(tmp);
1407 }
1408 return (FALSE);
1409}
1410
1411
1412int mode_of_file(char *fname)
1413{
1414 struct stat buf;
1415
1416 if (lstat(fname, &buf)) {
1417 return (-1);
1418 } // error
1419 else {
1420 return (buf.st_mode);
1421 }
1422}
1423
1424
1425
1426
1427/**
1428 * Create a small script that mounts /boot, calls @c grub-install, and syncs the disks.
1429 * @param outfile Where to put the script.
1430 * @return 0 for success, 1 for failure.
1431 */
1432int make_grub_install_scriptlet(char *outfile)
1433{
1434 FILE *fout;
1435 char *tmp = NULL;
1436 int retval = 0;
1437
1438 if ((fout = fopen(outfile, "w"))) {
1439 fprintf(fout,
1440 "#!/bin/sh\n\nmount /boot > /dev/null 2> /dev/null\ngrub-install $@\nres=$?\nsync;sync;sync\nexit $res\n");
1441 paranoid_fclose(fout);
1442 log_msg(2, "Created %s", outfile);
1443 mr_asprintf(&tmp, "chmod +x %s", outfile);
1444 paranoid_system(tmp);
1445 mr_free(tmp);
1446 retval = 0;
1447 } else {
1448 retval = 1;
1449 }
1450 return (retval);
1451}
1452
1453/* @} - end fileGroup */
Note: See TracBrowser for help on using the repository browser.