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-devices.c

    r2423 r2424  
    6161extern struct s_bkpinfo *bkpinfo;
    6262
    63 
     63/* Stuff that handles the -I and -E option when a whole disk DSF is used */
     64typedef struct mounted_fs_struct {
     65    char device[MAX_STR_LEN];       /* The name of the device */
     66    char mount_point[MAX_STR_LEN];  /* The devices mount point */
     67    unsigned char check;            /* 1 == included on DSF */
     68    struct mounted_fs_struct *next;
     69} MOUNTED_FS_STRUCT;
     70
     71static MOUNTED_FS_STRUCT *DSF_Head = NULL;      /* Points to the first entry of mounted_fs_struct list */
     72static MOUNTED_FS_STRUCT *DSF_Tail = NULL;      /* Points to the last entry of mounted_fs_struct list */
    6473
    6574
     
    20742083    log_it("prefix = %s", bkpinfo->prefix);
    20752084    log_it("compression = %ld", bkpinfo->compression_level);
    2076     log_it("include_paths = '%s'", bkpinfo->include_paths);
    2077     log_it("exclude_paths = '%s'", bkpinfo->exclude_paths);
     2085
     2086    /* Handle devices passed in bkpinfo and print result */
     2087    mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E');
     2088    mr_make_devlist_from_pathlist(bkpinfo->include_paths, 'I');
     2089
    20782090    log_it("scratchdir = '%s'", bkpinfo->scratchdir);
    20792091    log_it("tmpdir = '%s'", bkpinfo->tmpdir);
     
    26092621/* @} - end of deviceGroup */
    26102622
    2611 
    26122623/**
    26132624 * Return the type of partition format (GPT or MBR)
     
    26402651}
    26412652
     2653/**
     2654 * Frees the memory for all of the structures on the linked list of
     2655 * all of the non-NETFS mounted file systems.
     2656 */
     2657static void free_mounted_fs_list (void) {
     2658    MOUNTED_FS_STRUCT *DSFptr = NULL;
     2659    MOUNTED_FS_STRUCT *DSFnext = NULL;
     2660 
     2661    DSFptr = DSF_Head;
     2662    while (DSFptr != NULL) {
     2663        DSFnext = DSFptr->next;
     2664        paranoid_free(DSFptr);
     2665        DSFptr = DSFnext;
     2666    }
     2667    DSF_Head = NULL;
     2668    DSF_Tail = NULL;
     2669}
     2670
     2671/**
     2672 * Creates a singly linked list of all of the non-NETFS mounted file systems.
     2673 * @param DSFptr A pointer  to the structure MOUNTED_FS_STRUCT used to hold
     2674 * the list of mounted file systems.
     2675 * @return None.
     2676 */
     2677static void add_mounted_fs_struct (MOUNTED_FS_STRUCT *DSFptr)
     2678{
     2679    assert (DSFptr);
     2680    if (DSF_Head == NULL) {
     2681        DSF_Head = DSFptr;
     2682    } else {
     2683        DSF_Tail->next = DSFptr;
     2684    }
     2685    DSFptr->next = NULL;
     2686    DSF_Tail = DSFptr;
     2687}
     2688
     2689/**
     2690 * Find the structure, in the singly linked list of all of the non-NETFS
     2691 * mounted file systems, that contains the specified device.
     2692 * @param device The device to find
     2693 * @return NULL if it didn't find the device, a pointer to the
     2694 * structure if it did.
     2695 */
     2696static MOUNTED_FS_STRUCT *find_device_in_list (char *device)
     2697{
     2698    MOUNTED_FS_STRUCT *DSFptr = NULL;
     2699
     2700    DSFptr = DSF_Head;
     2701    while (DSFptr != NULL) {
     2702        if (!strcmp(DSFptr->device, device)) {
     2703            break;
     2704        }
     2705        DSFptr = DSFptr->next;
     2706    }
     2707    return (DSFptr);
     2708}
     2709
     2710/**
     2711 * Find the structure, in the singly linked list of all of the non-NETFS
     2712 * mounted file systems, that contains the specified mount point.
     2713 * @param mount_point The mount point to find
     2714 * @return NULL is it didn't find the mount point, a pointer to the
     2715 * structure if it did.
     2716 */
     2717static MOUNTED_FS_STRUCT *find_mount_point_in_list (char *mount_point)
     2718{
     2719    MOUNTED_FS_STRUCT *DSFptr = NULL;
     2720
     2721    DSFptr = DSF_Head;
     2722    while (DSFptr != NULL) {
     2723        if (!strcmp(DSFptr->mount_point, mount_point)) {
     2724            break;
     2725        }
     2726        DSFptr = DSFptr->next;
     2727    }
     2728    return (DSFptr);
     2729}
     2730
     2731/**
     2732 * Creates a linked list of all of the non-NETFS mounted file systems.
     2733 * We use a linked list because we don't know how many  mounted file
     2734 * there are (and there can be a lot).
     2735 * @return 0 on success and greated than 0 on failure.
     2736 */
     2737static int create_list_of_non_NETFS_mounted_file_systems (void)
     2738{
     2739    int i = 0;
     2740    int mount_cnt = 0;
     2741    char *mounted_file_system = NULL;
     2742    char *command = NULL;
     2743    char *token = NULL;
     2744    char token_chars[] =" :\t\r\f\a\0";
     2745    MOUNTED_FS_STRUCT *DSFptr = NULL;
     2746
     2747    free_mounted_fs_list();
     2748    /********
     2749    * Find the number of mounted file system entries and their respective mount points.
     2750    * I can't return all of the entries as one string because it's length can be longer
     2751    * than MAX_STR_LEN which is used in call_program_and_get_last_line_of_output().
     2752    * So start looping and get the number of  mounted file systems and query them one by one.
     2753    ********/
     2754    /* Get the number of mounted file systems ((those that start with "/dev/" */
     2755    mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");
     2756    log_msg(5, "Running: %s", command);
     2757    mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     2758    paranoid_free(command);
     2759
     2760    mount_cnt = atoi(mounted_file_system);
     2761    log_msg (5, "mount_cnt: %d", mount_cnt);
     2762    paranoid_free(mounted_file_system);
     2763
     2764    for (i=mount_cnt; i > 0; i--) {
     2765        mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);
     2766        log_msg(5, "Running: %s", command);
     2767        mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
     2768        paranoid_free(command);
     2769
     2770        log_msg (5, "mounted_file_system: %s", mounted_file_system);
     2771        if ((token = strtok(mounted_file_system, token_chars)) == NULL) {
     2772            log_msg (4, "Could not get the list of mounted file systems");
     2773            paranoid_free(mounted_file_system);
     2774            mr_free(token);
     2775            return (1);
     2776        }
     2777        if (token) {
     2778            log_msg (5, "token: %s", token);
     2779        }
     2780        while (token != NULL) {
     2781            log_msg (5, "token: %s", token);
     2782            if ((DSFptr = (MOUNTED_FS_STRUCT *) calloc(1, sizeof(MOUNTED_FS_STRUCT))) == NULL) {
     2783                fatal_error ("Cannot allocate memory");
     2784            }
     2785            add_mounted_fs_struct(DSFptr);
     2786            strcpy(DSFptr->device, token);
     2787            mr_free(token);
     2788            if ((token = strtok(NULL, token_chars)) == NULL) {
     2789                log_msg (5, "Ran out of entries on the mounted file systems list");
     2790                paranoid_free(mounted_file_system);
     2791                mr_free(token);
     2792                return (1);
     2793            }
     2794            log_msg (5, "token: %s", token);
     2795            strcpy(DSFptr->mount_point, token);
     2796            mr_free(token);
     2797            token = strtok(NULL, token_chars);
     2798        }
     2799        paranoid_free(mounted_file_system);
     2800    }
     2801    /********
     2802    * DSFptr = DSF_Head;
     2803    * while (DSFptr != NULL) {
     2804    * printf ("Dev: %s  MP: %s  Check: %d\n", DSFptr->device, DSFptr->mount_point, DSFptr->check);
     2805    * DSFptr = DSFptr->next;
     2806    * }
     2807    ********/
     2808    return (0);
     2809}
     2810
     2811
     2812
     2813/**
     2814 * Given a whole disk device special file, determine which mounted file systems
     2815 * are on the dsf's partitions and which mounted file systems are not.
     2816 * @param dsf The whole disk device special file.
     2817 * @param included_dsf_list A char pointer used to hold the list of mount points
     2818 * that are on the dsf. Memory for the array will be allocated within the function.
     2819 * @param excluded_dsf_list A char pointer used to hold the list of mount points
     2820 * that are not on the dsf. Memory for the array will be allocated within the function.
     2821 * @return 0 on success, -1 if no device special file was passed in, -2 if a device
     2822 * special file was passed in but it has no partitions on it, or 1 on failure
     2823 */
     2824static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list) {
     2825    int i = 0;
     2826    int c = 0;
     2827    int lastpos = 0;
     2828    char VG[MAX_STR_LEN];
     2829    char *tmp = NULL;
     2830    char *command = NULL;
     2831    char *partition_list = NULL;
     2832    char partitions[64][MAX_STR_LEN];
     2833    char *mount_list = NULL;
     2834    char *token = NULL;
     2835    char token_chars[] =" \t\r\f\a\0";
     2836    MOUNTED_FS_STRUCT *DSFptr = NULL;
     2837
     2838    memset((char *)partitions, 0, sizeof(partitions));
     2839
     2840    log_msg(5, "dsf: %s", dsf);
     2841
     2842    /********
     2843    * See if a device special file was passed in (i.e. it must start with /dev/
     2844    ********/
     2845    if (strncmp(dsf, "/dev/", 5)) {
     2846        log_msg (5, "%s does not start with /dev/ and (probably) is not a  device special file", dsf);
     2847        return (-1);
     2848    }
     2849    log_msg(5, "  %s looks like a device special file", dsf);
     2850    /* Verify that the dsf exists */
     2851    mr_asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf);
     2852    log_msg(5, "  Executing: %s", command);
     2853    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2854    paranoid_free(command);
     2855
     2856    log_msg(5, "  Return value: %s", tmp);
     2857    c = atoi(tmp);
     2858    paranoid_free(tmp);
     2859
     2860    if (!c) {
     2861        log_to_screen("Cannot find device special file %s", dsf);
     2862        return (1);
     2863    }
     2864    log_msg(5, "  %s device special file exists", dsf);
     2865
     2866    /* Get a list of the mounted file systems */
     2867    if (create_list_of_non_NETFS_mounted_file_systems()) {
     2868        log_to_screen ("Could not get the list of mounted file systems");
     2869        return (1);
     2870    }
     2871    log_msg (5, "Processing dsf: %s", dsf);
     2872    /********
     2873    * Get a list of the dsf's partitions. There could be no partitions on the disk
     2874    * or a dsf of a partition was passed in (e.g. /dev/sda1 instead of /dev/sda).
     2875    * Either way, it's an error.
     2876    ********/
     2877    mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
     2878    log_msg(4, "Executing: %s", command);
     2879    mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));
     2880    paranoid_free(command);
     2881    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
     2882    if (!strlen(partition_list)) {
     2883        /* There were no partitions on the disk */
     2884        log_msg(4, "Cannot find any partitions on device special file %s", dsf);
     2885        return (-2);
     2886    }
     2887
     2888    /* Fill the partition list */
     2889    i = 0;
     2890    lastpos = 0;
     2891    while ((token = mr_strtok(partition_list, token_chars, &lastpos)) != NULL) {
     2892        log_msg (5, "Found partition: %s", token);
     2893        strcpy(partitions[i++], token);
     2894        mr_free(token);
     2895    }
     2896    paranoid_free(partition_list);
     2897 
     2898    /********
     2899     * At this point, we have a list of all of the partitions on the dsf. Now try to
     2900     * see which partitions have a file system on them.
     2901     *
     2902     * Loop through each partition on the disk and:
     2903     *
     2904     * - If the partition is swap, it ignores it.
     2905     *
     2906     * - If the partition is mounted (e.g. /dev/sda1 is mounted on /boot), it adds an entry
     2907     *  to the linked list, copies to it the device name and mount point, and sets check == 1.
     2908     *
     2909     * - If the partition is part of a Volume Group that has Logical Volumes mounted, it adds
     2910     *  an entry to the linked list for each mounted Logical Volume in that Volume Group, copying
     2911     *  to it the device name and mount point, and sets check == 1. Note that if the Volume Group
     2912     *  contains more than one disk, it will still add the entry even if the Logical Volume's
     2913     *  extents are not on the dsf that was passed in to the function. For example, Volume Group
     2914     *  VolGroup00 contains the disks /dev/sda1 and /dev/sdb1, and the Logical Volumes LogVol01,
     2915     *  which is mounted on /var and has all of its extents on /dev/sda1, and LogVol02, which is
     2916     *  mounted as /usr and has all of its extents on /dev/sdb1. If you pass /dev/sda into the
     2917     *  function, both /var and /usr will be archived even though /usr is actually on/dev/sdb.
     2918     *
     2919     * - If the partition is part of a Volume Group that has Logical Volumes used in a mounted
     2920     *  software raid device, it adds an entry to the linked list, copies to it the software raid
     2921     *  device name and mount point, and sets check == 1.
     2922     *
     2923     * - If the partition is part of a mounted software raid device, it adds an entry to the linked
     2924     *  list, copies to it the software raid device name and mount point, and sets check == 1.
     2925     *
     2926     ********/
     2927    for (i=0; strlen(partitions[i]); i++) {
     2928        log_msg(4, "Processing partition: %s", partitions[i]);
     2929        /* See if it's swap. If it is, ignore it. */
     2930        mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
     2931          dsf, partitions[i]);
     2932        log_msg(4, "  Running: %s", command);
     2933        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2934        paranoid_free(command);
     2935        log_msg(4, "  Return value: %s", tmp);
     2936        c = strlen(tmp);
     2937        paranoid_free(tmp);
     2938        if (c) {
     2939            log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
     2940            continue;
     2941        }
     2942        /* It's not swap. See if we can find the mount point from the mount command. */
     2943        mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
     2944        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2945        paranoid_free(command);
     2946        if (strlen(tmp)) {
     2947            log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
     2948            if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
     2949                log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
     2950                paranoid_free(tmp);
     2951                return (1);
     2952            }
     2953            DSFptr->check = 1;
     2954            paranoid_free(tmp);
     2955            continue;
     2956        }
     2957        paranoid_free(tmp);
     2958        /* It's not swap and it's not mounted. See if it's LVM */
     2959        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
     2960        /* Get the partition ID; 8e for LVM */
     2961        mr_asprintf(&command, "parted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);
     2962        log_msg(4, "  Running: %s", command);
     2963        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     2964        paranoid_free(command);
     2965        if (strlen(tmp)) {
     2966            log_msg(4, "  Partition ID: %s", tmp);
     2967            if (!strcasecmp(tmp, "8e")) {
     2968                /* It's LVM: Find the VG it's in */
     2969                log_msg(4, "  It's LVM: Find the VG it's in...");
     2970                mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
     2971                log_msg(4, "  Running: %s", command);
     2972                strcpy(VG, call_program_and_get_last_line_of_output(command));
     2973                paranoid_free(command);
     2974                log_msg(4, "  Volume Group: %s", VG);
     2975                if (strlen(VG)) {
     2976                    /* Found the Volume Group. Now find all of the VG's mount points */
     2977                    log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
     2978                    mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
     2979                    log_msg(4, "  Running: %s", command);
     2980                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     2981                    paranoid_free(command);
     2982                    log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
     2983                    lastpos = 0;
     2984                    while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
     2985                        log_msg (5, "mount point token: %s", token);
     2986                        if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
     2987                            log_msg (4, "Can't find mount point %s in mounted file systems list", token);
     2988                            paranoid_free(tmp);
     2989                            mr_free(token);
     2990                            return (1);
     2991                        }
     2992                        DSFptr->check = 1;
     2993                        mr_free(token);
     2994                    }
     2995                    /********
     2996                     * Now we want to see if there are any software raid devices using
     2997                     * any of the Logical Volumes on the Volume Group.
     2998                     *******/
     2999                    paranoid_free(mount_list);
     3000                    mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     3001                    log_msg (5, "Running: %s", command);
     3002                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     3003                    paranoid_free(command);
     3004                    log_msg(4, "  Software raid device list: %s", mount_list);
     3005                    lastpos = 0;
     3006                    while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
     3007                        mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
     3008                        log_msg (5, "Running: %s", command);
     3009                        paranoid_free(tmp);
     3010                        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     3011                        paranoid_free(command);
     3012                        log_msg(4, "Number of Software raid device: %s", tmp);
     3013                        if (atoi(tmp)) {
     3014                            /* This device is on our disk */
     3015                            if ((DSFptr = find_device_in_list(token)) == NULL) {
     3016                                log_msg (4, "Can't find device %s in mounted file systems list", token);
     3017                                paranoid_free(tmp);
     3018                                mr_free(token);
     3019                                return (1);
     3020                            }
     3021                            DSFptr->check = 1;
     3022                        }
     3023                    }
     3024                    mr_free(token);
     3025                    paranoid_free(mount_list);
     3026                } else {
     3027                    log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
     3028                    paranoid_free(tmp);
     3029                    return (1);
     3030                }
     3031                paranoid_free(tmp);
     3032                continue;
     3033            }
     3034        } else {
     3035            log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
     3036        }
     3037        paranoid_free(tmp);
     3038        /********
     3039         * It's not swap, mounted, or LVM. See if it's used in a software raid device.
     3040         ********/
     3041        log_msg (5, "It's not swap, mounted, or LVM. See if it's used in a software raid device.");
     3042        mr_asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);
     3043        log_msg(4, "  Running: %s", command);
     3044        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     3045        paranoid_free(command);
     3046        if (!strlen(tmp)) {
     3047            log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
     3048            paranoid_free(tmp);
     3049            continue;
     3050        }
     3051        log_msg (5, "  UUID: %s", tmp);
     3052        /* Get the Software raid device list */
     3053        mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     3054        log_msg (5, "  Running: %s", command);
     3055        mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
     3056        paranoid_free(command);
     3057        log_msg(4, "  Software raid device list: %s", mount_list);
     3058        /* Loop through the software raid device list to see if we can find the partition */
     3059        lastpos = 0;
     3060        while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
     3061            mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
     3062            log_msg(4, "  Running: %s", command);
     3063            paranoid_free(tmp);
     3064            mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     3065            paranoid_free(command);
     3066            if (!atoi(tmp)) {
     3067                log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
     3068            } else {
     3069                if ((DSFptr = find_device_in_list(token)) == NULL) {
     3070                    log_msg (4, "Can't find device %s in mounted file systems list", token);
     3071                    paranoid_free(tmp);
     3072                    mr_free(token);
     3073                    return (1);
     3074                }
     3075                DSFptr->check = 1;
     3076                break;
     3077            }
     3078            mr_free(token);
     3079        }
     3080        paranoid_free(tmp);
     3081    }
     3082    paranoid_free(partition_list);
     3083    paranoid_free(mount_list);
     3084
     3085    /* Determine how much memory to allocate for included_dsf_list and excluded_dsf_list */
     3086    i = 0;
     3087    DSFptr= DSF_Head;
     3088    while (DSFptr != NULL) {
     3089        i += strlen(DSFptr->mount_point) + 1;
     3090        DSFptr = DSFptr->next;
     3091    }
     3092    log_msg (5, "i: %d", i);
     3093    if ((*included_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
     3094        fatal_error ("Cannot allocate memory");
     3095    }
     3096    if ((*excluded_dsf_list = (char *) calloc(i+100, sizeof(char))) == NULL) {
     3097        fatal_error ("Cannot allocate memory");
     3098    }
     3099    DSFptr= DSF_Head;
     3100    while (DSFptr != NULL) {
     3101        if (DSFptr->check) {
     3102            log_msg (5, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
     3103            strcat(*included_dsf_list, DSFptr->mount_point);
     3104            strcat(*included_dsf_list, " ");
     3105        } else {
     3106            log_msg (4, "%s is mounted on %s and is NOT on disk %s\n", DSFptr->device, DSFptr->mount_point, dsf);
     3107            strcat(*excluded_dsf_list, DSFptr->mount_point);
     3108            strcat(*excluded_dsf_list, " ");
     3109        }
     3110        DSFptr = DSFptr->next;
     3111    }
     3112    log_msg (5, "included_dsf_list: %s", *included_dsf_list);
     3113    log_msg (5, "excluded_dsf_list: %s", *excluded_dsf_list);
     3114    return (0);
     3115}
     3116
     3117
     3118/* Update the bkpinfo structure for exclude & include paths
     3119 * in order to handle correctly paths corresponding to devices */
     3120void mr_make_devlist_from_pathlist(char *pathlist, char mode) {
     3121
     3122char *token = NULL;
     3123int lastpos = 0;
     3124char *mounted_on_dsf = NULL;
     3125char *not_mounted_on_dsf = NULL;
     3126char token_chars[] =" \t\r\f\a\0";
     3127
     3128while ((token = mr_strtok(pathlist, token_chars, &lastpos)) != NULL) {
     3129    switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
     3130    case 1:
     3131        if (mode == 'E') {
     3132            log_msg(1, "WARNING ! %s doesn't exist in -E option", token);
     3133        } else {
     3134            fatal_error("Error processing -I option");
     3135        }
     3136        break;
     3137    /* Everything is OK; proceed to archive data */
     3138    case 0:
     3139        if (mode == 'E') {
     3140            if (strlen(mounted_on_dsf)) {
     3141                log_to_screen("Excluding the following file systems on %s:\n", token);
     3142                log_to_screen("  %s\n", mounted_on_dsf);
     3143                log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf);
     3144                strcat(bkpinfo->exclude_paths, mounted_on_dsf);
     3145                strcat(bkpinfo->exclude_paths, " ");
     3146                mr_strcat(bkpinfo->exclude_devs, " %s ", token);
     3147            } else {
     3148                log_to_screen("Archiving only the following file systems on %s:\n", token);
     3149                log_to_screen("  %s\n", mounted_on_dsf);
     3150                strcpy(bkpinfo->include_paths, "/");
     3151                if (strlen(not_mounted_on_dsf)) {
     3152                    log_msg (5, "Adding to bkpinfo->exclude_paths due to -I option: %s", not_mounted_on_dsf);
     3153                    log_to_screen("Not archiving the following file systems:\n");
     3154                    log_to_screen("  %s\n", not_mounted_on_dsf);
     3155                    strcat(bkpinfo->exclude_paths, not_mounted_on_dsf);
     3156                    strcat(bkpinfo->exclude_paths, "");
     3157                }
     3158            }
     3159        }
     3160        break;
     3161    /* It's a dsf but not a whole disk dsf */
     3162    case -2:
     3163        log_to_screen("Could %s be a partition instead of a whole disk device special file?\nIgnored.", token);
     3164        break;
     3165    /* A device special file was not passed in. Process it as a path. */
     3166    case -1:
     3167        if (mode == 'E') {
     3168            strcat(bkpinfo->exclude_paths, token);
     3169            strcat(bkpinfo->exclude_paths, " ");
     3170        } else {
     3171            strcat(bkpinfo->include_paths, token);
     3172            strcat(bkpinfo->include_paths, " ");
     3173        }
     3174        break;
     3175    }
     3176    mr_free(token);
     3177
     3178    if (bkpinfo->include_paths != NULL) {
     3179        log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
     3180    }
     3181    if (bkpinfo->exclude_paths != NULL) {
     3182        log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
     3183    }
     3184    if (bkpinfo->exclude_devs != NULL) {
     3185        log_msg(1, "exclude_devs is now '%s'", bkpinfo->exclude_devs);
     3186    }
     3187}
     3188}
     3189
     3190
     3191
     3192
    26423193/* @} - end of deviceGroup */
Note: See TracChangeset for help on using the changeset viewer.