source: MondoRescue/branches/stable/mondo/src/common/libmondo-files.c@ 1174

Last change on this file since 1174 was 1173, checked in by Bruno Cornec, 17 years ago

merges from trunk for memory management for libmondo-mountlist.c mainly

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