Commit 89d75796 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

mount: ignore subvol argument in btrfs sb

See comment for details, but basically this mountopt can be completely
wrong in some cases.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 45273419
......@@ -281,8 +281,43 @@ bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev,
*/
static bool mounts_sb_equal(struct mount_info *a, struct mount_info *b)
{
return a->s_dev == b->s_dev && a->fstype == b->fstype &&
!strcmp(a->source, b->source) && !strcmp(a->options, b->options);
if (a->fstype != b->fstype)
return false;
/* There is a btrfs bug where it doesn't emit subvol= correctly when
* files are bind mounted, so let's ignore it for now.
* https://marc.info/?l=linux-btrfs&m=145857372803614&w=2
*/
if (!strcmp(a->fstype->name, "btrfs")) {
char *posa = strstr(a->options, "subvol="), *posb = strstr(b->options, "subvol=");
bool equal;
if (!posa || !posb) {
pr_err("invalid btrfs options, no subvol argument");
return false;
}
*posa = *posb = 0;
equal = !strcmp(a->options, b->options);
*posa = *posb = 's';
if (!equal)
return false;
posa = strchr(posa, ',');
posb = strchr(posb, ',');
if ((posa && !posb) || (!posa && posb))
return false;
if (posa && strcmp(posa, posb))
return false;
} else {
if (strcmp(a->options, b->options))
return false;
}
return a->s_dev == b->s_dev && !strcmp(a->source, b->source);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment