fstools: allow multiple mount points for a single device (e.g., Btrfs subvolumes)#16
Open
shenwii wants to merge 1 commit into
Open
fstools: allow multiple mount points for a single device (e.g., Btrfs subvolumes)#16shenwii wants to merge 1 commit into
shenwii wants to merge 1 commit into
Conversation
Author
9027aab to
c7ba4b7
Compare
Previously, if multiple 'mount' sections in /etc/config/fstab referred to the same physical device (via UUID, Label, or device path), the latter configuration would override the previous ones, resulting in only one active mount point. This patch modifies the device matching logic to allow a single source device to be mounted to multiple target paths. This is particularly useful for users who need to expose the same partition in different directory structures. Signed-off-by: Shen Wei <shinkosame@gmail.com>
c7ba4b7 to
c86a72d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This MR enables support for mounting the same physical device (identified by UUID, Label, or device path) to multiple target mount points.
Background
Although the Linux kernel allows a single device to be mounted to different locations, the current implementation of
fstoolsincorrectly treats the device identifier as a unique key, preventing multiple mount entries. This is particularly restrictive for Btrfs users who need to mount different subvolumes (subvol) to various system paths.Key Changes
mount_addfunctionChanged the internal storage key from a simple identifier (UUID/Label/Device) to a composite key:
concat(identifier, ",", target). This allows the system to store and track multiple configuration records for the same device.find_block&find_mount_pointfunctionsUpdated these functions to return multiple device+target combinations. I have implemented a limit of 10 mount points per device, which should be sufficient for most use cases. All calling functions have been updated with loops to process these multiple results.
umount_devicefunctionAdded a
skip_extrootflag to handle logic conflicts betweenmount_actionandmain_umount.Testing
Configuration Example
To demonstrate the use case, this change allows a single Btrfs partition to be mounted to multiple paths using subvolumes in
/etc/config/fstab:Previously, if multiple mount sections shared the same UUID, the later entry would overwrite the previous one in the
vlist(due to the device identifier being used as the unique key). This patch ensures each unique(device, target)pair is treated as a distinct entry.Testing Result
The following commands have been tested and are working as expected:
block mountblock umountblock detectblock infoNote: Currently, the
block infocommand does not display mount options (such as Btrfssubvol). Consequently, while multiple mount points for the same device are now functional, theblock infooutput may not yet reflect these specific options. I plan to submit a follow-up patch to includeoptionsdetails in theblock infooutput to improve visibility.Note: Changes in
main_autofsand other areas were implemented for consistency but have not been fully tested in a live environment. Feedback or testing from others is welcome.