talos/internal/pkg/mount/v2/squashfs.go
Andrey Smirnov 62ec7ec336
refactor: replace the old v1 mount package with new one
Re-design some methods, simplify flows and allow more simple
interactions.

Learn from mistakes and design better methods.

Fixes #9471

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-10-30 14:21:28 +04:00

21 lines
670 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package mount
import (
"github.com/freddierice/go-losetup/v2"
"golang.org/x/sys/unix"
)
// Squashfs binds the squashfs to the loop device and returns the mountpoint for it to the specified target.
func Squashfs(target, squashfsFile string) (*Point, error) {
dev, err := losetup.Attach(squashfsFile, 0, true)
if err != nil {
return nil, err
}
return NewPoint(dev.Path(), target, "squashfs", WithFlags(unix.MS_RDONLY|unix.MS_I_VERSION), WithShared()), nil
}