summaryrefslogtreecommitdiff
path: root/cmd/btrfs-rec/inspect_mount.go
blob: cff33b6b566f618df3fe69e0fea6b9c3f8572f86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2022  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

package main

import (
	"github.com/datawire/ocibuild/pkg/cliutil"
	"github.com/spf13/cobra"

	"git.lukeshu.com/btrfs-progs-ng/lib/btrfs"
	"git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect"
)

func init() {
	var skipFileSums bool
	cmd := subcommand{
		Command: cobra.Command{
			Use:   "mount MOUNTPOINT",
			Short: "Mount the filesystem read-only",
			Args:  cliutil.WrapPositionalArgs(cobra.ExactArgs(1)),
		},
		RunE: func(fs *btrfs.FS, cmd *cobra.Command, args []string) error {
			return btrfsinspect.MountRO(cmd.Context(), fs, args[0], skipFileSums)
		},
	}
	cmd.Command.Flags().BoolVar(&skipFileSums, "skip-filesums", false,
		"ignore checksum failures on file contents; allow such files to be read")
	inspectors = append(inspectors, cmd)
}