diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-02 22:35:00 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-17 22:30:37 -0400 |
commit | e1569565240cf6487ebeb5ec4c1386c8ba70f493 (patch) | |
tree | a078f324529f9cefbc75fcf0e05b0d3e3a1b68ff /cmd/btrfs-rec/inspect/mount | |
parent | 26e58f1cd1d47b63b1b05b26c73c4f69f7e245cb (diff) |
btrfs: io4_fs.go: Subvolume: Don't have public members; use a constructor
Diffstat (limited to 'cmd/btrfs-rec/inspect/mount')
-rw-r--r-- | cmd/btrfs-rec/inspect/mount/mount.go | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/cmd/btrfs-rec/inspect/mount/mount.go b/cmd/btrfs-rec/inspect/mount/mount.go index 0e8faf1..4049393 100644 --- a/cmd/btrfs-rec/inspect/mount/mount.go +++ b/cmd/btrfs-rec/inspect/mount/mount.go @@ -28,6 +28,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree" "git.lukeshu.com/btrfs-progs-ng/lib/btrfsutil" "git.lukeshu.com/btrfs-progs-ng/lib/containers" "git.lukeshu.com/btrfs-progs-ng/lib/maps" @@ -45,14 +46,21 @@ func MountRO(ctx context.Context, fs *btrfs.FS, mountpoint string, noChecksums b deviceName = abs } + sb, err := fs.Superblock() + if err != nil { + return err + } + rootSubvol := &subvolume{ - Subvolume: btrfs.Subvolume{ - FS: btrfsutil.NewOldRebuiltForrest(ctx, fs), - TreeID: btrfsprim.FS_TREE_OBJECTID, - NoChecksums: noChecksums, - }, + Subvolume: btrfs.NewSubvolume( + btrfsutil.NewOldRebuiltForrest(ctx, fs), + btrfsprim.FS_TREE_OBJECTID, + noChecksums, + ), DeviceName: deviceName, Mountpoint: mountpoint, + + sb: sb, } return rootSubvol.Run(ctx) } @@ -107,10 +115,12 @@ type fileState struct { } type subvolume struct { - btrfs.Subvolume + *btrfs.Subvolume DeviceName string Mountpoint string + sb *btrfstree.Superblock + fuseutil.NotImplementedFileSystem lastHandle uint64 dirHandles typedsync.Map[fuseops.HandleID, *dirState] @@ -189,11 +199,8 @@ func (sv *subvolume) LoadDir(inode btrfsprim.ObjID) (val *btrfs.Dir, err error) workerName := fmt.Sprintf("%d-%s", val.Inode, filepath.Base(subMountpoint)) sv.grp.Go(workerName, func(ctx context.Context) error { subSv := &subvolume{ - Subvolume: btrfs.Subvolume{ - FS: sv.FS, - TreeID: entry.Location.ObjectID, - NoChecksums: sv.NoChecksums, - }, + sb: sv.sb, + Subvolume: sv.NewChildSubvolume(entry.Location.ObjectID), DeviceName: sv.DeviceName, Mountpoint: filepath.Join(sv.Mountpoint, subMountpoint[1:]), } @@ -208,11 +215,9 @@ func (sv *subvolume) LoadDir(inode btrfsprim.ObjID) (val *btrfs.Dir, err error) } func (sv *subvolume) StatFS(_ context.Context, op *fuseops.StatFSOp) error { + sb := sv.sb + // See linux.git/fs/btrfs/super.c:btrfs_statfs() - sb, err := sv.FS.Superblock() - if err != nil { - return err - } op.IoSize = sb.SectorSize op.BlockSize = sb.SectorSize |