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.

tools lib: Introduce fdarray duplicate function

Introduce a function to duplicate an existing file descriptor in
the fdarray structure. The function returns the position of the duplicated
file descriptor.

Reviewed-by: Riccardo Mancini <rickyman7@gmail.com>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Riccardo Mancini <rickyman7@gmail.com>
Acked-by: Namhyung Kim <namhyung@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/2891f1def287d5863cc82683a4d5879195c8d90c.1642440724.git.alexey.v.bayduraev@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Alexey Bayduraev and committed by
Arnaldo Carvalho de Melo
d87c25e8 7954f716

+18
+17
tools/lib/api/fd/array.c
··· 88 88 return pos; 89 89 } 90 90 91 + int fdarray__dup_entry_from(struct fdarray *fda, int pos, struct fdarray *from) 92 + { 93 + struct pollfd *entry; 94 + int npos; 95 + 96 + if (pos >= from->nr) 97 + return -EINVAL; 98 + 99 + entry = &from->entries[pos]; 100 + 101 + npos = fdarray__add(fda, entry->fd, entry->events, from->priv[pos].flags); 102 + if (npos >= 0) 103 + fda->priv[npos] = from->priv[pos]; 104 + 105 + return npos; 106 + } 107 + 91 108 int fdarray__filter(struct fdarray *fda, short revents, 92 109 void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), 93 110 void *arg)
+1
tools/lib/api/fd/array.h
··· 42 42 void fdarray__delete(struct fdarray *fda); 43 43 44 44 int fdarray__add(struct fdarray *fda, int fd, short revents, enum fdarray_flags flags); 45 + int fdarray__dup_entry_from(struct fdarray *fda, int pos, struct fdarray *from); 45 46 int fdarray__poll(struct fdarray *fda, int timeout); 46 47 int fdarray__filter(struct fdarray *fda, short revents, 47 48 void (*entry_destructor)(struct fdarray *fda, int fd, void *arg),