From b36a1c36427842907f3b941e1e400d3ec4688f06 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Fri, 3 Dec 2021 00:31:57 -0800 Subject: [PATCH 1/3] consider partitionless disks to have one partition Signed-off-by: Tai Groot --- pkg/block/block_linux.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/block/block_linux.go b/pkg/block/block_linux.go index f68666d9..72b8f83b 100644 --- a/pkg/block/block_linux.go +++ b/pkg/block/block_linux.go @@ -206,6 +206,23 @@ func diskPartitions(ctx *context.Context, paths *linuxpath.Paths, disk string) [ } out = append(out, p) } + // this is a disk with no partitions on it. + // Consider the filesystem on the disk to be a partition. + if len(out) == 0 { + size := partitionSizeBytes(paths, disk, "") + mp, pt, ro := partitionInfo(paths, disk) + du := diskPartUUID(ctx, disk) + p := &Partition{ + Name: disk, + SizeBytes: size, + MountPoint: mp, + Type: pt, + IsReadOnly: ro, + UUID: du, + } + out = append(out, p) + + } return out } From aafe05b32d39400e12d01c386d063b90db5691f6 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Fri, 3 Dec 2021 10:29:59 -0800 Subject: [PATCH 2/3] update docstring to reflect partitionless disk changes Signed-off-by: Tai Groot --- pkg/block/block_linux.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/block/block_linux.go b/pkg/block/block_linux.go index 72b8f83b..5850f83b 100644 --- a/pkg/block/block_linux.go +++ b/pkg/block/block_linux.go @@ -179,7 +179,9 @@ func diskWWN(paths *linuxpath.Paths, disk string) string { // diskPartitions takes the name of a disk (note: *not* the path of the disk, // but just the name. In other words, "sda", not "/dev/sda" and "nvme0n1" not // "/dev/nvme0n1") and returns a slice of pointers to Partition structs -// representing the partitions in that disk +// representing the partitions in that disk. If a disk has no partitions, +// it returns information on the disk instead, but the Partition UUID is set +// to the empty string (since there isn't one.) func diskPartitions(ctx *context.Context, paths *linuxpath.Paths, disk string) []*Partition { out := make([]*Partition, 0) path := filepath.Join(paths.SysBlock, disk) From d95fc213399367a7bc08d18a9a11622da8891880 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sat, 19 Mar 2022 12:42:21 -0700 Subject: [PATCH 3/3] Ignore permission deined errors when creating a snapshot --- pkg/snapshot/clonetree.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/snapshot/clonetree.go b/pkg/snapshot/clonetree.go index 97308031..c31ef341 100644 --- a/pkg/snapshot/clonetree.go +++ b/pkg/snapshot/clonetree.go @@ -8,6 +8,7 @@ package snapshot import ( "errors" + "io/fs" "io/ioutil" "os" "path/filepath" @@ -149,7 +150,7 @@ func copyFileTreeInto(paths []string, destDir string, opts *CopyFileOptions) err } } else { trace(" copying file: %q -> %q\n", path, destPath) - if err := copyPseudoFile(path, destPath); err != nil { + if err := copyPseudoFile(path, destPath); err != nil && !errors.Is(err, fs.ErrPermission) { return err } }