Skip to content

Commit

Permalink
[tinygo] cmds/core/df: use os.Stat instead of unix.Stat() to retrieve…
Browse files Browse the repository at this point in the history
… device number

Signed-off-by: Roger Standridge <[email protected]>
  • Loading branch information
archie2x committed Jul 27, 2024
1 parent ffb49ef commit d0c6ab5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
18 changes: 14 additions & 4 deletions cmds/core/df/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !tinygo && !(mips || mips64 || mips64le || mipsle || plan9 || windows)
//go:build !(mips || mips64 || mips64le || mipsle || plan9 || windows)

package main

import (
"golang.org/x/sys/unix"
"fmt"
"os"
"syscall"
)

func deviceNumber(path string) (uint64, error) {
st := &unix.Stat_t{}
err := unix.Stat(path, st)

// stat()
fi, err := os.Stat(path)
if err != nil {
return 0, err
}

// retrieve device number
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return 0, fmt.Errorf("stat %v: error retrieving devno", path)
}

return st.Dev, nil
}
2 changes: 1 addition & 1 deletion cmds/core/df/df.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !tinygo && !plan9 && !windows
//go:build !plan9 && !windows

// df reports details of mounted filesystems.
//
Expand Down
2 changes: 1 addition & 1 deletion cmds/core/df/df_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !tinygo && !plan9 && !windows
//go:build !plan9 && !windows

package main

Expand Down
8 changes: 4 additions & 4 deletions tools/tinygobb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ The neccessary additions to tinygo will be tracked in the according issue that t

## command list
### core
41 tinygo build errors found.
40 tinygo build errors found.

- [ ] `bind`
- [ ] `df`
- [ ] `dhclient`
- [ ] `dmesg`
- [ ] `fusermount`
Expand Down Expand Up @@ -55,7 +55,7 @@ The neccessary additions to tinygo will be tracked in the according issue that t
- [ ] `which`
- [ ] `nohup`

64 cmds build successful
65 cmds build successful
- [x] `backoff`
- [x] `base64`
- [x] `basename`
Expand All @@ -69,6 +69,7 @@ The neccessary additions to tinygo will be tracked in the according issue that t
- [x] `cpio`
- [x] `date`
- [x] `dd`
- [x] `df`
- [x] `dirname`
- [x] `echo`
- [x] `false`
Expand Down Expand Up @@ -182,4 +183,3 @@ The neccessary additions to tinygo will be tracked in the according issue that t
- [x] `watch`
- [x] `zbi`
- [x] `zimage`

0 comments on commit d0c6ab5

Please sign in to comment.