compat_ioctl.c 60 KB

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