compat_ioctl.c 45 KB

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