compat_ioctl.c 46 KB

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