Ignore:
Timestamp:
Feb 2, 2011, 1:18:23 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Document in man page and HOWTO the previous syntax modifications for -E/-I options and '|' separator
  • Fix #444. mondoarchive now supports inclusion/exclusion of dirs with spaces in their name. this required a syntax change for the -E/-I options where the list of dirs needs to be separated by '|' now instead of ' '.
  • Fix issus with mindi when launched from a dir containing spaces
  • Fix a but when no -E option is give on CLI (null) string generated
  • Fix #459 by correcting an old README containing info on the edit-mountlist binary which doesn't exist.

svn merge -r 2709:2714 svn+ssh://bruno@svn.mondorescue.org/mondo/svn/mondorescue/branches/2.2.9 .

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2704 r2715  
    19561956            log_msg (4, "%s is mounted on %s and is on disk %s", DSFptr->device, DSFptr->mount_point, ndsf);
    19571957            strcat(*included_dsf_list, DSFptr->mount_point);
    1958             strcat(*included_dsf_list, " ");
     1958            strcat(*included_dsf_list, "|");
    19591959        } else {
    19601960            log_msg (4, "%s is mounted on %s and is NOT on disk %s", DSFptr->device, DSFptr->mount_point, ndsf);
    19611961            strcat(*excluded_dsf_list, DSFptr->mount_point);
    1962             strcat(*excluded_dsf_list, " ");
     1962            strcat(*excluded_dsf_list, "|");
    19631963        }
    19641964        DSFptr = DSFptr->next;
     
    19801980char *mounted_on_dsf = NULL;
    19811981char *not_mounted_on_dsf = NULL;
    1982 char token_chars[] =" \t\r\f\a\0\n";
     1982char token_chars[] ="|\t\r\f\a\0\n";
    19831983char *tmp = NULL;
    19841984char *tmp1 = NULL;
     
    20012001                log_to_screen("==> %s", mounted_on_dsf);
    20022002                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                }
    20052013            }
    20062014        } else {
     
    20132021                log_to_screen("Not archiving the following file systems:");
    20142022                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                }
    20162028            }
    20172029        }
     
    20232035    /* A device special file was not passed in. Process it as a path. */
    20242036    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);
    20272039        if (mode == 'E') {
    20282040            /*  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);
    20302042            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                }
    20322049            }
    20332050        } else {
    20342051            /*  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);
    20362053            if (strstr(tmp,tmp1) == NULL) {
    20372054                mr_strcat(bkpinfo->include_paths, "%s", tmp1);
    20382055            }
     2056            mr_free(tmp1);
    20392057        }
    20402058        mr_free(tmp);
    2041         mr_free(tmp1);
    20422059        break;
    20432060    }
     
    20452062
    20462063    if (bkpinfo->include_paths != NULL) {
    2047         mr_strip_spaces(bkpinfo->include_paths);
    20482064        log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
    20492065    }
    20502066    if (bkpinfo->exclude_paths != NULL) {
    2051         mr_strip_spaces(bkpinfo->exclude_paths);
    20522067        log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
    20532068    }
    20542069    if (bkpinfo->exclude_devs != NULL) {
    2055         mr_strip_spaces(bkpinfo->exclude_devs);
    20562070        log_msg(1, "exclude_devs is now '%s'", bkpinfo->exclude_devs);
    20572071    }
     
    20612075
    20622076/**
    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.
    20682078 * @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 */
     2082char *list_of_NETFS_mounts_only(void)
     2083{
    20742084    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);
    21032089}
    21042090
     
    31063092        bkpinfo->include_paths = p;
    31073093
    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);
    31093095        if (p == NULL) {
    31103096            log_to_screen("User has chosen not to backup the PC");
     
    31143100        bkpinfo->include_paths = p;
    31153101
    3116         mr_asprintf(tmp, "%s", list_of_NETFS_mounts_only());
     3102        tmp = list_of_NETFS_mounts_only();
    31173103        if (strlen(tmp) > 2) {
    3118             mr_strcat(bkpinfo->exclude_paths, " %s",tmp);
     3104            mr_strcat(bkpinfo->exclude_paths, "|%s",tmp);
    31193105        }
    31203106        mr_free(tmp);
     
    31333119
    31343120
    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);
    31363122        if (p == NULL) {
    31373123            log_to_screen("User has chosen not to backup the PC");
     
    31403126        mr_free(bkpinfo->exclude_paths);
    31413127        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, "|");
    31443130
    31453131        p = popup_and_get_string("Temporary directory", "Please enter your temporary directory.", bkpinfo->tmpdir);
     
    32173203    /*  the mr_make_devlist_from_pathlist function appends
    32183204    *  to the *_paths variables so copy before */
    3219     mr_asprintf(tmp, "%s ", bkpinfo->exclude_paths);
     3205    mr_asprintf(tmp, "%s|", bkpinfo->exclude_paths);
    32203206    mr_make_devlist_from_pathlist(tmp, 'E');
    32213207    mr_free(tmp);
    3222     mr_asprintf(tmp, "%s ", bkpinfo->include_paths);
     3208    mr_asprintf(tmp, "%s|", bkpinfo->include_paths);
    32233209    mr_make_devlist_from_pathlist(tmp, 'I');
    32243210    mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.