ioctl: assume that all ioctl commands have unsigned int type
In linux, ioctl command number has a 32-bit unsigned integer type:
fs/ioctl.c:SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
If the kernel completely ignores other bits on 64-bit architectures,
why should strace care?
Let's follow the kernel and treat it as unsigned int.
* defs.h (struct_ioctlent): Change "code" type to "unsigned int".
(ioctl_decode, ioctl_lookup, block_ioctl, loop_ioctl, mtd_ioctl,
ubi_ioctl, ptp_ioctl, scsi_ioctl, sock_ioctl, term_ioctl, rtc_ioctl,
v4l2_ioctl): Likewise.
* ioctl.c (ioctl_decode, ioctl_lookup, compare, ioctl_next_match):
Likewise.
* block.c (block_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl, ubi_ioctl): Likewise.
* ptp.c (ptp_ioctl): Likewise.
* scsi.c (scsi_ioctl): Likewise.
* sock.c (sock_ioctl): Likewise.
* term.c (term_ioctl): Likewise.
* time.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* ioctlsort.c (struct ioctlent, compare, main): Likewise.
diff --git a/ioctlsort.c b/ioctlsort.c
index 393b534..f0f5744 100644
--- a/ioctlsort.c
+++ b/ioctlsort.c
@@ -13,7 +13,7 @@
struct ioctlent {
const char* header;
const char* name;
- unsigned long code;
+ unsigned int code;
};
struct ioctlent ioctls[] = {
@@ -23,8 +23,8 @@
int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
int compare(const void* a, const void* b) {
- unsigned long code1 = ((struct ioctlent *) a)->code;
- unsigned long code2 = ((struct ioctlent *) b)->code;
+ unsigned int code1 = ((struct ioctlent *) a)->code;
+ unsigned int code2 = ((struct ioctlent *) b)->code;
const char *name1 = ((struct ioctlent *) a)->name;
const char *name2 = ((struct ioctlent *) b)->name;
return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp(name1, name2);
@@ -51,7 +51,7 @@
for (i = 0; i < nioctls; i++)
if (i == 0 || ioctls[i-1].code != ioctls[i].code ||
is_not_prefix(ioctls[i-1].name, ioctls[i].name))
- printf("\t{\"%s\",\t\"%s\",\t%#06lx},\n",
+ printf("\t{\"%s\",\t\"%s\",\t%#06x},\n",
ioctls[i].header, ioctls[i].name, ioctls[i].code);
return 0;