Ignore:
Timestamp:
Sep 28, 2009, 2:29:12 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Attempt to stay backward compatible without protocol for -n option
  • Improving ssh support at restore time by providing a shadow file
  • analyze-my-lvm now removes excluded devices from list coming from mondoarchive
  • new mr_make_devlist_from_pathlist which handle the new bkpinfo->exclude_devs field containing the excluded devices and remove corresponding code from libmondo-cli.c
  • Move DSF code into libmondo-devices.c for coherency, and only the previous function is made externally available
  • Remove dev_to_exclude in libmondo-archive.c which wasn't working correctly and replace it with bkpinfo->exclude_devs
  • Fix an issue in is_this_device_mounted (string freed before last usage)
  • Adds support for bnx2x (BL 460 G6) and auth_rpcgss (Debian 2.6.31)

(Backport from 2.2.9)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2405 r2428  
    3838
    3939extern void setup_tmpdir(char *path);
     40void mr_make_devlist_from_pathlist(char *pathlist, char mode);
    4041extern double g_kernel_version;
    4142extern int g_current_media_number;
    4243extern pid_t g_main_pid;
    4344extern char *resolve_softlinks_to_get_to_actual_device_file(char *);
    44 
    45 /* Stuff that handles the -I and -E option when a whole disk DSF is used */
    46 typedef struct mounted_fs_struct {
    47     char device[MAX_STR_LEN];       /* The name of the device */
    48     char mount_point[MAX_STR_LEN];  /* The devices mount point */
    49     unsigned char check;            /* 1 == included on DSF */
    50     struct mounted_fs_struct *next;
    51 } MOUNTED_FS_STRUCT;
    52 static MOUNTED_FS_STRUCT *DSF_Head = NULL;      /* Points to the first entry of mounted_fs_struct list */
    53 static MOUNTED_FS_STRUCT *DSF_Tail = NULL;      /* Points to the last entry of mounted_fs_struct list */
    54 static void add_mounted_fs_struct (MOUNTED_FS_STRUCT *DSFptr);
    55 static void free_mounted_fs_list (void);
    56 static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list);
    57 static int create_list_of_non_NETFS_mounted_file_systems (void);
    58 static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point);
    59 static MOUNTED_FS_STRUCT *find_device_in_list (const char *device);
    6045
    6146/* Do we use extended attributes and acl ?
     
    161146
    162147/**
    163  * Frees the memory for all of the structures on the linked list of
    164  * all of the non-NETFS mounted file systems.
    165  */
    166 static void free_mounted_fs_list (void) {
    167     MOUNTED_FS_STRUCT *DSFptr = NULL;
    168     MOUNTED_FS_STRUCT *DSFnext = NULL;
    169  
    170     DSFptr = DSF_Head;
    171     while (DSFptr != NULL) {
    172         DSFnext = DSFptr->next;
    173         mr_free(DSFptr);
    174         DSFptr = DSFnext;
    175     }
    176     DSF_Head = NULL;
    177     DSF_Tail = NULL;
    178 }
    179 
    180 /**
    181  * Creates a singly linked list of all of the non-NETFS mounted file systems.
    182  * @param DSFptr A pointer  to the structure MOUNTED_FS_STRUCT used to hold
    183  * the list of mounted file systems.
    184  * @return None.
    185  */
    186 static void add_mounted_fs_struct (MOUNTED_FS_STRUCT *DSFptr)
    187 {
    188     assert (DSFptr);
    189     if (DSF_Head == NULL) {
    190         DSF_Head = DSFptr;
    191     } else {
    192         DSF_Tail->next = DSFptr;
    193     }
    194     DSFptr->next = NULL;
    195     DSF_Tail = DSFptr;
    196 }
    197 
    198 /**
    199  * Find the structure, in the singly linked list of all of the non-NETFS
    200  * mounted file systems, that contains the specified device.
    201  * @param device The device to find
    202  * @return NULL if it didn't find the device, a pointer to the
    203  * structure if it did.
    204  */
    205 static MOUNTED_FS_STRUCT *find_device_in_list (const char *device)
    206 {
    207     MOUNTED_FS_STRUCT *DSFptr = NULL;
    208 
    209     DSFptr = DSF_Head;
    210     while (DSFptr != NULL) {
    211         if (!strcmp(DSFptr->device, device)) {
    212             break;
    213         }
    214         DSFptr = DSFptr->next;
    215     }
    216     return (DSFptr);
    217 }
    218 
    219 /**
    220  * Find the structure, in the singly linked list of all of the non-NETFS
    221  * mounted file systems, that contains the specified mount point.
    222  * @param mount_point The mount point to find
    223  * @return NULL is it didn't find the mount point, a pointer to the
    224  * structure if it did.
    225  */
    226 static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point)
    227 {
    228     MOUNTED_FS_STRUCT *DSFptr = NULL;
    229 
    230     DSFptr = DSF_Head;
    231     while (DSFptr != NULL) {
    232         if (!strcmp(DSFptr->mount_point, mount_point)) {
    233             break;
    234         }
    235         DSFptr = DSFptr->next;
    236     }
    237     return (DSFptr);
    238 }
    239 
    240 /**
    241  * Creates a linked list of all of the non-NETFS mounted file systems.
    242  * We use a linked list because we don't know how many  mounted file
    243  * there are (and there can be a lot).
    244  * @return 0 on success and greated than 0 on failure.
    245  */
    246 static int create_list_of_non_NETFS_mounted_file_systems (void)
    247 {
    248     int i = 0;
    249     int mount_cnt = 0;
    250     char *mounted_file_system = NULL;
    251     char *command = NULL;
    252     char *token = NULL;
    253     char token_chars[] =" :\t\r\f\a\0";
    254     MOUNTED_FS_STRUCT *DSFptr = NULL;
    255 
    256     free_mounted_fs_list();
    257     /********
    258     * Find the number of mounted file system entries and their respective mount points.
    259     * I can't return all of the entries as one string because it's length can be longer
    260     * than MAX_STR_LEN which is used in call_program_and_get_last_line_of_output().
    261     * So start looping and get the number of  mounted file systems and query them one by one.
    262     ********/
    263     /* Get the number of mounted file systems ((those that start with "/dev/" */
    264     mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
    265     log_msg(5, "Running: %s", command);
    266     mounted_file_system = call_program_and_get_last_line_of_output(command);
    267     mr_free(command);
    268 
    269     mount_cnt = atoi(mounted_file_system);
    270     log_msg (5, "mount_cnt: %d", mount_cnt);
    271     mr_free(mounted_file_system);
    272 
    273     for (i=mount_cnt; i > 0; i--) {
    274         mr_asprintf(command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
    275         log_msg(5, "Running: %s", command);
    276         mounted_file_system = call_program_and_get_last_line_of_output(command);
    277         mr_free(command);
    278 
    279         log_msg (5, "mounted_file_system: %s", mounted_file_system);
    280         if ((token = strtok(mounted_file_system, token_chars)) == NULL) {
    281             log_msg (4, "Could not get the list of mounted file systems");
    282             mr_free(mounted_file_system);
    283             mr_free(token);
    284             return (1);
    285         }
    286         if (token) {
    287             log_msg (5, "token: %s", token);
    288         }
    289         while (token != NULL) {
    290             log_msg (5, "token: %s", token);
    291             if ((DSFptr = (MOUNTED_FS_STRUCT *) calloc(1, sizeof(MOUNTED_FS_STRUCT))) == NULL) {
    292                 fatal_error ("Cannot allocate memory");
    293             }
    294             add_mounted_fs_struct(DSFptr);
    295             strcpy(DSFptr->device, token);
    296             mr_free(token);
    297             if ((token = strtok(NULL, token_chars)) == NULL) {
    298                 log_msg (5, "Ran out of entries on the mounted file systems list");
    299                 mr_free(mounted_file_system);
    300                 mr_free(token);
    301                 return (1);
    302             }
    303             log_msg (5, "token: %s", token);
    304             strcpy(DSFptr->mount_point, token);
    305             mr_free(token);
    306             token = strtok(NULL, token_chars);
    307         }
    308         mr_free(mounted_file_system);
    309     }
    310     /********
    311     * DSFptr = DSF_Head;
    312     * while (DSFptr != NULL) {
    313     * printf ("Dev: %s  MP: %s  Check: %d\n", DSFptr->device, DSFptr->mount_point, DSFptr->check);
    314     * DSFptr = DSFptr->next;
    315     * }
    316     ********/
    317     return (0);
    318 }
    319 
    320 /**
    321  * Given a whole disk device special file, determine which mounted file systems
    322  * are on the dsf's partitions and which mounted file systems are not.
    323  * @param dsf The whole disk device special file.
    324  * @param included_dsf_list A char pointer used to hold the list of mount points
    325  * that are on the dsf. Memory for the array will be allocated within the function.
    326  * @param excluded_dsf_list A char pointer used to hold the list of mount points
    327  * that are not on the dsf. Memory for the array will be allocated within the function.
    328  * @return 0 on success, -1 if no device special file was passed in, -2 if a device
    329  * special file was passed in but it has no partitions on it, or 1 on failure
    330  */
    331 static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list) {
    332     int i = 0;
    333     int c = 0;
    334     int lastpos = 0;
    335     char *VG = NULL;
    336     char *tmp = NULL;
    337     char *command = NULL;
    338     char *partition_list = NULL;
    339     char partitions[64][MAX_STR_LEN];
    340     char *mount_list = NULL;
    341     char *token = NULL;
    342     char token_chars[] =" \t\r\f\a\0";
    343     MOUNTED_FS_STRUCT *DSFptr = NULL;
    344 
    345     memset((char *)partitions, 0, sizeof(partitions));
    346 
    347     log_msg(5, "dsf: %s", dsf);
    348 
    349     /********
    350     * See if a device special file was passed in (i.e. it must start with /dev/
    351     ********/
    352     if (strncmp(dsf, "/dev/", 5)) {
    353         log_msg (5, "%s does not start with /dev/ and (probably) is not a  device special file", dsf);
    354         return (-1);
    355     }
    356     log_msg(5, "  %s looks like a device special file", dsf);
    357     /* Verify that the dsf exists */
    358     mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf);
    359     log_msg(5, "  Executing: %s", command);
    360     tmp = call_program_and_get_last_line_of_output(command);
    361     mr_free(command);
    362 
    363     log_msg(5, "  Return value: %s", tmp);
    364     c = atoi(tmp);
    365     mr_free(tmp);
    366 
    367     if (!c) {
    368         log_to_screen("Cannot find device special file %s", dsf);
    369         return (1);
    370     }
    371     log_msg(5, "  %s device special file exists", dsf);
    372 
    373     /* Get a list of the mounted file systems */
    374     if (create_list_of_non_NETFS_mounted_file_systems()) {
    375         log_to_screen ("Could not get the list of mounted file systems");
    376         return (1);
    377     }
    378     log_msg (5, "Processing dsf: %s", dsf);
    379     /********
    380     * Get a list of the dsf's partitions. There could be no partitions on the disk
    381     * or a dsf of a partition was passed in (e.g. /dev/sda1 instead of /dev/sda).
    382     * Either way, it's an error.
    383     ********/
    384     mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    385     log_msg(4, "Executing: %s", command);
    386     partition_list = call_program_and_get_last_line_of_output(command);
    387     mr_free(command);
    388     log_msg(4, "Partition list for %s: %s", dsf, partition_list);
    389     if (!strlen(partition_list)) {
    390         /* There were no partitions on the disk */
    391         log_msg(4, "Cannot find any partitions on device special file %s", dsf);
    392         return (-2);
    393     }
    394 
    395     /* Fill the partition list */
    396     i = 0;
    397     lastpos = 0;
    398     while ((token = mr_strtok(partition_list, token_chars, &lastpos)) != NULL) {
    399         log_msg (5, "Found partition: %s", token);
    400         strcpy(partitions[i++], token);
    401         mr_free(token);
    402     }
    403     mr_free(partition_list);
    404  
    405     /********
    406      * At this point, we have a list of all of the partitions on the dsf. Now try to
    407      * see which partitions have a file system on them.
    408      *
    409      * Loop through each partition on the disk and:
    410      *
    411      * - If the partition is swap, it ignores it.
    412      *
    413      * - If the partition is mounted (e.g. /dev/sda1 is mounted on /boot), it adds an entry
    414      *  to the linked list, copies to it the device name and mount point, and sets check == 1.
    415      *
    416      * - If the partition is part of a Volume Group that has Logical Volumes mounted, it adds
    417      *  an entry to the linked list for each mounted Logical Volume in that Volume Group, copying
    418      *  to it the device name and mount point, and sets check == 1. Note that if the Volume Group
    419      *  contains more than one disk, it will still add the entry even if the Logical Volume's
    420      *  extents are not on the dsf that was passed in to the function. For example, Volume Group
    421      *  VolGroup00 contains the disks /dev/sda1 and /dev/sdb1, and the Logical Volumes LogVol01,
    422      *  which is mounted on /var and has all of its extents on /dev/sda1, and LogVol02, which is
    423      *  mounted as /usr and has all of its extents on /dev/sdb1. If you pass /dev/sda into the
    424      *  function, both /var and /usr will be archived even though /usr is actually on/dev/sdb.
    425      *
    426      * - If the partition is part of a Volume Group that has Logical Volumes used in a mounted
    427      *  software raid device, it adds an entry to the linked list, copies to it the software raid
    428      *  device name and mount point, and sets check == 1.
    429      *
    430      * - If the partition is part of a mounted software raid device, it adds an entry to the linked
    431      *  list, copies to it the software raid device name and mount point, and sets check == 1.
    432      *
    433      ********/
    434     for (i=0; strlen(partitions[i]); i++) {
    435         log_msg(4, "Processing partition: %s", partitions[i]);
    436         /* See if it's swap. If it is, ignore it. */
    437         mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
    438           dsf, partitions[i]);
    439         log_msg(4, "  Running: %s", command);
    440         tmp = call_program_and_get_last_line_of_output(command);
    441         mr_free(command);
    442 
    443         log_msg(4, "  Return value: %s", tmp);
    444         c = strlen(tmp);
    445         mr_free(tmp);
    446 
    447         if (c) {
    448             log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
    449             continue;
    450         }
    451         /* It's not swap. See if we can find the mount point from the mount command. */
    452         mr_asprintf(command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    453         tmp = call_program_and_get_last_line_of_output(command);
    454         mr_free(command);
    455 
    456         if (strlen(tmp)) {
    457             log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
    458             if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
    459                 log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
    460                 mr_free(tmp);
    461                 return (1);
    462             }
    463             DSFptr->check = 1;
    464             mr_free(tmp);
    465             continue;
    466         }
    467         mr_free(tmp);
    468         /* It's not swap and it's not mounted. See if it's LVM */
    469         log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
    470         /* Get the partition ID; 8e for LVM */
    471         mr_asprintf(command, "parted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
    472         log_msg(4, "  Running: %s", command);
    473         tmp = call_program_and_get_last_line_of_output(command);
    474         mr_free(command);
    475         if (strlen(tmp)) {
    476             log_msg(4, "  Partition ID: %s", tmp);
    477             if (!strcasecmp(tmp, "8e")) {
    478                 /* It's LVM: Find the VG it's in */
    479                 log_msg(4, "  It's LVM: Find the VG it's in...");
    480                 mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    481                 log_msg(4, "  Running: %s", command);
    482                 VG = call_program_and_get_last_line_of_output(command);
    483                 mr_free(command);
    484                 log_msg(4, "  Volume Group: %s", VG);
    485                 if (strlen(VG)) {
    486                     /* Found the Volume Group. Now find all of the VG's mount points */
    487                     log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
    488                     mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
    489                     log_msg(4, "  Running: %s", command);
    490                     mount_list = call_program_and_get_last_line_of_output(command);
    491                     mr_free(command);
    492 
    493                     log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    494                     lastpos = 0;
    495                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    496                         log_msg (5, "mount point token: %s", token);
    497                         if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    498                             log_msg (4, "Can't find mount point %s in mounted file systems list", token);
    499                             mr_free(tmp);
    500                             mr_free(token);
    501                             mr_free(VG);
    502                             return (1);
    503                         }
    504                         DSFptr->check = 1;
    505                         mr_free(token);
    506                     }
    507                     /********
    508                      * Now we want to see if there are any software raid devices using
    509                      * any of the Logical Volumes on the Volume Group.
    510                      *******/
    511                     mr_free(mount_list);
    512                     mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    513                     log_msg (5, "Running: %s", command);
    514                     mount_list = call_program_and_get_last_line_of_output(command);
    515                     mr_free(command);
    516                     log_msg(4, "  Software raid device list: %s", mount_list);
    517                     lastpos = 0;
    518                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    519                         mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    520                         log_msg (5, "Running: %s", command);
    521                         mr_free(tmp);
    522 
    523                         tmp = call_program_and_get_last_line_of_output(command);
    524                         mr_free(command);
    525 
    526                         log_msg(4, "Number of Software raid device: %s", tmp);
    527                         if (atoi(tmp)) {
    528                             /* This device is on our disk */
    529                             if ((DSFptr = find_device_in_list(token)) == NULL) {
    530                                 log_msg (4, "Can't find device %s in mounted file systems list", token);
    531                                 mr_free(tmp);
    532                                 mr_free(token);
    533                                 mr_free(VG);
    534                                 return (1);
    535                             }
    536                             DSFptr->check = 1;
    537                         }
    538                         mr_free(token);
    539                     }
    540                     mr_free(mount_list);
    541                 } else {
    542                     log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    543                     mr_free(tmp);
    544                     mr_free(VG);
    545                     return (1);
    546                 }
    547                 mr_free(tmp);
    548                 mr_free(VG);
    549                 continue;
    550             }
    551         } else {
    552             log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
    553         }
    554         mr_free(tmp);
    555         /********
    556          * It's not swap, mounted, or LVM. See if it's used in a software raid device.
    557          ********/
    558         log_msg (5, "It's not swap, mounted, or LVM. See if it's used in a software raid device.");
    559         mr_asprintf(command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
    560         log_msg(4, "  Running: %s", command);
    561         tmp = call_program_and_get_last_line_of_output(command);
    562         mr_free(command);
    563         if (!strlen(tmp)) {
    564             log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
    565             mr_free(tmp);
    566             continue;
    567         }
    568         log_msg (5, "  UUID: %s", tmp);
    569         /* Get the Software raid device list */
    570         mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    571         log_msg (5, "  Running: %s", command);
    572         mount_list = call_program_and_get_last_line_of_output(command);
    573         mr_free(command);
    574         log_msg(4, "  Software raid device list: %s", mount_list);
    575         /* Loop through the software raid device list to see if we can find the partition */
    576         lastpos = 0;
    577         while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    578             mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    579             log_msg(4, "  Running: %s", command);
    580             mr_free(tmp);
    581             tmp = call_program_and_get_last_line_of_output(command);
    582             mr_free(command);
    583             if (!atoi(tmp)) {
    584                 log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
    585             } else {
    586                 if ((DSFptr = find_device_in_list(token)) == NULL) {
    587                     log_msg (4, "Can't find device %s in mounted file systems list", token);
    588                     mr_free(tmp);
    589                     mr_free(token);
    590                     return (1);
    591                 }
    592                 DSFptr->check = 1;
    593                 break;
    594             }
    595             mr_free(token);
    596         }
    597         mr_free(tmp);
    598     }
    599     mr_free(partition_list);
    600     mr_free(mount_list);
    601 
    602     /* Determine how much memory to allocate for included_dsf_list and excluded_dsf_list */
    603     i = 0;
    604     DSFptr= DSF_Head;
    605     while (DSFptr != NULL) {
    606         i += strlen(DSFptr->mount_point) + 1;
    607         DSFptr = DSFptr->next;
    608     }
    609     log_msg (5, "i: %d", i);
    610     if ((*included_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
    611         fatal_error ("Cannot allocate memory");
    612     }
    613     if ((*excluded_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
    614         fatal_error ("Cannot allocate memory");
    615     }
    616     DSFptr= DSF_Head;
    617     while (DSFptr != NULL) {
    618         if (DSFptr->check) {
    619             log_msg (5, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
    620             strcat(*included_dsf_list, DSFptr->mount_point);
    621             strcat(*included_dsf_list, " ");
    622         } else {
    623             log_msg (4, "%s is mounted on %s and is NOT on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
    624             strcat(*excluded_dsf_list, DSFptr->mount_point);
    625             strcat(*excluded_dsf_list, " ");
    626         }
    627         DSFptr = DSFptr->next;
    628     }
    629     log_msg (5, "included_dsf_list: %s", *included_dsf_list);
    630     log_msg (5, "excluded_dsf_list: %s", *excluded_dsf_list);
    631     return (0);
    632 }
    633 
    634 
    635 /**
    636148 * Process mondoarchive's command-line switches.
    637149 * @param bkpinfo The backup information structure to populate.
     
    659171    char *p = NULL;
    660172    char *q = NULL;
    661     char *token = NULL;
    662     char *mounted_on_dsf = NULL;
    663     char *not_mounted_on_dsf = NULL;
    664     char token_chars[] =" \t\r\f\a\0";
    665173
    666174    long itbs = 0L;
     
    777285        }
    778286        mr_free(tmp1);
    779         while ((token = mr_strtok(flag_val['I'], token_chars, &lastpos)) != NULL) {
    780             switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
    781             /* It's a dsf but not a whole disk dsf */
    782             case -2:
    783                 log_to_screen("Could %s be a partition instead of a whole disk device special file?\n Ignored.", token);
    784                 break;
    785             /* Fatal error; exit */
    786             case 1:
    787                 mr_free(token);
    788                 fatal_error("Error processing -I option");
    789             /* Everything is OK; process to archive data */
    790             case 0:
    791                 log_to_screen("Archiving only the following file systems on %s:\n", token);
    792                 log_to_screen("  %s\n", mounted_on_dsf);
    793                 mr_asprintf(p, "/");
    794                 mr_free(bkpinfo->include_paths);
    795                 bkpinfo->include_paths = p;
    796                 if (strlen(not_mounted_on_dsf)) {
    797                     log_msg (5, "Adding to bkpinfo->exclude_paths due to -I option: %s", not_mounted_on_dsf);
    798                     log_to_screen("Not archiving the following file systems:\n");
    799                     log_to_screen("  %s\n", not_mounted_on_dsf);
    800                     mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf);
    801                 }
    802                 break;
    803             /* A device special file was not passed in. Process it as a path. */
    804             case -1:
    805                 mr_strcat(bkpinfo->include_paths, " %s ", token);
    806                 break;
    807             }
    808             mr_free(token);
    809         }
    810         if (bkpinfo->include_paths != NULL) {
    811             mr_strip_spaces(bkpinfo->include_paths);
    812             log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
    813         }
    814         if (bkpinfo->exclude_paths != NULL) {
    815             mr_strip_spaces(bkpinfo->exclude_paths);
    816             log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
    817         }
     287        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    818288        log_msg(4, "Finished with the -I option");
    819289    }
     
    978448        }
    979449        /* test for protocol */
    980         p = strchr(bkpinfo->netfs_mount, ':');
     450        p = strstr(bkpinfo->netfs_mount, "://");
    981451        if (p == NULL) {
    982             /* protocol not found abort */
    983             fatal_error("No protocol specified for remote share mount. Please do man mondoarchive as syntax changed");
     452            /* protocol not found assuming NFS for compatibility */
     453            mr_asprintf(q,"nfs");
     454
     455            p = strchr(bkpinfo->netfs_mount, ':');
     456            if (p == NULL) {
     457                fatal_error("No protocol specified for remote share mount, nor any old NFS syntax found.\nPlease do man mondoarchive as syntax changed");
     458            }
     459            /* p points on to the string server:/path */
     460            p = bkpinfo->netfs_mount;
     461
    984462        } else {
    985             /* Proto found. Store the 2 values */
    986             bkpinfo->netfs_proto = bkpinfo->netfs_mount;
     463            /* Isolate the protocol */
     464            *p = '\0';
     465            mr_asprintf(q,"%s",bkpinfo->netfs_mount);
     466
     467            /* Skip proto now */
    987468            p++;
    988             if (*p != '/') {
    989                 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share");
    990             }
    991469            p++;
    992             if (*p != '/') {
    993                 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share");
    994             }
    995470            p++;
    996             /* p points on to the string server:/path */
    997             bkpinfo->netfs_mount = p;
    998 
    999             /* new netfs mount - remove :// from proto */
    1000             /* going back to protocol */
    1001             p--;
    1002             p--;
    1003             p--;
    1004             *p = '\0';
    1005         }
     471        }
     472        /* whatever done before proto is pointed to by q */
     473        bkpinfo->netfs_proto = q;
     474
     475        /* p points on to the string server:/path */
     476        /* Store the 2 values */
     477        bkpinfo->netfs_mount = p;
     478
    1006479        /* test if we specified a user */
    1007480        p = strchr(bkpinfo->netfs_mount, '@');
     
    1134607        mr_free(tmp1);
    1135608        lastpos = 0;
    1136         while ((token = mr_strtok(flag_val['E'], token_chars, &lastpos)) != NULL) {
    1137             switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
    1138             case 1:
    1139                 log_msg(1, "WARNING ! a path doesn't exist in -E option");
    1140                 break;
    1141             /* Everything is OK; proceed to archive data */
    1142             case 0:
    1143                 if (strlen(mounted_on_dsf)) {
    1144                     log_to_screen("Excluding the following file systems on %s:\n", token);
    1145                     log_to_screen("  %s\n", mounted_on_dsf);
    1146                     log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf);
    1147                     mr_strcat(bkpinfo->exclude_paths, " %s ", mounted_on_dsf);
    1148                 }
    1149                 break;
    1150             /* It's a dsf but not a whole disk dsf */
    1151             case -2:
    1152                 log_to_screen("Could %s be a partition instead of a whole disk device special file?\nIgnored.", token);
    1153                 break;
    1154             /* A device special file was not passed in. Process it as a path. */
    1155             case -1:
    1156                 mr_strcat(bkpinfo->exclude_paths, " %s ", token);
    1157                 break;
    1158             }
    1159             mr_free(token);
    1160         }
    1161         if (bkpinfo->exclude_paths != NULL) {
    1162             log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
    1163         }
     609
     610        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
    1164611        log_msg(4, "Finished with the -E option");
    1165612    }
Note: See TracChangeset for help on using the changeset viewer.