diff options
Diffstat (limited to 'cmds-send.c')
-rw-r--r-- | cmds-send.c | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/cmds-send.c b/cmds-send.c index fc9a01ee..9d49ce9f 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -39,6 +39,7 @@ #include "ioctl.h" #include "commands.h" #include "list.h" +#include "utils.h" #include "send.h" #include "send-utils.h" @@ -57,54 +58,6 @@ struct btrfs_send { struct subvol_uuid_search sus; }; -int find_mount_root(const char *path, char **mount_root) -{ - FILE *mnttab; - int fd; - struct mntent *ent; - int len; - int ret; - int longest_matchlen = 0; - char *longest_match = NULL; - - fd = open(path, O_RDONLY | O_NOATIME); - if (fd < 0) - return -errno; - close(fd); - - mnttab = setmntent("/proc/self/mounts", "r"); - if (!mnttab) - return -errno; - - while ((ent = getmntent(mnttab))) { - len = strlen(ent->mnt_dir); - if (strncmp(ent->mnt_dir, path, len) == 0) { - /* match found */ - if (longest_matchlen < len) { - free(longest_match); - longest_matchlen = len; - longest_match = strdup(ent->mnt_dir); - } - } - } - endmntent(mnttab); - - if (!longest_match) { - fprintf(stderr, - "ERROR: Failed to find mount root for path %s.\n", - path); - return -ENOENT; - } - - ret = 0; - *mount_root = realpath(longest_match, NULL); - if (!*mount_root) - ret = -errno; - - free(longest_match); - return ret; -} - static int get_root_id(struct btrfs_send *s, const char *path, u64 *root_id) { struct subvol_info *si; |