[2211] | 1 | /*
|
---|
| 2 | * $Id$
|
---|
| 3 | *
|
---|
| 4 | * Test program for mountlist management at restore time
|
---|
[2990] | 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"
|
---|
[3564] | 14 | #include "../mondorestore/libmondo-mountlist-EXT.h"
|
---|
[2202] | 15 |
|
---|
[3564] | 16 |
|
---|
[2990] | 17 | #define RAIDTAB_TEST "/tmp/raidtab"
|
---|
| 18 | #define MOUNTLIST_TEST "/tmp/mountlist.txt"
|
---|
| 19 |
|
---|
[2202] | 20 | extern void twenty_seconds_til_yikes(void);
|
---|
| 21 |
|
---|
| 22 | extern bool g_text_mode;
|
---|
| 23 | extern FILE *g_fprep;
|
---|
| 24 | extern double g_kernel_version;
|
---|
| 25 | extern int g_partition_table_locked_up;
|
---|
| 26 | extern int g_noof_rows;
|
---|
| 27 |
|
---|
[3141] | 28 | /* Whether we should fail immediately at first error */
|
---|
| 29 | bool g_fail_immediately = FALSE;
|
---|
| 30 |
|
---|
[2202] | 31 | bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
|
---|
| 32 | bool g_I_have_just_nuked = FALSE;
|
---|
| 33 | char *g_biggielist_txt;
|
---|
| 34 | char *g_filelist_full;
|
---|
| 35 | char *g_filelist_imagedevs;
|
---|
| 36 | char *g_imagedevs_restthese;
|
---|
| 37 |
|
---|
| 38 | char *g_mondo_cfg_file;
|
---|
| 39 |
|
---|
| 40 | char *g_mountlist_fname;
|
---|
| 41 | char *g_mondo_home;
|
---|
| 42 |
|
---|
| 43 | char *g_getfacl;
|
---|
| 44 | char *g_getfattr;
|
---|
| 45 |
|
---|
| 46 | extern char *MONDO_LOGFILE;
|
---|
[2209] | 47 | extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
|
---|
[3374] | 48 | extern int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test);
|
---|
| 49 |
|
---|
| 50 | /* Reference to global bkpinfo */
|
---|
| 51 | struct s_bkpinfo *bkpinfo;
|
---|
| 52 |
|
---|
[2209] | 53 | /* We don't have a cleanup function yet */
|
---|
| 54 | void (*mr_cleanup)(void) = NULL;
|
---|
[2202] | 55 |
|
---|
[3374] | 56 | int main() {
|
---|
[2202] | 57 |
|
---|
[2234] | 58 | struct mountlist_itself *mountlist = NULL;
|
---|
[2350] | 59 | struct raidlist_itself *raidlist = NULL;
|
---|
| 60 | char *flaws_str = NULL;
|
---|
[2204] | 61 |
|
---|
[3185] | 62 | mr_asprintf(MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
|
---|
[2202] | 63 |
|
---|
[2234] | 64 | /* Globals */
|
---|
| 65 | g_loglevel = 99;
|
---|
| 66 | g_text_mode = FALSE;
|
---|
| 67 | g_main_pid = getpid();
|
---|
[2206] | 68 |
|
---|
[2234] | 69 | if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
|
---|
| 70 | fatal_error("Cannot malloc mountlist");
|
---|
| 71 | }
|
---|
| 72 | if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
|
---|
| 73 | fatal_error("Cannot malloc raidlist");
|
---|
| 74 | }
|
---|
| 75 | malloc_libmondo_global_strings();
|
---|
[2202] | 76 |
|
---|
| 77 | setup_newt_stuff();
|
---|
[3185] | 78 | mr_asprintf(g_mountlist_fname, MOUNTLIST_TEST);
|
---|
[2206] | 79 | log_it("before mountlist");
|
---|
[2202] | 80 | load_mountlist(mountlist, g_mountlist_fname);
|
---|
[2206] | 81 | log_it("after mountlist");
|
---|
[2204] | 82 | resize_mountlist_proportionately_to_suit_new_drives(mountlist);
|
---|
[2206] | 83 | log_it("after resize_mountlist_proportionately_to_suit_new_drives");
|
---|
[2990] | 84 | load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST);
|
---|
[2206] | 85 | log_it("after load_raidtab_into_raidlist");
|
---|
[2204] | 86 | edit_mountlist(g_mountlist_fname, mountlist, raidlist);
|
---|
[2206] | 87 | log_it("after edit_mountlist");
|
---|
[2234] | 88 |
|
---|
[2394] | 89 | flaws_str = evaluate_mountlist(mountlist);
|
---|
[2234] | 90 | log_it("after evaluate_mountlist");
|
---|
[2350] | 91 | mr_free(flaws_str);
|
---|
[2235] | 92 |
|
---|
[3566] | 93 | log_it("before write again raidlist content");
|
---|
| 94 | save_raidlist_to_raidtab(raidlist, RAIDTAB_TEST".new");
|
---|
| 95 | log_it("after write again raidlist content");
|
---|
[2990] | 96 |
|
---|
| 97 | log_it("before create mdadm dev");
|
---|
[3566] | 98 | /*
|
---|
[2990] | 99 | create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE);
|
---|
[2991] | 100 | create_raid_device_via_mdadm(raidlist,"/dev/md1",FALSE);
|
---|
[3566] | 101 | */
|
---|
[2990] | 102 | log_it("after create mdadm dev");
|
---|
| 103 |
|
---|
[2991] | 104 | free(mountlist);
|
---|
| 105 | free(raidlist);
|
---|
[2235] | 106 | mr_free(MONDO_LOGFILE);
|
---|
[2991] | 107 | mr_free(g_mountlist_fname);
|
---|
[2204] | 108 | exit(0);
|
---|
[2202] | 109 | }
|
---|