Skip to content

Commit

Permalink
refactor: fork and add linux build tags
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed May 22, 2024
1 parent e17d9b2 commit 23cdccf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
17 changes: 11 additions & 6 deletions fs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

/*
Copyright 2018 Google Inc.
Expand All @@ -21,14 +23,13 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"

"github.com/bradfitz/embiggen-disk/findmnt"
"github.com/skiffos/embiggen-disk/findmnt"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -123,7 +124,7 @@ func statFS(mnt string) (fs fsStat, err error) {
return
}

mounts, err := ioutil.ReadFile("/proc/mounts")
mounts, err := os.ReadFile("/proc/mounts")
if err != nil {
return
}
Expand Down Expand Up @@ -194,16 +195,20 @@ func statFSFindmnt(mnt string) (fs fsStat, err error) {

// findDevRoot finds which block device (e.g. "/dev/nvme0n1p1") patches the device number of /dev/root.
func findDevRoot() (string, error) {
fis, err := ioutil.ReadDir("/dev")
fis, err := os.ReadDir("/dev")
if err != nil {
return "", err
}
dev := map[string]uint64{}
for _, fi := range fis {
if fi.Mode()&os.ModeDevice == 0 || fi.Mode()&os.ModeCharDevice != 0 {
fii, err := fi.Info()
if err != nil {
continue
}
if fii.Mode()&os.ModeDevice == 0 || fii.Mode()&os.ModeCharDevice != 0 {
continue
}
dev[fi.Name()] = fi.Sys().(*syscall.Stat_t).Rdev
dev[fi.Name()] = uint64(fii.Sys().(*syscall.Stat_t).Rdev)
}
wantDevnum, ok := dev["root"]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/bradfitz/embiggen-disk
module github.com/skiffos/embiggen-disk

go 1.15

Expand Down
2 changes: 2 additions & 0 deletions lvm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

/*
Copyright 2018 Google Inc.
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

/*
Copyright 2018 Google Inc.
Expand Down
2 changes: 2 additions & 0 deletions part.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

/*
Copyright 2018 Google Inc.
Expand Down
2 changes: 2 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

/*
Copyright 2018 Google Inc.
Expand Down

0 comments on commit 23cdccf

Please sign in to comment.