Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 38 lines 816 B view raw
1// SPDX-License-Identifier: GPL-2.0 2#define _GNU_SOURCE 3#define __SANE_USERSPACE_TYPES__ 4 5#include <fcntl.h> 6#include <stdio.h> 7#include <sys/stat.h> 8#include <sys/xattr.h> 9 10#include "kselftest_harness.h" 11#include "wrappers.h" 12 13TEST(kernfs_listxattr) 14{ 15 int fd; 16 17 /* Read-only file that can never have any extended attributes set. */ 18 fd = open("/sys/kernel/warn_count", O_RDONLY | O_CLOEXEC); 19 ASSERT_GE(fd, 0); 20 ASSERT_EQ(flistxattr(fd, NULL, 0), 0); 21 EXPECT_EQ(close(fd), 0); 22} 23 24TEST(kernfs_getxattr) 25{ 26 int fd; 27 char buf[1]; 28 29 /* Read-only file that can never have any extended attributes set. */ 30 fd = open("/sys/kernel/warn_count", O_RDONLY | O_CLOEXEC); 31 ASSERT_GE(fd, 0); 32 ASSERT_LT(fgetxattr(fd, "user.foo", buf, sizeof(buf)), 0); 33 ASSERT_EQ(errno, ENODATA); 34 EXPECT_EQ(close(fd), 0); 35} 36 37TEST_HARNESS_MAIN 38