public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Disseldorp <ddiss@suse.de>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH 1/3] Btrfs-progs: fix mount point detection due to partial prefix match
Date: Mon, 14 Jan 2019 14:59:44 +0100	[thread overview]
Message-ID: <20190114145944.609d56b6@suse.de> (raw)
In-Reply-To: <20190114133024.18320-1-fdmanana@kernel.org>

On Mon, 14 Jan 2019 13:30:24 +0000, fdmanana@kernel.org wrote:

> From: Filipe Manana <fdmanana@suse.com>
> 
> When attempting to find the mount point of a path we can end up returning
> an incorrect mount point. This happens because we consider a mount point
> valid for the given path even if it matches only partially the patch.

s/patch/path/? "...even if it only partially matches" might be a bit
clearer.

> diff --git a/utils.c b/utils.c
> index 3a4bc92a..6616630b 100644
> --- a/utils.c
> +++ b/utils.c
> @@ -2064,7 +2064,8 @@ int find_mount_root(const char *path, char **mount_root)
>  
>  	while ((ent = getmntent(mnttab))) {
>  		len = strlen(ent->mnt_dir);
> -		if (strncmp(ent->mnt_dir, path, len) == 0) {
> +		if (strncmp(ent->mnt_dir, path, len) == 0 &&
> +		    (path[len] == '/' || path[len] == '\0')) {

Looks good and works for me.
Reviewed-by: David Disseldorp <ddiss@suse.de>

  reply	other threads:[~2019-01-14 13:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 13:30 [PATCH 1/3] Btrfs-progs: fix mount point detection due to partial prefix match fdmanana
2019-01-14 13:59 ` David Disseldorp [this message]
2019-01-14 14:12   ` Filipe Manana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190114145944.609d56b6@suse.de \
    --to=ddiss@suse.de \
    --cc=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox