Skip to content

libmount: when moving a mount point, all sub mount entries in utab sh…#1660

Merged
karelzak merged 1 commit intoutil-linux:masterfrom
fbuihuu:fix-move-with-sub-mounted-trees
May 4, 2022
Merged

libmount: when moving a mount point, all sub mount entries in utab sh…#1660
karelzak merged 1 commit intoutil-linux:masterfrom
fbuihuu:fix-move-with-sub-mounted-trees

Conversation

@fbuihuu
Copy link
Contributor

@fbuihuu fbuihuu commented Apr 22, 2022

…ould also be updated

Given that /run/mount/utab stores paths, this file needs to be adjusted when a
mount tree is moved.

However the moved tree may contains sub mount points in which case their utab
entries (if any) need to also be translated.

This patch takes care of that.

As suggested in systemd/systemd#15266, a better
approach might be to store mount IDs instead of paths since mount IDs remain
unchanged when mount trees are moved.

Fixes: #1659

…ould also be updated

Given that /run/mount/utab stores paths, this file needs to be adjusted when a
mount tree is moved.

However the moved tree may contains sub mount points in which case their utab
entries (if any) need to also be translated.

This patch takes care of that.

As suggested in systemd/systemd#15266, a better
approach might be to store mount IDs instead of paths since mount IDs remain
unchanged when mount trees are moved.

Fixes: util-linux#1659
@karelzak karelzak merged commit e6829b5 into util-linux:master May 4, 2022
karelzak added a commit that referenced this pull request May 4, 2022
* avoid double '//'

* don't update /fooxxx when /foo update requested (make sure that
  startswith() returns path terminated by '/')

* canonicalize only once the new path -- all in utab/mtab is already
  canonicalized, so after MS_MOVE we need to care about the new path
  only

* use asprintf() rather than strcpy() and strcat(), don't compose a
  new path from prefix and subdir when replace entire path

Addresses: #1660
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
Copy link
Collaborator

karelzak commented May 4, 2022

I found some issues in the commit, which should be fixed by 1ec32f4

Probably the most important is that we don't want to update /fooxxx on --move /foo /bar. I have also removed path canonicalization for each entry. It seems enough to canonicalize the path to the wanted target only (as subdirectories in the utab paths should be already canonicalized).

karelzak added a commit that referenced this pull request Jul 20, 2022
* avoid double '//'

* don't update /fooxxx when /foo update requested (make sure that
  startswith() returns path terminated by '/')

* canonicalize only once the new path -- all in utab/mtab is already
  canonicalized, so after MS_MOVE we need to care about the new path
  only

* use asprintf() rather than strcpy() and strcat(), don't compose a
  new path from prefix and subdir when replace entire path

Addresses: #1660
Signed-off-by: Karel Zak <kzak@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When moving a mounted tree, all mounted sub tree entries in utab should also be updated

2 participants