[2211] | 1 | /*
|
---|
| 2 | * $Id$
|
---|
| 3 | *
|
---|
| 4 | * Test program for mountlist management at restore time
|
---|
[3147] | 5 | * Can be used on host system with valgrind easier than with mondorestore
|
---|
[2211] | 6 | */
|
---|
[2202] | 7 | #include <stdio.h>
|
---|
| 8 | #include "my-stuff.h"
|
---|
[2211] | 9 | #include "mr_mem.h"
|
---|
[2202] | 10 | #include "../common/mondostructures.h"
|
---|
| 11 | #include "../common/libmondo.h"
|
---|
| 12 | #include "../mondorestore/mondorestore.h"
|
---|
[2204] | 13 | #include "../mondorestore/mr-externs.h"
|
---|
[2202] | 14 |
|
---|
[3147] | 15 | #define RAIDTAB_TEST "/tmp/raidtab"
|
---|
| 16 | #define MOUNTLIST_TEST "/tmp/mountlist.txt"
|
---|
| 17 |
|
---|
[2202] | 18 | extern void twenty_seconds_til_yikes(void);
|
---|
| 19 |
|
---|
| 20 | /* Reference to global bkpinfo */
|
---|
| 21 | struct s_bkpinfo *bkpinfo;
|
---|
| 22 |
|
---|
| 23 | extern bool g_text_mode;
|
---|
| 24 | extern FILE *g_fprep;
|
---|
| 25 | extern double g_kernel_version;
|
---|
| 26 | extern int g_partition_table_locked_up;
|
---|
| 27 | extern int g_noof_rows;
|
---|
| 28 |
|
---|
[3147] | 29 | /* Whether we should fail immediately at first error */
|
---|
| 30 | bool g_fail_immediately = FALSE;
|
---|
| 31 |
|
---|
[2202] | 32 | bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
|
---|
| 33 | bool g_I_have_just_nuked = FALSE;
|
---|
| 34 | char *g_isodir_device;
|
---|
| 35 | char *g_isodir_format;
|
---|
| 36 | char *g_filelist_full;
|
---|
| 37 | char *g_filelist_imagedevs;
|
---|
| 38 | char *g_imagedevs_restthese;
|
---|
| 39 |
|
---|
| 40 | char *g_mondo_home;
|
---|
| 41 |
|
---|
| 42 | char *g_getfacl;
|
---|
| 43 | char *g_getfattr;
|
---|
| 44 |
|
---|
| 45 | extern char *MONDO_LOGFILE;
|
---|
[2209] | 46 | extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
|
---|
| 47 | /* We don't have a cleanup function yet */
|
---|
[2320] | 48 | void (*mr_cleanup)(int) = NULL;
|
---|
[2202] | 49 |
|
---|
[2421] | 50 | int main() {
|
---|
[2202] | 51 |
|
---|
[2234] | 52 | struct mountlist_itself *mountlist = NULL;
|
---|
[2352] | 53 | struct raidlist_itself *raidlist = NULL;
|
---|
| 54 | char *flaws_str = NULL;
|
---|
[2204] | 55 |
|
---|
[2323] | 56 | mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
|
---|
[2202] | 57 |
|
---|
[2234] | 58 | /* Globals */
|
---|
| 59 | g_loglevel = 99;
|
---|
| 60 | g_text_mode = FALSE;
|
---|
| 61 | g_main_pid = getpid();
|
---|
[2206] | 62 |
|
---|
[2234] | 63 | if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
|
---|
| 64 | fatal_error("Cannot malloc mountlist");
|
---|
| 65 | }
|
---|
| 66 | if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
|
---|
| 67 | fatal_error("Cannot malloc raidlist");
|
---|
| 68 | }
|
---|
| 69 | malloc_libmondo_global_strings();
|
---|
[2202] | 70 |
|
---|
| 71 | setup_newt_stuff();
|
---|
[2206] | 72 | log_it("before mountlist");
|
---|
[2623] | 73 | load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
|
---|
[2206] | 74 | log_it("after mountlist");
|
---|
[2204] | 75 | resize_mountlist_proportionately_to_suit_new_drives(mountlist);
|
---|
[2206] | 76 | log_it("after resize_mountlist_proportionately_to_suit_new_drives");
|
---|
[3147] | 77 | load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
|
---|
[2206] | 78 | log_it("after load_raidtab_into_raidlist");
|
---|
[2623] | 79 | edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist);
|
---|
[2206] | 80 | log_it("after edit_mountlist");
|
---|
[2234] | 81 |
|
---|
[2395] | 82 | flaws_str = evaluate_mountlist(mountlist);
|
---|
[2234] | 83 | log_it("after evaluate_mountlist");
|
---|
[2352] | 84 | mr_free(flaws_str);
|
---|
[2235] | 85 |
|
---|
[3147] | 86 | log_it("before check raidlist content");
|
---|
| 87 | log_it("after check raidlist content");
|
---|
| 88 |
|
---|
| 89 | log_it("before create mdadm dev");
|
---|
| 90 | create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
|
---|
| 91 | create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
|
---|
| 92 | log_it("after create mdadm dev");
|
---|
| 93 |
|
---|
| 94 | free(mountlist);
|
---|
| 95 | free(raidlist);
|
---|
[2235] | 96 | mr_free(MONDO_LOGFILE);
|
---|
[2204] | 97 | exit(0);
|
---|
[2202] | 98 | }
|
---|