compat_ioctl.c 48 KB

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