* How does the size field work in IOCTL numbers?
@ 2016-09-02 23:27 Keno Fischer
2016-09-03 12:35 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Keno Fischer @ 2016-09-02 23:27 UTC (permalink / raw)
To: linux-kernel, vincent.weaver, peterz, mingo
Hi folks,
this is more of a general linux question, but since I noticed it
while looking perf_events code, I'm ccing perf_events folks
in case the answer is perf_events specific (hope that's ok).
uapi/linux/perf_event.h has the following:
#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5)
#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
Now, my question is how to interpret the last argument to the
_IO* macros. The man page for ioctl(2) says, it encodes the
"size of the argument argp in bytes", but I'm not sure how to
interpret that.
For example, IOC_PERIOD takes a pointer to a 64-bit value,
so the __u64 makes sense for me. But as far as I know,
IOC_ID also takes a pointer to a 64-bit value
(and writes the ID to it), but it has `__64 *` rather than
`__u64`. The we have IOC_SET_FILTER which as far as I know
takes a pointer to a variable-length string (but with the
above definition the size field is sizeof(char*)), and
IOC_SET_BPF which doesn't take a pointer at all,
but interprets the argument as a file descriptor (similar to
IOC_SET_OUTPUT, which doesn't have a size at all).
I don't understand what the rule is for what to put in that third
argument, or is it ioctl specific? Please let me know if I missed
something.
Thanks,
Keno
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How does the size field work in IOCTL numbers?
2016-09-02 23:27 How does the size field work in IOCTL numbers? Keno Fischer
@ 2016-09-03 12:35 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2016-09-03 12:35 UTC (permalink / raw)
To: Keno Fischer; +Cc: linux-kernel, vincent.weaver, mingo
On Fri, Sep 02, 2016 at 07:27:27PM -0400, Keno Fischer wrote:
> I don't understand what the rule is for what to put in that third
> argument, or is it ioctl specific? Please let me know if I missed
> something.
You can do whatever you like, but everything that is different between
ILP32 and LP64 requires COMPAT fixups.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-03 12:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-02 23:27 How does the size field work in IOCTL numbers? Keno Fischer
2016-09-03 12:35 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox