public inbox for nncp-devel@lists.cypherpunks.ru
Atom feed
* Build error on NetBSD
@ 2021-08-04 3:17 John Goerzen
2021-08-04 15:04 ` Sergey Matveev
0 siblings, 1 reply; 4+ messages in thread
From: John Goerzen @ 2021-08-04 3:17 UTC (permalink / raw)
To: nncp-devel
Hi,
SDF.org runs a long-running public-access Unix system, and is
active in the gopherspace, and other assorted things. They also
offer UUCP yet, so I figured it would be a perfect place to
introduce NNCP.
In trying to build NNCP 7.5.0, I got:
jgoerzen@sverige:~/nncp-7.5.0$ PREFIX=$HOME/nncp ./contrib/do
install
do install
do bin/all
do bin/hjson-cli
do bin/nncp-bundle
# go.cypherpunks.ru/nncp/v7
./ctx.go:154:12: undefined: unix.Statfs
./ctx.go:157:16: s.Bavail undefined (type unix.Statfs_t has no
field or method Bavail)
./ctx.go:157:32: s.Bsize undefined (type unix.Statfs_t has no
field or method Bsize)
do: nncp-bundle: got exit code 2
do: all: got exit code 1
do: install: got exit code 1
jgoerzen@sverige:~/nncp-7.5.0$ uname -a
NetBSD sverige 9.1 NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30
UTC 2020
mkrepro@mkrepro•NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC
amd64
jgoerzen@sverige:~/nncp-7.5.0$ go version
go version go1.15.5 netbsd/amd64
I guess that, at least in Go, Statfs is unimplemented or
incompletely implemented on NetBSD. I don't know enough about Go
to know if this can be worked around easily here, but if not,
maybe https://github.com/ricochet2200/go-disk-usage would be of
use.
Thanks,
John
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Build error on NetBSD
2021-08-04 3:17 Build error on NetBSD John Goerzen
@ 2021-08-04 15:04 ` Sergey Matveev
2021-08-04 16:02 ` John Goerzen
0 siblings, 1 reply; 4+ messages in thread
From: Sergey Matveev @ 2021-08-04 15:04 UTC (permalink / raw)
To: nncp-devel
[-- Attachment #1: Type: text/plain, Size: 906 bytes --]
Greetings!
*** John Goerzen [2021-08-03 22:17]:
>I guess that, at least in Go, Statfs is unimplemented or incompletely
>implemented on NetBSD.
That is right. They some kind of "sync" those C-structures to Go code,
but without any guarantees. Can you check if following code will work on
NetBSD? Currently I do not have NetBSD and it is failing installation
under bhyve :-(
package main
import "syscall"
func main() {
var s syscall.Statfs_t
if err := syscall.Statfs("/", &s); err != nil { panic(err) }
println(int64(s.Bavail) * int64(s.Bsize))
}
Some kind of:
$ tmp=`mktemp -d`
$ cd $tmp
[save Go code above in main.go]
$ go run main.go
If that works, I will replace free space determining with that code.
--
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263 6422 AE1A 8109 E498 57EF
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Build error on NetBSD
2021-08-04 15:04 ` Sergey Matveev
@ 2021-08-04 16:02 ` John Goerzen
2021-08-04 17:58 ` Sergey Matveev
0 siblings, 1 reply; 4+ messages in thread
From: John Goerzen @ 2021-08-04 16:02 UTC (permalink / raw)
To: Sergey Matveev; +Cc: nncp-devel
On Wed, Aug 04 2021, Sergey Matveev wrote:
> package main
> import "syscall"
> func main() {
> var s syscall.Statfs_t
> if err := syscall.Statfs("/", &s); err != nil {
> panic(err) }
> println(int64(s.Bavail) * int64(s.Bsize))
> }
That fails to compile, in a very similar manner to the NNCP code:
jgoerzen@sverige:~/t$ go build foo.go
# command-line-arguments
./foo.go:5:26: undefined: syscall.Statfs
./foo.go:6:32: s.Bavail undefined (type syscall.Statfs_t has no
field or method Bavail)
./foo.go:6:50: s.Bsize undefined (type syscall.Statfs_t has no
field or method Bsize)
NetBSD does have a C statvfs() call, and does not have statfs().
According to the Linux statfs(2) manpage, POSIX calls for
statvfs() and doesn't mention statfs(). I don't know if Go is
really using statvfs() on some platforms, but from what I could
see at
https://cs.opensource.google/go/x/sys/+/master:unix/zsyscall_netbsd_amd64.go
, there is simply no implementation for statfs on NetBSD in Go.
Compare to, say,
https://cs.opensource.google/go/x/sys/+/master:unix/zsyscall_linux_amd64.go
. Weird that it seems to not even be using libc here and going
with a direct syscall interface (!)
I got it to compile and work by just replacing that entire
function with "return true". I mean, that's not ideal, but I
don't see what else you'll be able to do on NetBSD. It will still
work, I think, though abort less early if a disk is getting full.
John
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Build error on NetBSD
2021-08-04 16:02 ` John Goerzen
@ 2021-08-04 17:58 ` Sergey Matveev
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Matveev @ 2021-08-04 17:58 UTC (permalink / raw)
To: nncp-devel
[-- Attachment #1: Type: text/plain, Size: 981 bytes --]
*** John Goerzen [2021-08-04 11:02]:
>NetBSD does have a C statvfs() call, and does not have statfs().
Yeah, I found that later too. So I will use Statvfs for NetBSD.
>According
>to the Linux statfs(2) manpage, POSIX calls for statvfs() and doesn't
>mention statfs().
But golang.org/x/sys/unix does not have Statvfs for FreeBSD :-), however
FreeBSD itself has statvfs() call.
>Weird that it seems to not even be using libc here and going with a
>direct syscall interface (!)
Yes, Go is known for that.
https://utcc.utoronto.ca/~cks/space/blog/programming/GoCLibraryAPIIssues
https://utcc.utoronto.ca/~cks/space/blog/programming/Go116OpenBSDUsesLibc
>I got it to compile and work by just replacing that entire function with
>"return true".
Good, thanks for checking it out! I will make Statvfs() usage for NetBSD
in the nearest release.
--
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263 6422 AE1A 8109 E498 57EF
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-04 17:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 3:17 Build error on NetBSD John Goerzen
2021-08-04 15:04 ` Sergey Matveev
2021-08-04 16:02 ` John Goerzen
2021-08-04 17:58 ` Sergey Matveev