]> Cypherpunks.ru repositories - nncp.git/commitdiff
OpenBSD compatible IsEnoughSpace()
authorSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 09:28:08 +0000 (12:28 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 09:28:43 +0000 (12:28 +0300)
doc/news.ru.texi
doc/news.texi
src/df.go
src/df_netbsd.go
src/df_openbsd.go [new file with mode: 0644]

index 18a271feabd9ca27d6500ced16b5cf8ac53b0a35..161708e66a7d5cc1d950edcfb0014656dd2b24f5 100644 (file)
@@ -17,6 +17,9 @@
 синхронизации через @env{$NNCPDEADLINE} переменную окружения. Может быть
 полезно для каналов с очень большими задержками.
 
+@item
+NNCP собирается на OpenBSD.
+
 @end itemize
 
 @node Релиз 8.4.0
index b52f5140457c91af0d4d3f29fde83cc923558e56..09b21bc676bdb9ef4a3542e101533596916cd10c 100644 (file)
@@ -19,6 +19,9 @@ Ability to override internal default timeout for online protocol through
 @env{$NNCPDEADLINE} environment variable. Can be useful for very high
 delay links.
 
+@item
+NNCP builds on OpenBSD.
+
 @end itemize
 
 @node Release 8_4_0
index 43d14a96b88d078f5d748c137878e6f866591525..ead8fe37982a58f7ab3356e8b8e0abdb2543bbdc 100644 (file)
--- a/src/df.go
+++ b/src/df.go
@@ -1,8 +1,5 @@
-//go:build !netbsd
-// +build !netbsd
-
-// NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-// Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
+//go:build !netbsd && !openbsd
+// +build !netbsd,!openbsd
 
 package nncp
 
index 349c9c8cda6019b38df80f60df8fa4694569ec5b..7037a713b0b6cde115aba197ad8fe9886280518a 100644 (file)
@@ -1,9 +1,6 @@
 //go:build netbsd
 // +build netbsd
 
-// NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-// Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
-
 package nncp
 
 import (
diff --git a/src/df_openbsd.go b/src/df_openbsd.go
new file mode 100644 (file)
index 0000000..b57c431
--- /dev/null
@@ -0,0 +1,18 @@
+//go:build openbsd
+// +build openbsd
+
+package nncp
+
+import (
+       "log"
+
+       "golang.org/x/sys/unix"
+)
+
+func (ctx *Ctx) IsEnoughSpace(want int64) bool {
+       var s unix.Statfs_t
+       if err := unix.Statfs(ctx.Spool, &s); err != nil {
+               log.Fatalln("Can not stat spool:", err)
+       }
+       return int64(s.F_bavail)*int64(s.F_bsize) > want
+}