Seadrive incorrect block count for `stat`, breaks disk images, potential data loss

Issue: SeaDrive’s fuse library always returns st_blocks = 0. This means that stat ~/SeaDrive/.../Example always shows Blocks: 0.

This has potential to be really bad. It causes compatibility issues with tools that use block count, like disk image mounting. An easy example is to drop a .iso file in SeaDrive, then try and mount it via gnome-disk-image-mounter example.iso – it will silently fail if the .iso is in SeaDrive.

There’s even a chance of silent data loss if tools use block count to determine whether to read the contents of the file. It would be reasonable to skip reading a source file if it has 0 blocks, as it would be considered to be 100% empty/entirely sparse.

Potential fix: Populate st_blocks field to ceil( st_size / 512 )
e.g. In fuse_ops.c:412 something like:

st.st_blocks = (st.st_size + 511) / 512; // Ceil

Example: Disk image mounting

# Create a .iso file as an example
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ mkdir /tmp/isocontents && dd if=/dev/zero of=/tmp/isocontents/example bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.00236388 s, 4.4 GB/s

[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ genisoimage -o test.iso /tmp/isocontents
I: -input-charset not specified, using utf-8 (detected in locale settings)
 94.45% done, estimate finish Thu Jun  4 21:20:40 2026
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 112
Path table size(bytes): 10
Max brk space used 0
5294 extents written (10 MB)

# `stat` shows Blocks: 0 (incorrect!)
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ stat test.iso
  File: test.iso
  Size: 10842112        Blocks: 0          IO Block: 4096   regular file
Device: 0,84    Inode: 8182        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     rob)   Gid: (  100/   users)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 2026-06-04 21:20:40.000000000 +0100
Change: 1970-01-01 01:00:00.000000000 +0100
 Birth: -

# Try and mount from SeaDrive - FAILS
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ udisksctl loop-setup -f test.iso
Error setting up loop device for test.iso: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error waiting for loop object after creating '/dev/loop6': Timed out waiting for object

# Copy to local disk
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ cp test.iso ~/test.iso

# `stat` shows correct 'Blocks:' count
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ stat ~/test.iso
  File: /home/rob/test.iso
  Size: 10842112        Blocks: 21176      IO Block: 4096   regular file
Device: 8,2     Inode: 20054072    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     rob)   Gid: (  100/   users)
Access: 2026-06-04 21:21:19.604083223 +0100
Modify: 2026-06-04 21:21:19.480084308 +0100
Change: 2026-06-04 21:21:19.480084308 +0100
 Birth: 2026-06-04 21:21:19.464084448 +0100

# Try and mount from local disk - SUCCESS
[nix-shell:/run/user/1000/SeaDrive/My Libraries/Files]$ udisksctl loop-setup -f ~/test.iso
Mapped file /home/rob/test.iso as /dev/loop7.

Follow-up: I attempted a patch (populated st_blocks with appropriate values). It didn’t actually fix the underlying issue.

Turns out the issue is as follows:

  1. gnome-disk-image-mounter / udisksctl loop-setup notify udisksd to set up a loop device for the .iso file.
  2. If the .iso file lives in a SeaDrive FUSE mount, udisksd can’t access it. Because it runs as root, and a seadrive-fuse mount is mounted without permission for other users (including root) to access the mount.
  3. This causes the error: Error setting up loop device for test.iso: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error waiting for loop object after creating '/dev/loop6': Timed out waiting for object. If gnome-disk-image-mounter was used, e.g. via nautilus, the failure is silent.
  4. You end up in a half-mounted state with an unusable zero-sized loop device because the file was not readable as root so its size was unknown.

The fix:

  1. Mount SeaDrive with the fuse option -o allow_root
  2. Ensure /etc/fuse.conf enables user_allow_other. (Or on NixOS, programs.fuse.userAllowOther = true)

The st_blocks = 0 issue is still not ideal, but it turns out it was not the cause of the issues I was experiencing. It’s likely causing some other weird edge causes though, so should probably be fixed.

PR here anyway: fuse-ops.c: populate st_blocks by iamcalledrob · Pull Request #41 · haiwen/seadrive-fuse · GitHub

Thanks for reporting the issue. We will give it a check.