compat_ioctl.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  1. /*
  2. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  3. *
  4. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  5. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
  7. * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz)
  8. *
  9. * These routines maintain argument size conversion between 32bit and 64bit
  10. * ioctls.
  11. */
  12. #include <linux/joystick.h>
  13. #include <linux/types.h>
  14. #include <linux/compat.h>
  15. #include <linux/kernel.h>
  16. #include <linux/capability.h>
  17. #include <linux/compiler.h>
  18. #include <linux/sched.h>
  19. #include <linux/smp.h>
  20. #include <linux/ioctl.h>
  21. #include <linux/if.h>
  22. #include <linux/if_bridge.h>
  23. #include <linux/raid/md_u.h>
  24. #include <linux/kd.h>
  25. #include <linux/route.h>
  26. #include <linux/in6.h>
  27. #include <linux/ipv6_route.h>
  28. #include <linux/skbuff.h>
  29. #include <linux/netlink.h>
  30. #include <linux/vt.h>
  31. #include <linux/falloc.h>
  32. #include <linux/fs.h>
  33. #include <linux/file.h>
  34. #include <linux/ppp_defs.h>
  35. #include <linux/ppp-ioctl.h>
  36. #include <linux/if_pppox.h>
  37. #include <linux/mtio.h>
  38. #include <linux/auto_fs.h>
  39. #include <linux/auto_fs4.h>
  40. #include <linux/tty.h>
  41. #include <linux/vt_kern.h>
  42. #include <linux/fb.h>
  43. #include <linux/videodev2.h>
  44. #include <linux/netdevice.h>
  45. #include <linux/raw.h>
  46. #include <linux/blkdev.h>
  47. #include <linux/elevator.h>
  48. #include <linux/rtc.h>
  49. #include <linux/pci.h>
  50. #include <linux/serial.h>
  51. #include <linux/if_tun.h>
  52. #include <linux/ctype.h>
  53. #include <linux/syscalls.h>
  54. #include <linux/i2c.h>
  55. #include <linux/i2c-dev.h>
  56. #include <linux/atalk.h>
  57. #include <linux/gfp.h>
  58. #include <net/bluetooth/bluetooth.h>
  59. #include <net/bluetooth/hci.h>
  60. #include <net/bluetooth/rfcomm.h>
  61. #include <linux/capi.h>
  62. #include <linux/gigaset_dev.h>
  63. #ifdef CONFIG_BLOCK
  64. #include <linux/loop.h>
  65. #include <linux/cdrom.h>
  66. #include <linux/fd.h>
  67. #include <scsi/scsi.h>
  68. #include <scsi/scsi_ioctl.h>
  69. #include <scsi/sg.h>
  70. #endif
  71. #include <asm/uaccess.h>
  72. #include <linux/ethtool.h>
  73. #include <linux/mii.h>
  74. #include <linux/if_bonding.h>
  75. #include <linux/watchdog.h>
  76. #include <linux/soundcard.h>
  77. #include <linux/lp.h>
  78. #include <linux/ppdev.h>
  79. #include <linux/atm.h>
  80. #include <linux/atmarp.h>
  81. #include <linux/atmclip.h>
  82. #include <linux/atmdev.h>
  83. #include <linux/atmioc.h>
  84. #include <linux/atmlec.h>
  85. #include <linux/atmmpc.h>
  86. #include <linux/atmsvc.h>
  87. #include <linux/atm_tcp.h>
  88. #include <linux/sonet.h>
  89. #include <linux/atm_suni.h>
  90. #include <linux/usb.h>
  91. #include <linux/usbdevice_fs.h>
  92. #include <linux/nbd.h>
  93. #include <linux/random.h>
  94. #include <linux/filter.h>
  95. #include <linux/hiddev.h>
  96. #define __DVB_CORE__
  97. #include <linux/dvb/audio.h>
  98. #include <linux/dvb/dmx.h>
  99. #include <linux/dvb/frontend.h>
  100. #include <linux/dvb/video.h>
  101. #include <linux/sort.h>
  102. #ifdef CONFIG_SPARC
  103. #include <asm/fbio.h>
  104. #endif
  105. static int w_long(unsigned int fd, unsigned int cmd,
  106. compat_ulong_t __user *argp)
  107. {
  108. mm_segment_t old_fs = get_fs();
  109. int err;
  110. unsigned long val;
  111. set_fs (KERNEL_DS);
  112. err = sys_ioctl(fd, cmd, (unsigned long)&val);
  113. set_fs (old_fs);
  114. if (!err && put_user(val, argp))
  115. return -EFAULT;
  116. return err;
  117. }
  118. struct compat_video_event {
  119. int32_t type;
  120. compat_time_t timestamp;
  121. union {
  122. video_size_t size;
  123. unsigned int frame_rate;
  124. } u;
  125. };
  126. static int do_video_get_event(unsigned int fd, unsigned int cmd,
  127. struct compat_video_event __user *up)
  128. {
  129. struct video_event kevent;
  130. mm_segment_t old_fs = get_fs();
  131. int err;
  132. set_fs(KERNEL_DS);
  133. err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
  134. set_fs(old_fs);
  135. if (!err) {
  136. err = put_user(kevent.type, &up->type);
  137. err |= put_user(kevent.timestamp, &up->timestamp);
  138. err |= put_user(kevent.u.size.w, &up->u.size.w);
  139. err |= put_user(kevent.u.size.h, &up->u.size.h);
  140. err |= put_user(kevent.u.size.aspect_ratio,
  141. &up->u.size.aspect_ratio);
  142. if (err)
  143. err = -EFAULT;
  144. }
  145. return err;
  146. }
  147. struct compat_video_still_picture {
  148. compat_uptr_t iFrame;
  149. int32_t size;
  150. };
  151. static int do_video_stillpicture(unsigned int fd, unsigned int cmd,
  152. struct compat_video_still_picture __user *up)
  153. {
  154. struct video_still_picture __user *up_native;
  155. compat_uptr_t fp;
  156. int32_t size;
  157. int err;
  158. err = get_user(fp, &up->iFrame);
  159. err |= get_user(size, &up->size);
  160. if (err)
  161. return -EFAULT;
  162. up_native =
  163. compat_alloc_user_space(sizeof(struct video_still_picture));
  164. err = put_user(compat_ptr(fp), &up_native->iFrame);
  165. err |= put_user(size, &up_native->size);
  166. if (err)
  167. return -EFAULT;
  168. err = sys_ioctl(fd, cmd, (unsigned long) up_native);
  169. return err;
  170. }
  171. struct compat_video_spu_palette {
  172. int length;
  173. compat_uptr_t palette;
  174. };
  175. static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd,
  176. struct compat_video_spu_palette __user *up)
  177. {
  178. struct video_spu_palette __user *up_native;
  179. compat_uptr_t palp;
  180. int length, err;
  181. err = get_user(palp, &up->palette);
  182. err |= get_user(length, &up->length);
  183. if (err)
  184. return -EFAULT;
  185. up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
  186. err = put_user(compat_ptr(palp), &up_native->palette);
  187. err |= put_user(length, &up_native->length);
  188. if (err)
  189. return -EFAULT;
  190. err = sys_ioctl(fd, cmd, (unsigned long) up_native);
  191. return err;
  192. }
  193. #ifdef CONFIG_BLOCK
  194. typedef struct sg_io_hdr32 {
  195. compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
  196. compat_int_t dxfer_direction; /* [i] data transfer direction */
  197. unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
  198. unsigned char mx_sb_len; /* [i] max length to write to sbp */
  199. unsigned short iovec_count; /* [i] 0 implies no scatter gather */
  200. compat_uint_t dxfer_len; /* [i] byte count of data transfer */
  201. compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
  202. or scatter gather list */
  203. compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
  204. compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
  205. compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
  206. compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
  207. compat_int_t pack_id; /* [i->o] unused internally (normally) */
  208. compat_uptr_t usr_ptr; /* [i->o] unused internally */
  209. unsigned char status; /* [o] scsi status */
  210. unsigned char masked_status; /* [o] shifted, masked scsi status */
  211. unsigned char msg_status; /* [o] messaging level data (optional) */
  212. unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
  213. unsigned short host_status; /* [o] errors from host adapter */
  214. unsigned short driver_status; /* [o] errors from software driver */
  215. compat_int_t resid; /* [o] dxfer_len - actual_transferred */
  216. compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
  217. compat_uint_t info; /* [o] auxiliary information */
  218. } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
  219. typedef struct sg_iovec32 {
  220. compat_uint_t iov_base;
  221. compat_uint_t iov_len;
  222. } sg_iovec32_t;
  223. static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
  224. {
  225. sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
  226. sg_iovec32_t __user *iov32 = dxferp;
  227. int i;
  228. for (i = 0; i < iovec_count; i++) {
  229. u32 base, len;
  230. if (get_user(base, &iov32[i].iov_base) ||
  231. get_user(len, &iov32[i].iov_len) ||
  232. put_user(compat_ptr(base), &iov[i].iov_base) ||
  233. put_user(len, &iov[i].iov_len))
  234. return -EFAULT;
  235. }
  236. if (put_user(iov, &sgio->dxferp))
  237. return -EFAULT;
  238. return 0;
  239. }
  240. static int sg_ioctl_trans(unsigned int fd, unsigned int cmd,
  241. sg_io_hdr32_t __user *sgio32)
  242. {
  243. sg_io_hdr_t __user *sgio;
  244. u16 iovec_count;
  245. u32 data;
  246. void __user *dxferp;
  247. int err;
  248. int interface_id;
  249. if (get_user(interface_id, &sgio32->interface_id))
  250. return -EFAULT;
  251. if (interface_id != 'S')
  252. return sys_ioctl(fd, cmd, (unsigned long)sgio32);
  253. if (get_user(iovec_count, &sgio32->iovec_count))
  254. return -EFAULT;
  255. {
  256. void __user *top = compat_alloc_user_space(0);
  257. void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
  258. (iovec_count * sizeof(sg_iovec_t)));
  259. if (new > top)
  260. return -EINVAL;
  261. sgio = new;
  262. }
  263. /* Ok, now construct. */
  264. if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
  265. (2 * sizeof(int)) +
  266. (2 * sizeof(unsigned char)) +
  267. (1 * sizeof(unsigned short)) +
  268. (1 * sizeof(unsigned int))))
  269. return -EFAULT;
  270. if (get_user(data, &sgio32->dxferp))
  271. return -EFAULT;
  272. dxferp = compat_ptr(data);
  273. if (iovec_count) {
  274. if (sg_build_iovec(sgio, dxferp, iovec_count))
  275. return -EFAULT;
  276. } else {
  277. if (put_user(dxferp, &sgio->dxferp))
  278. return -EFAULT;
  279. }
  280. {
  281. unsigned char __user *cmdp;
  282. unsigned char __user *sbp;
  283. if (get_user(data, &sgio32->cmdp))
  284. return -EFAULT;
  285. cmdp = compat_ptr(data);
  286. if (get_user(data, &sgio32->sbp))
  287. return -EFAULT;
  288. sbp = compat_ptr(data);
  289. if (put_user(cmdp, &sgio->cmdp) ||
  290. put_user(sbp, &sgio->sbp))
  291. return -EFAULT;
  292. }
  293. if (copy_in_user(&sgio->timeout, &sgio32->timeout,
  294. 3 * sizeof(int)))
  295. return -EFAULT;
  296. if (get_user(data, &sgio32->usr_ptr))
  297. return -EFAULT;
  298. if (put_user(compat_ptr(data), &sgio->usr_ptr))
  299. return -EFAULT;
  300. err = sys_ioctl(fd, cmd, (unsigned long) sgio);
  301. if (err >= 0) {
  302. void __user *datap;
  303. if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
  304. sizeof(int)) ||
  305. get_user(datap, &sgio->usr_ptr) ||
  306. put_user((u32)(unsigned long)datap,
  307. &sgio32->usr_ptr) ||
  308. copy_in_user(&sgio32->status, &sgio->status,
  309. (4 * sizeof(unsigned char)) +
  310. (2 * sizeof(unsigned short)) +
  311. (3 * sizeof(int))))
  312. err = -EFAULT;
  313. }
  314. return err;
  315. }
  316. struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
  317. char req_state;
  318. char orphan;
  319. char sg_io_owned;
  320. char problem;
  321. int pack_id;
  322. compat_uptr_t usr_ptr;
  323. unsigned int duration;
  324. int unused;
  325. };
  326. static int sg_grt_trans(unsigned int fd, unsigned int cmd, struct
  327. compat_sg_req_info __user *o)
  328. {
  329. int err, i;
  330. sg_req_info_t __user *r;
  331. r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
  332. err = sys_ioctl(fd,cmd,(unsigned long)r);
  333. if (err < 0)
  334. return err;
  335. for (i = 0; i < SG_MAX_QUEUE; i++) {
  336. void __user *ptr;
  337. int d;
  338. if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
  339. get_user(ptr, &r[i].usr_ptr) ||
  340. get_user(d, &r[i].duration) ||
  341. put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
  342. put_user(d, &o[i].duration))
  343. return -EFAULT;
  344. }
  345. return err;
  346. }
  347. #endif /* CONFIG_BLOCK */
  348. struct sock_fprog32 {
  349. unsigned short len;
  350. compat_caddr_t filter;
  351. };
  352. #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
  353. #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
  354. static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd,
  355. struct sock_fprog32 __user *u_fprog32)
  356. {
  357. struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
  358. void __user *fptr64;
  359. u32 fptr32;
  360. u16 flen;
  361. if (get_user(flen, &u_fprog32->len) ||
  362. get_user(fptr32, &u_fprog32->filter))
  363. return -EFAULT;
  364. fptr64 = compat_ptr(fptr32);
  365. if (put_user(flen, &u_fprog64->len) ||
  366. put_user(fptr64, &u_fprog64->filter))
  367. return -EFAULT;
  368. if (cmd == PPPIOCSPASS32)
  369. cmd = PPPIOCSPASS;
  370. else
  371. cmd = PPPIOCSACTIVE;
  372. return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
  373. }
  374. struct ppp_option_data32 {
  375. compat_caddr_t ptr;
  376. u32 length;
  377. compat_int_t transmit;
  378. };
  379. #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
  380. struct ppp_idle32 {
  381. compat_time_t xmit_idle;
  382. compat_time_t recv_idle;
  383. };
  384. #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
  385. static int ppp_gidle(unsigned int fd, unsigned int cmd,
  386. struct ppp_idle32 __user *idle32)
  387. {
  388. struct ppp_idle __user *idle;
  389. __kernel_time_t xmit, recv;
  390. int err;
  391. idle = compat_alloc_user_space(sizeof(*idle));
  392. err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
  393. if (!err) {
  394. if (get_user(xmit, &idle->xmit_idle) ||
  395. get_user(recv, &idle->recv_idle) ||
  396. put_user(xmit, &idle32->xmit_idle) ||
  397. put_user(recv, &idle32->recv_idle))
  398. err = -EFAULT;
  399. }
  400. return err;
  401. }
  402. static int ppp_scompress(unsigned int fd, unsigned int cmd,
  403. struct ppp_option_data32 __user *odata32)
  404. {
  405. struct ppp_option_data __user *odata;
  406. __u32 data;
  407. void __user *datap;
  408. odata = compat_alloc_user_space(sizeof(*odata));
  409. if (get_user(data, &odata32->ptr))
  410. return -EFAULT;
  411. datap = compat_ptr(data);
  412. if (put_user(datap, &odata->ptr))
  413. return -EFAULT;
  414. if (copy_in_user(&odata->length, &odata32->length,
  415. sizeof(__u32) + sizeof(int)))
  416. return -EFAULT;
  417. return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
  418. }
  419. #ifdef CONFIG_BLOCK
  420. struct mtget32 {
  421. compat_long_t mt_type;
  422. compat_long_t mt_resid;
  423. compat_long_t mt_dsreg;
  424. compat_long_t mt_gstat;
  425. compat_long_t mt_erreg;
  426. compat_daddr_t mt_fileno;
  427. compat_daddr_t mt_blkno;
  428. };
  429. #define MTIOCGET32 _IOR('m', 2, struct mtget32)
  430. struct mtpos32 {
  431. compat_long_t mt_blkno;
  432. };
  433. #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
  434. static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp)
  435. {
  436. mm_segment_t old_fs = get_fs();
  437. struct mtget get;
  438. struct mtget32 __user *umget32;
  439. struct mtpos pos;
  440. struct mtpos32 __user *upos32;
  441. unsigned long kcmd;
  442. void *karg;
  443. int err = 0;
  444. switch(cmd) {
  445. case MTIOCPOS32:
  446. kcmd = MTIOCPOS;
  447. karg = &pos;
  448. break;
  449. default: /* MTIOCGET32 */
  450. kcmd = MTIOCGET;
  451. karg = &get;
  452. break;
  453. }
  454. set_fs (KERNEL_DS);
  455. err = sys_ioctl (fd, kcmd, (unsigned long)karg);
  456. set_fs (old_fs);
  457. if (err)
  458. return err;
  459. switch (cmd) {
  460. case MTIOCPOS32:
  461. upos32 = argp;
  462. err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
  463. break;
  464. case MTIOCGET32:
  465. umget32 = argp;
  466. err = __put_user(get.mt_type, &umget32->mt_type);
  467. err |= __put_user(get.mt_resid, &umget32->mt_resid);
  468. err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
  469. err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
  470. err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
  471. err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
  472. err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
  473. break;
  474. }
  475. return err ? -EFAULT: 0;
  476. }
  477. #endif /* CONFIG_BLOCK */
  478. /* Bluetooth ioctls */
  479. #define HCIUARTSETPROTO _IOW('U', 200, int)
  480. #define HCIUARTGETPROTO _IOR('U', 201, int)
  481. #define HCIUARTGETDEVICE _IOR('U', 202, int)
  482. #define HCIUARTSETFLAGS _IOW('U', 203, int)
  483. #define HCIUARTGETFLAGS _IOR('U', 204, int)
  484. #define BNEPCONNADD _IOW('B', 200, int)
  485. #define BNEPCONNDEL _IOW('B', 201, int)
  486. #define BNEPGETCONNLIST _IOR('B', 210, int)
  487. #define BNEPGETCONNINFO _IOR('B', 211, int)
  488. #define CMTPCONNADD _IOW('C', 200, int)
  489. #define CMTPCONNDEL _IOW('C', 201, int)
  490. #define CMTPGETCONNLIST _IOR('C', 210, int)
  491. #define CMTPGETCONNINFO _IOR('C', 211, int)
  492. #define HIDPCONNADD _IOW('H', 200, int)
  493. #define HIDPCONNDEL _IOW('H', 201, int)
  494. #define HIDPGETCONNLIST _IOR('H', 210, int)
  495. #define HIDPGETCONNINFO _IOR('H', 211, int)
  496. struct serial_struct32 {
  497. compat_int_t type;
  498. compat_int_t line;
  499. compat_uint_t port;
  500. compat_int_t irq;
  501. compat_int_t flags;
  502. compat_int_t xmit_fifo_size;
  503. compat_int_t custom_divisor;
  504. compat_int_t baud_base;
  505. unsigned short close_delay;
  506. char io_type;
  507. char reserved_char[1];
  508. compat_int_t hub6;
  509. unsigned short closing_wait; /* time to wait before closing */
  510. unsigned short closing_wait2; /* no longer used... */
  511. compat_uint_t iomem_base;
  512. unsigned short iomem_reg_shift;
  513. unsigned int port_high;
  514. /* compat_ulong_t iomap_base FIXME */
  515. compat_int_t reserved[1];
  516. };
  517. static int serial_struct_ioctl(unsigned fd, unsigned cmd,
  518. struct serial_struct32 __user *ss32)
  519. {
  520. typedef struct serial_struct SS;
  521. typedef struct serial_struct32 SS32;
  522. int err;
  523. struct serial_struct ss;
  524. mm_segment_t oldseg = get_fs();
  525. __u32 udata;
  526. unsigned int base;
  527. if (cmd == TIOCSSERIAL) {
  528. if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
  529. return -EFAULT;
  530. if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
  531. return -EFAULT;
  532. if (__get_user(udata, &ss32->iomem_base))
  533. return -EFAULT;
  534. ss.iomem_base = compat_ptr(udata);
  535. if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  536. __get_user(ss.port_high, &ss32->port_high))
  537. return -EFAULT;
  538. ss.iomap_base = 0UL;
  539. }
  540. set_fs(KERNEL_DS);
  541. err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
  542. set_fs(oldseg);
  543. if (cmd == TIOCGSERIAL && err >= 0) {
  544. if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
  545. return -EFAULT;
  546. if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
  547. return -EFAULT;
  548. base = (unsigned long)ss.iomem_base >> 32 ?
  549. 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
  550. if (__put_user(base, &ss32->iomem_base) ||
  551. __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  552. __put_user(ss.port_high, &ss32->port_high))
  553. return -EFAULT;
  554. }
  555. return err;
  556. }
  557. /*
  558. * I2C layer ioctls
  559. */
  560. struct i2c_msg32 {
  561. u16 addr;
  562. u16 flags;
  563. u16 len;
  564. compat_caddr_t buf;
  565. };
  566. struct i2c_rdwr_ioctl_data32 {
  567. compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
  568. u32 nmsgs;
  569. };
  570. struct i2c_smbus_ioctl_data32 {
  571. u8 read_write;
  572. u8 command;
  573. u32 size;
  574. compat_caddr_t data; /* union i2c_smbus_data *data */
  575. };
  576. struct i2c_rdwr_aligned {
  577. struct i2c_rdwr_ioctl_data cmd;
  578. struct i2c_msg msgs[0];
  579. };
  580. static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
  581. struct i2c_rdwr_ioctl_data32 __user *udata)
  582. {
  583. struct i2c_rdwr_aligned __user *tdata;
  584. struct i2c_msg __user *tmsgs;
  585. struct i2c_msg32 __user *umsgs;
  586. compat_caddr_t datap;
  587. int nmsgs, i;
  588. if (get_user(nmsgs, &udata->nmsgs))
  589. return -EFAULT;
  590. if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
  591. return -EINVAL;
  592. if (get_user(datap, &udata->msgs))
  593. return -EFAULT;
  594. umsgs = compat_ptr(datap);
  595. tdata = compat_alloc_user_space(sizeof(*tdata) +
  596. nmsgs * sizeof(struct i2c_msg));
  597. tmsgs = &tdata->msgs[0];
  598. if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
  599. put_user(tmsgs, &tdata->cmd.msgs))
  600. return -EFAULT;
  601. for (i = 0; i < nmsgs; i++) {
  602. if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
  603. return -EFAULT;
  604. if (get_user(datap, &umsgs[i].buf) ||
  605. put_user(compat_ptr(datap), &tmsgs[i].buf))
  606. return -EFAULT;
  607. }
  608. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  609. }
  610. static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd,
  611. struct i2c_smbus_ioctl_data32 __user *udata)
  612. {
  613. struct i2c_smbus_ioctl_data __user *tdata;
  614. compat_caddr_t datap;
  615. tdata = compat_alloc_user_space(sizeof(*tdata));
  616. if (tdata == NULL)
  617. return -ENOMEM;
  618. if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
  619. return -EFAULT;
  620. if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
  621. return -EFAULT;
  622. if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
  623. return -EFAULT;
  624. if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
  625. return -EFAULT;
  626. if (__get_user(datap, &udata->data) ||
  627. __put_user(compat_ptr(datap), &tdata->data))
  628. return -EFAULT;
  629. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  630. }
  631. #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
  632. #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
  633. #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
  634. #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
  635. static int rtc_ioctl(unsigned fd, unsigned cmd, void __user *argp)
  636. {
  637. mm_segment_t oldfs = get_fs();
  638. compat_ulong_t val32;
  639. unsigned long kval;
  640. int ret;
  641. switch (cmd) {
  642. case RTC_IRQP_READ32:
  643. case RTC_EPOCH_READ32:
  644. set_fs(KERNEL_DS);
  645. ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
  646. RTC_IRQP_READ : RTC_EPOCH_READ,
  647. (unsigned long)&kval);
  648. set_fs(oldfs);
  649. if (ret)
  650. return ret;
  651. val32 = kval;
  652. return put_user(val32, (unsigned int __user *)argp);
  653. case RTC_IRQP_SET32:
  654. return sys_ioctl(fd, RTC_IRQP_SET, (unsigned long)argp);
  655. case RTC_EPOCH_SET32:
  656. return sys_ioctl(fd, RTC_EPOCH_SET, (unsigned long)argp);
  657. }
  658. return -ENOIOCTLCMD;
  659. }
  660. /* on ia32 l_start is on a 32-bit boundary */
  661. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  662. struct space_resv_32 {
  663. __s16 l_type;
  664. __s16 l_whence;
  665. __s64 l_start __attribute__((packed));
  666. /* len == 0 means until end of file */
  667. __s64 l_len __attribute__((packed));
  668. __s32 l_sysid;
  669. __u32 l_pid;
  670. __s32 l_pad[4]; /* reserve area */
  671. };
  672. #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
  673. #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
  674. /* just account for different alignment */
  675. static int compat_ioctl_preallocate(struct file *file,
  676. struct space_resv_32 __user *p32)
  677. {
  678. struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
  679. if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
  680. copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
  681. copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
  682. copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
  683. copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
  684. copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
  685. copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
  686. return -EFAULT;
  687. return ioctl_preallocate(file, p);
  688. }
  689. #endif
  690. /*
  691. * simple reversible transform to make our table more evenly
  692. * distributed after sorting.
  693. */
  694. #define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0xffffffff)
  695. #define COMPATIBLE_IOCTL(cmd) XFORM((u32)cmd),
  696. /* ioctl should not be warned about even if it's not implemented.
  697. Valid reasons to use this:
  698. - It is implemented with ->compat_ioctl on some device, but programs
  699. call it on others too.
  700. - The ioctl is not implemented in the native kernel, but programs
  701. call it commonly anyways.
  702. Most other reasons are not valid. */
  703. #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
  704. static unsigned int ioctl_pointer[] = {
  705. /* compatible ioctls first */
  706. COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
  707. COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
  708. /* Big T */
  709. COMPATIBLE_IOCTL(TCGETA)
  710. COMPATIBLE_IOCTL(TCSETA)
  711. COMPATIBLE_IOCTL(TCSETAW)
  712. COMPATIBLE_IOCTL(TCSETAF)
  713. COMPATIBLE_IOCTL(TCSBRK)
  714. COMPATIBLE_IOCTL(TCXONC)
  715. COMPATIBLE_IOCTL(TCFLSH)
  716. COMPATIBLE_IOCTL(TCGETS)
  717. COMPATIBLE_IOCTL(TCSETS)
  718. COMPATIBLE_IOCTL(TCSETSW)
  719. COMPATIBLE_IOCTL(TCSETSF)
  720. COMPATIBLE_IOCTL(TIOCLINUX)
  721. COMPATIBLE_IOCTL(TIOCSBRK)
  722. COMPATIBLE_IOCTL(TIOCGDEV)
  723. COMPATIBLE_IOCTL(TIOCCBRK)
  724. COMPATIBLE_IOCTL(TIOCGSID)
  725. COMPATIBLE_IOCTL(TIOCGICOUNT)
  726. /* Little t */
  727. COMPATIBLE_IOCTL(TIOCGETD)
  728. COMPATIBLE_IOCTL(TIOCSETD)
  729. COMPATIBLE_IOCTL(TIOCEXCL)
  730. COMPATIBLE_IOCTL(TIOCNXCL)
  731. COMPATIBLE_IOCTL(TIOCCONS)
  732. COMPATIBLE_IOCTL(TIOCGSOFTCAR)
  733. COMPATIBLE_IOCTL(TIOCSSOFTCAR)
  734. COMPATIBLE_IOCTL(TIOCSWINSZ)
  735. COMPATIBLE_IOCTL(TIOCGWINSZ)
  736. COMPATIBLE_IOCTL(TIOCMGET)
  737. COMPATIBLE_IOCTL(TIOCMBIC)
  738. COMPATIBLE_IOCTL(TIOCMBIS)
  739. COMPATIBLE_IOCTL(TIOCMSET)
  740. COMPATIBLE_IOCTL(TIOCPKT)
  741. COMPATIBLE_IOCTL(TIOCNOTTY)
  742. COMPATIBLE_IOCTL(TIOCSTI)
  743. COMPATIBLE_IOCTL(TIOCOUTQ)
  744. COMPATIBLE_IOCTL(TIOCSPGRP)
  745. COMPATIBLE_IOCTL(TIOCGPGRP)
  746. COMPATIBLE_IOCTL(TIOCGPTN)
  747. COMPATIBLE_IOCTL(TIOCSPTLCK)
  748. COMPATIBLE_IOCTL(TIOCSERGETLSR)
  749. COMPATIBLE_IOCTL(TIOCSIG)
  750. #ifdef TCGETS2
  751. COMPATIBLE_IOCTL(TCGETS2)
  752. COMPATIBLE_IOCTL(TCSETS2)
  753. COMPATIBLE_IOCTL(TCSETSW2)
  754. COMPATIBLE_IOCTL(TCSETSF2)
  755. #endif
  756. /* Little f */
  757. COMPATIBLE_IOCTL(FIOCLEX)
  758. COMPATIBLE_IOCTL(FIONCLEX)
  759. COMPATIBLE_IOCTL(FIOASYNC)
  760. COMPATIBLE_IOCTL(FIONBIO)
  761. COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
  762. COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
  763. /* 0x00 */
  764. COMPATIBLE_IOCTL(FIBMAP)
  765. COMPATIBLE_IOCTL(FIGETBSZ)
  766. /* 'X' - originally XFS but some now in the VFS */
  767. COMPATIBLE_IOCTL(FIFREEZE)
  768. COMPATIBLE_IOCTL(FITHAW)
  769. COMPATIBLE_IOCTL(KDGETKEYCODE)
  770. COMPATIBLE_IOCTL(KDSETKEYCODE)
  771. COMPATIBLE_IOCTL(KDGKBTYPE)
  772. COMPATIBLE_IOCTL(KDGETMODE)
  773. COMPATIBLE_IOCTL(KDGKBMODE)
  774. COMPATIBLE_IOCTL(KDGKBMETA)
  775. COMPATIBLE_IOCTL(KDGKBENT)
  776. COMPATIBLE_IOCTL(KDSKBENT)
  777. COMPATIBLE_IOCTL(KDGKBSENT)
  778. COMPATIBLE_IOCTL(KDSKBSENT)
  779. COMPATIBLE_IOCTL(KDGKBDIACR)
  780. COMPATIBLE_IOCTL(KDSKBDIACR)
  781. COMPATIBLE_IOCTL(KDKBDREP)
  782. COMPATIBLE_IOCTL(KDGKBLED)
  783. COMPATIBLE_IOCTL(KDGETLED)
  784. #ifdef CONFIG_BLOCK
  785. /* Big S */
  786. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
  787. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
  788. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
  789. COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
  790. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
  791. COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
  792. COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
  793. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
  794. #endif
  795. /* Big V (don't complain on serial console) */
  796. IGNORE_IOCTL(VT_OPENQRY)
  797. IGNORE_IOCTL(VT_GETMODE)
  798. /* Little p (/dev/rtc, /dev/envctrl, etc.) */
  799. COMPATIBLE_IOCTL(RTC_AIE_ON)
  800. COMPATIBLE_IOCTL(RTC_AIE_OFF)
  801. COMPATIBLE_IOCTL(RTC_UIE_ON)
  802. COMPATIBLE_IOCTL(RTC_UIE_OFF)
  803. COMPATIBLE_IOCTL(RTC_PIE_ON)
  804. COMPATIBLE_IOCTL(RTC_PIE_OFF)
  805. COMPATIBLE_IOCTL(RTC_WIE_ON)
  806. COMPATIBLE_IOCTL(RTC_WIE_OFF)
  807. COMPATIBLE_IOCTL(RTC_ALM_SET)
  808. COMPATIBLE_IOCTL(RTC_ALM_READ)
  809. COMPATIBLE_IOCTL(RTC_RD_TIME)
  810. COMPATIBLE_IOCTL(RTC_SET_TIME)
  811. COMPATIBLE_IOCTL(RTC_WKALM_SET)
  812. COMPATIBLE_IOCTL(RTC_WKALM_RD)
  813. /*
  814. * These two are only for the sbus rtc driver, but
  815. * hwclock tries them on every rtc device first when
  816. * running on sparc. On other architectures the entries
  817. * are useless but harmless.
  818. */
  819. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  820. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  821. /* Little m */
  822. COMPATIBLE_IOCTL(MTIOCTOP)
  823. /* Socket level stuff */
  824. COMPATIBLE_IOCTL(FIOQSIZE)
  825. #ifdef CONFIG_BLOCK
  826. /* loop */
  827. IGNORE_IOCTL(LOOP_CLR_FD)
  828. /* md calls this on random blockdevs */
  829. IGNORE_IOCTL(RAID_VERSION)
  830. /* qemu/qemu-img might call these two on plain files for probing */
  831. IGNORE_IOCTL(CDROM_DRIVE_STATUS)
  832. IGNORE_IOCTL(FDGETPRM32)
  833. /* SG stuff */
  834. COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
  835. COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
  836. COMPATIBLE_IOCTL(SG_EMULATED_HOST)
  837. COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
  838. COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
  839. COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
  840. COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
  841. COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
  842. COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
  843. COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
  844. COMPATIBLE_IOCTL(SG_GET_PACK_ID)
  845. COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
  846. COMPATIBLE_IOCTL(SG_SET_DEBUG)
  847. COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
  848. COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
  849. COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
  850. COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
  851. COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
  852. COMPATIBLE_IOCTL(SG_SCSI_RESET)
  853. COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
  854. COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
  855. COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
  856. #endif
  857. /* PPP stuff */
  858. COMPATIBLE_IOCTL(PPPIOCGFLAGS)
  859. COMPATIBLE_IOCTL(PPPIOCSFLAGS)
  860. COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
  861. COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
  862. COMPATIBLE_IOCTL(PPPIOCGUNIT)
  863. COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
  864. COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
  865. COMPATIBLE_IOCTL(PPPIOCGMRU)
  866. COMPATIBLE_IOCTL(PPPIOCSMRU)
  867. COMPATIBLE_IOCTL(PPPIOCSMAXCID)
  868. COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
  869. COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
  870. COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
  871. /* PPPIOCSCOMPRESS is translated */
  872. COMPATIBLE_IOCTL(PPPIOCGNPMODE)
  873. COMPATIBLE_IOCTL(PPPIOCSNPMODE)
  874. COMPATIBLE_IOCTL(PPPIOCGDEBUG)
  875. COMPATIBLE_IOCTL(PPPIOCSDEBUG)
  876. /* PPPIOCSPASS is translated */
  877. /* PPPIOCSACTIVE is translated */
  878. /* PPPIOCGIDLE is translated */
  879. COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
  880. COMPATIBLE_IOCTL(PPPIOCATTACH)
  881. COMPATIBLE_IOCTL(PPPIOCDETACH)
  882. COMPATIBLE_IOCTL(PPPIOCSMRRU)
  883. COMPATIBLE_IOCTL(PPPIOCCONNECT)
  884. COMPATIBLE_IOCTL(PPPIOCDISCONN)
  885. COMPATIBLE_IOCTL(PPPIOCATTCHAN)
  886. COMPATIBLE_IOCTL(PPPIOCGCHAN)
  887. COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS)
  888. /* PPPOX */
  889. COMPATIBLE_IOCTL(PPPOEIOCSFWD)
  890. COMPATIBLE_IOCTL(PPPOEIOCDFWD)
  891. /* ppdev */
  892. COMPATIBLE_IOCTL(PPSETMODE)
  893. COMPATIBLE_IOCTL(PPRSTATUS)
  894. COMPATIBLE_IOCTL(PPRCONTROL)
  895. COMPATIBLE_IOCTL(PPWCONTROL)
  896. COMPATIBLE_IOCTL(PPFCONTROL)
  897. COMPATIBLE_IOCTL(PPRDATA)
  898. COMPATIBLE_IOCTL(PPWDATA)
  899. COMPATIBLE_IOCTL(PPCLAIM)
  900. COMPATIBLE_IOCTL(PPRELEASE)
  901. COMPATIBLE_IOCTL(PPYIELD)
  902. COMPATIBLE_IOCTL(PPEXCL)
  903. COMPATIBLE_IOCTL(PPDATADIR)
  904. COMPATIBLE_IOCTL(PPNEGOT)
  905. COMPATIBLE_IOCTL(PPWCTLONIRQ)
  906. COMPATIBLE_IOCTL(PPCLRIRQ)
  907. COMPATIBLE_IOCTL(PPSETPHASE)
  908. COMPATIBLE_IOCTL(PPGETMODES)
  909. COMPATIBLE_IOCTL(PPGETMODE)
  910. COMPATIBLE_IOCTL(PPGETPHASE)
  911. COMPATIBLE_IOCTL(PPGETFLAGS)
  912. COMPATIBLE_IOCTL(PPSETFLAGS)
  913. /* Big A */
  914. /* sparc only */
  915. /* Big Q for sound/OSS */
  916. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
  917. COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
  918. COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
  919. COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
  920. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
  921. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
  922. COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
  923. COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
  924. COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
  925. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
  926. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
  927. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
  928. COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
  929. COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
  930. COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
  931. COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
  932. COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
  933. COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
  934. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
  935. COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
  936. COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
  937. COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
  938. /* Big T for sound/OSS */
  939. COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
  940. COMPATIBLE_IOCTL(SNDCTL_TMR_START)
  941. COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
  942. COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
  943. COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
  944. COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
  945. COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
  946. COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
  947. /* Little m for sound/OSS */
  948. COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
  949. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
  950. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
  951. /* Big P for sound/OSS */
  952. COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
  953. COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
  954. COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
  955. COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
  956. COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
  957. COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
  958. COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
  959. COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
  960. COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
  961. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
  962. COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
  963. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
  964. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
  965. COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
  966. COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
  967. COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
  968. COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
  969. COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
  970. COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
  971. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
  972. /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
  973. /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
  974. COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
  975. COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
  976. COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
  977. COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
  978. COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
  979. COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
  980. COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
  981. COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
  982. /* Big C for sound/OSS */
  983. COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
  984. COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
  985. COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
  986. COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
  987. COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
  988. COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
  989. COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
  990. COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
  991. COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
  992. COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
  993. /* Big M for sound/OSS */
  994. COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
  995. COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
  996. COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
  997. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
  998. COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
  999. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
  1000. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
  1001. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
  1002. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
  1003. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
  1004. COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
  1005. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
  1006. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
  1007. COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
  1008. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
  1009. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
  1010. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
  1011. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
  1012. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
  1013. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
  1014. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
  1015. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
  1016. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
  1017. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
  1018. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
  1019. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
  1020. /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
  1021. /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
  1022. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
  1023. COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
  1024. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
  1025. COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
  1026. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
  1027. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
  1028. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
  1029. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
  1030. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
  1031. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
  1032. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
  1033. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
  1034. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
  1035. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
  1036. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
  1037. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
  1038. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
  1039. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
  1040. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
  1041. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
  1042. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
  1043. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
  1044. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
  1045. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
  1046. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
  1047. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
  1048. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
  1049. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
  1050. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
  1051. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
  1052. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
  1053. /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
  1054. /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
  1055. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
  1056. COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
  1057. COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
  1058. COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
  1059. COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
  1060. COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
  1061. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
  1062. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
  1063. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
  1064. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
  1065. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
  1066. COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
  1067. COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
  1068. COMPATIBLE_IOCTL(OSS_GETVERSION)
  1069. /* Raw devices */
  1070. COMPATIBLE_IOCTL(RAW_SETBIND)
  1071. COMPATIBLE_IOCTL(RAW_GETBIND)
  1072. /* Watchdog */
  1073. COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
  1074. COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
  1075. COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
  1076. COMPATIBLE_IOCTL(WDIOC_GETTEMP)
  1077. COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
  1078. COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
  1079. COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
  1080. COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
  1081. /* Big R */
  1082. COMPATIBLE_IOCTL(RNDGETENTCNT)
  1083. COMPATIBLE_IOCTL(RNDADDTOENTCNT)
  1084. COMPATIBLE_IOCTL(RNDGETPOOL)
  1085. COMPATIBLE_IOCTL(RNDADDENTROPY)
  1086. COMPATIBLE_IOCTL(RNDZAPENTCNT)
  1087. COMPATIBLE_IOCTL(RNDCLEARPOOL)
  1088. /* Bluetooth */
  1089. COMPATIBLE_IOCTL(HCIDEVUP)
  1090. COMPATIBLE_IOCTL(HCIDEVDOWN)
  1091. COMPATIBLE_IOCTL(HCIDEVRESET)
  1092. COMPATIBLE_IOCTL(HCIDEVRESTAT)
  1093. COMPATIBLE_IOCTL(HCIGETDEVLIST)
  1094. COMPATIBLE_IOCTL(HCIGETDEVINFO)
  1095. COMPATIBLE_IOCTL(HCIGETCONNLIST)
  1096. COMPATIBLE_IOCTL(HCIGETCONNINFO)
  1097. COMPATIBLE_IOCTL(HCIGETAUTHINFO)
  1098. COMPATIBLE_IOCTL(HCISETAUTHINFO)
  1099. COMPATIBLE_IOCTL(HCISETRAW)
  1100. COMPATIBLE_IOCTL(HCISETSCAN)
  1101. COMPATIBLE_IOCTL(HCISETAUTH)
  1102. COMPATIBLE_IOCTL(HCISETENCRYPT)
  1103. COMPATIBLE_IOCTL(HCISETPTYPE)
  1104. COMPATIBLE_IOCTL(HCISETLINKPOL)
  1105. COMPATIBLE_IOCTL(HCISETLINKMODE)
  1106. COMPATIBLE_IOCTL(HCISETACLMTU)
  1107. COMPATIBLE_IOCTL(HCISETSCOMTU)
  1108. COMPATIBLE_IOCTL(HCIBLOCKADDR)
  1109. COMPATIBLE_IOCTL(HCIUNBLOCKADDR)
  1110. COMPATIBLE_IOCTL(HCIINQUIRY)
  1111. COMPATIBLE_IOCTL(HCIUARTSETPROTO)
  1112. COMPATIBLE_IOCTL(HCIUARTGETPROTO)
  1113. COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
  1114. COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
  1115. COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
  1116. COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
  1117. COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
  1118. COMPATIBLE_IOCTL(BNEPCONNADD)
  1119. COMPATIBLE_IOCTL(BNEPCONNDEL)
  1120. COMPATIBLE_IOCTL(BNEPGETCONNLIST)
  1121. COMPATIBLE_IOCTL(BNEPGETCONNINFO)
  1122. COMPATIBLE_IOCTL(CMTPCONNADD)
  1123. COMPATIBLE_IOCTL(CMTPCONNDEL)
  1124. COMPATIBLE_IOCTL(CMTPGETCONNLIST)
  1125. COMPATIBLE_IOCTL(CMTPGETCONNINFO)
  1126. COMPATIBLE_IOCTL(HIDPCONNADD)
  1127. COMPATIBLE_IOCTL(HIDPCONNDEL)
  1128. COMPATIBLE_IOCTL(HIDPGETCONNLIST)
  1129. COMPATIBLE_IOCTL(HIDPGETCONNINFO)
  1130. /* CAPI */
  1131. COMPATIBLE_IOCTL(CAPI_REGISTER)
  1132. COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
  1133. COMPATIBLE_IOCTL(CAPI_GET_VERSION)
  1134. COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
  1135. COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
  1136. COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
  1137. COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
  1138. COMPATIBLE_IOCTL(CAPI_INSTALLED)
  1139. COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
  1140. COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
  1141. COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
  1142. COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
  1143. COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
  1144. /* Siemens Gigaset */
  1145. COMPATIBLE_IOCTL(GIGASET_REDIR)
  1146. COMPATIBLE_IOCTL(GIGASET_CONFIG)
  1147. COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
  1148. COMPATIBLE_IOCTL(GIGASET_VERSION)
  1149. /* Misc. */
  1150. COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
  1151. COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
  1152. COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
  1153. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
  1154. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
  1155. COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
  1156. /* NBD */
  1157. COMPATIBLE_IOCTL(NBD_DO_IT)
  1158. COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
  1159. COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
  1160. COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
  1161. COMPATIBLE_IOCTL(NBD_DISCONNECT)
  1162. /* i2c */
  1163. COMPATIBLE_IOCTL(I2C_SLAVE)
  1164. COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
  1165. COMPATIBLE_IOCTL(I2C_TENBIT)
  1166. COMPATIBLE_IOCTL(I2C_PEC)
  1167. COMPATIBLE_IOCTL(I2C_RETRIES)
  1168. COMPATIBLE_IOCTL(I2C_TIMEOUT)
  1169. /* hiddev */
  1170. COMPATIBLE_IOCTL(HIDIOCGVERSION)
  1171. COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
  1172. COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
  1173. COMPATIBLE_IOCTL(HIDIOCGSTRING)
  1174. COMPATIBLE_IOCTL(HIDIOCINITREPORT)
  1175. COMPATIBLE_IOCTL(HIDIOCGREPORT)
  1176. COMPATIBLE_IOCTL(HIDIOCSREPORT)
  1177. COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
  1178. COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
  1179. COMPATIBLE_IOCTL(HIDIOCGUSAGE)
  1180. COMPATIBLE_IOCTL(HIDIOCSUSAGE)
  1181. COMPATIBLE_IOCTL(HIDIOCGUCODE)
  1182. COMPATIBLE_IOCTL(HIDIOCGFLAG)
  1183. COMPATIBLE_IOCTL(HIDIOCSFLAG)
  1184. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
  1185. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
  1186. /* dvb */
  1187. COMPATIBLE_IOCTL(AUDIO_STOP)
  1188. COMPATIBLE_IOCTL(AUDIO_PLAY)
  1189. COMPATIBLE_IOCTL(AUDIO_PAUSE)
  1190. COMPATIBLE_IOCTL(AUDIO_CONTINUE)
  1191. COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
  1192. COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
  1193. COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
  1194. COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
  1195. COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
  1196. COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
  1197. COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
  1198. COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
  1199. COMPATIBLE_IOCTL(AUDIO_SET_ID)
  1200. COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
  1201. COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
  1202. COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
  1203. COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
  1204. COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
  1205. COMPATIBLE_IOCTL(DMX_START)
  1206. COMPATIBLE_IOCTL(DMX_STOP)
  1207. COMPATIBLE_IOCTL(DMX_SET_FILTER)
  1208. COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
  1209. COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
  1210. COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
  1211. COMPATIBLE_IOCTL(DMX_GET_CAPS)
  1212. COMPATIBLE_IOCTL(DMX_SET_SOURCE)
  1213. COMPATIBLE_IOCTL(DMX_GET_STC)
  1214. COMPATIBLE_IOCTL(FE_GET_INFO)
  1215. COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
  1216. COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
  1217. COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
  1218. COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
  1219. COMPATIBLE_IOCTL(FE_SET_TONE)
  1220. COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
  1221. COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
  1222. COMPATIBLE_IOCTL(FE_READ_STATUS)
  1223. COMPATIBLE_IOCTL(FE_READ_BER)
  1224. COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
  1225. COMPATIBLE_IOCTL(FE_READ_SNR)
  1226. COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
  1227. COMPATIBLE_IOCTL(FE_SET_FRONTEND)
  1228. COMPATIBLE_IOCTL(FE_GET_FRONTEND)
  1229. COMPATIBLE_IOCTL(FE_GET_EVENT)
  1230. COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
  1231. COMPATIBLE_IOCTL(VIDEO_STOP)
  1232. COMPATIBLE_IOCTL(VIDEO_PLAY)
  1233. COMPATIBLE_IOCTL(VIDEO_FREEZE)
  1234. COMPATIBLE_IOCTL(VIDEO_CONTINUE)
  1235. COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
  1236. COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
  1237. COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
  1238. COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
  1239. COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
  1240. COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
  1241. COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
  1242. COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
  1243. COMPATIBLE_IOCTL(VIDEO_SET_ID)
  1244. COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
  1245. COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
  1246. COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
  1247. COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
  1248. COMPATIBLE_IOCTL(VIDEO_SET_SPU)
  1249. COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
  1250. COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
  1251. COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
  1252. COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
  1253. /* joystick */
  1254. COMPATIBLE_IOCTL(JSIOCGVERSION)
  1255. COMPATIBLE_IOCTL(JSIOCGAXES)
  1256. COMPATIBLE_IOCTL(JSIOCGBUTTONS)
  1257. COMPATIBLE_IOCTL(JSIOCGNAME(0))
  1258. #ifdef TIOCGLTC
  1259. COMPATIBLE_IOCTL(TIOCGLTC)
  1260. COMPATIBLE_IOCTL(TIOCSLTC)
  1261. #endif
  1262. #ifdef TIOCSTART
  1263. /*
  1264. * For these two we have definitions in ioctls.h and/or termios.h on
  1265. * some architectures but no actual implemention. Some applications
  1266. * like bash call them if they are defined in the headers, so we provide
  1267. * entries here to avoid syslog message spew.
  1268. */
  1269. COMPATIBLE_IOCTL(TIOCSTART)
  1270. COMPATIBLE_IOCTL(TIOCSTOP)
  1271. #endif
  1272. /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
  1273. but we don't want warnings on other file systems. So declare
  1274. them as compatible here. */
  1275. #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
  1276. #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
  1277. IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
  1278. IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
  1279. #ifdef CONFIG_SPARC
  1280. /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
  1281. IGNORE_IOCTL(FBIOGTYPE)
  1282. IGNORE_IOCTL(FBIOSATTR)
  1283. IGNORE_IOCTL(FBIOGATTR)
  1284. IGNORE_IOCTL(FBIOSVIDEO)
  1285. IGNORE_IOCTL(FBIOGVIDEO)
  1286. IGNORE_IOCTL(FBIOSCURPOS)
  1287. IGNORE_IOCTL(FBIOGCURPOS)
  1288. IGNORE_IOCTL(FBIOGCURMAX)
  1289. IGNORE_IOCTL(FBIOPUTCMAP32)
  1290. IGNORE_IOCTL(FBIOGETCMAP32)
  1291. IGNORE_IOCTL(FBIOSCURSOR32)
  1292. IGNORE_IOCTL(FBIOGCURSOR32)
  1293. #endif
  1294. };
  1295. /*
  1296. * Convert common ioctl arguments based on their command number
  1297. *
  1298. * Please do not add any code in here. Instead, implement
  1299. * a compat_ioctl operation in the place that handleѕ the
  1300. * ioctl for the native case.
  1301. */
  1302. static long do_ioctl_trans(int fd, unsigned int cmd,
  1303. unsigned long arg, struct file *file)
  1304. {
  1305. void __user *argp = compat_ptr(arg);
  1306. switch (cmd) {
  1307. case PPPIOCGIDLE32:
  1308. return ppp_gidle(fd, cmd, argp);
  1309. case PPPIOCSCOMPRESS32:
  1310. return ppp_scompress(fd, cmd, argp);
  1311. case PPPIOCSPASS32:
  1312. case PPPIOCSACTIVE32:
  1313. return ppp_sock_fprog_ioctl_trans(fd, cmd, argp);
  1314. #ifdef CONFIG_BLOCK
  1315. case SG_IO:
  1316. return sg_ioctl_trans(fd, cmd, argp);
  1317. case SG_GET_REQUEST_TABLE:
  1318. return sg_grt_trans(fd, cmd, argp);
  1319. case MTIOCGET32:
  1320. case MTIOCPOS32:
  1321. return mt_ioctl_trans(fd, cmd, argp);
  1322. #endif
  1323. /* Serial */
  1324. case TIOCGSERIAL:
  1325. case TIOCSSERIAL:
  1326. return serial_struct_ioctl(fd, cmd, argp);
  1327. /* i2c */
  1328. case I2C_FUNCS:
  1329. return w_long(fd, cmd, argp);
  1330. case I2C_RDWR:
  1331. return do_i2c_rdwr_ioctl(fd, cmd, argp);
  1332. case I2C_SMBUS:
  1333. return do_i2c_smbus_ioctl(fd, cmd, argp);
  1334. /* Not implemented in the native kernel */
  1335. case RTC_IRQP_READ32:
  1336. case RTC_IRQP_SET32:
  1337. case RTC_EPOCH_READ32:
  1338. case RTC_EPOCH_SET32:
  1339. return rtc_ioctl(fd, cmd, argp);
  1340. /* dvb */
  1341. case VIDEO_GET_EVENT:
  1342. return do_video_get_event(fd, cmd, argp);
  1343. case VIDEO_STILLPICTURE:
  1344. return do_video_stillpicture(fd, cmd, argp);
  1345. case VIDEO_SET_SPU_PALETTE:
  1346. return do_video_set_spu_palette(fd, cmd, argp);
  1347. }
  1348. /*
  1349. * These take an integer instead of a pointer as 'arg',
  1350. * so we must not do a compat_ptr() translation.
  1351. */
  1352. switch (cmd) {
  1353. /* Big T */
  1354. case TCSBRKP:
  1355. case TIOCMIWAIT:
  1356. case TIOCSCTTY:
  1357. /* RAID */
  1358. case HOT_REMOVE_DISK:
  1359. case HOT_ADD_DISK:
  1360. case SET_DISK_FAULTY:
  1361. case SET_BITMAP_FILE:
  1362. /* Big K */
  1363. case KDSIGACCEPT:
  1364. case KIOCSOUND:
  1365. case KDMKTONE:
  1366. case KDSETMODE:
  1367. case KDSKBMODE:
  1368. case KDSKBMETA:
  1369. case KDSKBLED:
  1370. case KDSETLED:
  1371. /* NBD */
  1372. case NBD_SET_SOCK:
  1373. case NBD_SET_BLKSIZE:
  1374. case NBD_SET_SIZE:
  1375. case NBD_SET_SIZE_BLOCKS:
  1376. return do_vfs_ioctl(file, fd, cmd, arg);
  1377. }
  1378. return -ENOIOCTLCMD;
  1379. }
  1380. static int compat_ioctl_check_table(unsigned int xcmd)
  1381. {
  1382. int i;
  1383. const int max = ARRAY_SIZE(ioctl_pointer) - 1;
  1384. BUILD_BUG_ON(max >= (1 << 16));
  1385. /* guess initial offset into table, assuming a
  1386. normalized distribution */
  1387. i = ((xcmd >> 16) * max) >> 16;
  1388. /* do linear search up first, until greater or equal */
  1389. while (ioctl_pointer[i] < xcmd && i < max)
  1390. i++;
  1391. /* then do linear search down */
  1392. while (ioctl_pointer[i] > xcmd && i > 0)
  1393. i--;
  1394. return ioctl_pointer[i] == xcmd;
  1395. }
  1396. asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
  1397. unsigned long arg)
  1398. {
  1399. struct file *filp;
  1400. int error = -EBADF;
  1401. int fput_needed;
  1402. filp = fget_light(fd, &fput_needed);
  1403. if (!filp)
  1404. goto out;
  1405. /* RED-PEN how should LSM module know it's handling 32bit? */
  1406. error = security_file_ioctl(filp, cmd, arg);
  1407. if (error)
  1408. goto out_fput;
  1409. /*
  1410. * To allow the compat_ioctl handlers to be self contained
  1411. * we need to check the common ioctls here first.
  1412. * Just handle them with the standard handlers below.
  1413. */
  1414. switch (cmd) {
  1415. case FIOCLEX:
  1416. case FIONCLEX:
  1417. case FIONBIO:
  1418. case FIOASYNC:
  1419. case FIOQSIZE:
  1420. break;
  1421. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  1422. case FS_IOC_RESVSP_32:
  1423. case FS_IOC_RESVSP64_32:
  1424. error = compat_ioctl_preallocate(filp, compat_ptr(arg));
  1425. goto out_fput;
  1426. #else
  1427. case FS_IOC_RESVSP:
  1428. case FS_IOC_RESVSP64:
  1429. error = ioctl_preallocate(filp, compat_ptr(arg));
  1430. goto out_fput;
  1431. #endif
  1432. case FIBMAP:
  1433. case FIGETBSZ:
  1434. case FIONREAD:
  1435. if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
  1436. break;
  1437. /*FALL THROUGH*/
  1438. default:
  1439. if (filp->f_op && filp->f_op->compat_ioctl) {
  1440. error = filp->f_op->compat_ioctl(filp, cmd, arg);
  1441. if (error != -ENOIOCTLCMD)
  1442. goto out_fput;
  1443. }
  1444. if (!filp->f_op || !filp->f_op->unlocked_ioctl)
  1445. goto do_ioctl;
  1446. break;
  1447. }
  1448. if (compat_ioctl_check_table(XFORM(cmd)))
  1449. goto found_handler;
  1450. error = do_ioctl_trans(fd, cmd, arg, filp);
  1451. if (error == -ENOIOCTLCMD)
  1452. error = -ENOTTY;
  1453. goto out_fput;
  1454. found_handler:
  1455. arg = (unsigned long)compat_ptr(arg);
  1456. do_ioctl:
  1457. error = do_vfs_ioctl(filp, fd, cmd, arg);
  1458. out_fput:
  1459. fput_light(filp, fput_needed);
  1460. out:
  1461. return error;
  1462. }
  1463. static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
  1464. {
  1465. unsigned int a, b;
  1466. a = *(unsigned int *)p;
  1467. b = *(unsigned int *)q;
  1468. if (a > b)
  1469. return 1;
  1470. if (a < b)
  1471. return -1;
  1472. return 0;
  1473. }
  1474. static int __init init_sys32_ioctl(void)
  1475. {
  1476. sort(ioctl_pointer, ARRAY_SIZE(ioctl_pointer), sizeof(*ioctl_pointer),
  1477. init_sys32_ioctl_cmp, NULL);
  1478. return 0;
  1479. }
  1480. __initcall(init_sys32_ioctl);