Ignore:
Timestamp:
Aug 18, 2009, 2:37:55 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3332@localhost: bruno | 2009-08-07 23:59:34 +0200

  • bkpinfo->tmpchdir is now dynamically allocated
  • reorganize how tmpdir and scratchdir are initialized and the startup of the main sections
  • change of interface for maintain_collection_of_recent_archives, mondo_makefilelist, chop_filelist
  • sensibly_set_tmpdir_and_scratchdir => sensibly_set_scratchdir
  • reset_bkpinfo => init_bkpinfo
  • add function mr_free_bkpinfo
  • Fix a bug in mr_strtok
  • mondoarchive seems to globally work. Newt stuff needs more testing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c

    r2320 r2321  
    170170    char *say_at_end = NULL;
    171171
    172 /* Make sure I'm root; abort if not */
    173     if (getuid() != 0) {
    174         fprintf(stderr, "Please run as root.\r\n");
    175         exit(127);
    176     }
    177 
    178 /* If -V, -v or --version then echo version no. and quit */
    179     if (argc == 2
    180         && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
    181             || !strcmp(argv[argc - 1], "--version"))) {
    182         printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
    183         exit(0);
    184     }
    185 
    186172/* Initialize variables */
    187 
    188     printf("Initializing...\n");
    189     if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
    190         fatal_error("Cannot malloc bkpinfo");
    191     }
    192     reset_bkpinfo();
    193173
    194174    res = 0;
    195175    retval = 0;
    196176    diffs = 0;
    197     malloc_libmondo_global_strings();
     177
     178    printf("Initializing...\n");
     179
     180    bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
     181    init_bkpinfo();
    198182
    199183    /* initialize log file with time stamp */
     
    201185    log_msg(0, "Time started: %s", mr_date());
    202186
     187    /* Memory allocation is done in those functions */
     188    malloc_libmondo_global_strings();
     189    if (argc == 1) {
     190        g_text_mode = FALSE;
     191    } else {
     192        g_text_mode = TRUE;
     193    }
     194    setup_newt_stuff();
     195
     196    /* Make sure I'm root; abort if not */
     197    if (getuid() != 0) {
     198        fatal_error("Please run as root.\n");
     199    }
     200
     201    /* If -V, -v or --version then echo version no. and quit */
     202    if (argc == 2 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V") || !strcmp(argv[argc - 1], "--version"))) {
     203        printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
     204        finish(0);
     205    }
     206
     207
    203208    /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
    204209    mr_asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH"));
    205210    setenv("PATH", tmp1, 1);
    206     paranoid_free(tmp1);
     211    mr_free(tmp1);
    207212
    208213    /* Add the ARCH environment variable for ia64 purposes */
    209214    mr_asprintf(&tmp1,"%s",get_architecture());
    210215    setenv("ARCH", tmp1, 1);
    211     paranoid_free(tmp1);
     216    mr_free(tmp1);
    212217
    213218    /* Add MONDO_SHARE environment variable for mindi */
     
    231236        g_loglevel = 10;
    232237        g_text_mode = TRUE;
    233         setup_newt_stuff();
    234238        if (!strstr(argv[2], "filelist")) {
    235239            printf("Sorry - filelist goes first\n");
     
    242246    if (argc == 4 && !strcmp(argv[1], "setfattr")) {
    243247        g_loglevel = 10;
    244         g_text_mode = TRUE;
    245         setup_newt_stuff();
    246248        finish(set_fattr_list(argv[2], argv[3]));
    247249    }
     
    249251    if (argc == 3 && !strcmp(argv[1], "wildcards")) {
    250252        g_loglevel = 10;
    251         g_text_mode = TRUE;
    252         setup_newt_stuff();
    253253        malloc_string(tmp);
    254254        turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
     
    260260    if (argc == 4 && !strcmp(argv[1], "getfacl")) {
    261261        g_loglevel = 10;
    262         g_text_mode = TRUE;
    263         setup_newt_stuff();
    264262        if (!strstr(argv[2], "filelist")) {
    265263            printf("Sorry - filelist goes first\n");
     
    272270    if (argc == 4 && !strcmp(argv[1], "setfacl")) {
    273271        g_loglevel = 10;
    274         g_text_mode = TRUE;
    275         setup_newt_stuff();
    276272        finish(set_acl_list(argv[2], argv[3]));
    277273    }
     
    279275    if (argc > 2 && !strcmp(argv[1], "find-cd")) {
    280276        g_loglevel = 10;
    281         g_text_mode = TRUE;
    282         setup_newt_stuff();
    283277        malloc_string(tmp);
    284278        if (find_cdrw_device(tmp)) {
     
    299293    if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
    300294        g_loglevel = 10;
    301         g_text_mode = TRUE;
    302         setup_newt_stuff();
    303295        malloc_string(tmp);
    304296        if (find_dvd_device(tmp, atoi(argv[2]))) {
     
    331323/* Process command line, if there is one. If not, ask user for info. */
    332324    if (argc == 1) {
    333         g_text_mode = FALSE;
    334         setup_newt_stuff();
    335325        res = interactively_obtain_media_parameters_from_user(TRUE);    /* yes, archiving */
    336326        if (res) {
     
    347337            finish(1);
    348338        }
    349         setup_newt_stuff();
    350339    }
    351340
    352341/* Finish configuring global structures */
    353342    if (post_param_configuration()) {
    354         fatal_error
    355             ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
    356     }
    357 
    358     log_to_screen
    359         ("BusyBox's sources are available from http://www.busybox.net");
     343        fatal_error("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
     344    }
     345
     346    log_to_screen("BusyBox's sources are available from http://www.busybox.net");
    360347
    361348    /* If we're meant to backup then backup */
     
    412399    if (say_at_end != NULL) {
    413400        log_to_screen(say_at_end);
    414         paranoid_free(say_at_end);
     401        mr_free(say_at_end);
    415402    }
    416403    mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
Note: See TracChangeset for help on using the changeset viewer.