The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Daniel Palmer <daniel@thingy.jp>
To: w@1wt.eu, linux@weissschuh.net
Cc: david.laight.linux@gmail.com, linux-kernel@vger.kernel.org,
	Daniel Palmer <daniel@thingy.jp>
Subject: [PATCH v4 2/3] tools/nolibc: Add statfs()
Date: Thu,  7 May 2026 18:03:52 +0900	[thread overview]
Message-ID: <20260507090353.356764-3-daniel@thingy.jp> (raw)
In-Reply-To: <20260507090353.356764-1-daniel@thingy.jp>

Add statfs().

Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
 tools/include/nolibc/Makefile     |  1 +
 tools/include/nolibc/nolibc.h     |  1 +
 tools/include/nolibc/sys/statfs.h | 50 +++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 tools/include/nolibc/sys/statfs.h

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 00fd2e566d75..e6281f58e6e2 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -60,6 +60,7 @@ all_files := \
 		sys/resource.h \
 		sys/select.h \
 		sys/stat.h \
+		sys/statfs.h \
 		sys/syscall.h \
 		sys/sysmacros.h \
 		sys/time.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index faa94f247281..425cf87befdc 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -107,6 +107,7 @@
 #include "sys/resource.h"
 #include "sys/select.h"
 #include "sys/stat.h"
+#include "sys/statfs.h"
 #include "sys/syscall.h"
 #include "sys/sysmacros.h"
 #include "sys/time.h"
diff --git a/tools/include/nolibc/sys/statfs.h b/tools/include/nolibc/sys/statfs.h
new file mode 100644
index 000000000000..26976ac2e94a
--- /dev/null
+++ b/tools/include/nolibc/sys/statfs.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * statfs for NOLIBC
+ * Copyright (C) 2026 Daniel Palmer <daniel@thingy.jp>
+ */
+
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
+#ifndef _NOLIBC_SYS_STATFS_H
+#define _NOLIBC_SYS_STATFS_H
+
+#include "../sys.h"
+
+/* Some preprocessor hackery to get struct statfs to
+ * always be the 64bit one.
+ */
+#define statfs __nolibc_kernel_statfs
+#define statfs64 __nolibc_kernel_statfs64
+#include <asm/statfs.h>
+#undef statfs
+#undef statfs64
+
+#ifdef __NR_statfs64
+#define statfs __nolibc_kernel_statfs64
+#else
+#define statfs __nolibc_kernel_statfs
+#endif
+
+/*
+ * statfs(const char *path, struct statfs *buf);
+ */
+
+static __attribute__((unused))
+int _sys_statfs(const char *path, struct statfs *buf)
+{
+#ifdef __NR_statfs64
+	return __nolibc_syscall3(__NR_statfs64, path, sizeof(*buf), buf);
+#else
+	return __nolibc_syscall2(__NR_statfs, path, buf);
+#endif
+}
+
+static __attribute__((unused))
+int statfs(const char *path, struct statfs *buf)
+{
+	return __sysret(_sys_statfs(path, buf));
+}
+
+#endif /* _NOLIBC_SYS_STATFS_H */
-- 
2.53.0


  parent reply	other threads:[~2026-05-07  9:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  9:03 [PATCH v4 0/3] nolibc: Add fallocate() Daniel Palmer
2026-05-07  9:03 ` [PATCH v4 1/3] tools/nolibc: fcntl: " Daniel Palmer
2026-05-07  9:03 ` Daniel Palmer [this message]
2026-05-07  9:03 ` [PATCH v4 3/3] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
2026-05-11  6:29 ` [PATCH v4 0/3] nolibc: Add fallocate() Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260507090353.356764-3-daniel@thingy.jp \
    --to=daniel@thingy.jp \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox