Skip to content

Commit df7aa2b

Browse files
committed
ioctl: take all 32 bits of ioctl commands into account
Historically, only 16 bits (8-bit number and 8-bit type) of 32-bit ioctl commands were used for decoding, which was the source for numerous annoying collisions like this: ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(0, MGSL_IOCGPARAMS or MMTIMER_GETRES or MTIOCTOP or SNDCTL_MIDI_MPUMODE, 0x7fffd47f7338) = -1 ENOTTY (Inappropriate ioctl for device) The solution is to use all 32 bits for decoding, not just "number" and "type", but also "size" and "direction". As some architectures override defaults that come from asm-generic/ and provide alternative definitions for some ioctl commands, we support per-architecture ioctl definitions and merge them with common definitions at build time. During the merge, we used to keep both generic and architecture-specific definitions, now architecture-specific definitions have precedence over generic ones -- ioctlsort omits definitions from asm-generic/ for those ioctl names that have different definitions in asm/. Additional bits of "direction" are architecture specific -- the number of bits and their values differ between architectures. To reduce architecture differences in the source code, we keep "direction" in symbolic form and compile it in ioctlsort. Additional bits of "size" are also architecture specific -- not only the number of bits differ between architectures, but sizes of many types depend on sizeof(long). To reduce architecture differences in the source code, we keep 32-bit and 64-bit versions of common ioctl definitions, and use the appropriate version for each architecture and personality. To implement this, the tools for generating ioctl definitions from kernel headers have been rewritten, and the source format of ioctl definitions has been extended. The final ioctlent*.h files that are included by syscall.c are now generated from source ioctls_inc*.h and ioctls_arch*.h files at build time with ioctlsort. * ioctl.c (ioctl_lookup): Use all 32 bits of ioctl command code. * ioctlsort.c: Rewritten. * linux/32/ioctls_inc.h: New file. * linux/64/ioctls_inc.h: New file. * linux/aarch64/ioctls_arch0.h: New file. * linux/aarch64/ioctls_arch1.h: New file. * linux/aarch64/ioctls_inc0.h: New file. * linux/aarch64/ioctls_inc1.h: New file. * linux/alpha/ioctls_arch0.h: New file. * linux/alpha/ioctls_inc0.h: New file. * linux/arc/ioctls_arch0.h: New file. * linux/arc/ioctls_inc0.h: New file. * linux/arm/ioctls_arch0.h: New file. * linux/arm/ioctls_inc0.h: New file. * linux/avr32/ioctls_arch0.h: New file. * linux/avr32/ioctls_inc0.h: New file. * linux/bfin/ioctls_arch0.h: New file. * linux/bfin/ioctls_inc0.h: New file. * linux/hppa/ioctls_arch0.h: New file. * linux/hppa/ioctls_inc0.h: New file. * linux/i386/ioctls_arch0.h: New file. * linux/i386/ioctls_inc0.h: New file. * linux/ia64/ioctls_arch0.h: New file. * linux/ia64/ioctls_inc0.h: New file. * linux/m68k/ioctls_arch0.h: New file. * linux/m68k/ioctls_inc0.h: New file. * linux/metag/ioctls_arch0.h: New file. * linux/metag/ioctls_inc0.h: New file. * linux/microblaze/ioctls_arch0.h: New file. * linux/microblaze/ioctls_inc0.h: New file. * linux/mips/ioctls_arch0.h: New file. * linux/mips/ioctls_inc0.h: New file. * linux/or1k/ioctls_arch0.h: New file. * linux/or1k/ioctls_inc0.h: New file. * linux/powerpc/ioctls_arch0.h: New file. * linux/powerpc/ioctls_inc0.h: New file. * linux/powerpc64/ioctls_arch0.h: New file. * linux/powerpc64/ioctls_arch1.h: New file. * linux/powerpc64/ioctls_inc0.h: New file. * linux/powerpc64/ioctls_inc1.h: New file. * linux/s390/ioctls_arch0.h: New file. * linux/s390/ioctls_inc0.h: New file. * linux/s390x/ioctls_arch0.h: New file. * linux/s390x/ioctls_inc0.h: New file. * linux/sh/ioctls_arch0.h: New file. * linux/sh/ioctls_inc0.h: New file. * linux/sh64/ioctls_arch0.h: New file. * linux/sh64/ioctls_inc0.h: New file. * linux/sparc/ioctls_arch0.h: New file. * linux/sparc/ioctls_inc0.h: New file. * linux/sparc64/ioctls_arch0.h: New file. * linux/sparc64/ioctls_arch2.h: New file. * linux/sparc64/ioctls_inc0.h: New file. * linux/sparc64/ioctls_inc2.h: New file. * linux/tile/ioctls_arch0.h: New file. * linux/tile/ioctls_arch1.h: New file. * linux/tile/ioctls_inc0.h: New file. * linux/tile/ioctls_inc1.h: New file. * linux/x32/ioctls_arch0.h: New file. * linux/x32/ioctls_arch1.h: New file. * linux/x32/ioctls_inc0.h: New file. * linux/x32/ioctls_inc1.h: New file. * linux/x86_64/ioctls_arch0.h: New file. * linux/x86_64/ioctls_arch1.h: New file. * linux/x86_64/ioctls_inc0.h: New file. * linux/x86_64/ioctls_inc1.h: New file. * linux/xtensa/ioctls_arch0.h: New file. * linux/xtensa/ioctls_inc0.h: New file. * linux/aarch64/ioctlent.h.in: Remove. * linux/aarch64/ioctlent1.h: Remove. * linux/alpha/ioctlent.h.in: Remove. * linux/arc/ioctlent.h.in: Remove. * linux/arm/ioctlent.h.in: Remove. * linux/avr32/ioctlent.h.in: Remove. * linux/bfin/ioctlent.h.in: Remove. * linux/hppa/ioctlent.h.in: Remove. * linux/i386/ioctlent.h.in: Remove. * linux/ia64/ioctlent.h.in: Remove. * linux/ioctlent.h.in: Remove. * linux/ioctlent.sh: Remove. * linux/m68k/ioctlent.h.in: Remove. * linux/metag/ioctlent.h.in: Remove. * linux/microblaze/ioctlent.h.in: Remove. * linux/mips/ioctlent.h.in: Remove. * linux/mips/ioctlent.sh: Remove. * linux/or1k/ioctlent.h.in: Remove. * linux/powerpc/ioctlent.h.in: Remove. * linux/powerpc64/ioctlent.h: Remove. * linux/powerpc64/ioctlent1.h: Remove. * linux/s390/ioctlent.h.in: Remove. * linux/s390x/ioctlent.h.in: Remove. * linux/sh/ioctlent.h.in: Remove. * linux/sh64/ioctlent.h.in: Remove. * linux/sparc/ioctlent.h.in: Remove. * linux/sparc64/ioctlent.h.in: Remove. * linux/sparc64/ioctlent2.h: Remove. * linux/tile/ioctlent.h.in: Remove. * linux/tile/ioctlent1.h: Remove. * linux/x32/ioctlent.h.in: Remove. * linux/x32/ioctlent1.h: Remove. * linux/x86_64/ioctlent.h.in: Remove. * linux/x86_64/ioctlent1.h: Remove. * linux/xtensa/ioctlent.h.in: Remove. * linux/x86_64/ioctlent2.h: Include ioctlent0.h instead of ioctlent.h. * syscall.c (struct_ioctlent ioctlent0): Likewise. * Makefile.am: Remove all ioctlent-related definitions. Define the list of ioctlent*.h files that have to be generated by presence of $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h files. Add rules for ioctlent*.h files generation. (EXTRA_DIST): Update. * maint/ioctls_gen.sh: New file. * maint/ioctls_hex.sh: New file. * maint/ioctls_sym.sh: New file. * maint/print_ioctlent.c: New file. * HACKING-scripts: Update for ioctlent.sh -> ioctls_gen.sh migration. * .gitignore: Add ioctlent[012].h and ioctls_all[012].h. * configure.ac (AC_CHECK_HEADERS): Add linux/hiddev.h and linux/mmtimer.h for tests. * tests/ioctl.c: New file. * tests/ioctl.test: New test. * tests/Makefile.am (check_PROGRAMS): Add ioctl. (TESTS): Add ioctl.test. * tests/.gitignore: Add ioctl.
1 parent 6f9a01c commit df7aa2b

File tree

118 files changed

+7272
-3004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+7272
-3004
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Makefile.in
3535
/strace
3636
/test-driver
3737

38-
/linux/ioctlent.h
38+
/ioctlent[012].h
39+
/ioctls_all[012].h
3940

4041
/strace-*.tar.xz

HACKING-scripts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,38 @@ architecture to be specific). Hopefully, it'll be obvious how to swap out a
1414
different system or architecture as your circumstances apply.
1515

1616
ksrc=/usr/src/linux
17-
asrc=$ksrc/arch/blackfin/include/asm
17+
asrc=$ksrc/arch/blackfin/include
1818

1919
To use the errnoent.sh script, give it all the headers that might contain
2020
appropriate errno values. Excessive headers are not a problem. The resulting
2121
output should be directly usable without modification.
2222
sh ./errnoent.sh \
2323
$ksrc/include/linux/*errno*.h \
2424
$ksrc/include/asm-generic/*errno*.h \
25-
$asrc/*errno*.h \
25+
$asrc/asm/*errno*.h \
2626
> errnoent.h
2727

28-
To use the ioctlent.sh script, give it all the base include directories. The
28+
To use the ioctls_gen.sh script, give it all the base include directories. The
2929
script will crawl all the headers and try to discover appropriate ioctls.
3030
Unlike the other scripts, this one creates files for further processing. This
31-
is because ioctls tend to have a lot of define indirection, and the ioctlent.h
31+
is because ioctls tend to have a lot of define indirection, and the ioctlent0.h
3232
header needs to be fully expanded into numeric form and sorted properly. So
33-
first we process all of the ioctls with the ioctlent.sh into ioctldefs.h and
34-
ioctls.h, and then we compile them into ioctlsort.c. The resulting output,
35-
while directly usable, only contains definitions that match exactly the current
36-
kernel version that the script ran against. That means older/newer ioctl
37-
defines that might be present in the existing ioctlent.h header will be lost if
38-
things are copied directly. A little creative use of `diff` and manual merging
39-
should be used to produce the final ioctlent.h header.
40-
sh ./linux/ioctlent.sh $ksrc/include $asrc
41-
gcc -Wall -I. linux/ioctlsort.c -o ioctlsort
42-
./ioctlsort > ioctlent.h
33+
first we process all of the ioctls with the ioctls_gen.sh into ioctls_inc.h and
34+
ioctls_arch.h, and then we compile them into ioctlsort.c. The resulting
35+
output, while directly usable, only contains definitions that match exactly the
36+
current kernel version that the script ran against. That means older/newer
37+
ioctl defines that might be present in the existing ioctlent0.h header will be
38+
lost if things are copied directly. A little creative use of `diff` and manual
39+
merging should be used to produce the final ioctlent0.h header.
40+
sh ./maint/ioctls_gen.sh $ksrc/include $asrc
41+
gcc -Wall -I. ioctlsort.c -o ioctlsort
42+
./ioctlsort > ioctlent0.h
4343

4444
To use the signalent.sh script, give it all the headers that might contain
4545
appropriate signal values. Excessive headers are not a problem. The resulting
4646
output should be directly usable without modification.
4747
sh ./signalent.sh \
48-
$asrc/signal.h \
48+
$asrc/asm/signal.h \
4949
> signalent.h
5050

5151
To use the syscallent.sh script, give it the header with the list of your
@@ -54,5 +54,5 @@ a proper header as it can really only detect the system call number and its
5454
name. It has no way of knowing the number of arguments or strace flags for
5555
decoding them (yet?).
5656
sh ./syscallent.sh \
57-
$asrc/unistd.h \
57+
$asrc/asm/unistd.h \
5858
> syscallent.h

Makefile.am

Lines changed: 92 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -147,28 +147,37 @@ EXTRA_DIST = \
147147
debian/watch \
148148
errnoent.sh \
149149
ioctlsort.c \
150+
linux/32/ioctls_inc.h \
150151
linux/32/syscallent.h \
152+
linux/64/ioctls_inc.h \
151153
linux/64/syscallent.h \
152154
linux/aarch64/errnoent1.h \
153-
linux/aarch64/ioctlent.h.in \
154-
linux/aarch64/ioctlent1.h \
155+
linux/aarch64/ioctls_arch0.h \
156+
linux/aarch64/ioctls_arch1.h \
157+
linux/aarch64/ioctls_inc0.h \
158+
linux/aarch64/ioctls_inc1.h \
155159
linux/aarch64/signalent1.h \
156160
linux/aarch64/syscallent.h \
157161
linux/aarch64/syscallent1.h \
158162
linux/alpha/errnoent.h \
159-
linux/alpha/ioctlent.h.in \
163+
linux/alpha/ioctls_arch0.h \
164+
linux/alpha/ioctls_inc0.h \
160165
linux/alpha/signalent.h \
161166
linux/alpha/syscallent.h \
162167
linux/alpha/userent.h \
163-
linux/arc/ioctlent.h.in \
168+
linux/arc/ioctls_arch0.h \
169+
linux/arc/ioctls_inc0.h \
164170
linux/arc/syscallent.h \
165-
linux/arm/ioctlent.h.in \
171+
linux/arm/ioctls_arch0.h \
172+
linux/arm/ioctls_inc0.h \
166173
linux/arm/syscallent.h \
167174
linux/arm/userent.h \
168-
linux/avr32/ioctlent.h.in \
175+
linux/avr32/ioctls_arch0.h \
176+
linux/avr32/ioctls_inc0.h \
169177
linux/avr32/syscallent.h \
170178
linux/avr32/userent.h \
171-
linux/bfin/ioctlent.h.in \
179+
linux/bfin/ioctls_arch0.h \
180+
linux/bfin/ioctls_inc0.h \
172181
linux/bfin/syscallent.h \
173182
linux/bfin/userent.h \
174183
linux/crisv10/userent.h \
@@ -177,35 +186,39 @@ EXTRA_DIST = \
177186
linux/errnoent.h \
178187
linux/fanotify.h \
179188
linux/hppa/errnoent.h \
180-
linux/hppa/ioctlent.h.in \
189+
linux/hppa/ioctls_arch0.h \
190+
linux/hppa/ioctls_inc0.h \
181191
linux/hppa/signalent.h \
182192
linux/hppa/syscallent.h \
183-
linux/i386/ioctlent.h.in \
193+
linux/i386/ioctls_arch0.h \
194+
linux/i386/ioctls_inc0.h \
184195
linux/i386/syscallent.h \
185196
linux/i386/userent.h \
186197
linux/i386/userent0.h \
187-
linux/ia64/ioctlent.h.in \
198+
linux/ia64/ioctls_arch0.h \
199+
linux/ia64/ioctls_inc0.h \
188200
linux/ia64/signalent.h \
189201
linux/ia64/syscallent.h \
190202
linux/ia64/userent.h \
191203
linux/inet_diag.h \
192204
linux/inotify.h \
193-
linux/ioctlent.h.in \
194-
linux/ioctlent.sh \
195205
linux/kexec.h \
196206
linux/keyctl.h \
197-
linux/m68k/ioctlent.h.in \
207+
linux/m68k/ioctls_arch0.h \
208+
linux/m68k/ioctls_inc0.h \
198209
linux/m68k/syscallent.h \
199210
linux/m68k/userent.h \
200-
linux/metag/ioctlent.h.in \
211+
linux/metag/ioctls_arch0.h \
212+
linux/metag/ioctls_inc0.h \
201213
linux/metag/syscallent.h \
202-
linux/microblaze/ioctlent.h.in \
214+
linux/microblaze/ioctls_arch0.h \
215+
linux/microblaze/ioctls_inc0.h \
203216
linux/microblaze/syscallent.h \
204217
linux/microblaze/userent.h \
205218
linux/mips/errnoent.h \
206219
linux/mips/genstub.sh \
207-
linux/mips/ioctlent.h.in \
208-
linux/mips/ioctlent.sh \
220+
linux/mips/ioctls_arch0.h \
221+
linux/mips/ioctls_inc0.h \
209222
linux/mips/signalent.h \
210223
linux/mips/syscallent-compat.h \
211224
linux/mips/syscallent-n32.h \
@@ -214,35 +227,43 @@ EXTRA_DIST = \
214227
linux/mips/syscallent.h \
215228
linux/mips/userent.h \
216229
linux/mtd-abi.h \
217-
linux/or1k/ioctlent.h.in \
230+
linux/or1k/ioctls_arch0.h \
231+
linux/or1k/ioctls_inc0.h \
218232
linux/or1k/syscallent.h \
219233
linux/or1k/userent.h \
220234
linux/personality.h \
221-
linux/powerpc/ioctlent.h.in \
235+
linux/powerpc/ioctls_arch0.h \
236+
linux/powerpc/ioctls_inc0.h \
222237
linux/powerpc/syscallent.h \
223238
linux/powerpc/userent.h \
224239
linux/powerpc64/errnoent1.h \
225-
linux/powerpc64/ioctlent.h \
226-
linux/powerpc64/ioctlent1.h \
240+
linux/powerpc64/ioctls_arch0.h \
241+
linux/powerpc64/ioctls_arch1.h \
242+
linux/powerpc64/ioctls_inc0.h \
243+
linux/powerpc64/ioctls_inc1.h \
227244
linux/powerpc64/signalent1.h \
228245
linux/powerpc64/syscallent.h \
229246
linux/powerpc64/syscallent1.h \
230247
linux/powerpc64/userent.h \
231248
linux/ptp_clock.h \
232249
linux/reboot.h \
233-
linux/s390/ioctlent.h.in \
250+
linux/s390/ioctls_arch0.h \
251+
linux/s390/ioctls_inc0.h \
234252
linux/s390/syscallent.h \
235253
linux/s390/userent.h \
236254
linux/s390/userent0.h \
237255
linux/s390/userent1.h \
238-
linux/s390x/ioctlent.h.in \
256+
linux/s390x/ioctls_arch0.h \
257+
linux/s390x/ioctls_inc0.h \
239258
linux/s390x/syscallent.h \
240259
linux/s390x/userent.h \
241-
linux/sh/ioctlent.h.in \
260+
linux/sh/ioctls_arch0.h \
261+
linux/sh/ioctls_inc0.h \
242262
linux/sh/syscallent.h \
243263
linux/sh/userent.h \
244264
linux/sh/userent0.h \
245-
linux/sh64/ioctlent.h.in \
265+
linux/sh64/ioctls_arch0.h \
266+
linux/sh64/ioctls_inc0.h \
246267
linux/sh64/syscallent.h \
247268
linux/sh64/userent.h \
248269
linux/signalent.h \
@@ -251,8 +272,9 @@ EXTRA_DIST = \
251272
linux/sparc/errnoent.h \
252273
linux/sparc/errnoent1.h \
253274
linux/sparc/gen.pl \
254-
linux/sparc/ioctlent.h.in \
255275
linux/sparc/ioctlent1.h \
276+
linux/sparc/ioctls_arch0.h \
277+
linux/sparc/ioctls_inc0.h \
256278
linux/sparc/signalent.h \
257279
linux/sparc/signalent1.h \
258280
linux/sparc/syscall1.h \
@@ -263,9 +285,11 @@ EXTRA_DIST = \
263285
linux/sparc64/errnoent.h \
264286
linux/sparc64/errnoent1.h \
265287
linux/sparc64/errnoent2.h \
266-
linux/sparc64/ioctlent.h.in \
267288
linux/sparc64/ioctlent1.h \
268-
linux/sparc64/ioctlent2.h \
289+
linux/sparc64/ioctls_arch0.h \
290+
linux/sparc64/ioctls_arch2.h \
291+
linux/sparc64/ioctls_inc0.h \
292+
linux/sparc64/ioctls_inc2.h \
269293
linux/sparc64/signalent.h \
270294
linux/sparc64/signalent1.h \
271295
linux/sparc64/signalent2.h \
@@ -277,8 +301,10 @@ EXTRA_DIST = \
277301
linux/subcall.h \
278302
linux/syscall.h \
279303
linux/tile/errnoent1.h \
280-
linux/tile/ioctlent.h.in \
281-
linux/tile/ioctlent1.h \
304+
linux/tile/ioctls_arch0.h \
305+
linux/tile/ioctls_arch1.h \
306+
linux/tile/ioctls_inc0.h \
307+
linux/tile/ioctls_inc1.h \
282308
linux/tile/signalent1.h \
283309
linux/tile/syscallent.h \
284310
linux/tile/syscallent1.h \
@@ -289,8 +315,10 @@ EXTRA_DIST = \
289315
linux/userent0.h \
290316
linux/x32/errnoent.h \
291317
linux/x32/errnoent1.h \
292-
linux/x32/ioctlent.h.in \
293-
linux/x32/ioctlent1.h \
318+
linux/x32/ioctls_arch0.h \
319+
linux/x32/ioctls_arch1.h \
320+
linux/x32/ioctls_inc0.h \
321+
linux/x32/ioctls_inc1.h \
294322
linux/x32/signalent.h \
295323
linux/x32/signalent1.h \
296324
linux/x32/syscallent.h \
@@ -299,18 +327,25 @@ EXTRA_DIST = \
299327
linux/x86_64/errnoent1.h \
300328
linux/x86_64/errnoent2.h \
301329
linux/x86_64/gentab.pl \
302-
linux/x86_64/ioctlent.h.in \
303-
linux/x86_64/ioctlent1.h \
304330
linux/x86_64/ioctlent2.h \
331+
linux/x86_64/ioctls_arch0.h \
332+
linux/x86_64/ioctls_arch1.h \
333+
linux/x86_64/ioctls_inc0.h \
334+
linux/x86_64/ioctls_inc1.h \
305335
linux/x86_64/signalent1.h \
306336
linux/x86_64/signalent2.h \
307337
linux/x86_64/syscallent.h \
308338
linux/x86_64/syscallent1.h \
309339
linux/x86_64/syscallent2.h \
310340
linux/x86_64/userent.h \
311-
linux/xtensa/ioctlent.h.in \
341+
linux/xtensa/ioctls_arch0.h \
342+
linux/xtensa/ioctls_inc0.h \
312343
linux/xtensa/syscallent.h \
313344
linux/xtensa/userent.h \
345+
maint/ioctls_gen.sh \
346+
maint/ioctls_hex.sh \
347+
maint/ioctls_sym.sh \
348+
maint/print_ioctlent.c \
314349
signalent.sh \
315350
strace-graph \
316351
strace-log-merge \
@@ -346,16 +381,30 @@ news-check: NEWS
346381
exit 1; \
347382
fi
348383

349-
ioctlent_h = $(builddir)/$(OS)/ioctlent.h
384+
ioctlsort_CC = $(CC)
385+
ioctlsort_DEFS = $(DEFS)
386+
ioctlsort_INCLUDES = $(DEFAULT_INCLUDES) $(INCLUDES)
387+
ioctlsort_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS)
388+
ioctlsort_CFLAGS = $(AM_CFLAGS) $(CFLAGS)
389+
ioctlsort_LD = $(CCLD)
390+
ioctlsort_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS)
391+
392+
ioctls_inc_h = $(wildcard $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h)
393+
ioctlent_h = $(patsubst $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%,ioctlent%,$(ioctls_inc_h))
350394
BUILT_SOURCES += $(ioctlent_h)
351395
CLEANFILES = $(ioctlent_h)
352-
ioctlent_h_deps = $(srcdir)/$(OS)/ioctlent.h.in $(srcdir)/$(OS)/$(ARCH)/ioctlent.h.in
353-
$(ioctlent_h): $(top_builddir)/config.status $(ioctlent_h_deps)
354-
$(MKDIR_P) $(builddir)/$(OS)
355-
cat $(ioctlent_h_deps) | \
356-
$(COMPILE) -E -P - | \
357-
sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | \
358-
LC_ALL=C sort -u -k2,2 -k1,1 > $@
396+
397+
ioctlent%.h: ioctlsort%
398+
./$< > $@
399+
400+
ioctlsort%: ioctlsort%.o
401+
$(ioctlsort_LD) $(ioctlsort_LDFLAGS) $< -o $@
402+
403+
ioctlsort%.o: ioctls_all%.h $(srcdir)/ioctlsort.c
404+
$(ioctlsort_CC) $(ioctlsort_DEFS) $(ioctlsort_INCLUDES) $(ioctlsort_CPPFLAGS) $(ioctlsort_CFLAGS) -DIOCTLSORT_INC=\"$<\" -c -o $@ $(srcdir)/ioctlsort.c
405+
406+
ioctls_all%.h: $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%.h $(srcdir)/$(OS)/$(ARCH)/ioctls_arch%.h
407+
cat $^ > $@
359408

360409
if MAINTAINER_MODE
361410

@@ -385,28 +434,4 @@ $(srcdir)/CREDITS: $(srcdir)/CREDITS.in $(srcdir)/.mailmap \
385434

386435
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner --mode=go-w,go+rX
387436

388-
INCLUDEDIR = /usr/include
389-
KERNEL_RELEASE = $(shell uname -r)
390-
# Candidates for the kernel headers tree.
391-
KERNEL_INCLUDE = \
392-
/lib/modules/$(KERNEL_RELEASE)/build/include \
393-
/usr/src/linux-$(KERNEL_RELEASE)/include \
394-
$(INCLUDEDIR)
395-
IOCTLDIR = $(shell find $(KERNEL_INCLUDE) -maxdepth 0 -type d -print -quit 2>/dev/null)
396-
IOCTLASM = $(INCLUDEDIR)/asm
397-
398-
noinst_PROGRAMS = ioctlsort
399-
ioctlsort_SOURCES = ioctlsort.c
400-
nodist_ioctlsort_SOURCES = ioctls.h ioctldefs.h
401-
CLEANFILES += $(nodist_ioctlsort_SOURCES)
402-
ioctlsort.$(OBJEXT): $(nodist_ioctlsort_SOURCES)
403-
ioctls.h: $(srcdir)/linux/ioctlent.sh
404-
$(SHELL) $< $(IOCTLDIR) $(IOCTLASM)
405-
ioctldefs.h: ioctls.h ;
406-
407-
ioctlent_h_in = linux/ioctlent.h.in
408-
BUILT_SOURCES += $(ioctlent_h_in)
409-
$(srcdir)/$(ioctlent_h_in): ioctlsort
410-
$(<D)/$(<F) > $@
411-
412437
endif

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ AC_CHECK_HEADERS(m4_normalize([
223223
inttypes.h
224224
ioctls.h
225225
linux/falloc.h
226+
linux/hiddev.h
226227
linux/input.h
228+
linux/mmtimer.h
227229
linux/perf_event.h
228230
linux/ptrace.h
229231
linux/utsname.h

ioctl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ compare(const void *a, const void *b)
4848
}
4949

5050
const struct_ioctlent *
51-
ioctl_lookup(unsigned int code)
51+
ioctl_lookup(const unsigned int code)
5252
{
5353
struct_ioctlent *iop;
5454

55-
code &= (_IOC_NRMASK<<_IOC_NRSHIFT) | (_IOC_TYPEMASK<<_IOC_TYPESHIFT);
5655
iop = bsearch((const void *) (const unsigned long) code, ioctlent,
5756
nioctlents, sizeof(ioctlent[0]), compare);
5857
while (iop > ioctlent) {

0 commit comments

Comments
 (0)