[BUG] Linux DiskProvider incorrectly selects underlying filesystem for over-mounted paths

Open Beginner friendly
#373 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp, docker, linux
Domain
backend

Research direction

Read src/NzbDrone.Mono/Disk/DiskProvider.cs and src/NzbDrone.Mono/Disk/ProcMountProvider.cs to trace how /proc/mounts and DriveInfo entries are combined and deduplicated. Add a regression test for two mounts at the same path, with ext4 followed by cifs; done when the discovered mount is cifs with DriveType.Network and DriveInfo remains a fallback.

Written by the indexing model from the issue text.

Description

bug

Describe the bug

On Linux, Chaptarr can select the wrong filesystem when multiple mounts share the same mount-point path.

NzbDrone.Mono.Disk.DiskProvider.GetAllMounts() combines mounts from /proc/mounts with DriveInfo mounts, then calls:

mounts.DistinctBy(v => v.RootDirectory)

DistinctBy keeps the first entry for each mount point. When a filesystem is mounted over an existing mount point, the underlying mount can appear first in /proc/mounts, causing Chaptarr to discard the actual over-mounted filesystem.

For example, the underlying filesystem may be reported as ext4, while the filesystem mounted over it is a network share using cifs. Chaptarr then identifies the path as a local filesystem instead of a network mount.

To Reproduce

  1. Run Chaptarr in Docker on Linux.

  2. Create or use a directory on a local filesystem as a mount point.

  3. Mount a network share (CIFS/SMB) over that directory.

  4. Inspect /proc/mounts. Both entries may appear, with the underlying filesystem first:

    /dev/mapper/local-root /mnt/example ext4 rw,... 0 0
    //server/share /mnt/example cifs rw,... 0 0
    
  5. Let Chaptarr discover the mounts.

  6. Observe that the first entry (ext4) is retained and the CIFS entry is discarded because both have the same RootDirectory.

Expected behavior

When multiple mounts share the same mount-point path, Chaptarr should identify the filesystem that is actually mounted on top, rather than retaining the underlying filesystem.

In this example, the mount should be identified as cifs with DriveType.Network.

The DriveInfo fallback should also remain secondary to mount information obtained from /proc/mounts.

Screenshots

Not applicable. The issue can be demonstrated using the mount table output above.

System Information

  • OS: Linux (Proxmox LXC)
  • Chaptarr Version: 0.9.1000.0
  • Installation Method: Docker
  • Browser: Not relevant to this issue

Docker Information

  • Docker version: Not yet included
  • Docker Compose version: Not yet included
  • Container: Chaptarr

Additional context

This appears to be an issue in the Linux mount-discovery implementation rather than something specific to one NAS or installation.

Relevant source files:

  • src/NzbDrone.Mono/Disk/DiskProvider.cs
  • src/NzbDrone.Mono/Disk/ProcMountProvider.cs

A possible fix would be to retain the topmost/latest /proc/mounts entry for each mount point, while ensuring that DriveInfo entries do not override entries obtained from /proc/mounts.

A regression test should cover two mounts with the same mount point, where an ext4 entry is followed by a cifs entry, and verify that the resulting mount is identified as cifs.

This issue is separate from an AudioBookShelf deletion-synchronization problem; a connection between the two has not been established.

Logs

Example mount information:

$ findmnt -T /mnt/example

TARGET       SOURCE                  FSTYPE
/mnt/example /dev/mapper/local-root  ext4
/mnt/example //server/share          cifs

The corresponding /proc/mounts entries are included above.

No Chaptarr error is necessarily logged, because the problem is that the mount is classified incorrectly rather than an exception being thrown.

Dominant language
C#
Stars
664
Forks
48
Avg merge
5h 47m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Chaptarr/chaptarr

All issues in Chaptarr/chaptarr

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.