Ignore:
Timestamp:
Feb 27, 2007, 7:56:09 AM (17 years ago)
Author:
Bruno Cornec
Message:

First merge for mondo-rstr-tools.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c

    r1213 r1216  
    55
    66#include <pthread.h>
     7#include <unistd.h>
    78#include "my-stuff.h"
    89#include "mr_mem.h"
     
    1314#include "libmondo.h"
    1415#include "mr-externs.h"
    15 //#include "mondo-restore.h"
    16 //#include "mondo-rstr-compare-EXT.h"
    1716#include "mondo-rstr-tools.h"
    1817
     
    4039
    4140extern t_bkptype g_backup_media_type;
     41extern char *g_backup_media_string;
    4242
    4343extern int g_partition_table_locked_up;
     
    5959    mr_free(g_filelist_full);
    6060    mr_free(g_filelist_imagedevs);
    61 //  mr_free (g_imagedevs_pot );
    6261    mr_free(g_imagedevs_restthese);
    6362    mr_free(g_mondo_cfg_file);
     
    6665    mr_free(g_isodir_device);
    6766    mr_free(g_isodir_format);
    68 
    69 }
    70 
     67}
    7168
    7269
     
    8077void ask_about_these_imagedevs(char *infname, char *outfname)
    8178{
    82     FILE *fin;
    83     FILE *fout;
     79    FILE *fin = NULL;
     80    FILE *fout = NULL;
    8481  /************************************************************************
    8582   * allocate memory regions. test and set  -sab 16 feb 2003              *
    8683   ************************************************************************/
    87     char *incoming_ptr;
    88     char *question_ptr;
    89 
    90     char incoming[MAX_STR_LEN] = "\0";
    91     char question[MAX_STR_LEN];
     84    char *incoming = NULL;
     85    char *question = NULL;
     86
     87    size_t n = 0;
    9288
    9389    assert_string_is_neither_NULL_nor_zerolength(infname);
    9490    assert_string_is_neither_NULL_nor_zerolength(outfname);
    9591
    96     incoming_ptr = mr_malloc(sizeof(incoming));
    97     question_ptr = mr_malloc(sizeof(question));
    98 
    99     memset(incoming_ptr, '\0', sizeof(incoming));
    100     memset(question_ptr, '\0', sizeof(question));
    101 
    102 
    103 
    10492    if (!(fin = fopen(infname, "r"))) {
    10593        fatal_error("Cannot openin infname");
     
    10896        fatal_error("Cannot openin outfname");
    10997    }
    110     for (fgets(incoming_ptr, MAX_STR_LEN, fin);
    111          !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) {
    112         mr_strip_spaces(incoming_ptr);
     98    for (mr_getline(&incoming, &n, fin);
     99         !feof(fin); mr_getline(&incoming, &n, fin)) {
     100        mr_strip_spaces(incoming);
    113101
    114102        if (incoming[0] == '\0') {
     
    116104        }
    117105
    118         sprintf(question_ptr,
    119                 "Should I restore the image of %s ?", incoming_ptr);
    120 
    121         if (ask_me_yes_or_no(question_ptr)) {
    122             fprintf(fout, "%s\n", incoming_ptr);
    123         }
     106        mr_asprintf(&question,
     107                 _("Should I restore the image of %s ?"), incoming);
     108
     109        if (ask_me_yes_or_no(question)) {
     110            fprintf(fout, "%s\n", incoming);
     111        }
     112        mr_free(question);
    124113    }
    125114
    126115  /*** free memory ***********/
    127     mr_free(incoming_ptr);
    128     incoming_ptr = NULL;
    129     mr_free(question_ptr);
    130     question_ptr = NULL;
    131 
     116    mr_free(incoming);
    132117
    133118    paranoid_fclose(fout);
     
    138123 *ASK_ABOUT_THESE_IMAGEDEVS                                               *
    139124 **************************************************************************/
    140 
    141 
    142 
    143 
    144 
    145 
    146125
    147126
     
    161140                                 char *output_mountlist_file)
    162141{
    163     char *mountpt;
    164     char *command;
    165     char *orig_fname;
     142    char *mountpt = NULL;
     143    char *command = NULL;
     144    char *orig_fname = NULL;
    166145    int retval = 0;
    167146
    168147    assert(bkpinfo != NULL);
    169     malloc_string(mountpt);
    170     malloc_string(command);
    171     malloc_string(orig_fname);
    172148    assert_string_is_neither_NULL_nor_zerolength(ramdisk_fname);
    173149    assert_string_is_neither_NULL_nor_zerolength(output_cfg_file);
    174150    assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file);
    175     sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    176     sprintf(command, "mkdir -p %s", mountpt);
     151    mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
     152    mr_asprintf(&command, "mkdir -p %s", mountpt);
    177153    run_program_and_log_output(command, FALSE);
    178     sprintf(command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",
     154    mr_free(command);
     155
     156    mr_asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",
    179157            ramdisk_fname, bkpinfo->tmpdir);
    180 
    181158    run_program_and_log_output(command, FALSE);
    182     sprintf(command, "umount %s", mountpt);
    183 
     159    mr_free(command);
     160
     161    mr_asprintf(&command, "umount %s", mountpt);
    184162    run_program_and_log_output(command, FALSE);
    185 
    186     sprintf(command, "mount -o loop %s/mindi.rd -t ext2 %s",
     163    mr_free(command);
     164
     165    mr_asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",
    187166            bkpinfo->tmpdir, mountpt);
    188 
    189167    run_program_and_log_output(command, FALSE);
    190 
    191     sprintf(command, "mkdir -p %s/tmp", bkpinfo->tmpdir);
    192 
     168    mr_free(command);
     169
     170    mr_asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);
    193171    run_program_and_log_output(command, FALSE);
    194 
    195     sprintf(command, "cp -f %s/%s %s",  // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg
     172    mr_free(command);
     173
     174    mr_asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg
    196175            mountpt, g_mondo_cfg_file, output_cfg_file);
    197176    run_program_and_log_output(command, FALSE);
    198 
    199     sprintf(orig_fname, "%s/%s", mountpt, g_mountlist_fname);
     177    mr_free(command);
     178
     179    mr_asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);
    200180    if (does_file_exist(orig_fname)) {
    201         sprintf(command, "cp -f %s %s", orig_fname, output_mountlist_file);
     181        mr_asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);
    202182        run_program_and_log_output(command, FALSE);
    203     }
    204     sprintf(command, "umount %s", mountpt);
     183        mr_free(command);
     184    }
     185    mr_asprintf(&command, "umount %s", mountpt);
     186    mr_free(mountpt);
     187
    205188    run_program_and_log_output(command, FALSE);
     189    mr_free(command);
     190
    206191    if (!does_file_exist(output_cfg_file)
    207192        || (!does_file_exist(output_mountlist_file)
     
    213198        retval = 0;
    214199    }
    215     mr_free(mountpt);
    216     mr_free(command);
    217200    mr_free(orig_fname);
    218201    return (retval);
    219 
    220 }
    221 
    222 
     202}
    223203
    224204
     
    231211    while (get_cfg_file_from_archive(bkpinfo)) {
    232212        if (!ask_me_yes_or_no
    233             ("Failed to find config file/archives. Choose another source?"))
     213            (_
     214             ("Failed to find config file/archives. Choose another source?")))
    234215        {
    235216            fatal_error("Could not find config file/archives. Aborting.");
     
    251232
    252233  /** needs malloc **/
    253     char *command;
    254     char *file;
    255     char *tmp;
    256     int res;
    257 
    258     malloc_string(command);
    259     malloc_string(file);
    260     malloc_string(tmp);
     234    char *command = NULL;
     235    char *file = NULL;
     236    char *tmp = NULL;
     237    int res = 0;
     238
    261239    assert_string_is_neither_NULL_nor_zerolength(f);
    262240    assert_string_is_neither_NULL_nor_zerolength(list_fname);
     
    264242
    265243    if (strncmp(preamble, f, strlen(preamble)) == 0) {
    266         strcpy(file, f + strlen(preamble));
    267     } else {
    268         strcpy(file, f);
     244        mr_asprintf(&file, f + strlen(preamble));
     245    } else {
     246        mr_asprintf(&file, f);
    269247    }
    270248    if (file[0] == '/' && file[1] == '/') {
    271         strcpy(tmp, file);
    272         strcpy(file, tmp + 1);
    273     }
    274     sprintf(tmp,
    275             "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
     249        mr_asprintf(&tmp, file);
     250        mr_free(file);
     251        mr_asprintf(&file, tmp + 1);
     252        mr_free(tmp);
     253    }
     254    mr_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
    276255            f, file);
    277     mr_msg(2, tmp);
    278     sprintf(command, "grep -E '^%s$' %s", file, list_fname);
     256    mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
     257    mr_free(file);
     258
    279259    res = run_program_and_log_output(command, FALSE);
    280260    mr_free(command);
    281     mr_free(file);
    282     mr_free(tmp);
    283261    if (res) {
    284262        return (FALSE);
     
    287265    }
    288266}
    289 
    290267/**************************************************************************
    291268 *END_IS_FILE_IN_LIST                                                     *
    292269 **************************************************************************/
    293 
    294270
    295271
     
    305281int iso_fiddly_bits(struct s_bkpinfo *bkpinfo, bool nuke_me_please)
    306282{
    307     char *mount_isodir_command, *tmp, *command;
    308     int retval = 0, i;
     283    char *mount_isodir_command = NULL;
     284    char *tmp = NULL;
     285    char *command = NULL;
     286    int retval = 0, i = 0;
    309287    bool already_mounted = FALSE;
    310288
    311289    assert(bkpinfo != NULL);
    312     malloc_string(mount_isodir_command);
    313     malloc_string(tmp);
    314     malloc_string(command);
     290
    315291    g_ISO_restore_mode = TRUE;
    316292    read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    317293    if (bkpinfo->disaster_recovery) {
    318 /* Patch Conor Daly 26-june-2004
    319  * Don't let this clobber an existing bkpinfo->isodir */
    320         if (!bkpinfo->isodir[0]) {
    321             strcpy(bkpinfo->isodir, "/tmp/isodir");
     294    /* Patch Conor Daly 26-june-2004
     295    * Don't let this clobber an existing bkpinfo->isodir */
     296        if (!bkpinfo->isodir) {
     297            mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
    322298        }
    323299/* End patch */
    324         sprintf(command, "mkdir -p %s", bkpinfo->isodir);
     300        mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
    325301        run_program_and_log_output(command, 5);
     302        mr_free(command);
    326303        mr_msg(2, "Setting isodir to %s", bkpinfo->isodir);
    327304    }
     
    335312
    336313    if (is_this_device_mounted(g_isodir_device)) {
    337         log_to_screen("WARNING - isodir is already mounted");
     314        log_to_screen(_("WARNING - isodir is already mounted"));
    338315        already_mounted = TRUE;
    339316    } else {
    340         sprintf(mount_isodir_command, "mount %s", g_isodir_device);
    341317        if (strlen(g_isodir_format) > 1) {
    342             sprintf(mount_isodir_command + strlen(mount_isodir_command),
    343                     " -t %s", g_isodir_format);
    344         }
    345         strcat(mount_isodir_command, " -o ro ");
    346         strcat(mount_isodir_command, bkpinfo->isodir);
     318            mr_asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);
     319        } else {
     320            mr_asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);
     321        }
    347322        run_program_and_log_output("df -m", FALSE);
    348         sprintf(tmp,
    349                 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
     323        mr_msg(1, "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
    350324                mount_isodir_command);
    351         mr_msg(1, tmp);
    352325        if (run_program_and_log_output(mount_isodir_command, FALSE)) {
    353326            popup_and_OK
    354                 ("Cannot mount the device where the ISO files are stored.");
     327                (_
     328                 ("Cannot mount the device where the ISO files are stored."));
     329            mr_free(mount_isodir_command);
    355330            return (1);
    356331        }
     332        mr_free(mount_isodir_command);
    357333        log_to_screen
    358             ("I have mounted the device where the ISO files are stored.");
     334            (_
     335             ("I have mounted the device where the ISO files are stored."));
    359336    }
    360337    if (!IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    362339    }
    363340    i = what_number_cd_is_this(bkpinfo);    /* has the side-effect of calling mount_cdrom() */
    364     sprintf(tmp, "%s #%d has been mounted via loopback mount",
    365             media_descriptor_string(bkpinfo->backup_media_type), i);
    366     mr_msg(1, tmp);
     341    mr_msg(1, "%s #%d has been mounted via loopback mount",
     342            bkpinfo->backup_media_string, i);
    367343    if (i < 0) {
    368344        popup_and_OK
    369             ("Cannot find ISO images in the directory you specified.");
     345            (_("Cannot find ISO images in the directory you specified."));
    370346        retval = 1;
    371347    }
    372348    mr_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__,
    373349            bkpinfo->isodir);
    374     mr_free(mount_isodir_command);
    375     mr_free(tmp);
    376     mr_free(command);
    377350    return (retval);
    378351}
    379352
    380353
    381 
    382 
    383354/**
    384355 * Kill all Petris processes.
     
    386357void kill_petris(void)
    387358{
    388     char *command;
    389     malloc_string(command);
    390     sprintf(command,
     359    char *command = NULL;
     360    mr_asprintf(&command,
    391361            "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null");
    392362    paranoid_system(command);
     
    398368 **************************************************************************/
    399369
    400 
    401 /**
    402  * (Disabled) Modify rc.local to fix some things on first boot.
    403  * This function currently doesn't do anything except make sure /tmp has the
    404  * right permissions.
    405  * @param path The path to /etc on the user's filesystem.
     370/**
     371 * Mount @p device at @p mpt as @p format.
     372 * @param device The device (/dev entry) to mount.
     373 * @param mpt The directory to mount it on.
     374 * @param format The filesystem type of @p device.
     375 * @param writeable If TRUE, mount read-write; if FALSE, mount read-only.
    406376 * @return 0 for success, nonzero for failure.
    407377 */
    408 int modify_rclocal_one_time(char *path)
    409 {
    410   /** malloc **/
    411     char *rclocal_fname;
    412     char *newfile_fname;
    413     char *tmp;
    414 
    415     malloc_string(rclocal_fname);
    416     malloc_string(newfile_fname);
     378int mount_device(char *device, char *mpt, char *format, bool writeable)
     379{
     380    int res = 0;
     381
     382    char *tmp = NULL;
     383    char *command = NULL;
     384    char *mountdir = NULL;
     385    char *mountpoint = NULL;
     386    char *additional_parameters = NULL;
     387    char *p1 = NULL;
     388    char *p2 = NULL;
     389    char *p3 = NULL;
     390
     391    assert_string_is_neither_NULL_nor_zerolength(device);
     392    assert_string_is_neither_NULL_nor_zerolength(mpt);
     393    assert(format != NULL);
    417394    malloc_string(tmp);
    418     assert_string_is_neither_NULL_nor_zerolength(path);
    419 
    420     sprintf(rclocal_fname, "%s/rc.local", path);
    421 
    422 //  sprintf(tmp, "chmod 1777 %s/tmp", MNT_RESTORING);
    423 //  run_program_and_log_output( tmp, FALSE );
    424     return (0);                 /* remove this line to open the floodgates... */
    425 
    426     if (!does_file_exist(rclocal_fname)) {
    427         sprintf(rclocal_fname, "%s/rc.d/rc.local", path);
    428     }
    429     if (!does_file_exist(rclocal_fname)) {
    430         mr_free(rclocal_fname);
    431         mr_free(newfile_fname);
    432         mr_free(tmp);
    433         return (1);
    434     }
    435     sprintf(newfile_fname, "%s/rc.local.mondorescue", path);
    436     sprintf(tmp, "grep mondorescue %s > /dev/null 2> /dev/null",
    437             rclocal_fname);
    438     if (system(tmp)) {
    439         sprintf(tmp, "echo \"[ -e %s ] && %s\n\" >> %s",
    440                 newfile_fname, newfile_fname, rclocal_fname);
    441 
    442         paranoid_system(tmp);
    443     }
    444     sprintf(tmp, "echo -en \"#!/bin/sh\
    445 \\n\
    446 \\n\
    447 grep -v mondorescue %s > %s\\n\
    448 rm -f /var/lock/subsys/*xfs*\\n\
    449 rm -f /var/run/xfs.*\\n\
    450 killall xfs\\n\
    451 service xfs start\\n\
    452 yes | rm -f %s\\n\
    453 \" > %s", rclocal_fname, rclocal_fname, newfile_fname, newfile_fname);
    454     sprintf(tmp, "chmod +x \"%s\"", newfile_fname);
    455     run_program_and_log_output(tmp, FALSE);
    456     mr_free(rclocal_fname);
    457     mr_free(newfile_fname);
     395    malloc_string(command);
     396    malloc_string(mountdir);
     397    malloc_string(additional_parameters);
     398
     399    if (!strcmp(mpt, "/1")) {
     400        mr_asprintf(&mountpoint, "/");
     401        mr_msg(3, "Mommm! SME is being a dildo!");
     402    } else {
     403        mr_asprintf(&mountpoint, mpt);
     404    }
     405
     406    if (!strcmp(mountpoint, "lvm")) {
     407        mr_free(mountpoint);
     408        return (0);
     409    }
     410    if (!strcmp(mountpoint, "image")) {
     411        mr_free(mountpoint);
     412        return (0);
     413    }
     414    sprintf(tmp, "Mounting device %s   ", device);
     415    mr_msg(1, tmp);
     416    if (writeable) {
     417        strcpy(additional_parameters, "-o rw");
     418    } else {
     419        strcpy(additional_parameters, "-o ro");
     420    }
     421    if (find_home_of_exe("setfattr")) {
     422        strcat(additional_parameters, ",user_xattr");
     423    }
     424    if (find_home_of_exe("setfacl")) {
     425        strcat(additional_parameters, ",acl");
     426    }
     427
     428    if (!strcmp(mountpoint, "swap")) {
     429        sprintf(command, "swapon %s", device);
     430    } else {
     431        if (!strcmp(mountpoint, "/")) {
     432            strcpy(mountdir, MNT_RESTORING);
     433        } else {
     434            sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
     435        }
     436        sprintf(command, "mkdir -p %s", mountdir);
     437        run_program_and_log_output(command, FALSE);
     438        sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device,
     439                additional_parameters, mountdir, MONDO_LOGFILE);
     440        mr_msg(2, "command='%s'", command);
     441    }
     442    res = run_program_and_log_output(command, TRUE);
     443    if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
     444        mr_msg(1, "Re-trying without the fancy extra parameters");
     445        sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
     446                mountdir, MONDO_LOGFILE);
     447        res = run_program_and_log_output(command, TRUE);
     448    }
     449    if (res) {
     450        mr_msg(1, "Unable to mount device %s (type %s) at %s", device,
     451                format, mountdir);
     452        mr_msg(1, "command was '%s'", command);
     453        if (!strcmp(mountpoint, "swap")) {
     454            log_to_screen(tmp);
     455        } else {
     456            mr_msg(2, "Retrying w/o the '-t' switch");
     457            sprintf(command, "mount %s %s 2>> %s", device, mountdir,
     458                    MONDO_LOGFILE);
     459            mr_msg(2, "2nd command = '%s'", command);
     460            res = run_program_and_log_output(command, TRUE);
     461            if (res == 0) {
     462                mr_msg(1,
     463                        "That's OK. I called mount w/o a filesystem type and it worked fine in the end.");
     464            } else {
     465                log_to_screen(tmp);
     466            }
     467        }
     468    }
     469    if (res && !strcmp(mountpoint, "swap")) {
     470        mr_msg(2, "That's ok. It's just a swap partition.");
     471        mr_msg(2, "Non-fatal error. Returning 0.");
     472        res = 0;
     473    }
     474
    458475    mr_free(tmp);
    459     return (0);
     476    mr_free(command);
     477    mr_free(mountdir);
     478    mr_free(mountpoint);
     479    mr_free(additional_parameters);
     480
     481    return (res);
    460482}
    461483
    462484/**************************************************************************
    463  *END_ MODIFY_RCLOCAL_ONE_TIME                                            *
     485 *END_MOUNT_DEVICE                                                        *
    464486 **************************************************************************/
    465 
    466487
    467488
     
    690711 *END_MOUNT_CDROM                                                         *
    691712 **************************************************************************/
    692 
    693 
    694 /**
    695  * Mount @p device at @p mpt as @p format.
    696  * @param device The device (/dev entry) to mount.
    697  * @param mpt The directory to mount it on.
    698  * @param format The filesystem type of @p device.
    699  * @param writeable If TRUE, mount read-write; if FALSE, mount read-only.
    700  * @return 0 for success, nonzero for failure.
    701  */
    702 int mount_device(char *device, char *mpt, char *format, bool writeable)
    703 {
    704     int res = 0;
    705 
    706   /** malloc **/
    707     char *tmp, *command, *mountdir, *mountpoint, *additional_parameters;
    708 
    709     assert_string_is_neither_NULL_nor_zerolength(device);
    710     assert_string_is_neither_NULL_nor_zerolength(mpt);
    711     assert(format != NULL);
    712     malloc_string(tmp);
    713     malloc_string(command);
    714     malloc_string(mountdir);
    715     malloc_string(mountpoint);
    716     malloc_string(additional_parameters);
    717 
    718     if (!strcmp(mpt, "/1")) {
    719         strcpy(mountpoint, "/");
    720         mr_msg(3, "Mommm! SME is being a dildo!");
    721     } else {
    722         strcpy(mountpoint, mpt);
    723     }
    724 
    725     if (!strcmp(mountpoint, "lvm")) {
    726         return (0);
    727     }
    728     if (!strcmp(mountpoint, "image")) {
    729         return (0);
    730     }
    731     sprintf(tmp, "Mounting device %s   ", device);
    732     mr_msg(1, tmp);
    733     if (writeable) {
    734         strcpy(additional_parameters, "-o rw");
    735     } else {
    736         strcpy(additional_parameters, "-o ro");
    737     }
    738     if (find_home_of_exe("setfattr")) {
    739         strcat(additional_parameters, ",user_xattr");
    740     }
    741     if (find_home_of_exe("setfacl")) {
    742         strcat(additional_parameters, ",acl");
    743     }
    744 
    745     if (!strcmp(mountpoint, "swap")) {
    746         sprintf(command, "swapon %s", device);
    747     } else {
    748         if (!strcmp(mountpoint, "/")) {
    749             strcpy(mountdir, MNT_RESTORING);
    750         } else {
    751             sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
    752         }
    753         sprintf(command, "mkdir -p %s", mountdir);
    754         run_program_and_log_output(command, FALSE);
    755         sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device,
    756                 additional_parameters, mountdir, MONDO_LOGFILE);
    757         mr_msg(2, "command='%s'", command);
    758     }
    759     res = run_program_and_log_output(command, TRUE);
    760     if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
    761         mr_msg(1, "Re-trying without the fancy extra parameters");
    762         sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
    763                 mountdir, MONDO_LOGFILE);
    764         res = run_program_and_log_output(command, TRUE);
    765     }
    766     if (res) {
    767         mr_msg(1, "Unable to mount device %s (type %s) at %s", device,
    768                 format, mountdir);
    769         mr_msg(1, "command was '%s'", command);
    770         if (!strcmp(mountpoint, "swap")) {
    771             log_to_screen(tmp);
    772         } else {
    773             mr_msg(2, "Retrying w/o the '-t' switch");
    774             sprintf(command, "mount %s %s 2>> %s", device, mountdir,
    775                     MONDO_LOGFILE);
    776             mr_msg(2, "2nd command = '%s'", command);
    777             res = run_program_and_log_output(command, TRUE);
    778             if (res == 0) {
    779                 mr_msg(1,
    780                         "That's OK. I called mount w/o a filesystem type and it worked fine in the end.");
    781             } else {
    782                 log_to_screen(tmp);
    783             }
    784         }
    785     }
    786     if (res && !strcmp(mountpoint, "swap")) {
    787         mr_msg(2, "That's ok. It's just a swap partition.");
    788         mr_msg(2, "Non-fatal error. Returning 0.");
    789         res = 0;
    790     }
    791 
    792     mr_free(tmp);
    793     mr_free(command);
    794     mr_free(mountdir);
    795     mr_free(mountpoint);
    796     mr_free(additional_parameters);
    797 
    798     return (res);
    799 }
    800 
    801 /**************************************************************************
    802  *END_MOUNT_DEVICE                                                        *
    803  **************************************************************************/
    804 
    805713
    806714
Note: See TracChangeset for help on using the changeset viewer.