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