Changeset 2715 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Feb 2, 2011, 1:18:23 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2704 r2715 1956 1956 log_msg (4, "%s is mounted on %s and is on disk %s", DSFptr->device, DSFptr->mount_point, ndsf); 1957 1957 strcat(*included_dsf_list, DSFptr->mount_point); 1958 strcat(*included_dsf_list, " 1958 strcat(*included_dsf_list, "|"); 1959 1959 } else { 1960 1960 log_msg (4, "%s is mounted on %s and is NOT on disk %s", DSFptr->device, DSFptr->mount_point, ndsf); 1961 1961 strcat(*excluded_dsf_list, DSFptr->mount_point); 1962 strcat(*excluded_dsf_list, " 1962 strcat(*excluded_dsf_list, "|"); 1963 1963 } 1964 1964 DSFptr = DSFptr->next; … … 1980 1980 char *mounted_on_dsf = NULL; 1981 1981 char *not_mounted_on_dsf = NULL; 1982 char token_chars[] =" 1982 char token_chars[] ="|\t\r\f\a\0\n"; 1983 1983 char *tmp = NULL; 1984 1984 char *tmp1 = NULL; … … 2001 2001 log_to_screen("==> %s", mounted_on_dsf); 2002 2002 log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf); 2003 mr_strcat(bkpinfo->exclude_paths, " %s ", mounted_on_dsf); 2004 mr_strcat(bkpinfo->exclude_devs, " %s ", token); 2003 if (bkpinfo->exclude_paths) { 2004 mr_strcat(bkpinfo->exclude_paths,"|%s",mounted_on_dsf); 2005 } else { 2006 mr_asprintf(bkpinfo->exclude_paths,"%s",mounted_on_dsf); 2007 } 2008 if (bkpinfo->exclude_devs) { 2009 mr_strcat(bkpinfo->exclude_devs,"|%s",token); 2010 } else { 2011 mr_asprintf(bkpinfo->exclude_devs,"%s",token); 2012 } 2005 2013 } 2006 2014 } else { … … 2013 2021 log_to_screen("Not archiving the following file systems:"); 2014 2022 log_to_screen("==> %s", not_mounted_on_dsf); 2015 mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf); 2023 if (bkpinfo->exclude_paths) { 2024 mr_strcat(bkpinfo->exclude_paths, "|%s",not_mounted_on_dsf); 2025 } else { 2026 mr_asprintf(bkpinfo->exclude_paths,"%s",not_mounted_on_dsf); 2027 } 2016 2028 } 2017 2029 } … … 2023 2035 /* A device special file was not passed in. Process it as a path. */ 2024 2036 case -1: 2025 /* we need to add a space after token to be sure our strstr test works correctly*/2026 mr_asprintf(tmp1," %s",token);2037 /* Adds a | to ensure correct detection even at both ends */ 2038 mr_asprintf(tmp1,"|%s",token); 2027 2039 if (mode == 'E') { 2028 2040 /* Add the token if not already in the list */ 2029 mr_asprintf(tmp," %s",bkpinfo->exclude_paths);2041 mr_asprintf(tmp,"|%s|",bkpinfo->exclude_paths); 2030 2042 if (strstr(tmp,tmp1) == NULL) { 2031 mr_strcat(bkpinfo->exclude_paths, "%s", tmp1); 2043 if (bkpinfo->exclude_paths) { 2044 mr_strcat(bkpinfo->exclude_paths,tmp1); 2045 mr_free(tmp1); 2046 } else { 2047 bkpinfo->exclude_paths = tmp1; 2048 } 2032 2049 } 2033 2050 } else { 2034 2051 /* Add the token if not already in the list */ 2035 mr_asprintf(tmp," %s",bkpinfo->include_paths);2052 mr_asprintf(tmp,"|%s|",bkpinfo->include_paths); 2036 2053 if (strstr(tmp,tmp1) == NULL) { 2037 2054 mr_strcat(bkpinfo->include_paths, "%s", tmp1); 2038 2055 } 2056 mr_free(tmp1); 2039 2057 } 2040 2058 mr_free(tmp); 2041 mr_free(tmp1);2042 2059 break; 2043 2060 } … … 2045 2062 2046 2063 if (bkpinfo->include_paths != NULL) { 2047 mr_strip_spaces(bkpinfo->include_paths);2048 2064 log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths); 2049 2065 } 2050 2066 if (bkpinfo->exclude_paths != NULL) { 2051 mr_strip_spaces(bkpinfo->exclude_paths);2052 2067 log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths); 2053 2068 } 2054 2069 if (bkpinfo->exclude_devs != NULL) { 2055 mr_strip_spaces(bkpinfo->exclude_devs);2056 2070 log_msg(1, "exclude_devs is now '%s'", bkpinfo->exclude_devs); 2057 2071 } … … 2061 2075 2062 2076 /** 2063 * @addtogroup utilityGroup 2064 * @{ 2065 */ 2066 /** 2067 * Get a space-separated list of NETFS devices and mounts. 2077 * Get a |-separated list of NETFS mounts. 2068 2078 * @return The list created. 2069 * @note The return value points to static data that will be overwritten with each call.2070 * /2071 char *list_of_NETFS_devices_and_mounts(void) 2072 { 2073 char *exclude_these_devices = NULL; 2079 * @note The return value points to allocated string that needs to be freed 2080 * @bug Even though we only want the mounts, the devices are still checked. 2081 */ 2082 char *list_of_NETFS_mounts_only(void) 2083 { 2074 2084 char *exclude_these_directories = NULL; 2075 static char result_sz[1024]; 2076 2077 mr_asprintf(exclude_these_directories,"%s",list_of_NETFS_mounts_only()); 2078 exclude_these_devices = 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;}'",TRUE); 2079 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2080 mr_free(exclude_these_devices); 2081 mr_free(exclude_these_directories); 2082 return (result_sz); 2083 } 2084 2085 2086 2087 2088 /** 2089 * Get a space-separated list of NETFS mounts. 2090 * @return The list created. 2091 * @note The return value points to static data that will be overwritten with each call. 2092 * @bug Even though we only want the mounts, the devices are still checked. 2093 */ 2094 char *list_of_NETFS_mounts_only(void) 2095 { 2096 char *exclude_these_directories = NULL; 2097 static char result_sz[512]; 2098 2099 exclude_these_directories = 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;}'",TRUE); 2100 snprintf(result_sz, 511, "%s", exclude_these_directories); 2101 mr_free(exclude_these_directories); 2102 return (result_sz); 2085 2086 exclude_these_directories = 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;}'",TRUE); 2087 log_msg(9,"list_of_NETFS_mounts_only returns %s\n",exclude_these_directories); 2088 return(exclude_these_directories); 2103 2089 } 2104 2090 … … 3106 3092 bkpinfo->include_paths = p; 3107 3093 3108 p = popup_and_get_string("Backup paths", "Please enter paths which you want me to backup . The default is '/' (i.e. everything).", bkpinfo->include_paths);3094 p = popup_and_get_string("Backup paths", "Please enter paths which you want me to backup separated by '|'. The default is '/' (i.e. everything).", bkpinfo->include_paths); 3109 3095 if (p == NULL) { 3110 3096 log_to_screen("User has chosen not to backup the PC"); … … 3114 3100 bkpinfo->include_paths = p; 3115 3101 3116 mr_asprintf(tmp, "%s", list_of_NETFS_mounts_only());3102 tmp = list_of_NETFS_mounts_only(); 3117 3103 if (strlen(tmp) > 2) { 3118 mr_strcat(bkpinfo->exclude_paths, " 3104 mr_strcat(bkpinfo->exclude_paths, "|%s",tmp); 3119 3105 } 3120 3106 mr_free(tmp); … … 3133 3119 3134 3120 3135 p = 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.", bkpinfo->exclude_paths);3121 p = popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with pipes. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", bkpinfo->exclude_paths); 3136 3122 if (p == NULL) { 3137 3123 log_to_screen("User has chosen not to backup the PC"); … … 3140 3126 mr_free(bkpinfo->exclude_paths); 3141 3127 bkpinfo->exclude_paths = p; 3142 /* Always needs to be finished by a space */3143 mr_strcat(bkpinfo->exclude_paths, " 3128 /* Always needs to be finished by a pipe */ 3129 mr_strcat(bkpinfo->exclude_paths, "|"); 3144 3130 3145 3131 p = popup_and_get_string("Temporary directory", "Please enter your temporary directory.", bkpinfo->tmpdir); … … 3217 3203 /* the mr_make_devlist_from_pathlist function appends 3218 3204 * to the *_paths variables so copy before */ 3219 mr_asprintf(tmp, "%s 3205 mr_asprintf(tmp, "%s|", bkpinfo->exclude_paths); 3220 3206 mr_make_devlist_from_pathlist(tmp, 'E'); 3221 3207 mr_free(tmp); 3222 mr_asprintf(tmp, "%s 3208 mr_asprintf(tmp, "%s|", bkpinfo->include_paths); 3223 3209 mr_make_devlist_from_pathlist(tmp, 'I'); 3224 3210 mr_free(tmp);
Note:
See TracChangeset
for help on using the changeset viewer.