Changeset 2715 in MondoRescue for branches/2.2.10/mondo/src/common
- Timestamp:
- Feb 2, 2011, 1:18:23 PM (13 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2704 r2715 268 268 /* Cut the flag_val['I'] in parts containing all paths to test them */ 269 269 while (p != NULL) { 270 q = strchr(p, ' 270 q = strchr(p, '|'); 271 271 if (q != NULL) { 272 272 *q = '\0'; … … 590 590 /* Cut the flag_val['E'] in parts containing all paths to test them */ 591 591 while (p != NULL) { 592 q = strchr(p, ' 592 q = strchr(p, '|'); 593 593 if (q != NULL) { 594 594 *q = '\0'; … … 625 625 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude Network mounts & devices 626 626 { 627 mr_asprintf(psz, "%s", list_of_NETFS_mounts_only()); 628 mr_strcat(bkpinfo->exclude_paths, " %s ", psz); 629 mr_free(psz); 627 psz = list_of_NETFS_mounts_only(); 628 log_msg(5, "-N means we'll exclude %s", psz); 629 if (bkpinfo->exclude_paths) { 630 mr_strcat(bkpinfo->exclude_paths, "|%s", psz); 631 mr_free(psz); 632 } else { 633 bkpinfo->exclude_paths = psz; 634 } 630 635 631 636 if (bkpinfo->exclude_paths != NULL) { -
branches/2.2.10/mondo/src/common/libmondo-devices-EXT.h
r2508 r2715 46 46 extern int eject_device(char *); 47 47 48 extern char *list_of_NETFS_devices_and_mounts();49 48 extern char *list_of_NETFS_mounts_only(void); 50 49 -
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); -
branches/2.2.10/mondo/src/common/libmondo-devices.h
r2508 r2715 38 38 int eject_device(char *); 39 39 40 char *list_of_NETFS_devices_and_mounts();41 40 char *list_of_NETFS_mounts_only(); 42 41 -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2704 r2715 1283 1283 mr_asprintf(sz_res, "%s", incoming); 1284 1284 p = sz_res; 1285 while ((*p != ' 1285 while ((*p != '|' || in_quotes) && *p != '\0') { 1286 1286 if (*p == '\"') { 1287 1287 in_quotes = !in_quotes; … … 1311 1311 int open_and_list_dir(char *dir1, char *sth, FILE * fout, time_t time_of_last_full_backup) { 1312 1312 1313 const char delims[] = " 1313 const char delims[] = "|"; 1314 1314 1315 1315 DIR *dip; … … 1322 1322 static int percentage = 0; 1323 1323 char *skip_these = NULL; 1324 char *new_with_ spaces = NULL;1324 char *new_with_pipe; 1325 1325 char *strtmp; 1326 1326 char *token; … … 1347 1347 } 1348 1348 } 1349 mr_asprintf(&find_excludes, "|"); 1349 1350 1350 1351 if (!depth) { 1351 mr_asprintf(find_excludes, " 1352 mr_asprintf(find_excludes, "|"); 1352 1353 if (sth != NULL) { 1353 1354 while((token = mr_strtok(sth, delims, &lastpos))) { … … 1417 1418 1418 1419 // log_msg(0, "Cataloguing %s", dir); 1419 if (sth[0] == ' ') { 1420 mr_asprintf(skip_these, "%s", sth); 1421 } else { 1422 mr_asprintf(skip_these, " %s ", sth); 1423 } 1424 mr_asprintf(new_with_spaces, " %s ", dir1); 1420 mr_asprintf(skip_these, "|%s|", sth); 1421 mr_asprintf(new_with_pipe, "|%s|", dir1); 1425 1422 if ((dip = opendir(dir1)) == NULL) { 1426 1423 mr_asprintf(tmp,"opendir %s", dir1); 1427 1424 log_OS_error(tmp); 1428 1425 mr_free(tmp); 1429 } else if (strstr(skip_these, new_with_ spaces)) {1426 } else if (strstr(skip_these, new_with_pipe)) { 1430 1427 log_msg(10, "Found dir ***%s**** excluded", dir1); 1431 1428 fprintf(fout, "%s\n", dir1); // if excluded dir then print dir ONLY … … 1440 1437 mr_asprintf(new,"%s%s",dir1,dit->d_name); 1441 1438 } 1442 mr_free(new_with_ spaces);1443 mr_asprintf(new_with_spaces, " %s", new);1444 if (strstr(skip_these, new_with_ spaces)) {1439 mr_free(new_with_pipe); 1440 mr_asprintf(new_with_spaces, "|%s|", new); 1441 if (strstr(skip_these, new_with_pipe)) { 1445 1442 fprintf(fout, "%s\n", new); 1446 1443 log_msg(10, "Found child dir ***%s**** excluded", new); 1447 mr_free(new_with_ spaces);1444 mr_free(new_with_pipe); 1448 1445 } else { 1449 mr_free(new_with_ spaces);1446 mr_free(new_with_pipe); 1450 1447 if (!lstat(new, &statbuf)) { 1451 1448 if (!S_ISLNK(statbuf.st_mode) … … 1474 1471 } 1475 1472 } 1476 mr_free(new_with_ spaces);1473 mr_free(new_with_pipe); 1477 1474 mr_free(skip_these); 1478 1475 mr_free(dir); … … 1584 1581 mr_free(tmp1); 1585 1582 1586 mr_asprintf(exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys /dev/shm " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir); 1587 mr_free(tmp2); 1583 mr_asprintf(exclude_paths, MONDO_CACHE"|%s|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/dev/shm|"MINDI_CACHE,(excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir); 1588 1584 1589 1585 log_msg(2, "Excluding paths = '%s'", exclude_paths); … … 1610 1606 p += strlen(q); 1611 1607 paranoid_free(q); 1612 while (*p == ' 1608 while (*p == '|') { 1613 1609 p++; 1614 1610 }
Note:
See TracChangeset
for help on using the changeset viewer.