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