Changeset 2713 in MondoRescue
- Timestamp:
- Feb 2, 2011, 12:35:51 PM (14 years ago)
- Location:
- branches/2.2.9/mondo/src/common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-cli.c
r2698 r2713 277 277 } 278 278 if (bkpinfo->include_paths[0]) { 279 strcat(bkpinfo->include_paths, " 279 strcat(bkpinfo->include_paths, "|"); 280 280 } 281 281 … … 286 286 /* Cut the flag_val['I'] in parts containing all paths to test them */ 287 287 while (p != NULL) { 288 q = strchr(p, ' 288 q = strchr(p, '|'); 289 289 if (q != NULL) { 290 290 *q = '\0'; … … 612 612 log_to_screen("Please supply a sensible value with '-E'\n"); 613 613 } 614 mr_strcat(bkpinfo->exclude_paths, " ");615 614 mr_asprintf(&tmp1, "%s", flag_val['E']); 616 615 … … 620 619 /* Cut the flag_val['E'] in parts containing all paths to test them */ 621 620 while (p != NULL) { 622 q = strchr(p, ' 621 q = strchr(p, '|'); 623 622 if (q != NULL) { 624 623 *q = '\0'; … … 655 654 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude Network mounts & devices 656 655 { 657 mr_asprintf(&psz, "%s", list_of_NETFS_mounts_only()); 658 mr_strcat(bkpinfo->exclude_paths, "%s ", psz); 659 mr_free(psz); 656 psz = list_of_NETFS_mounts_only(); 657 log_msg(5, "-N means we'll exclude %s", psz); 658 if (bkpinfo->exclude_paths) { 659 mr_strcat(bkpinfo->exclude_paths, "|%s", psz); 660 mr_free(psz); 661 } else { 662 bkpinfo->exclude_paths = psz; 663 } 660 664 661 665 if (bkpinfo->exclude_paths != NULL) { -
branches/2.2.9/mondo/src/common/libmondo-devices-EXT.h
r2380 r2713 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.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 -
branches/2.2.9/mondo/src/common/libmondo-devices.h
r2380 r2713 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.9/mondo/src/common/libmondo-filelist.c
r2711 r2713 1295 1295 mr_asprintf(&sz_res, "%s", incoming); 1296 1296 p = sz_res; 1297 while ((*p != ' 1297 while ((*p != '|' || in_quotes) && *p != '\0') { 1298 1298 if (*p == '\"') { 1299 1299 in_quotes = !in_quotes; … … 1326 1326 time_t time_of_last_full_backup) 1327 1327 { 1328 const char delims[] = " 1328 const char delims[] = "|"; 1329 1329 1330 1330 DIR *dip; … … 1336 1336 static int percentage = 0; 1337 1337 char *skip_these; 1338 char *new_with_ spaces;1338 char *new_with_pipe; 1339 1339 char *strtmp; 1340 1340 char *token; … … 1434 1434 1435 1435 // log_msg(0, "Cataloguing %s", dir); 1436 if (sth[0] == ' ') { 1437 mr_asprintf(&skip_these, "%s", sth); 1438 } else { 1439 mr_asprintf(&skip_these, " %s ", sth); 1440 } 1441 mr_asprintf(&new_with_spaces, " %s ", dir1); 1436 mr_asprintf(&skip_these, "|%s|", sth); 1437 1438 mr_asprintf(&new_with_pipe, "|%s|", dir1); 1442 1439 if ((dip = opendir(dir1)) == NULL) { 1443 1440 mr_asprintf(&tmp,"opendir %s", dir1); 1444 1441 log_OS_error(tmp); 1445 1442 paranoid_free(tmp); 1446 } else if (strstr(skip_these, new_with_ spaces)) {1443 } else if (strstr(skip_these, new_with_pipe)) { 1447 1444 log_msg(10, "Found dir ***%s**** excluded", dir1); 1448 1445 fprintf(fout, "%s\n", dir1); // if excluded dir then print dir ONLY … … 1457 1454 mr_asprintf(&new,"%s%s",dir1,dit->d_name); 1458 1455 } 1459 paranoid_free(new_with_ spaces);1460 mr_asprintf(&new_with_ spaces, " %s", new);1461 if (strstr(skip_these, new_with_ spaces)) {1456 paranoid_free(new_with_pipe); 1457 mr_asprintf(&new_with_pipe, "|%s|", new); 1458 if (strstr(skip_these, new_with_pipe)) { 1462 1459 fprintf(fout, "%s\n", new); 1463 1460 log_msg(10, "Found child dir ***%s**** excluded", new); 1464 paranoid_free(new_with_ spaces);1461 paranoid_free(new_with_pipe); 1465 1462 } else { 1466 paranoid_free(new_with_ spaces);1463 paranoid_free(new_with_pipe); 1467 1464 if (!lstat(new, &statbuf)) { 1468 1465 if (!S_ISLNK(statbuf.st_mode) … … 1497 1494 } 1498 1495 } 1499 paranoid_free(new_with_ spaces);1496 paranoid_free(new_with_pipe); 1500 1497 paranoid_free(skip_these); 1501 1498 mr_free(dir); … … 1538 1535 char *p, *q; 1539 1536 char *sz_datefile; 1540 char *sz_filelist, *exclude_paths, *tmp; 1537 char *sz_filelist, *tmp; 1538 char *exclude_paths = NULL; 1541 1539 int i; 1542 1540 FILE *fout; … … 1549 1547 malloc_string(tmp); 1550 1548 malloc_string(g_skeleton_filelist); 1551 if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {1552 fatal_error("Cannot malloc exclude_paths");1553 }1554 1549 mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1555 1550 if (!include_paths && !userdef_filelist) { … … 1619 1614 paranoid_free(tmp1); 1620 1615 1621 snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \ 1622 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \ 1623 /proc /sys /dev/shm " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1616 mr_asprintf(&exclude_paths, MONDO_CACHE"|%s|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/dev/shm|"MINDI_CACHE,excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1624 1617 paranoid_free(tmp2); 1625 1618 … … 1648 1641 p += strlen(q); 1649 1642 paranoid_free(q); 1650 while (*p == ' 1643 while (*p == '|') { 1651 1644 p++; 1652 1645 }
Note:
See TracChangeset
for help on using the changeset viewer.