Skip to content

Commit 23cdccf

Browse files
committed
refactor: fork and add linux build tags
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent e17d9b2 commit 23cdccf

6 files changed

Lines changed: 20 additions & 7 deletions

File tree

fs.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
Copyright 2018 Google Inc.
35
@@ -21,14 +23,13 @@ import (
2123
"bytes"
2224
"errors"
2325
"fmt"
24-
"io/ioutil"
2526
"os"
2627
"os/exec"
2728
"path/filepath"
2829
"strings"
2930
"syscall"
3031

31-
"github.com/bradfitz/embiggen-disk/findmnt"
32+
"github.com/skiffos/embiggen-disk/findmnt"
3233
"golang.org/x/sys/unix"
3334
)
3435

@@ -123,7 +124,7 @@ func statFS(mnt string) (fs fsStat, err error) {
123124
return
124125
}
125126

126-
mounts, err := ioutil.ReadFile("/proc/mounts")
127+
mounts, err := os.ReadFile("/proc/mounts")
127128
if err != nil {
128129
return
129130
}
@@ -194,16 +195,20 @@ func statFSFindmnt(mnt string) (fs fsStat, err error) {
194195

195196
// findDevRoot finds which block device (e.g. "/dev/nvme0n1p1") patches the device number of /dev/root.
196197
func findDevRoot() (string, error) {
197-
fis, err := ioutil.ReadDir("/dev")
198+
fis, err := os.ReadDir("/dev")
198199
if err != nil {
199200
return "", err
200201
}
201202
dev := map[string]uint64{}
202203
for _, fi := range fis {
203-
if fi.Mode()&os.ModeDevice == 0 || fi.Mode()&os.ModeCharDevice != 0 {
204+
fii, err := fi.Info()
205+
if err != nil {
206+
continue
207+
}
208+
if fii.Mode()&os.ModeDevice == 0 || fii.Mode()&os.ModeCharDevice != 0 {
204209
continue
205210
}
206-
dev[fi.Name()] = fi.Sys().(*syscall.Stat_t).Rdev
211+
dev[fi.Name()] = uint64(fii.Sys().(*syscall.Stat_t).Rdev)
207212
}
208213
wantDevnum, ok := dev["root"]
209214
if !ok {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/bradfitz/embiggen-disk
1+
module github.com/skiffos/embiggen-disk
22

33
go 1.15
44

lvm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
Copyright 2018 Google Inc.
35

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
Copyright 2018 Google Inc.
35

part.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
Copyright 2018 Google Inc.
35

util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
Copyright 2018 Google Inc.
35

0 commit comments

Comments
 (0)