/tools/testing/selftests/memfd/ |
D | memfd_test.c | 39 int r, fd; in mfd_assert_new() local 41 fd = sys_memfd_create(name, flags); in mfd_assert_new() 42 if (fd < 0) { in mfd_assert_new() 48 r = ftruncate(fd, sz); in mfd_assert_new() 54 return fd; in mfd_assert_new() 59 int r, fd; in mfd_assert_reopen_fd() local 64 fd = open(path, O_RDWR); in mfd_assert_reopen_fd() 65 if (fd < 0) { in mfd_assert_reopen_fd() 70 return fd; in mfd_assert_reopen_fd() 86 static unsigned int mfd_assert_get_seals(int fd) in mfd_assert_get_seals() argument [all …]
|
D | fuse_test.c | 46 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/testing/selftests/wireguard/qemu/ |
D | init.c | 59 int fd; in seed_rng() local 72 fd = open("/dev/urandom", O_WRONLY); in seed_rng() 73 if (fd < 0) in seed_rng() 76 if (ioctl(fd, RNDADDENTROPY, &entropy) < 0) in seed_rng() 79 close(fd); in seed_rng() 111 int fd; in enable_logging() local 113 fd = open("/proc/sys/kernel/printk", O_WRONLY); in enable_logging() 114 if (fd >= 0) { in enable_logging() 115 if (write(fd, "9\n", 2) != 2) in enable_logging() 117 close(fd); in enable_logging() [all …]
|
/tools/perf/tests/ |
D | wp.c | 14 #define WP_TEST_ASSERT_VAL(fd, text, val) \ argument 17 wp_read(fd, &count, sizeof(long long)); \ 24 static int wp_read(int fd, long long *count, int size) in wp_read() argument 26 int ret = read(fd, count, size); in wp_read() 53 int fd; in __event() local 57 fd = sys_perf_event_open(&attr, 0, -1, -1, in __event() 59 if (fd < 0) in __event() 62 return fd; in __event() 67 int fd; in wp_ro_test() local 70 fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1)); in wp_ro_test() [all …]
|
D | bp_account.c | 31 int fd; in __event() local 48 fd = sys_perf_event_open(attr, -1, 0, -1, in __event() 50 if (fd < 0) { in __event() 55 return fd; in __event() 71 int i, fd[wp_cnt], fd_wp, ret; in bp_accounting() local 74 fd[i] = wp_event((void *)&the_var, &attr); in bp_accounting() 75 TEST_ASSERT_VAL("failed to create wp\n", fd[i] != -1); in bp_accounting() 83 ret = ioctl(fd[0], PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &attr_mod); in bp_accounting() 95 close(fd[i]); in bp_accounting() 104 int fd[100], cnt = 0, i; in detect_cnt() local [all …]
|
/tools/testing/selftests/efivarfs/ |
D | open-unlink.c | 16 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/ |
D | reuseaddr_ports_exhausted.c | 58 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 …]
|
D | ipv6_flowlabel_mgr.c | 48 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 …]
|
/tools/testing/vsock/ |
D | vsock_test.c | 35 int fd; in test_stream_connection_reset() local 37 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_connection_reset() 41 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_connection_reset() 55 close(fd); in test_stream_connection_reset() 71 int fd; in test_stream_bind_only_client() local 76 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_client() 80 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_bind_only_client() 97 close(fd); in test_stream_bind_only_client() 112 int fd; in test_stream_bind_only_server() local 114 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_server() [all …]
|
/tools/testing/selftests/bpf/ |
D | test_maps.c | 40 int fd; in test_hashmap() local 42 fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), in test_hashmap() 44 if (fd < 0) { in test_hashmap() 52 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); in test_hashmap() 56 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && in test_hashmap() 61 assert(bpf_map_update_elem(fd, &key, &value, -1) == -1 && in test_hashmap() 65 assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234); in test_hashmap() 69 assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT); in test_hashmap() 72 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == -1 && in test_hashmap() 77 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0); in test_hashmap() [all …]
|
D | network_helpers.c | 43 static int settimeo(int fd, int timeout_ms) in settimeo() argument 52 if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, in settimeo() 58 if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, in settimeo() 67 #define save_errno_close(fd) ({ int __save = errno; close(fd); errno = __save; }) argument 74 int fd; in start_server() local 79 fd = socket(family, type, 0); in start_server() 80 if (fd < 0) { in start_server() 85 if (settimeo(fd, timeout_ms)) in start_server() 88 if (bind(fd, (const struct sockaddr *)&addr, len) < 0) { in start_server() 94 if (listen(fd, 1) < 0) { in start_server() [all …]
|
/tools/testing/selftests/sync/ |
D | sync.c | 58 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/proc/ |
D | fd-003-kthread.c | 44 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/perf/tests/attr/ |
D | test-stat-detailed-3 | 9 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 …]
|
D | test-stat-detailed-2 | 9 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 …]
|
D | test-stat-detailed-1 | 9 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 …]
|
/tools/power/cpupower/utils/helpers/ |
D | msr.c | 29 int fd; in read_msr() local 33 fd = open(msr_file_name, O_RDONLY); in read_msr() 34 if (fd < 0) in read_msr() 36 if (lseek(fd, idx, SEEK_CUR) == -1) in read_msr() 38 if (read(fd, val, sizeof *val) != sizeof *val) in read_msr() 40 close(fd); in read_msr() 43 close(fd); in read_msr() 58 int fd; in write_msr() local 62 fd = open(msr_file_name, O_WRONLY); in write_msr() 63 if (fd < 0) in write_msr() [all …]
|
/tools/testing/selftests/powerpc/dscr/ |
D | dscr.h | 74 int fd = -1, ret; in get_default_dscr() local 78 if (fd == -1) { in get_default_dscr() 79 fd = open(DSCR_DEFAULT, O_RDONLY); in get_default_dscr() 80 if (fd == -1) { in get_default_dscr() 86 lseek(fd, 0, SEEK_SET); in get_default_dscr() 87 ret = read(fd, buf, sizeof(buf)); in get_default_dscr() 93 close(fd); in get_default_dscr() 99 int fd = -1, ret; in set_default_dscr() local 102 if (fd == -1) { in set_default_dscr() 103 fd = open(DSCR_DEFAULT, O_RDWR); in set_default_dscr() [all …]
|
/tools/testing/selftests/rtc/ |
D | rtctest.c | 27 int fd; in FIXTURE() local 31 self->fd = open(rtc_file, O_RDONLY); in FIXTURE_SETUP() 32 ASSERT_NE(-1, self->fd); in FIXTURE_SETUP() 36 close(self->fd); in FIXTURE_TEARDOWN() 44 rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); in TEST_F() 57 rc = ioctl(self->fd, RTC_UIE_ON, 0); 66 rc = read(self->fd, &data, sizeof(data)); 73 rc = ioctl(self->fd, RTC_UIE_OFF, 0); 82 rc = ioctl(self->fd, RTC_UIE_ON, 0); in TEST_F() 94 FD_SET(self->fd, &readfds); in TEST_F() [all …]
|
/tools/perf/scripts/perl/ |
D | rw-by-file.pl | 31 $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_; 34 $reads{$fd}{bytes_requested} += $count; 35 $reads{$fd}{total_reads}++; 42 $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_; 45 $writes{$fd}{bytes_written} += $count; 46 $writes{$fd}{total_writes}++; 57 foreach my $fd (sort {$reads{$b}{bytes_requested} <=> 59 my $total_reads = $reads{$fd}{total_reads}; 60 my $bytes_requested = $reads{$fd}{bytes_requested}; 61 printf("%6u %10u %10u\n", $fd, $total_reads, $bytes_requested); [all …]
|
/tools/lib/api/fd/ |
D | array.c | 76 int fdarray__add(struct fdarray *fda, int fd, short revents, enum fdarray_flags flags) in fdarray__add() argument 84 fda->entries[fda->nr].fd = fd; in fdarray__add() 92 void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), in fdarray__filter() 95 int fd, nr = 0; in fdarray__filter() local 100 for (fd = 0; fd < fda->nr; ++fd) { in fdarray__filter() 101 if (!fda->entries[fd].events) in fdarray__filter() 104 if (fda->entries[fd].revents & revents) { in fdarray__filter() 106 entry_destructor(fda, fd, arg); in fdarray__filter() 108 fda->entries[fd].revents = fda->entries[fd].events = 0; in fdarray__filter() 112 if (!(fda->priv[fd].flags & fdarray_flag__nonfilterable)) in fdarray__filter() [all …]
|
/tools/testing/selftests/powerpc/ |
D | utils.c | 32 int rc, fd; in read_auxv() local 34 fd = open("/proc/self/auxv", O_RDONLY); in read_auxv() 35 if (fd == -1) { in read_auxv() 40 num = read(fd, buf, buf_size); in read_auxv() 55 close(fd); in read_auxv() 145 int rc = -1, fd; in read_sysfs_file() local 149 if ((fd = open(path, O_RDONLY)) < 0) in read_sysfs_file() 152 rc = read(fd, result, result_size); in read_sysfs_file() 154 close(fd); in read_sysfs_file() 164 int rc = -1, fd; in read_debugfs_file() local [all …]
|
/tools/testing/selftests/vm/ |
D | compaction_test.c | 60 int fd; in prereq() local 62 fd = open("/proc/sys/vm/compact_unevictable_allowed", in prereq() 64 if (fd < 0) { in prereq() 70 if (read(fd, &allowed, sizeof(char)) != sizeof(char)) { in prereq() 73 close(fd); in prereq() 77 close(fd); in prereq() 86 int fd; in check_compaction() local 95 fd = open("/proc/sys/vm/nr_hugepages", O_RDWR | O_NONBLOCK); in check_compaction() 96 if (fd < 0) { in check_compaction() 101 if (read(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages)) <= 0) { in check_compaction() [all …]
|
/tools/spi/ |
D | spidev_fdx.c | 18 static void do_read(int fd, int len) in do_read() argument 30 status = read(fd, buf, len); in do_read() 49 static void do_msg(int fd, int len) in do_msg() argument 68 status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer); in do_msg() 80 static void dumpstat(const char *name, int fd) in dumpstat() argument 85 if (ioctl(fd, SPI_IOC_RD_MODE32, &mode) < 0) { in dumpstat() 89 if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { in dumpstat() 93 if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) { in dumpstat() 97 if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) { in dumpstat() 111 int fd; in main() local [all …]
|
/tools/testing/selftests/dmabuf-heaps/ |
D | dmabuf-heap.c | 22 static int check_vgem(int fd) in check_vgem() argument 31 ret = ioctl(fd, DRM_IOCTL_VERSION, &version); in check_vgem() 40 int i, fd; in open_vgem() local 43 fd = -1; in open_vgem() 49 fd = open(name, O_RDWR); in open_vgem() 50 if (fd < 0) in open_vgem() 53 if (!check_vgem(fd)) { in open_vgem() 54 close(fd); in open_vgem() 55 fd = -1; in open_vgem() 61 return fd; in open_vgem() [all …]
|