Changeset 2713 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-devices.c
- Timestamp:
- Feb 2, 2011, 12:35:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2697 r2713 2016 2016 log_msg (4, "%s is mounted on %s and is on disk %s", DSFptr->device, DSFptr->mount_point, ndsf); 2017 2017 strcat(*included_dsf_list, DSFptr->mount_point); 2018 strcat(*included_dsf_list, " 2018 strcat(*included_dsf_list, "|"); 2019 2019 } else { 2020 2020 log_msg (4, "%s is mounted on %s and is NOT on disk %s", DSFptr->device, DSFptr->mount_point, ndsf); 2021 2021 strcat(*excluded_dsf_list, DSFptr->mount_point); 2022 strcat(*excluded_dsf_list, " 2022 strcat(*excluded_dsf_list, "|"); 2023 2023 } 2024 2024 DSFptr = DSFptr->next; … … 2043 2043 char *mounted_on_dsf = NULL; 2044 2044 char *not_mounted_on_dsf = NULL; 2045 char token_chars[] =" 2045 char token_chars[] ="|\t\r\f\a\0\n"; 2046 2046 char *tmp = NULL; 2047 2047 char *tmp1 = NULL; … … 2064 2064 log_to_screen("==> %s", mounted_on_dsf); 2065 2065 log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf); 2066 mr_strcat(bkpinfo->exclude_paths, " %s ",mounted_on_dsf); 2067 mr_strcat(bkpinfo->exclude_devs, " %s ",token); 2066 if (bkpinfo->exclude_paths) { 2067 mr_strcat(bkpinfo->exclude_paths,"|%s",mounted_on_dsf); 2068 } else { 2069 mr_asprintf(bkpinfo->exclude_paths,"%s",mounted_on_dsf); 2070 } 2071 if (bkpinfo->exclude_devs) { 2072 mr_strcat(bkpinfo->exclude_devs,"|%s",token); 2073 } else { 2074 mr_asprintf(bkpinfo->exclude_devs,"%s",token); 2075 } 2068 2076 } 2069 2077 } else { … … 2075 2083 log_to_screen("Not archiving the following file systems:"); 2076 2084 log_to_screen("==> %s", not_mounted_on_dsf); 2077 mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf); 2085 if (bkpinfo->exclude_paths) { 2086 mr_strcat(bkpinfo->exclude_paths, "|%s",not_mounted_on_dsf); 2087 } else { 2088 mr_asprintf(bkpinfo->exclude_paths,"%s",not_mounted_on_dsf); 2089 } 2078 2090 } 2079 2091 } … … 2085 2097 /* A device special file was not passed in. Process it as a path. */ 2086 2098 case -1: 2087 /* we need to add a space efore and after token to be sure our strstr test works correctly*/2088 mr_asprintf(&tmp1," %s",token);2099 /* Adds a | to ensure correct detection even at both ends */ 2100 mr_asprintf(&tmp1,"|%s",token); 2089 2101 if (mode == 'E') { 2090 2102 /* Add the token if not already in the list */ 2091 mr_asprintf(&tmp," %s",bkpinfo->exclude_paths);2103 mr_asprintf(&tmp,"|%s|",bkpinfo->exclude_paths); 2092 2104 if (strstr(tmp,tmp1) == NULL) { 2093 mr_strcat(bkpinfo->exclude_paths, tmp1); 2105 if (bkpinfo->exclude_paths) { 2106 mr_strcat(bkpinfo->exclude_paths,tmp1); 2107 mr_free(tmp1); 2108 } else { 2109 bkpinfo->exclude_paths = tmp1; 2110 } 2094 2111 } 2095 2112 } else { 2096 2113 /* Add the token if not already in the list */ 2097 mr_asprintf(&tmp," %s",bkpinfo->include_paths);2114 mr_asprintf(&tmp,"|%s|",bkpinfo->include_paths); 2098 2115 if (strstr(tmp,tmp1) == NULL) { 2099 strcat(bkpinfo->include_paths, tmp1); 2100 } 2116 strcat(bkpinfo->include_paths,tmp1); 2117 } 2118 mr_free(tmp1); 2101 2119 } 2102 2120 mr_free(tmp); 2103 mr_free(tmp1);2104 2121 break; 2105 2122 } … … 2648 2665 if (!popup_and_get_string 2649 2666 ("Backup paths", 2650 "Please enter paths which you want me to backup. The default is '/' (i.e. everything).",2667 "Please enter paths (separated by '|') which you want me to backup. The default is '/' (i.e. everything).", 2651 2668 bkpinfo->include_paths, MAX_STR_LEN)) { 2652 2669 log_to_screen("User has chosen not to backup the PC"); 2653 2670 finish(1); 2654 2671 } 2655 mr_asprintf(&tmp, "%s", list_of_NETFS_mounts_only());2672 tmp = list_of_NETFS_mounts_only(); 2656 2673 if (strlen(tmp) > 2) { 2657 mr_strcat(bkpinfo->exclude_paths, " 2674 mr_strcat(bkpinfo->exclude_paths, "|%s",tmp); 2658 2675 } 2659 2676 mr_free(tmp); … … 2672 2689 2673 2690 strncpy(p,bkpinfo->exclude_paths,(8*MAX_STR_LEN)-1); 2674 popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with spaces. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", p, (8*MAX_STR_LEN)-1);2691 popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with '|'. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", p, (8*MAX_STR_LEN)-1); 2675 2692 if (p == NULL) { 2676 2693 log_to_screen("User has chosen not to backup the PC"); … … 2756 2773 /* the mr_make_devlist_from_pathlist function appends 2757 2774 * to the *_paths variables so copy before */ 2758 mr_asprintf(&tmp, "%s ", bkpinfo->exclude_paths); 2759 mr_make_devlist_from_pathlist(tmp, 'E'); 2760 mr_free(tmp); 2761 mr_asprintf(&tmp, "%s ", bkpinfo->include_paths); 2762 mr_make_devlist_from_pathlist(tmp, 'I'); 2763 mr_free(tmp); 2775 mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E'); 2776 mr_make_devlist_from_pathlist(bkpinfo->include_paths, 'I'); 2764 2777 2765 2778 log_it("scratchdir = '%s'", bkpinfo->scratchdir); … … 2785 2798 2786 2799 2787 2788 2789 /** 2790 * @addtogroup utilityGroup 2791 * @{ 2792 */ 2793 /** 2794 * Get a space-separated list of NETFS devices and mounts. 2800 /** 2801 * Get a |-separated list of NETFS mounts. 2795 2802 * @return The list created. 2796 * @note The return value points to static data that will be overwritten with each call.2797 * /2798 char *list_of_NETFS_devices_and_mounts(void) 2799 { 2800 char *exclude_these_devices = NULL; 2803 * @note The return value points to allocated string that needs to be freed 2804 * @bug Even though we only want the mounts, the devices are still checked. 2805 */ 2806 char *list_of_NETFS_mounts_only(void) 2807 { 2801 2808 char *exclude_these_directories = NULL; 2802 static char result_sz[1024]; 2803 2804 mr_asprintf(&exclude_these_directories,"%s",list_of_NETFS_mounts_only()); 2805 mr_asprintf(&exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2806 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2807 mr_free(exclude_these_devices); 2808 mr_free(exclude_these_directories); 2809 return (result_sz); 2810 } 2811 2812 2813 2814 2815 /** 2816 * Get a space-separated list of NETFS mounts. 2817 * @return The list created. 2818 * @note The return value points to static data that will be overwritten with each call. 2819 * @bug Even though we only want the mounts, the devices are still checked. 2820 */ 2821 char *list_of_NETFS_mounts_only(void) 2822 { 2823 char *exclude_these_directories = NULL; 2824 static char result_sz[512]; 2825 2826 mr_asprintf(&exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2827 snprintf(result_sz, 511, "%s", exclude_these_directories); 2828 mr_free(exclude_these_directories); 2829 return (result_sz); 2809 2810 mr_asprintf(&exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' '|' | awk '{print $0;}'")); 2811 log_msg(9,"list_of_NETFS_mounts_only returns %s\n",exclude_these_directories); 2812 return(exclude_these_directories); 2830 2813 } 2831 2814
Note:
See TracChangeset
for help on using the changeset viewer.