Skip to contentSkip to conversation

Add statx glibc/syscall support

PATCH In review Richard Purdie 2 participants 2 messages Nov 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add statx glibc/syscall support

Modern distros (e.g. fedora30) are starting to use the new statx() syscall through the newly exposed glibc wrapper function in software like coreutils (e.g. the ls command). Add support to intercept this to pseudo.

---
 ports/linux/guts/statx.c | 48 ++++++++++++++++++++++++++++++++++++++++
 ports/linux/portdefs.h   |  1 +
 ports/linux/wrapfuncs.in |  1 +
 3 files changed, 50 insertions(+)
 create mode 100644 ports/linux/guts/statx.c
ports/linux/statx/guts/statx.c new file +42 -0
new file mode 100644
index 0000000..a3259c4
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019 Linux Foundation
+ * Author: Richard Purdie
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * int
+ * statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf) {
+ *	int rc = -1;
+ */
+	pseudo_msg_t *msg;
+	PSEUDO_STATBUF buf;
+	int save_errno;
+
+	rc = real_statx(dirfd, pathname, flags, mask, statxbuf);
+	save_errno = errno;
+	if (rc == -1) {
+		return rc;
+	}
+
+	buf.st_uid = statxbuf->stx_uid;
+	buf.st_gid = statxbuf->stx_gid;
+	buf.st_dev = makedev(statxbuf->stx_dev_major, statxbuf->stx_dev_minor);
+	buf.st_ino = statxbuf->stx_ino;
+	buf.st_mode = statxbuf->stx_mode;
+	buf.st_rdev = makedev(statxbuf->stx_rdev_major, statxbuf->stx_rdev_minor);
+	buf.st_nlink = statxbuf->stx_nlink;
+	msg = pseudo_client_op(OP_STAT, 0, -1, dirfd, pathname, &buf);
+	if (msg && msg->result == RESULT_SUCCEED) {
+		pseudo_debug(PDBGF_FILE, "statx(path %s), flags %o, stat rc %d, stat uid %o\n", pathname, flags, rc, statxbuf->stx_uid);
+		statxbuf->stx_uid = msg->uid;
+		statxbuf->stx_gid = msg->gid;
+		statxbuf->stx_mode = msg->mode;
+		statxbuf->stx_rdev_major = major(msg->rdev);
+		statxbuf->stx_rdev_minor = minor(msg->rdev);
+	} else {
+		pseudo_debug(PDBGF_FILE, "statx(path %s) failed, flags %o, stat rc %d, stat uid %o\n", pathname, flags, rc, statxbuf->stx_uid);
+	}
+	errno = save_errno;
+/*	return rc;
+ * }
+ */
ports/linux/statx/portdefs.h new file +6 -0
new file mode 100644
index 0000000..bf934dc
@@ -0,0 +1,6 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
ports/linux/statx/wrapfuncs.in new file +1 -0
new file mode 100644
index 0000000..c9cd4c3
@@ -0,0 +1 @@
+int statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf);
ports/linux/subports +10 -0
index a29044a..49081bf 100755
@@ -54,3 +54,13 @@ else
 fi
 rm -f dummy.c dummy.o
 
+cat > dummy.c <<EOF
+#define _GNU_SOURCE
+#include <sys/stat.h>
+struct statx x;
+EOF
+if ${CC} -c -o dummy.o dummy.c >/dev/null 2>&1; then
+	echo "linux/statx"
+fi
+rm -f dummy.c dummy.o
+
#1 lore raw

✗ patchtest: failure for Add statx glibc/syscall support

== Series Details ==

Series: Add statx glibc/syscall support
Revision: 1
URL : https://patchwork.openembedded.org/series/21022/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at ae6e7dd19b)

* Patch            [pseudo] Add statx glibc/syscall support
 Issue             Shortlog does not follow expected format [test_shortlog_format] 
  Suggested fix    Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe