aboutsummaryrefslogtreecommitdiff
path: root/cmd/verify.go
blob: 9c7947cb0217b5adeb85a113602abfca3fb923d2 (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cmd

import (
	"fmt"
	"github.com/axtloss/fsverify/core"
	"github.com/spf13/cobra"
)

func NewVerifyCommand() *cobra.Command {
	cmd := &cobra.Command{
		Use:          "verify",
		Short:        "Verify the root filesystem based on the given verification",
		RunE:         ValidateCommand,
		SilenceUsage: true,
	}

	return cmd
}

func ValidateCommand(_ *cobra.Command, args []string) error {

	header, err := core.ReadHeader("./part.fsverify")
	fmt.Println(header.MagicNumber)
	fmt.Println(header.Signature)
	fmt.Println(header.FilesystemSize)
	fmt.Println(header.TableSize)
	if err != nil {
		return err
	}
	dbfile, err := core.ReadDB("./part.fsverify")
	if err != nil {
		return err
	}
	fmt.Println("DBFILE: ", dbfile)
	db, err := core.OpenDB(dbfile)
	if err != nil {
		return err
	}

	getnode, err := core.GetNode("aaaa", db)
	if err != nil {
		return err
	}
	fmt.Println(getnode)
	return nil
}