Ignore:
Timestamp:
Sep 25, 2009, 6:44:01 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • 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
File:
1 edited

Legend:

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

    r2388 r2424  
    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 (char *mount_point);
    59 static MOUNTED_FS_STRUCT *find_device_in_list (char *device);
    6045
    6146/* Do we use extended attributes and acl ?
     
    177162
    178163/**
    179  * Frees the memory for all of the structures on the linked list of
    180  * all of the non-NETFS mounted file systems.
    181  */
    182 static void free_mounted_fs_list (void) {
    183     MOUNTED_FS_STRUCT *DSFptr = NULL;
    184     MOUNTED_FS_STRUCT *DSFnext = NULL;
    185  
    186     DSFptr = DSF_Head;
    187     while (DSFptr != NULL) {
    188         DSFnext = DSFptr->next;
    189         paranoid_free(DSFptr);
    190         DSFptr = DSFnext;
    191     }
    192     DSF_Head = NULL;
    193     DSF_Tail = NULL;
    194 }
    195 
    196 /**
    197  * Creates a singly linked list of all of the non-NETFS mounted file systems.
    198  * @param DSFptr A pointer  to the structure MOUNTED_FS_STRUCT used to hold
    199  * the list of mounted file systems.
    200  * @return None.
    201  */
    202 static void add_mounted_fs_struct (MOUNTED_FS_STRUCT *DSFptr)
    203 {
    204     assert (DSFptr);
    205     if (DSF_Head == NULL) {
    206         DSF_Head = DSFptr;
    207     } else {
    208         DSF_Tail->next = DSFptr;
    209     }
    210     DSFptr->next = NULL;
    211     DSF_Tail = DSFptr;
    212 }
    213 
    214 /**
    215  * Find the structure, in the singly linked list of all of the non-NETFS
    216  * mounted file systems, that contains the specified device.
    217  * @param device The device to find
    218  * @return NULL if it didn't find the device, a pointer to the
    219  * structure if it did.
    220  */
    221 static MOUNTED_FS_STRUCT *find_device_in_list (char *device)
    222 {
    223     MOUNTED_FS_STRUCT *DSFptr = NULL;
    224 
    225     DSFptr = DSF_Head;
    226     while (DSFptr != NULL) {
    227         if (!strcmp(DSFptr->device, device)) {
    228             break;
    229         }
    230         DSFptr = DSFptr->next;
    231     }
    232     return (DSFptr);
    233 }
    234 
    235 /**
    236  * Find the structure, in the singly linked list of all of the non-NETFS
    237  * mounted file systems, that contains the specified mount point.
    238  * @param mount_point The mount point to find
    239  * @return NULL is it didn't find the mount point, a pointer to the
    240  * structure if it did.
    241  */
    242 static MOUNTED_FS_STRUCT *find_mount_point_in_list (char *mount_point)
    243 {
    244     MOUNTED_FS_STRUCT *DSFptr = NULL;
    245 
    246     DSFptr = DSF_Head;
    247     while (DSFptr != NULL) {
    248         if (!strcmp(DSFptr->mount_point, mount_point)) {
    249             break;
    250         }
    251         DSFptr = DSFptr->next;
    252     }
    253     return (DSFptr);
    254 }
    255 
    256 /**
    257  * Creates a linked list of all of the non-NETFS mounted file systems.
    258  * We use a linked list because we don't know how many  mounted file
    259  * there are (and there can be a lot).
    260  * @return 0 on success and greated than 0 on failure.
    261  */
    262 static int create_list_of_non_NETFS_mounted_file_systems (void)
    263 {
    264     int i = 0;
    265     int mount_cnt = 0;
    266     char *mounted_file_system = NULL;
    267     char *command = NULL;
    268     char *token = NULL;
    269     char token_chars[] =" :\t\r\f\a\0";
    270     MOUNTED_FS_STRUCT *DSFptr = NULL;
    271 
    272     free_mounted_fs_list();
    273     /********
    274     * Find the number of mounted file system entries and their respective mount points.
    275     * I can't return all of the entries as one string because it's length can be longer
    276     * than MAX_STR_LEN which is used in call_program_and_get_last_line_of_output().
    277     * So start looping and get the number of  mounted file systems and query them one by one.
    278     ********/
    279     /* Get the number of mounted file systems ((those that start with "/dev/" */
    280     mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
    281     log_msg(5, "Running: %s", command);
    282     mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    283     paranoid_free(command);
    284 
    285     mount_cnt = atoi(mounted_file_system);
    286     log_msg (5, "mount_cnt: %d", mount_cnt);
    287     paranoid_free(mounted_file_system);
    288 
    289     for (i=mount_cnt; i > 0; i--) {
    290         mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
    291         log_msg(5, "Running: %s", command);
    292         mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    293         paranoid_free(command);
    294 
    295         log_msg (5, "mounted_file_system: %s", mounted_file_system);
    296         if ((token = strtok(mounted_file_system, token_chars)) == NULL) {
    297             log_msg (4, "Could not get the list of mounted file systems");
    298             paranoid_free(mounted_file_system);
    299             mr_free(token);
    300             return (1);
    301         }
    302         if (token) {
    303             log_msg (5, "token: %s", token);
    304         }
    305         while (token != NULL) {
    306             log_msg (5, "token: %s", token);
    307             if ((DSFptr = (MOUNTED_FS_STRUCT *) calloc(1, sizeof(MOUNTED_FS_STRUCT))) == NULL) {
    308                 fatal_error ("Cannot allocate memory");
    309             }
    310             add_mounted_fs_struct(DSFptr);
    311             strcpy(DSFptr->device, token);
    312             mr_free(token);
    313             if ((token = strtok(NULL, token_chars)) == NULL) {
    314                 log_msg (5, "Ran out of entries on the mounted file systems list");
    315                 paranoid_free(mounted_file_system);
    316                 mr_free(token);
    317                 return (1);
    318             }
    319             log_msg (5, "token: %s", token);
    320             strcpy(DSFptr->mount_point, token);
    321             mr_free(token);
    322             token = strtok(NULL, token_chars);
    323         }
    324         paranoid_free(mounted_file_system);
    325     }
    326     /********
    327     * DSFptr = DSF_Head;
    328     * while (DSFptr != NULL) {
    329     * printf ("Dev: %s  MP: %s  Check: %d\n", DSFptr->device, DSFptr->mount_point, DSFptr->check);
    330     * DSFptr = DSFptr->next;
    331     * }
    332     ********/
    333     return (0);
    334 }
    335 
    336 /**
    337  * Given a whole disk device special file, determine which mounted file systems
    338  * are on the dsf's partitions and which mounted file systems are not.
    339  * @param dsf The whole disk device special file.
    340  * @param included_dsf_list A char pointer used to hold the list of mount points
    341  * that are on the dsf. Memory for the array will be allocated within the function.
    342  * @param excluded_dsf_list A char pointer used to hold the list of mount points
    343  * that are not on the dsf. Memory for the array will be allocated within the function.
    344  * @return 0 on success, -1 if no device special file was passed in, -2 if a device
    345  * special file was passed in but it has no partitions on it, or 1 on failure
    346  */
    347 static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list) {
    348     int i = 0;
    349     int c = 0;
    350     int lastpos = 0;
    351     char VG[MAX_STR_LEN];
    352     char *tmp = NULL;
    353     char *command = NULL;
    354     char *partition_list = NULL;
    355     char partitions[64][MAX_STR_LEN];
    356     char *mount_list = NULL;
    357     char *token = NULL;
    358     char token_chars[] =" \t\r\f\a\0";
    359     MOUNTED_FS_STRUCT *DSFptr = NULL;
    360 
    361     memset((char *)partitions, 0, sizeof(partitions));
    362 
    363     log_msg(5, "dsf: %s", dsf);
    364 
    365     /********
    366     * See if a device special file was passed in (i.e. it must start with /dev/
    367     ********/
    368     if (strncmp(dsf, "/dev/", 5)) {
    369         log_msg (5, "%s does not start with /dev/ and (probably) is not a  device special file", dsf);
    370         return (-1);
    371     }
    372     log_msg(5, "  %s looks like a device special file", dsf);
    373     /* Verify that the dsf exists */
    374     mr_asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf);
    375     log_msg(5, "  Executing: %s", command);
    376     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    377     paranoid_free(command);
    378 
    379     log_msg(5, "  Return value: %s", tmp);
    380     c = atoi(tmp);
    381     paranoid_free(tmp);
    382 
    383     if (!c) {
    384         log_to_screen("Cannot find device special file %s", dsf);
    385         return (1);
    386     }
    387     log_msg(5, "  %s device special file exists", dsf);
    388 
    389     /* Get a list of the mounted file systems */
    390     if (create_list_of_non_NETFS_mounted_file_systems()) {
    391         log_to_screen ("Could not get the list of mounted file systems");
    392         return (1);
    393     }
    394     log_msg (5, "Processing dsf: %s", dsf);
    395     /********
    396     * Get a list of the dsf's partitions. There could be no partitions on the disk
    397     * or a dsf of a partition was passed in (e.g. /dev/sda1 instead of /dev/sda).
    398     * Either way, it's an error.
    399     ********/
    400     mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    401     log_msg(4, "Executing: %s", command);
    402     mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));
    403     paranoid_free(command);
    404     log_msg(4, "Partition list for %s: %s", dsf, partition_list);
    405     if (!strlen(partition_list)) {
    406         /* There were no partitions on the disk */
    407         log_msg(4, "Cannot find any partitions on device special file %s", dsf);
    408         return (-2);
    409     }
    410 
    411     /* Fill the partition list */
    412     i = 0;
    413     lastpos = 0;
    414     while ((token = mr_strtok(partition_list, token_chars, &lastpos)) != NULL) {
    415         log_msg (5, "Found partition: %s", token);
    416         strcpy(partitions[i++], token);
    417         mr_free(token);
    418     }
    419     paranoid_free(partition_list);
    420  
    421     /********
    422      * At this point, we have a list of all of the partitions on the dsf. Now try to
    423      * see which partitions have a file system on them.
    424      *
    425      * Loop through each partition on the disk and:
    426      *
    427      * - If the partition is swap, it ignores it.
    428      *
    429      * - If the partition is mounted (e.g. /dev/sda1 is mounted on /boot), it adds an entry
    430      *  to the linked list, copies to it the device name and mount point, and sets check == 1.
    431      *
    432      * - If the partition is part of a Volume Group that has Logical Volumes mounted, it adds
    433      *  an entry to the linked list for each mounted Logical Volume in that Volume Group, copying
    434      *  to it the device name and mount point, and sets check == 1. Note that if the Volume Group
    435      *  contains more than one disk, it will still add the entry even if the Logical Volume's
    436      *  extents are not on the dsf that was passed in to the function. For example, Volume Group
    437      *  VolGroup00 contains the disks /dev/sda1 and /dev/sdb1, and the Logical Volumes LogVol01,
    438      *  which is mounted on /var and has all of its extents on /dev/sda1, and LogVol02, which is
    439      *  mounted as /usr and has all of its extents on /dev/sdb1. If you pass /dev/sda into the
    440      *  function, both /var and /usr will be archived even though /usr is actually on/dev/sdb.
    441      *
    442      * - If the partition is part of a Volume Group that has Logical Volumes used in a mounted
    443      *  software raid device, it adds an entry to the linked list, copies to it the software raid
    444      *  device name and mount point, and sets check == 1.
    445      *
    446      * - If the partition is part of a mounted software raid device, it adds an entry to the linked
    447      *  list, copies to it the software raid device name and mount point, and sets check == 1.
    448      *
    449      ********/
    450     for (i=0; strlen(partitions[i]); i++) {
    451         log_msg(4, "Processing partition: %s", partitions[i]);
    452         /* See if it's swap. If it is, ignore it. */
    453         mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
    454           dsf, partitions[i]);
    455         log_msg(4, "  Running: %s", command);
    456         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    457         paranoid_free(command);
    458         log_msg(4, "  Return value: %s", tmp);
    459         c = strlen(tmp);
    460         paranoid_free(tmp);
    461         if (c) {
    462             log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
    463             continue;
    464         }
    465         /* It's not swap. See if we can find the mount point from the mount command. */
    466         mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    467         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    468         paranoid_free(command);
    469         if (strlen(tmp)) {
    470             log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
    471             if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
    472                 log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
    473                 paranoid_free(tmp);
    474                 return (1);
    475             }
    476             DSFptr->check = 1;
    477             paranoid_free(tmp);
    478             continue;
    479         }
    480         paranoid_free(tmp);
    481         /* It's not swap and it's not mounted. See if it's LVM */
    482         log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
    483         /* Get the partition ID; 8e for LVM */
    484         mr_asprintf(&command, "parted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
    485         log_msg(4, "  Running: %s", command);
    486         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    487         paranoid_free(command);
    488         if (strlen(tmp)) {
    489             log_msg(4, "  Partition ID: %s", tmp);
    490             if (!strcasecmp(tmp, "8e")) {
    491                 /* It's LVM: Find the VG it's in */
    492                 log_msg(4, "  It's LVM: Find the VG it's in...");
    493                 mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    494                 log_msg(4, "  Running: %s", command);
    495                 strcpy(VG, call_program_and_get_last_line_of_output(command));
    496                 paranoid_free(command);
    497                 log_msg(4, "  Volume Group: %s", VG);
    498                 if (strlen(VG)) {
    499                     /* Found the Volume Group. Now find all of the VG's mount points */
    500                     log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
    501                     mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
    502                     log_msg(4, "  Running: %s", command);
    503                     mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    504                     paranoid_free(command);
    505                     log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    506                     lastpos = 0;
    507                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    508                         log_msg (5, "mount point token: %s", token);
    509                         if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    510                             log_msg (4, "Can't find mount point %s in mounted file systems list", token);
    511                             paranoid_free(tmp);
    512                             mr_free(token);
    513                             return (1);
    514                         }
    515                         DSFptr->check = 1;
    516                         mr_free(token);
    517                     }
    518                     /********
    519                      * Now we want to see if there are any software raid devices using
    520                      * any of the Logical Volumes on the Volume Group.
    521                      *******/
    522                     paranoid_free(mount_list);
    523                     mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    524                     log_msg (5, "Running: %s", command);
    525                     mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    526                     paranoid_free(command);
    527                     log_msg(4, "  Software raid device list: %s", mount_list);
    528                     lastpos = 0;
    529                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    530                         mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    531                         log_msg (5, "Running: %s", command);
    532                         paranoid_free(tmp);
    533                         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    534                         paranoid_free(command);
    535                         log_msg(4, "Number of Software raid device: %s", tmp);
    536                         if (atoi(tmp)) {
    537                             /* This device is on our disk */
    538                             if ((DSFptr = find_device_in_list(token)) == NULL) {
    539                                 log_msg (4, "Can't find device %s in mounted file systems list", token);
    540                                 paranoid_free(tmp);
    541                                 mr_free(token);
    542                                 return (1);
    543                             }
    544                             DSFptr->check = 1;
    545                         }
    546                     }
    547                     mr_free(token);
    548                     paranoid_free(mount_list);
    549                 } else {
    550                     log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    551                     paranoid_free(tmp);
    552                     return (1);
    553                 }
    554                 paranoid_free(tmp);
    555                 continue;
    556             }
    557         } else {
    558             log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
    559         }
    560         paranoid_free(tmp);
    561         /********
    562          * It's not swap, mounted, or LVM. See if it's used in a software raid device.
    563          ********/
    564         log_msg (5, "It's not swap, mounted, or LVM. See if it's used in a software raid device.");
    565         mr_asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
    566         log_msg(4, "  Running: %s", command);
    567         mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    568         paranoid_free(command);
    569         if (!strlen(tmp)) {
    570             log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
    571             paranoid_free(tmp);
    572             continue;
    573         }
    574         log_msg (5, "  UUID: %s", tmp);
    575         /* Get the Software raid device list */
    576         mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    577         log_msg (5, "  Running: %s", command);
    578         mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    579         paranoid_free(command);
    580         log_msg(4, "  Software raid device list: %s", mount_list);
    581         /* Loop through the software raid device list to see if we can find the partition */
    582         lastpos = 0;
    583         while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    584             mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    585             log_msg(4, "  Running: %s", command);
    586             paranoid_free(tmp);
    587             mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    588             paranoid_free(command);
    589             if (!atoi(tmp)) {
    590                 log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
    591             } else {
    592                 if ((DSFptr = find_device_in_list(token)) == NULL) {
    593                     log_msg (4, "Can't find device %s in mounted file systems list", token);
    594                     paranoid_free(tmp);
    595                     mr_free(token);
    596                     return (1);
    597                 }
    598                 DSFptr->check = 1;
    599                 break;
    600             }
    601             mr_free(token);
    602         }
    603         paranoid_free(tmp);
    604     }
    605     paranoid_free(partition_list);
    606     paranoid_free(mount_list);
    607 
    608     /* Determine how much memory to allocate for included_dsf_list and excluded_dsf_list */
    609     i = 0;
    610     DSFptr= DSF_Head;
    611     while (DSFptr != NULL) {
    612         i += strlen(DSFptr->mount_point) + 1;
    613         DSFptr = DSFptr->next;
    614     }
    615     log_msg (5, "i: %d", i);
    616     if ((*included_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
    617         fatal_error ("Cannot allocate memory");
    618     }
    619     if ((*excluded_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
    620         fatal_error ("Cannot allocate memory");
    621     }
    622     DSFptr= DSF_Head;
    623     while (DSFptr != NULL) {
    624         if (DSFptr->check) {
    625             log_msg (5, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
    626             strcat(*included_dsf_list, DSFptr->mount_point);
    627             strcat(*included_dsf_list, " ");
    628         } else {
    629             log_msg (4, "%s is mounted on %s and is NOT on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
    630             strcat(*excluded_dsf_list, DSFptr->mount_point);
    631             strcat(*excluded_dsf_list, " ");
    632         }
    633         DSFptr = DSFptr->next;
    634     }
    635     log_msg (5, "included_dsf_list: %s", *included_dsf_list);
    636     log_msg (5, "excluded_dsf_list: %s", *excluded_dsf_list);
    637     return (0);
    638 }
    639 
    640 
    641 /**
    642164 * Process mondoarchive's command-line switches.
    643165 * @param bkpinfo The backup information structure to populate.
     
    665187    char *p = NULL;
    666188    char *q = NULL;
    667     char *token = NULL;
    668     char *mounted_on_dsf = NULL;
    669     char *not_mounted_on_dsf = NULL;
    670     char token_chars[] =" \t\r\f\a\0";
    671189
    672190    long itbs = 0L;
     
    785303        }
    786304        paranoid_free(tmp1);
    787         while ((token = mr_strtok(flag_val['I'], token_chars, &lastpos)) != NULL) {
    788             switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
    789             /* It's a dsf but not a whole disk dsf */
    790             case -2:
    791                 log_to_screen("Could %s be a partition instead of a whole disk device special file?\n Ignored.", token);
    792                 break;
    793             /* Fatal error; exit */
    794             case 1:
    795                 fatal_error("Error processing -I option");
    796             /* Everything is OK; process to archive data */
    797             case 0:
    798                 log_to_screen("Archiving only the following file systems on %s:\n", token);
    799                 log_to_screen("  %s\n", mounted_on_dsf);
    800                 strcpy(bkpinfo->include_paths, "/");
    801                 if (strlen(not_mounted_on_dsf)) {
    802                     log_msg (5, "Adding to bkpinfo->exclude_paths due to -I option: %s", not_mounted_on_dsf);
    803                     log_to_screen("Not archiving the following file systems:\n");
    804                     log_to_screen("  %s\n", not_mounted_on_dsf);
    805                     strcat(bkpinfo->exclude_paths, not_mounted_on_dsf);
    806                     strcat(bkpinfo->exclude_paths, "");
    807                 }
    808                 break;
    809             /* A device special file was not passed in. Process it as a path. */
    810             case -1:
    811                     strcat(bkpinfo->include_paths, token);
    812                     strcat(bkpinfo->include_paths, " ");
    813                 break;
    814             }
    815             mr_free(token);
    816         }
    817         log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
    818         if (bkpinfo->exclude_paths != NULL) {
    819             log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
    820         }
     305        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    821306        log_msg(4, "Finished with the -I option");
    822307    }
     
    1152637        paranoid_free(tmp1);
    1153638        lastpos = 0;
    1154         while ((token = mr_strtok(flag_val['E'], token_chars, &lastpos)) != NULL) {
    1155             switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
    1156             case 1:
    1157                 log_msg(1, "WARNING ! a path doesn't exist in -E option");
    1158                 break;
    1159             /* Everything is OK; proceed to archive data */
    1160             case 0:
    1161                 if (strlen(mounted_on_dsf)) {
    1162                     log_to_screen("Excluding the following file systems on %s:\n", token);
    1163                     log_to_screen("  %s\n", mounted_on_dsf);
    1164                     log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf);
    1165                     strcat(bkpinfo->exclude_paths, mounted_on_dsf);
    1166                     strcat(bkpinfo->exclude_paths, " ");
    1167                 }
    1168                 break;
    1169             /* It's a dsf but not a whole disk dsf */
    1170             case -2:
    1171                 log_to_screen("Could %s be a partition instead of a whole disk device special file?\nIgnored.", token);
    1172                 break;
    1173             /* A device special file was not passed in. Process it as a path. */
    1174             case -1:
    1175                 strcat(bkpinfo->exclude_paths, token);
    1176                 strcat(bkpinfo->exclude_paths, " ");
    1177                 break;
    1178             }
    1179             mr_free(token);
    1180         }
    1181         log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
     639
     640        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
    1182641        log_msg(4, "Finished with the -E option");
    1183642    }
Note: See TracChangeset for help on using the changeset viewer.