8 #include <linux/types.h>
10 #include "ioctldefs.h"
11 #include <linux/atmioc.h>
19 struct ioctlent ioctls[] = {
23 int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
25 int compare(const void* a, const void* b) {
26 unsigned long code1 = ((struct ioctlent *) a)->code;
27 unsigned long code2 = ((struct ioctlent *) b)->code;
28 const char *name1 = ((struct ioctlent *) a)->name;
29 const char *name2 = ((struct ioctlent *) b)->name;
30 return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp(name1, name2);
33 int main(int argc, char** argv) {
36 /* ioctl_lookup() only looks at the NR and TYPE bits atm. */
37 for (i = 0; i < nioctls; i++)
38 ioctls[i].code &= (_IOC_NRMASK << _IOC_NRSHIFT) |
39 (_IOC_TYPEMASK << _IOC_TYPESHIFT);
41 qsort(ioctls, nioctls, sizeof(ioctls[0]), compare);
42 puts("\t/* Generated by ioctlsort */");
43 for (i = 0; i < nioctls; i++)
44 if (i == 0 || ioctls[i].code != ioctls[i-1].code ||
45 strcmp(ioctls[i].name, ioctls[i-1].name))
46 printf("\t{\"%s\",\t\"%s\",\t%#06lx},\n",
47 ioctls[i].header, ioctls[i].name, ioctls[i].code);