Home
last modified time | relevance | path

Searched refs:fd (Results 1 – 25 of 660) sorted by relevance

12345678910>>...27

/tools/testing/selftests/memfd/
Dmemfd_test.c50 static ssize_t fd2name(int fd, char *buf, size_t bufsize) in fd2name() argument
56 size = snprintf(buf1, PATH_MAX, "/proc/self/fd/%d", fd); in fd2name()
58 printf("snprintf(%d) failed on %m\n", fd); in fd2name()
76 int r, fd; in mfd_assert_new() local
78 fd = sys_memfd_create(name, flags); in mfd_assert_new()
79 if (fd < 0) { in mfd_assert_new()
85 r = ftruncate(fd, sz); in mfd_assert_new()
91 return fd; in mfd_assert_new()
96 int fd = open("/proc/sys/vm/memfd_noexec", O_WRONLY | O_CLOEXEC); in sysctl_assert_write() local
98 if (fd < 0) { in sysctl_assert_write()
[all …]
Dfuse_test.c46 int r, fd; in mfd_assert_new() local
48 fd = sys_memfd_create(name, flags); in mfd_assert_new()
49 if (fd < 0) { in mfd_assert_new()
55 r = ftruncate(fd, sz); in mfd_assert_new()
61 return fd; in mfd_assert_new()
64 static __u64 mfd_assert_get_seals(int fd) in mfd_assert_get_seals() argument
68 r = fcntl(fd, F_GET_SEALS); in mfd_assert_get_seals()
70 printf("GET_SEALS(%d) failed: %m\n", fd); in mfd_assert_get_seals()
77 static void mfd_assert_has_seals(int fd, __u64 seals) in mfd_assert_has_seals() argument
81 s = mfd_assert_get_seals(fd); in mfd_assert_has_seals()
[all …]
/tools/perf/tests/
Dwp.c16 #define WP_TEST_ASSERT_VAL(fd, text, val) \ argument
19 wp_read(fd, &count, sizeof(long long)); \
27 static int wp_read(int fd, long long *count, int size) in wp_read() argument
29 int ret = read(fd, count, size); in wp_read()
56 int fd; in __event() local
60 fd = sys_perf_event_open(&attr, 0, -1, -1, in __event()
62 if (fd < 0) { in __event()
63 fd = -errno; in __event()
67 return fd; in __event()
77 int fd; in test__wp_ro()
[all …]
Dbp_account.c44 int fd; in __event() local
61 fd = sys_perf_event_open(attr, -1, 0, -1, in __event()
63 if (fd < 0) { in __event()
68 return fd; in __event()
84 int i, fd[wp_cnt], fd_wp, ret; in bp_accounting() local
87 fd[i] = wp_event((void *)&the_var, &attr); in bp_accounting()
88 TEST_ASSERT_VAL("failed to create wp\n", fd[i] != -1); in bp_accounting()
96 ret = ioctl(fd[0], PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &attr_mod); in bp_accounting()
108 close(fd[i]); in bp_accounting()
117 int fd[100], cnt = 0, i; in detect_cnt() local
[all …]
/tools/testing/selftests/wireguard/qemu/
Dinit.c61 int bits = 256, fd; in seed_rng() local
66 fd = open("/dev/random", O_WRONLY); in seed_rng()
67 if (fd < 0) in seed_rng()
69 if (ioctl(fd, RNDADDTOENTCNT, &bits) < 0) in seed_rng()
71 close(fd); in seed_rng()
112 int fd; in enable_logging() local
114 fd = open("/proc/sys/kernel/printk", O_WRONLY); in enable_logging()
115 if (fd >= 0) { in enable_logging()
116 if (write(fd, "9\n", 2) != 2) in enable_logging()
118 close(fd); in enable_logging()
[all …]
/tools/testing/selftests/efivarfs/
Dopen-unlink.c16 int fd; in set_immutable() local
20 fd = open(path, O_RDONLY); in set_immutable()
21 if (fd < 0) in set_immutable()
22 return fd; in set_immutable()
24 rc = ioctl(fd, FS_IOC_GETFLAGS, &flags); in set_immutable()
27 close(fd); in set_immutable()
37 rc = ioctl(fd, FS_IOC_SETFLAGS, &flags); in set_immutable()
39 close(fd); in set_immutable()
47 int fd; in get_immutable() local
51 fd = open(path, O_RDONLY); in get_immutable()
[all …]
/tools/testing/selftests/net/
Dipv6_flowlabel_mgr.c48 static int flowlabel_get(int fd, uint32_t label, uint8_t share, uint16_t flags) in flowlabel_get() argument
61 return setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR, &req, sizeof(req)); in flowlabel_get()
64 static int flowlabel_put(int fd, uint32_t label) in flowlabel_put() argument
71 return setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR, &req, sizeof(req)); in flowlabel_put()
74 static void run_tests(int fd) in run_tests() argument
80 expect_fail(flowlabel_get(fd, 1, IPV6_FL_S_ANY, 0)); in run_tests()
83 expect_fail(flowlabel_put(fd, 1)); in run_tests()
86 expect_fail(flowlabel_get(fd, 0x1FFFFF, IPV6_FL_S_ANY, in run_tests()
90 expect_pass(flowlabel_get(fd, 1, IPV6_FL_S_ANY, IPV6_FL_F_CREATE)); in run_tests()
92 expect_pass(flowlabel_get(fd, 1, IPV6_FL_S_ANY, 0)); in run_tests()
[all …]
Dreuseaddr_ports_exhausted.c58 int fd, ret; in bind_port() local
60 fd = socket(AF_INET, SOCK_STREAM, 0); in bind_port()
61 ASSERT_NE(-1, fd) TH_LOG("failed to open socket."); in bind_port()
63 ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)); in bind_port()
66 ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuseport, sizeof(int)); in bind_port()
73 if (bind(fd, (struct sockaddr *)&local_addr, len) == -1) { in bind_port()
74 close(fd); in bind_port()
78 return fd; in bind_port()
84 int i, j, fd[2]; in TEST() local
90 fd[j] = bind_port(_metadata, opts->reuseaddr[j], opts->reuseport[j]); in TEST()
[all …]
Dtun.c20 static int tun_attach(int fd, char *dev) in tun_attach() argument
28 return ioctl(fd, TUNSETQUEUE, (void *) &ifr); in tun_attach()
31 static int tun_detach(int fd, char *dev) in tun_detach() argument
39 return ioctl(fd, TUNSETQUEUE, (void *) &ifr); in tun_detach()
45 int fd, err; in tun_alloc() local
47 fd = open("/dev/net/tun", O_RDWR); in tun_alloc()
48 if (fd < 0) { in tun_alloc()
50 return fd; in tun_alloc()
57 err = ioctl(fd, TUNSETIFF, (void *) &ifr); in tun_alloc()
60 close(fd); in tun_alloc()
[all …]
Dip_local_port_range.c30 static int get_so_domain(int fd) in get_so_domain() argument
36 err = getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &domain, &len); in get_so_domain()
43 static int bind_to_loopback_any_port(int fd) in bind_to_loopback_any_port() argument
53 switch (get_so_domain(fd)) { in bind_to_loopback_any_port()
70 return bind(fd, &addr.sa, addr_len); in bind_to_loopback_any_port()
73 static int get_sock_port(int fd) in get_sock_port() argument
85 err = getsockname(fd, &addr.sa, &addr_len); in get_sock_port()
100 static int get_ip_local_port_range(int fd, __u32 *range) in get_ip_local_port_range() argument
107 err = getsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val, &len); in get_ip_local_port_range()
172 int fd, err; in TEST_F() local
[all …]
/tools/testing/vsock/
Dvsock_test.c40 int fd; in test_stream_connection_reset() local
42 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_connection_reset()
46 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_connection_reset()
60 close(fd); in test_stream_connection_reset()
76 int fd; in test_stream_bind_only_client() local
81 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_client()
85 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_bind_only_client()
102 close(fd); in test_stream_bind_only_client()
117 int fd; in test_stream_bind_only_server() local
119 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_server()
[all …]
/tools/testing/selftests/mm/
Dgup_longterm.c38 static __fsword_t get_fs_type(int fd) in get_fs_type() argument
44 ret = fstatfs(fd, &fs); in get_fs_type()
91 static void do_test(int fd, size_t size, enum test_type type, bool shared) in do_test() argument
93 __fsword_t fs_type = get_fs_type(fd); in do_test()
98 if (ftruncate(fd, size)) { in do_test()
103 if (fallocate(fd, 0, 0, size)) { in do_test()
112 shared ? MAP_SHARED : MAP_PRIVATE, fd, 0); in do_test()
234 typedef void (*test_fn)(int fd, size_t size);
238 int fd; in run_with_memfd() local
242 fd = memfd_create("test", 0); in run_with_memfd()
[all …]
/tools/testing/selftests/iommu/
Diommufd_fail_nth.c31 int fd; in writeat() local
33 fd = openat(dfd, fn, O_WRONLY); in writeat()
34 if (fd == -1) in writeat()
36 res = write(fd, val, val_len); in writeat()
38 close(fd); in writeat()
207 int fd; in FIXTURE() local
213 self->fd = -1; in FIXTURE_SETUP()
226 teardown_iommufd(self->fd, _metadata); in FIXTURE_TEARDOWN()
238 self->fd = open("/dev/iommu", O_RDWR); in TEST_FAIL_NTH()
239 if (self->fd == -1) in TEST_FAIL_NTH()
[all …]
Diommufd_utils.h42 ioctl(self->fd, \
47 static int _test_cmd_mock_domain(int fd, unsigned int ioas_id, __u32 *stdev_id, in _test_cmd_mock_domain() argument
58 ret = ioctl(fd, IOMMU_TEST_CMD, &cmd); in _test_cmd_mock_domain()
71 ASSERT_EQ(0, _test_cmd_mock_domain(self->fd, ioas_id, stdev_id, \
74 EXPECT_ERRNO(_errno, _test_cmd_mock_domain(self->fd, ioas_id, \
77 static int _test_cmd_mock_domain_replace(int fd, __u32 stdev_id, __u32 pt_id, in _test_cmd_mock_domain_replace() argument
90 ret = ioctl(fd, IOMMU_TEST_CMD, &cmd); in _test_cmd_mock_domain_replace()
99 ASSERT_EQ(0, _test_cmd_mock_domain_replace(self->fd, stdev_id, pt_id, \
102 EXPECT_ERRNO(_errno, _test_cmd_mock_domain_replace(self->fd, stdev_id, \
105 static int _test_cmd_hwpt_alloc(int fd, __u32 device_id, __u32 pt_id, in _test_cmd_hwpt_alloc() argument
[all …]
/tools/testing/selftests/bpf/
Dtest_maps.c40 int fd; in test_hashmap() local
42 fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(key), sizeof(value), 2, &map_opts); in test_hashmap()
43 if (fd < 0) { in test_hashmap()
51 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_hashmap()
55 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) < 0 && in test_hashmap()
60 assert(bpf_map_update_elem(fd, &key, &value, -1) < 0 && in test_hashmap()
64 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234); in test_hashmap()
69 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_hashmap()
72 assert(bpf_map_lookup_and_delete_elem(fd, &key, &value) == 0 && value == 1234); in test_hashmap()
75 assert(bpf_map_lookup_elem(fd, &key, &value) < 0 && errno == ENOENT); in test_hashmap()
[all …]
/tools/perf/tests/attr/
Dtest-stat-detailed-29 fd=1
15 fd=2
21 fd=3
27 fd=4
33 fd=5
40 fd=6
47 fd=7
54 fd=8
61 fd=9
68 fd=10
[all …]
Dtest-stat-detailed-39 fd=1
15 fd=2
21 fd=3
27 fd=4
33 fd=5
40 fd=6
47 fd=7
54 fd=8
61 fd=9
68 fd=10
[all …]
Dtest-stat-detailed-19 fd=1
15 fd=2
21 fd=3
27 fd=4
33 fd=5
40 fd=6
47 fd=7
54 fd=8
61 fd=9
68 fd=10
[all …]
Dtest-stat-default8 fd=1
14 fd=2
20 fd=3
26 fd=4
32 fd=5
39 fd=6
45 fd=7
52 fd=8
59 fd=9
66 fd=10
[all …]
/tools/power/cpupower/utils/helpers/
Dmsr.c28 int fd; in read_msr() local
32 fd = open(msr_file_name, O_RDONLY); in read_msr()
33 if (fd < 0) in read_msr()
35 if (lseek(fd, idx, SEEK_CUR) == -1) in read_msr()
37 if (read(fd, val, sizeof *val) != sizeof *val) in read_msr()
39 close(fd); in read_msr()
42 close(fd); in read_msr()
57 int fd; in write_msr() local
61 fd = open(msr_file_name, O_WRONLY); in write_msr()
62 if (fd < 0) in write_msr()
[all …]
/tools/testing/selftests/sync/
Dsync.c58 int sync_wait(int fd, int timeout) in sync_wait() argument
62 fds.fd = fd; in sync_wait()
84 static struct sync_file_info *sync_file_info(int fd) in sync_file_info() argument
94 err = ioctl(fd, SYNC_IOC_FILE_INFO, info); in sync_file_info()
114 err = ioctl(fd, SYNC_IOC_FILE_INFO, info); in sync_file_info()
131 int sync_fence_size(int fd) in sync_fence_size() argument
134 struct sync_file_info *info = sync_file_info(fd); in sync_fence_size()
146 int sync_fence_count_with_status(int fd, int status) in sync_fence_count_with_status() argument
150 struct sync_file_info *info = sync_file_info(fd); in sync_fence_count_with_status()
171 int sw_sync_timeline_inc(int fd, unsigned int count) in sw_sync_timeline_inc() argument
[all …]
/tools/testing/selftests/rtc/
Drtctest.c29 int fd; in FIXTURE() local
33 self->fd = open(rtc_file, O_RDONLY); in FIXTURE_SETUP()
37 close(self->fd); in FIXTURE_TEARDOWN()
44 if (self->fd == -1 && errno == ENOENT) in TEST_F()
46 ASSERT_NE(-1, self->fd); in TEST_F()
49 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); in TEST_F()
91 if (self->fd == -1 && errno == ENOENT)
93 ASSERT_NE(-1, self->fd);
98 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
106 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
[all …]
/tools/testing/selftests/proc/
Dfd-003-kthread.c44 int dir_fd, fd; in kernel_thread_fd() local
56 fd = openat(dir_fd, "stat", O_RDONLY); in kernel_thread_fd()
57 if (fd == -1) { in kernel_thread_fd()
61 rv = read(fd, buf, sizeof(buf)); in kernel_thread_fd()
62 close(fd); in kernel_thread_fd()
88 fd = -1; in kernel_thread_fd()
90 fd = openat(dir_fd, "fd", O_RDONLY|O_DIRECTORY); in kernel_thread_fd()
93 return fd; in kernel_thread_fd()
96 static void test_readdir(int fd) in test_readdir() argument
101 d = fdopendir(fd); in test_readdir()
[all …]
/tools/testing/selftests/bpf/prog_tests/
Dbloom_filter_map.c13 int fd, err; in test_fail_cases() local
16 fd = bpf_map_create(BPF_MAP_TYPE_BLOOM_FILTER, NULL, 4, sizeof(value), 100, NULL); in test_fail_cases()
17 if (!ASSERT_LT(fd, 0, "bpf_map_create bloom filter invalid key size")) in test_fail_cases()
18 close(fd); in test_fail_cases()
21 fd = bpf_map_create(BPF_MAP_TYPE_BLOOM_FILTER, NULL, 0, 0, 100, NULL); in test_fail_cases()
22 if (!ASSERT_LT(fd, 0, "bpf_map_create bloom filter invalid value size 0")) in test_fail_cases()
23 close(fd); in test_fail_cases()
26 fd = bpf_map_create(BPF_MAP_TYPE_BLOOM_FILTER, NULL, 0, INT32_MAX, 100, NULL); in test_fail_cases()
27 if (!ASSERT_LT(fd, 0, "bpf_map_create bloom filter invalid value too large")) in test_fail_cases()
28 close(fd); in test_fail_cases()
[all …]
Dlog_buf.c154 int fd = -1; in bpf_prog_load_log_buf() local
165 fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, "good_prog", "GPL", in bpf_prog_load_log_buf()
168 ASSERT_GE(fd, 0, "good_fd1"); in bpf_prog_load_log_buf()
169 if (fd >= 0) in bpf_prog_load_log_buf()
170 close(fd); in bpf_prog_load_log_buf()
171 fd = -1; in bpf_prog_load_log_buf()
176 fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, "good_prog", "GPL", in bpf_prog_load_log_buf()
179 ASSERT_GE(fd, 0, "good_fd2"); in bpf_prog_load_log_buf()
180 if (fd >= 0) in bpf_prog_load_log_buf()
181 close(fd); in bpf_prog_load_log_buf()
[all …]

12345678910>>...27