134d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <stdio.h> 234d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <stdlib.h> 334d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <string.h> 434d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <sys/types.h> 534d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <stdint.h> 634d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 734d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <asm/ioctl.h> 834d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <linux/types.h> 934d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 1034d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include "ioctldefs.h" 1134d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include <linux/atmioc.h> 1234d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 1334d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Projectstruct ioctlent { 1434d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project const char* header; 1534d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project const char* name; 1634d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project unsigned long code; 1734d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project}; 1834d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 1934d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Projectstruct ioctlent ioctls[] = { 2034d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project#include "ioctls.h" 2134d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project}; 2234d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 2334d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Projectint nioctls = sizeof(ioctls) / sizeof(ioctls[0]); 2434d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 2534d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Projectint compare(const void* a, const void* b) { 2634d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project unsigned long code1 = ((struct ioctlent *) a)->code; 2734d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project unsigned long code2 = ((struct ioctlent *) b)->code; 2834d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project const char *name1 = ((struct ioctlent *) a)->name; 2934d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project const char *name2 = ((struct ioctlent *) b)->name; 30bb0c2d52fc596f5e21652486c0b6a0b3e3b7e4cbElliott Hughes return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp(name1, name2); 3134d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project} 3234d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 3334d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Projectint main(int argc, char** argv) { 3434d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project int i; 3534d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 36f76f96e20f766e6bb91593885b1e800f8bc14a52Jeff Brown /* ioctl_lookup() only looks at the NR and TYPE bits atm. */ 3734d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project for (i = 0; i < nioctls; i++) 38f76f96e20f766e6bb91593885b1e800f8bc14a52Jeff Brown ioctls[i].code &= (_IOC_NRMASK << _IOC_NRSHIFT) | 39f76f96e20f766e6bb91593885b1e800f8bc14a52Jeff Brown (_IOC_TYPEMASK << _IOC_TYPESHIFT); 4034d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 4134d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project qsort(ioctls, nioctls, sizeof(ioctls[0]), compare); 42bb0c2d52fc596f5e21652486c0b6a0b3e3b7e4cbElliott Hughes puts("\t/* Generated by ioctlsort */"); 4334d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project for (i = 0; i < nioctls; i++) 4434d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project if (i == 0 || ioctls[i].code != ioctls[i-1].code || 45bb0c2d52fc596f5e21652486c0b6a0b3e3b7e4cbElliott Hughes strcmp(ioctls[i].name, ioctls[i-1].name)) 46f76f96e20f766e6bb91593885b1e800f8bc14a52Jeff Brown printf("\t{\"%s\",\t\"%s\",\t%#06lx},\n", 4734d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project ioctls[i].header, ioctls[i].name, ioctls[i].code); 4834d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project 4934d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project return 0; 5034d6eabc451f16d5f168fc1595ee604f21bccc51The Android Open Source Project} 51