[libc-commits] [libc] [libc] Add sys/xattr.h and entrypoints flistxattr, listxattr, and llistxattr. (PR #224357)

Alex Strelnikov via libc-commits libc-commits at lists.llvm.org
Thu Sep 17 11:12:11 PDT 2026


================
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unit tests for flistxattr.
+///
+//===----------------------------------------------------------------------===//
+
+#include "hdr/sys_stat_macros.h"
+#include "src/__support/CPP/scope.h"
+#include "src/__support/OSUtil/linux/syscall.h"
+#include "src/__support/libc_errno.h"
+#include "src/fcntl/creat.h"
+#include "src/sys/xattr/flistxattr.h"
+#include "src/unistd/close.h"
+#include "src/unistd/unlink.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+namespace {
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+using LlvmLibcListxattrTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
+using LIBC_NAMESPACE::cpp::scope_exit;
+using LIBC_NAMESPACE::cpp::string_view;
+
+int recreate_test_file(const char *path) {
+  LIBC_NAMESPACE::unlink(path);
+  LIBC_NAMESPACE::libc_errno = 0;
+  return LIBC_NAMESPACE::creat(path, S_IRWXU);
+}
+
+TEST_F(LlvmLibcListxattrTest, NoExtendedAttributes) {
+  int fd = recreate_test_file("testdata/flistxattr_no_xattrs.txt");
----------------
strel-12 wrote:

Done, thank you.

https://github.com/llvm/llvm-project/pull/224357


More information about the libc-commits mailing list