compat_ioctl.c 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896
  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_NET
  213. static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
  214. {
  215. struct compat_timeval __user *up = compat_ptr(arg);
  216. struct timeval ktv;
  217. mm_segment_t old_fs = get_fs();
  218. int err;
  219. set_fs(KERNEL_DS);
  220. err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
  221. set_fs(old_fs);
  222. if(!err) {
  223. err = put_user(ktv.tv_sec, &up->tv_sec);
  224. err |= __put_user(ktv.tv_usec, &up->tv_usec);
  225. }
  226. return err;
  227. }
  228. static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg)
  229. {
  230. struct compat_timespec __user *up = compat_ptr(arg);
  231. struct timespec kts;
  232. mm_segment_t old_fs = get_fs();
  233. int err;
  234. set_fs(KERNEL_DS);
  235. err = sys_ioctl(fd, cmd, (unsigned long)&kts);
  236. set_fs(old_fs);
  237. if (!err) {
  238. err = put_user(kts.tv_sec, &up->tv_sec);
  239. err |= __put_user(kts.tv_nsec, &up->tv_nsec);
  240. }
  241. return err;
  242. }
  243. struct ifmap32 {
  244. compat_ulong_t mem_start;
  245. compat_ulong_t mem_end;
  246. unsigned short base_addr;
  247. unsigned char irq;
  248. unsigned char dma;
  249. unsigned char port;
  250. };
  251. struct ifreq32 {
  252. #define IFHWADDRLEN 6
  253. #define IFNAMSIZ 16
  254. union {
  255. char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
  256. } ifr_ifrn;
  257. union {
  258. struct sockaddr ifru_addr;
  259. struct sockaddr ifru_dstaddr;
  260. struct sockaddr ifru_broadaddr;
  261. struct sockaddr ifru_netmask;
  262. struct sockaddr ifru_hwaddr;
  263. short ifru_flags;
  264. compat_int_t ifru_ivalue;
  265. compat_int_t ifru_mtu;
  266. struct ifmap32 ifru_map;
  267. char ifru_slave[IFNAMSIZ]; /* Just fits the size */
  268. char ifru_newname[IFNAMSIZ];
  269. compat_caddr_t ifru_data;
  270. /* XXXX? ifru_settings should be here */
  271. } ifr_ifru;
  272. };
  273. struct ifconf32 {
  274. compat_int_t ifc_len; /* size of buffer */
  275. compat_caddr_t ifcbuf;
  276. };
  277. static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
  278. {
  279. struct ifreq __user *uifr;
  280. int err;
  281. uifr = compat_alloc_user_space(sizeof(struct ifreq));
  282. if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)))
  283. return -EFAULT;
  284. err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
  285. if (err)
  286. return err;
  287. if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
  288. return -EFAULT;
  289. return 0;
  290. }
  291. static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
  292. {
  293. struct ifconf32 ifc32;
  294. struct ifconf ifc;
  295. struct ifconf __user *uifc;
  296. struct ifreq32 __user *ifr32;
  297. struct ifreq __user *ifr;
  298. unsigned int i, j;
  299. int err;
  300. if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
  301. return -EFAULT;
  302. if (ifc32.ifcbuf == 0) {
  303. ifc32.ifc_len = 0;
  304. ifc.ifc_len = 0;
  305. ifc.ifc_req = NULL;
  306. uifc = compat_alloc_user_space(sizeof(struct ifconf));
  307. } else {
  308. size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
  309. sizeof (struct ifreq);
  310. uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
  311. ifc.ifc_len = len;
  312. ifr = ifc.ifc_req = (void __user *)(uifc + 1);
  313. ifr32 = compat_ptr(ifc32.ifcbuf);
  314. for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
  315. if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
  316. return -EFAULT;
  317. ifr++;
  318. ifr32++;
  319. }
  320. }
  321. if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
  322. return -EFAULT;
  323. err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
  324. if (err)
  325. return err;
  326. if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
  327. return -EFAULT;
  328. ifr = ifc.ifc_req;
  329. ifr32 = compat_ptr(ifc32.ifcbuf);
  330. for (i = 0, j = 0;
  331. i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
  332. i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
  333. if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
  334. return -EFAULT;
  335. ifr32++;
  336. ifr++;
  337. }
  338. if (ifc32.ifcbuf == 0) {
  339. /* Translate from 64-bit structure multiple to
  340. * a 32-bit one.
  341. */
  342. i = ifc.ifc_len;
  343. i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
  344. ifc32.ifc_len = i;
  345. } else {
  346. ifc32.ifc_len = i;
  347. }
  348. if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
  349. return -EFAULT;
  350. return 0;
  351. }
  352. static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  353. {
  354. struct ifreq __user *ifr;
  355. struct ifreq32 __user *ifr32;
  356. u32 data;
  357. void __user *datap;
  358. ifr = compat_alloc_user_space(sizeof(*ifr));
  359. ifr32 = compat_ptr(arg);
  360. if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
  361. return -EFAULT;
  362. if (get_user(data, &ifr32->ifr_ifru.ifru_data))
  363. return -EFAULT;
  364. datap = compat_ptr(data);
  365. if (put_user(datap, &ifr->ifr_ifru.ifru_data))
  366. return -EFAULT;
  367. return sys_ioctl(fd, cmd, (unsigned long) ifr);
  368. }
  369. static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  370. {
  371. struct ifreq kifr;
  372. struct ifreq __user *uifr;
  373. struct ifreq32 __user *ifr32 = compat_ptr(arg);
  374. mm_segment_t old_fs;
  375. int err;
  376. u32 data;
  377. void __user *datap;
  378. switch (cmd) {
  379. case SIOCBONDENSLAVE:
  380. case SIOCBONDRELEASE:
  381. case SIOCBONDSETHWADDR:
  382. case SIOCBONDCHANGEACTIVE:
  383. if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
  384. return -EFAULT;
  385. old_fs = get_fs();
  386. set_fs (KERNEL_DS);
  387. err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
  388. set_fs (old_fs);
  389. return err;
  390. case SIOCBONDSLAVEINFOQUERY:
  391. case SIOCBONDINFOQUERY:
  392. uifr = compat_alloc_user_space(sizeof(*uifr));
  393. if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
  394. return -EFAULT;
  395. if (get_user(data, &ifr32->ifr_ifru.ifru_data))
  396. return -EFAULT;
  397. datap = compat_ptr(data);
  398. if (put_user(datap, &uifr->ifr_ifru.ifru_data))
  399. return -EFAULT;
  400. return sys_ioctl (fd, cmd, (unsigned long)uifr);
  401. default:
  402. return -EINVAL;
  403. };
  404. }
  405. static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  406. {
  407. struct ifreq __user *u_ifreq64;
  408. struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
  409. char tmp_buf[IFNAMSIZ];
  410. void __user *data64;
  411. u32 data32;
  412. if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
  413. IFNAMSIZ))
  414. return -EFAULT;
  415. if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
  416. return -EFAULT;
  417. data64 = compat_ptr(data32);
  418. u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
  419. /* Don't check these user accesses, just let that get trapped
  420. * in the ioctl handler instead.
  421. */
  422. if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
  423. IFNAMSIZ))
  424. return -EFAULT;
  425. if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
  426. return -EFAULT;
  427. return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
  428. }
  429. static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
  430. {
  431. struct ifreq ifr;
  432. struct ifreq32 __user *uifr32;
  433. struct ifmap32 __user *uifmap32;
  434. mm_segment_t old_fs;
  435. int err;
  436. uifr32 = compat_ptr(arg);
  437. uifmap32 = &uifr32->ifr_ifru.ifru_map;
  438. switch (cmd) {
  439. case SIOCSIFMAP:
  440. err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
  441. err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
  442. err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
  443. err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
  444. err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
  445. err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
  446. err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
  447. if (err)
  448. return -EFAULT;
  449. break;
  450. case SIOCSHWTSTAMP:
  451. if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
  452. return -EFAULT;
  453. ifr.ifr_data = compat_ptr(uifr32->ifr_ifru.ifru_data);
  454. break;
  455. default:
  456. if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
  457. return -EFAULT;
  458. break;
  459. }
  460. old_fs = get_fs();
  461. set_fs (KERNEL_DS);
  462. err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
  463. set_fs (old_fs);
  464. if (!err) {
  465. switch (cmd) {
  466. /* TUNSETIFF is defined as _IOW, it should be _IORW
  467. * as the data is copied back to user space, but that
  468. * cannot be fixed without breaking all existing apps.
  469. */
  470. case TUNSETIFF:
  471. case TUNGETIFF:
  472. case SIOCGIFFLAGS:
  473. case SIOCGIFMETRIC:
  474. case SIOCGIFMTU:
  475. case SIOCGIFMEM:
  476. case SIOCGIFHWADDR:
  477. case SIOCGIFINDEX:
  478. case SIOCGIFADDR:
  479. case SIOCGIFBRDADDR:
  480. case SIOCGIFDSTADDR:
  481. case SIOCGIFNETMASK:
  482. case SIOCGIFTXQLEN:
  483. if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
  484. return -EFAULT;
  485. break;
  486. case SIOCGIFMAP:
  487. err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
  488. err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
  489. err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
  490. err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
  491. err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
  492. err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
  493. err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
  494. if (err)
  495. err = -EFAULT;
  496. break;
  497. }
  498. }
  499. return err;
  500. }
  501. struct rtentry32 {
  502. u32 rt_pad1;
  503. struct sockaddr rt_dst; /* target address */
  504. struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
  505. struct sockaddr rt_genmask; /* target network mask (IP) */
  506. unsigned short rt_flags;
  507. short rt_pad2;
  508. u32 rt_pad3;
  509. unsigned char rt_tos;
  510. unsigned char rt_class;
  511. short rt_pad4;
  512. short rt_metric; /* +1 for binary compatibility! */
  513. /* char * */ u32 rt_dev; /* forcing the device at add */
  514. u32 rt_mtu; /* per route MTU/Window */
  515. u32 rt_window; /* Window clamping */
  516. unsigned short rt_irtt; /* Initial RTT */
  517. };
  518. struct in6_rtmsg32 {
  519. struct in6_addr rtmsg_dst;
  520. struct in6_addr rtmsg_src;
  521. struct in6_addr rtmsg_gateway;
  522. u32 rtmsg_type;
  523. u16 rtmsg_dst_len;
  524. u16 rtmsg_src_len;
  525. u32 rtmsg_metric;
  526. u32 rtmsg_info;
  527. u32 rtmsg_flags;
  528. s32 rtmsg_ifindex;
  529. };
  530. static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  531. {
  532. int ret;
  533. void *r = NULL;
  534. struct in6_rtmsg r6;
  535. struct rtentry r4;
  536. char devname[16];
  537. u32 rtdev;
  538. mm_segment_t old_fs = get_fs();
  539. struct socket *mysock = sockfd_lookup(fd, &ret);
  540. if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
  541. struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
  542. ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
  543. 3 * sizeof(struct in6_addr));
  544. ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
  545. ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
  546. ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
  547. ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
  548. ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
  549. ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
  550. ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
  551. r = (void *) &r6;
  552. } else { /* ipv4 */
  553. struct rtentry32 __user *ur4 = compat_ptr(arg);
  554. ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
  555. 3 * sizeof(struct sockaddr));
  556. ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
  557. ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
  558. ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
  559. ret |= __get_user (r4.rt_window, &(ur4->rt_window));
  560. ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
  561. ret |= __get_user (rtdev, &(ur4->rt_dev));
  562. if (rtdev) {
  563. ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
  564. r4.rt_dev = devname; devname[15] = 0;
  565. } else
  566. r4.rt_dev = NULL;
  567. r = (void *) &r4;
  568. }
  569. if (ret) {
  570. ret = -EFAULT;
  571. goto out;
  572. }
  573. set_fs (KERNEL_DS);
  574. ret = sys_ioctl (fd, cmd, (unsigned long) r);
  575. set_fs (old_fs);
  576. out:
  577. if (mysock)
  578. sockfd_put(mysock);
  579. return ret;
  580. }
  581. #endif
  582. #ifdef CONFIG_BLOCK
  583. typedef struct sg_io_hdr32 {
  584. compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
  585. compat_int_t dxfer_direction; /* [i] data transfer direction */
  586. unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
  587. unsigned char mx_sb_len; /* [i] max length to write to sbp */
  588. unsigned short iovec_count; /* [i] 0 implies no scatter gather */
  589. compat_uint_t dxfer_len; /* [i] byte count of data transfer */
  590. compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
  591. or scatter gather list */
  592. compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
  593. compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
  594. compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
  595. compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
  596. compat_int_t pack_id; /* [i->o] unused internally (normally) */
  597. compat_uptr_t usr_ptr; /* [i->o] unused internally */
  598. unsigned char status; /* [o] scsi status */
  599. unsigned char masked_status; /* [o] shifted, masked scsi status */
  600. unsigned char msg_status; /* [o] messaging level data (optional) */
  601. unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
  602. unsigned short host_status; /* [o] errors from host adapter */
  603. unsigned short driver_status; /* [o] errors from software driver */
  604. compat_int_t resid; /* [o] dxfer_len - actual_transferred */
  605. compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
  606. compat_uint_t info; /* [o] auxiliary information */
  607. } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
  608. typedef struct sg_iovec32 {
  609. compat_uint_t iov_base;
  610. compat_uint_t iov_len;
  611. } sg_iovec32_t;
  612. static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
  613. {
  614. sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
  615. sg_iovec32_t __user *iov32 = dxferp;
  616. int i;
  617. for (i = 0; i < iovec_count; i++) {
  618. u32 base, len;
  619. if (get_user(base, &iov32[i].iov_base) ||
  620. get_user(len, &iov32[i].iov_len) ||
  621. put_user(compat_ptr(base), &iov[i].iov_base) ||
  622. put_user(len, &iov[i].iov_len))
  623. return -EFAULT;
  624. }
  625. if (put_user(iov, &sgio->dxferp))
  626. return -EFAULT;
  627. return 0;
  628. }
  629. static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  630. {
  631. sg_io_hdr_t __user *sgio;
  632. sg_io_hdr32_t __user *sgio32;
  633. u16 iovec_count;
  634. u32 data;
  635. void __user *dxferp;
  636. int err;
  637. sgio32 = compat_ptr(arg);
  638. if (get_user(iovec_count, &sgio32->iovec_count))
  639. return -EFAULT;
  640. {
  641. void __user *top = compat_alloc_user_space(0);
  642. void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
  643. (iovec_count * sizeof(sg_iovec_t)));
  644. if (new > top)
  645. return -EINVAL;
  646. sgio = new;
  647. }
  648. /* Ok, now construct. */
  649. if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
  650. (2 * sizeof(int)) +
  651. (2 * sizeof(unsigned char)) +
  652. (1 * sizeof(unsigned short)) +
  653. (1 * sizeof(unsigned int))))
  654. return -EFAULT;
  655. if (get_user(data, &sgio32->dxferp))
  656. return -EFAULT;
  657. dxferp = compat_ptr(data);
  658. if (iovec_count) {
  659. if (sg_build_iovec(sgio, dxferp, iovec_count))
  660. return -EFAULT;
  661. } else {
  662. if (put_user(dxferp, &sgio->dxferp))
  663. return -EFAULT;
  664. }
  665. {
  666. unsigned char __user *cmdp;
  667. unsigned char __user *sbp;
  668. if (get_user(data, &sgio32->cmdp))
  669. return -EFAULT;
  670. cmdp = compat_ptr(data);
  671. if (get_user(data, &sgio32->sbp))
  672. return -EFAULT;
  673. sbp = compat_ptr(data);
  674. if (put_user(cmdp, &sgio->cmdp) ||
  675. put_user(sbp, &sgio->sbp))
  676. return -EFAULT;
  677. }
  678. if (copy_in_user(&sgio->timeout, &sgio32->timeout,
  679. 3 * sizeof(int)))
  680. return -EFAULT;
  681. if (get_user(data, &sgio32->usr_ptr))
  682. return -EFAULT;
  683. if (put_user(compat_ptr(data), &sgio->usr_ptr))
  684. return -EFAULT;
  685. err = sys_ioctl(fd, cmd, (unsigned long) sgio);
  686. if (err >= 0) {
  687. void __user *datap;
  688. if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
  689. sizeof(int)) ||
  690. get_user(datap, &sgio->usr_ptr) ||
  691. put_user((u32)(unsigned long)datap,
  692. &sgio32->usr_ptr) ||
  693. copy_in_user(&sgio32->status, &sgio->status,
  694. (4 * sizeof(unsigned char)) +
  695. (2 * sizeof(unsigned short)) +
  696. (3 * sizeof(int))))
  697. err = -EFAULT;
  698. }
  699. return err;
  700. }
  701. struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
  702. char req_state;
  703. char orphan;
  704. char sg_io_owned;
  705. char problem;
  706. int pack_id;
  707. compat_uptr_t usr_ptr;
  708. unsigned int duration;
  709. int unused;
  710. };
  711. static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  712. {
  713. int err, i;
  714. sg_req_info_t __user *r;
  715. struct compat_sg_req_info __user *o = (void __user *)arg;
  716. r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
  717. err = sys_ioctl(fd,cmd,(unsigned long)r);
  718. if (err < 0)
  719. return err;
  720. for (i = 0; i < SG_MAX_QUEUE; i++) {
  721. void __user *ptr;
  722. int d;
  723. if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
  724. get_user(ptr, &r[i].usr_ptr) ||
  725. get_user(d, &r[i].duration) ||
  726. put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
  727. put_user(d, &o[i].duration))
  728. return -EFAULT;
  729. }
  730. return err;
  731. }
  732. #endif /* CONFIG_BLOCK */
  733. struct sock_fprog32 {
  734. unsigned short len;
  735. compat_caddr_t filter;
  736. };
  737. #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
  738. #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
  739. static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  740. {
  741. struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
  742. struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
  743. void __user *fptr64;
  744. u32 fptr32;
  745. u16 flen;
  746. if (get_user(flen, &u_fprog32->len) ||
  747. get_user(fptr32, &u_fprog32->filter))
  748. return -EFAULT;
  749. fptr64 = compat_ptr(fptr32);
  750. if (put_user(flen, &u_fprog64->len) ||
  751. put_user(fptr64, &u_fprog64->filter))
  752. return -EFAULT;
  753. if (cmd == PPPIOCSPASS32)
  754. cmd = PPPIOCSPASS;
  755. else
  756. cmd = PPPIOCSACTIVE;
  757. return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
  758. }
  759. struct ppp_option_data32 {
  760. compat_caddr_t ptr;
  761. u32 length;
  762. compat_int_t transmit;
  763. };
  764. #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
  765. struct ppp_idle32 {
  766. compat_time_t xmit_idle;
  767. compat_time_t recv_idle;
  768. };
  769. #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
  770. static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
  771. {
  772. struct ppp_idle __user *idle;
  773. struct ppp_idle32 __user *idle32;
  774. __kernel_time_t xmit, recv;
  775. int err;
  776. idle = compat_alloc_user_space(sizeof(*idle));
  777. idle32 = compat_ptr(arg);
  778. err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
  779. if (!err) {
  780. if (get_user(xmit, &idle->xmit_idle) ||
  781. get_user(recv, &idle->recv_idle) ||
  782. put_user(xmit, &idle32->xmit_idle) ||
  783. put_user(recv, &idle32->recv_idle))
  784. err = -EFAULT;
  785. }
  786. return err;
  787. }
  788. static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
  789. {
  790. struct ppp_option_data __user *odata;
  791. struct ppp_option_data32 __user *odata32;
  792. __u32 data;
  793. void __user *datap;
  794. odata = compat_alloc_user_space(sizeof(*odata));
  795. odata32 = compat_ptr(arg);
  796. if (get_user(data, &odata32->ptr))
  797. return -EFAULT;
  798. datap = compat_ptr(data);
  799. if (put_user(datap, &odata->ptr))
  800. return -EFAULT;
  801. if (copy_in_user(&odata->length, &odata32->length,
  802. sizeof(__u32) + sizeof(int)))
  803. return -EFAULT;
  804. return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
  805. }
  806. static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  807. {
  808. int err;
  809. switch (cmd) {
  810. case PPPIOCGIDLE32:
  811. err = ppp_gidle(fd, cmd, arg);
  812. break;
  813. case PPPIOCSCOMPRESS32:
  814. err = ppp_scompress(fd, cmd, arg);
  815. break;
  816. default:
  817. do {
  818. static int count;
  819. if (++count <= 20)
  820. printk("ppp_ioctl: Unknown cmd fd(%d) "
  821. "cmd(%08x) arg(%08x)\n",
  822. (int)fd, (unsigned int)cmd, (unsigned int)arg);
  823. } while(0);
  824. err = -EINVAL;
  825. break;
  826. };
  827. return err;
  828. }
  829. #ifdef CONFIG_BLOCK
  830. struct mtget32 {
  831. compat_long_t mt_type;
  832. compat_long_t mt_resid;
  833. compat_long_t mt_dsreg;
  834. compat_long_t mt_gstat;
  835. compat_long_t mt_erreg;
  836. compat_daddr_t mt_fileno;
  837. compat_daddr_t mt_blkno;
  838. };
  839. #define MTIOCGET32 _IOR('m', 2, struct mtget32)
  840. struct mtpos32 {
  841. compat_long_t mt_blkno;
  842. };
  843. #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
  844. static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  845. {
  846. mm_segment_t old_fs = get_fs();
  847. struct mtget get;
  848. struct mtget32 __user *umget32;
  849. struct mtpos pos;
  850. struct mtpos32 __user *upos32;
  851. unsigned long kcmd;
  852. void *karg;
  853. int err = 0;
  854. switch(cmd) {
  855. case MTIOCPOS32:
  856. kcmd = MTIOCPOS;
  857. karg = &pos;
  858. break;
  859. case MTIOCGET32:
  860. kcmd = MTIOCGET;
  861. karg = &get;
  862. break;
  863. default:
  864. do {
  865. static int count;
  866. if (++count <= 20)
  867. printk("mt_ioctl: Unknown cmd fd(%d) "
  868. "cmd(%08x) arg(%08x)\n",
  869. (int)fd, (unsigned int)cmd, (unsigned int)arg);
  870. } while(0);
  871. return -EINVAL;
  872. }
  873. set_fs (KERNEL_DS);
  874. err = sys_ioctl (fd, kcmd, (unsigned long)karg);
  875. set_fs (old_fs);
  876. if (err)
  877. return err;
  878. switch (cmd) {
  879. case MTIOCPOS32:
  880. upos32 = compat_ptr(arg);
  881. err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
  882. break;
  883. case MTIOCGET32:
  884. umget32 = compat_ptr(arg);
  885. err = __put_user(get.mt_type, &umget32->mt_type);
  886. err |= __put_user(get.mt_resid, &umget32->mt_resid);
  887. err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
  888. err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
  889. err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
  890. err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
  891. err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
  892. break;
  893. }
  894. return err ? -EFAULT: 0;
  895. }
  896. #endif /* CONFIG_BLOCK */
  897. #ifdef CONFIG_VT
  898. static int vt_check(struct file *file)
  899. {
  900. struct tty_struct *tty;
  901. struct inode *inode = file->f_path.dentry->d_inode;
  902. struct vc_data *vc;
  903. if (file->f_op->unlocked_ioctl != tty_ioctl)
  904. return -EINVAL;
  905. tty = (struct tty_struct *)file->private_data;
  906. if (tty_paranoia_check(tty, inode, "tty_ioctl"))
  907. return -EINVAL;
  908. if (tty->ops->ioctl != vt_ioctl)
  909. return -EINVAL;
  910. vc = (struct vc_data *)tty->driver_data;
  911. if (!vc_cons_allocated(vc->vc_num)) /* impossible? */
  912. return -ENOIOCTLCMD;
  913. /*
  914. * To have permissions to do most of the vt ioctls, we either have
  915. * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
  916. */
  917. if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
  918. return 1;
  919. return 0;
  920. }
  921. struct consolefontdesc32 {
  922. unsigned short charcount; /* characters in font (256 or 512) */
  923. unsigned short charheight; /* scan lines per character (1-32) */
  924. compat_caddr_t chardata; /* font data in expanded form */
  925. };
  926. static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
  927. {
  928. struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
  929. struct console_font_op op;
  930. compat_caddr_t data;
  931. int i, perm;
  932. perm = vt_check(file);
  933. if (perm < 0) return perm;
  934. switch (cmd) {
  935. case PIO_FONTX:
  936. if (!perm)
  937. return -EPERM;
  938. op.op = KD_FONT_OP_SET;
  939. op.flags = 0;
  940. op.width = 8;
  941. if (get_user(op.height, &user_cfd->charheight) ||
  942. get_user(op.charcount, &user_cfd->charcount) ||
  943. get_user(data, &user_cfd->chardata))
  944. return -EFAULT;
  945. op.data = compat_ptr(data);
  946. return con_font_op(vc_cons[fg_console].d, &op);
  947. case GIO_FONTX:
  948. op.op = KD_FONT_OP_GET;
  949. op.flags = 0;
  950. op.width = 8;
  951. if (get_user(op.height, &user_cfd->charheight) ||
  952. get_user(op.charcount, &user_cfd->charcount) ||
  953. get_user(data, &user_cfd->chardata))
  954. return -EFAULT;
  955. if (!data)
  956. return 0;
  957. op.data = compat_ptr(data);
  958. i = con_font_op(vc_cons[fg_console].d, &op);
  959. if (i)
  960. return i;
  961. if (put_user(op.height, &user_cfd->charheight) ||
  962. put_user(op.charcount, &user_cfd->charcount) ||
  963. put_user((compat_caddr_t)(unsigned long)op.data,
  964. &user_cfd->chardata))
  965. return -EFAULT;
  966. return 0;
  967. }
  968. return -EINVAL;
  969. }
  970. struct console_font_op32 {
  971. compat_uint_t op; /* operation code KD_FONT_OP_* */
  972. compat_uint_t flags; /* KD_FONT_FLAG_* */
  973. compat_uint_t width, height; /* font size */
  974. compat_uint_t charcount;
  975. compat_caddr_t data; /* font data with height fixed to 32 */
  976. };
  977. static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
  978. {
  979. struct console_font_op op;
  980. struct console_font_op32 __user *fontop = compat_ptr(arg);
  981. int perm = vt_check(file), i;
  982. struct vc_data *vc;
  983. if (perm < 0) return perm;
  984. if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
  985. return -EFAULT;
  986. if (!perm && op.op != KD_FONT_OP_GET)
  987. return -EPERM;
  988. op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
  989. op.flags |= KD_FONT_FLAG_OLD;
  990. vc = ((struct tty_struct *)file->private_data)->driver_data;
  991. i = con_font_op(vc, &op);
  992. if (i)
  993. return i;
  994. ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
  995. if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
  996. return -EFAULT;
  997. return 0;
  998. }
  999. struct unimapdesc32 {
  1000. unsigned short entry_ct;
  1001. compat_caddr_t entries;
  1002. };
  1003. static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
  1004. {
  1005. struct unimapdesc32 tmp;
  1006. struct unimapdesc32 __user *user_ud = compat_ptr(arg);
  1007. int perm = vt_check(file);
  1008. struct vc_data *vc;
  1009. if (perm < 0)
  1010. return perm;
  1011. if (copy_from_user(&tmp, user_ud, sizeof tmp))
  1012. return -EFAULT;
  1013. if (tmp.entries)
  1014. if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries),
  1015. tmp.entry_ct*sizeof(struct unipair)))
  1016. return -EFAULT;
  1017. vc = ((struct tty_struct *)file->private_data)->driver_data;
  1018. switch (cmd) {
  1019. case PIO_UNIMAP:
  1020. if (!perm)
  1021. return -EPERM;
  1022. return con_set_unimap(vc, tmp.entry_ct,
  1023. compat_ptr(tmp.entries));
  1024. case GIO_UNIMAP:
  1025. if (!perm && fg_console != vc->vc_num)
  1026. return -EPERM;
  1027. return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
  1028. compat_ptr(tmp.entries));
  1029. }
  1030. return 0;
  1031. }
  1032. #endif /* CONFIG_VT */
  1033. static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
  1034. {
  1035. mm_segment_t old_fs = get_fs();
  1036. __kernel_uid_t kuid;
  1037. int err;
  1038. cmd = SMB_IOC_GETMOUNTUID;
  1039. set_fs(KERNEL_DS);
  1040. err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
  1041. set_fs(old_fs);
  1042. if (err >= 0)
  1043. err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
  1044. return err;
  1045. }
  1046. struct atmif_sioc32 {
  1047. compat_int_t number;
  1048. compat_int_t length;
  1049. compat_caddr_t arg;
  1050. };
  1051. struct atm_iobuf32 {
  1052. compat_int_t length;
  1053. compat_caddr_t buffer;
  1054. };
  1055. #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
  1056. #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
  1057. #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
  1058. #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
  1059. #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
  1060. #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
  1061. #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
  1062. #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
  1063. #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
  1064. #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
  1065. #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
  1066. #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
  1067. #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
  1068. #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
  1069. #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
  1070. #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
  1071. #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
  1072. static struct {
  1073. unsigned int cmd32;
  1074. unsigned int cmd;
  1075. } atm_ioctl_map[] = {
  1076. { ATM_GETLINKRATE32, ATM_GETLINKRATE },
  1077. { ATM_GETNAMES32, ATM_GETNAMES },
  1078. { ATM_GETTYPE32, ATM_GETTYPE },
  1079. { ATM_GETESI32, ATM_GETESI },
  1080. { ATM_GETADDR32, ATM_GETADDR },
  1081. { ATM_RSTADDR32, ATM_RSTADDR },
  1082. { ATM_ADDADDR32, ATM_ADDADDR },
  1083. { ATM_DELADDR32, ATM_DELADDR },
  1084. { ATM_GETCIRANGE32, ATM_GETCIRANGE },
  1085. { ATM_SETCIRANGE32, ATM_SETCIRANGE },
  1086. { ATM_SETESI32, ATM_SETESI },
  1087. { ATM_SETESIF32, ATM_SETESIF },
  1088. { ATM_GETSTAT32, ATM_GETSTAT },
  1089. { ATM_GETSTATZ32, ATM_GETSTATZ },
  1090. { ATM_GETLOOP32, ATM_GETLOOP },
  1091. { ATM_SETLOOP32, ATM_SETLOOP },
  1092. { ATM_QUERYLOOP32, ATM_QUERYLOOP }
  1093. };
  1094. #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
  1095. static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
  1096. {
  1097. struct atm_iobuf __user *iobuf;
  1098. struct atm_iobuf32 __user *iobuf32;
  1099. u32 data;
  1100. void __user *datap;
  1101. int len, err;
  1102. iobuf = compat_alloc_user_space(sizeof(*iobuf));
  1103. iobuf32 = compat_ptr(arg);
  1104. if (get_user(len, &iobuf32->length) ||
  1105. get_user(data, &iobuf32->buffer))
  1106. return -EFAULT;
  1107. datap = compat_ptr(data);
  1108. if (put_user(len, &iobuf->length) ||
  1109. put_user(datap, &iobuf->buffer))
  1110. return -EFAULT;
  1111. err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
  1112. if (!err) {
  1113. if (copy_in_user(&iobuf32->length, &iobuf->length,
  1114. sizeof(int)))
  1115. err = -EFAULT;
  1116. }
  1117. return err;
  1118. }
  1119. static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
  1120. {
  1121. struct atmif_sioc __user *sioc;
  1122. struct atmif_sioc32 __user *sioc32;
  1123. u32 data;
  1124. void __user *datap;
  1125. int err;
  1126. sioc = compat_alloc_user_space(sizeof(*sioc));
  1127. sioc32 = compat_ptr(arg);
  1128. if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
  1129. get_user(data, &sioc32->arg))
  1130. return -EFAULT;
  1131. datap = compat_ptr(data);
  1132. if (put_user(datap, &sioc->arg))
  1133. return -EFAULT;
  1134. err = sys_ioctl(fd, cmd, (unsigned long) sioc);
  1135. if (!err) {
  1136. if (copy_in_user(&sioc32->length, &sioc->length,
  1137. sizeof(int)))
  1138. err = -EFAULT;
  1139. }
  1140. return err;
  1141. }
  1142. static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
  1143. {
  1144. int i;
  1145. unsigned int cmd = 0;
  1146. switch (cmd32) {
  1147. case SONET_GETSTAT:
  1148. case SONET_GETSTATZ:
  1149. case SONET_GETDIAG:
  1150. case SONET_SETDIAG:
  1151. case SONET_CLRDIAG:
  1152. case SONET_SETFRAMING:
  1153. case SONET_GETFRAMING:
  1154. case SONET_GETFRSENSE:
  1155. return do_atmif_sioc(fd, cmd32, arg);
  1156. }
  1157. for (i = 0; i < NR_ATM_IOCTL; i++) {
  1158. if (cmd32 == atm_ioctl_map[i].cmd32) {
  1159. cmd = atm_ioctl_map[i].cmd;
  1160. break;
  1161. }
  1162. }
  1163. if (i == NR_ATM_IOCTL)
  1164. return -EINVAL;
  1165. switch (cmd) {
  1166. case ATM_GETNAMES:
  1167. return do_atm_iobuf(fd, cmd, arg);
  1168. case ATM_GETLINKRATE:
  1169. case ATM_GETTYPE:
  1170. case ATM_GETESI:
  1171. case ATM_GETADDR:
  1172. case ATM_RSTADDR:
  1173. case ATM_ADDADDR:
  1174. case ATM_DELADDR:
  1175. case ATM_GETCIRANGE:
  1176. case ATM_SETCIRANGE:
  1177. case ATM_SETESI:
  1178. case ATM_SETESIF:
  1179. case ATM_GETSTAT:
  1180. case ATM_GETSTATZ:
  1181. case ATM_GETLOOP:
  1182. case ATM_SETLOOP:
  1183. case ATM_QUERYLOOP:
  1184. return do_atmif_sioc(fd, cmd, arg);
  1185. }
  1186. return -EINVAL;
  1187. }
  1188. static __used int
  1189. ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
  1190. {
  1191. return -EINVAL;
  1192. }
  1193. static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
  1194. {
  1195. return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
  1196. }
  1197. /* Bluetooth ioctls */
  1198. #define HCIUARTSETPROTO _IOW('U', 200, int)
  1199. #define HCIUARTGETPROTO _IOR('U', 201, int)
  1200. #define BNEPCONNADD _IOW('B', 200, int)
  1201. #define BNEPCONNDEL _IOW('B', 201, int)
  1202. #define BNEPGETCONNLIST _IOR('B', 210, int)
  1203. #define BNEPGETCONNINFO _IOR('B', 211, int)
  1204. #define CMTPCONNADD _IOW('C', 200, int)
  1205. #define CMTPCONNDEL _IOW('C', 201, int)
  1206. #define CMTPGETCONNLIST _IOR('C', 210, int)
  1207. #define CMTPGETCONNINFO _IOR('C', 211, int)
  1208. #define HIDPCONNADD _IOW('H', 200, int)
  1209. #define HIDPCONNDEL _IOW('H', 201, int)
  1210. #define HIDPGETCONNLIST _IOR('H', 210, int)
  1211. #define HIDPGETCONNINFO _IOR('H', 211, int)
  1212. #ifdef CONFIG_BLOCK
  1213. struct raw32_config_request
  1214. {
  1215. compat_int_t raw_minor;
  1216. __u64 block_major;
  1217. __u64 block_minor;
  1218. } __attribute__((packed));
  1219. static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
  1220. {
  1221. int ret;
  1222. if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
  1223. return -EFAULT;
  1224. ret = __get_user(req->raw_minor, &user_req->raw_minor);
  1225. ret |= __get_user(req->block_major, &user_req->block_major);
  1226. ret |= __get_user(req->block_minor, &user_req->block_minor);
  1227. return ret ? -EFAULT : 0;
  1228. }
  1229. static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
  1230. {
  1231. int ret;
  1232. if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
  1233. return -EFAULT;
  1234. ret = __put_user(req->raw_minor, &user_req->raw_minor);
  1235. ret |= __put_user(req->block_major, &user_req->block_major);
  1236. ret |= __put_user(req->block_minor, &user_req->block_minor);
  1237. return ret ? -EFAULT : 0;
  1238. }
  1239. static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  1240. {
  1241. int ret;
  1242. switch (cmd) {
  1243. case RAW_SETBIND:
  1244. case RAW_GETBIND: {
  1245. struct raw_config_request req;
  1246. struct raw32_config_request __user *user_req = compat_ptr(arg);
  1247. mm_segment_t oldfs = get_fs();
  1248. if ((ret = get_raw32_request(&req, user_req)))
  1249. return ret;
  1250. set_fs(KERNEL_DS);
  1251. ret = sys_ioctl(fd,cmd,(unsigned long)&req);
  1252. set_fs(oldfs);
  1253. if ((!ret) && (cmd == RAW_GETBIND)) {
  1254. ret = set_raw32_request(&req, user_req);
  1255. }
  1256. break;
  1257. }
  1258. default:
  1259. ret = sys_ioctl(fd, cmd, arg);
  1260. break;
  1261. }
  1262. return ret;
  1263. }
  1264. #endif /* CONFIG_BLOCK */
  1265. struct serial_struct32 {
  1266. compat_int_t type;
  1267. compat_int_t line;
  1268. compat_uint_t port;
  1269. compat_int_t irq;
  1270. compat_int_t flags;
  1271. compat_int_t xmit_fifo_size;
  1272. compat_int_t custom_divisor;
  1273. compat_int_t baud_base;
  1274. unsigned short close_delay;
  1275. char io_type;
  1276. char reserved_char[1];
  1277. compat_int_t hub6;
  1278. unsigned short closing_wait; /* time to wait before closing */
  1279. unsigned short closing_wait2; /* no longer used... */
  1280. compat_uint_t iomem_base;
  1281. unsigned short iomem_reg_shift;
  1282. unsigned int port_high;
  1283. /* compat_ulong_t iomap_base FIXME */
  1284. compat_int_t reserved[1];
  1285. };
  1286. static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  1287. {
  1288. typedef struct serial_struct SS;
  1289. typedef struct serial_struct32 SS32;
  1290. struct serial_struct32 __user *ss32 = compat_ptr(arg);
  1291. int err;
  1292. struct serial_struct ss;
  1293. mm_segment_t oldseg = get_fs();
  1294. __u32 udata;
  1295. unsigned int base;
  1296. if (cmd == TIOCSSERIAL) {
  1297. if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
  1298. return -EFAULT;
  1299. if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
  1300. return -EFAULT;
  1301. if (__get_user(udata, &ss32->iomem_base))
  1302. return -EFAULT;
  1303. ss.iomem_base = compat_ptr(udata);
  1304. if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  1305. __get_user(ss.port_high, &ss32->port_high))
  1306. return -EFAULT;
  1307. ss.iomap_base = 0UL;
  1308. }
  1309. set_fs(KERNEL_DS);
  1310. err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
  1311. set_fs(oldseg);
  1312. if (cmd == TIOCGSERIAL && err >= 0) {
  1313. if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
  1314. return -EFAULT;
  1315. if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
  1316. return -EFAULT;
  1317. base = (unsigned long)ss.iomem_base >> 32 ?
  1318. 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
  1319. if (__put_user(base, &ss32->iomem_base) ||
  1320. __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  1321. __put_user(ss.port_high, &ss32->port_high))
  1322. return -EFAULT;
  1323. }
  1324. return err;
  1325. }
  1326. struct usbdevfs_ctrltransfer32 {
  1327. u8 bRequestType;
  1328. u8 bRequest;
  1329. u16 wValue;
  1330. u16 wIndex;
  1331. u16 wLength;
  1332. u32 timeout; /* in milliseconds */
  1333. compat_caddr_t data;
  1334. };
  1335. #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
  1336. static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
  1337. {
  1338. struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
  1339. struct usbdevfs_ctrltransfer __user *p;
  1340. __u32 udata;
  1341. p = compat_alloc_user_space(sizeof(*p));
  1342. if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
  1343. get_user(udata, &p32->data) ||
  1344. put_user(compat_ptr(udata), &p->data))
  1345. return -EFAULT;
  1346. return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
  1347. }
  1348. struct usbdevfs_bulktransfer32 {
  1349. compat_uint_t ep;
  1350. compat_uint_t len;
  1351. compat_uint_t timeout; /* in milliseconds */
  1352. compat_caddr_t data;
  1353. };
  1354. #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
  1355. static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
  1356. {
  1357. struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
  1358. struct usbdevfs_bulktransfer __user *p;
  1359. compat_uint_t n;
  1360. compat_caddr_t addr;
  1361. p = compat_alloc_user_space(sizeof(*p));
  1362. if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
  1363. get_user(n, &p32->len) || put_user(n, &p->len) ||
  1364. get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
  1365. get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
  1366. return -EFAULT;
  1367. return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
  1368. }
  1369. /*
  1370. * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
  1371. * are handled in usbdevfs core. -Christopher Li
  1372. */
  1373. struct usbdevfs_disconnectsignal32 {
  1374. compat_int_t signr;
  1375. compat_caddr_t context;
  1376. };
  1377. #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
  1378. static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
  1379. {
  1380. struct usbdevfs_disconnectsignal kdis;
  1381. struct usbdevfs_disconnectsignal32 __user *udis;
  1382. mm_segment_t old_fs;
  1383. u32 uctx;
  1384. int err;
  1385. udis = compat_ptr(arg);
  1386. if (get_user(kdis.signr, &udis->signr) ||
  1387. __get_user(uctx, &udis->context))
  1388. return -EFAULT;
  1389. kdis.context = compat_ptr(uctx);
  1390. old_fs = get_fs();
  1391. set_fs(KERNEL_DS);
  1392. err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
  1393. set_fs(old_fs);
  1394. return err;
  1395. }
  1396. /*
  1397. * I2C layer ioctls
  1398. */
  1399. struct i2c_msg32 {
  1400. u16 addr;
  1401. u16 flags;
  1402. u16 len;
  1403. compat_caddr_t buf;
  1404. };
  1405. struct i2c_rdwr_ioctl_data32 {
  1406. compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
  1407. u32 nmsgs;
  1408. };
  1409. struct i2c_smbus_ioctl_data32 {
  1410. u8 read_write;
  1411. u8 command;
  1412. u32 size;
  1413. compat_caddr_t data; /* union i2c_smbus_data *data */
  1414. };
  1415. struct i2c_rdwr_aligned {
  1416. struct i2c_rdwr_ioctl_data cmd;
  1417. struct i2c_msg msgs[0];
  1418. };
  1419. static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  1420. {
  1421. struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
  1422. struct i2c_rdwr_aligned __user *tdata;
  1423. struct i2c_msg __user *tmsgs;
  1424. struct i2c_msg32 __user *umsgs;
  1425. compat_caddr_t datap;
  1426. int nmsgs, i;
  1427. if (get_user(nmsgs, &udata->nmsgs))
  1428. return -EFAULT;
  1429. if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
  1430. return -EINVAL;
  1431. if (get_user(datap, &udata->msgs))
  1432. return -EFAULT;
  1433. umsgs = compat_ptr(datap);
  1434. tdata = compat_alloc_user_space(sizeof(*tdata) +
  1435. nmsgs * sizeof(struct i2c_msg));
  1436. tmsgs = &tdata->msgs[0];
  1437. if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
  1438. put_user(tmsgs, &tdata->cmd.msgs))
  1439. return -EFAULT;
  1440. for (i = 0; i < nmsgs; i++) {
  1441. if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
  1442. return -EFAULT;
  1443. if (get_user(datap, &umsgs[i].buf) ||
  1444. put_user(compat_ptr(datap), &tmsgs[i].buf))
  1445. return -EFAULT;
  1446. }
  1447. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  1448. }
  1449. static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  1450. {
  1451. struct i2c_smbus_ioctl_data __user *tdata;
  1452. struct i2c_smbus_ioctl_data32 __user *udata;
  1453. compat_caddr_t datap;
  1454. tdata = compat_alloc_user_space(sizeof(*tdata));
  1455. if (tdata == NULL)
  1456. return -ENOMEM;
  1457. if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
  1458. return -EFAULT;
  1459. udata = compat_ptr(arg);
  1460. if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
  1461. return -EFAULT;
  1462. if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
  1463. return -EFAULT;
  1464. if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
  1465. return -EFAULT;
  1466. if (__get_user(datap, &udata->data) ||
  1467. __put_user(compat_ptr(datap), &tdata->data))
  1468. return -EFAULT;
  1469. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  1470. }
  1471. /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
  1472. * for some operations; this forces use of the newer bridge-utils that
  1473. * use compatible ioctls
  1474. */
  1475. static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  1476. {
  1477. u32 tmp;
  1478. if (get_user(tmp, (u32 __user *) arg))
  1479. return -EFAULT;
  1480. if (tmp == BRCTL_GET_VERSION)
  1481. return BRCTL_VERSION + 1;
  1482. return -EINVAL;
  1483. }
  1484. #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
  1485. #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
  1486. #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
  1487. #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
  1488. static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  1489. {
  1490. mm_segment_t oldfs = get_fs();
  1491. compat_ulong_t val32;
  1492. unsigned long kval;
  1493. int ret;
  1494. switch (cmd) {
  1495. case RTC_IRQP_READ32:
  1496. case RTC_EPOCH_READ32:
  1497. set_fs(KERNEL_DS);
  1498. ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
  1499. RTC_IRQP_READ : RTC_EPOCH_READ,
  1500. (unsigned long)&kval);
  1501. set_fs(oldfs);
  1502. if (ret)
  1503. return ret;
  1504. val32 = kval;
  1505. return put_user(val32, (unsigned int __user *)arg);
  1506. case RTC_IRQP_SET32:
  1507. return sys_ioctl(fd, RTC_IRQP_SET, arg);
  1508. case RTC_EPOCH_SET32:
  1509. return sys_ioctl(fd, RTC_EPOCH_SET, arg);
  1510. default:
  1511. /* unreached */
  1512. return -ENOIOCTLCMD;
  1513. }
  1514. }
  1515. static int
  1516. lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  1517. {
  1518. struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
  1519. struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
  1520. struct timeval ts;
  1521. if (get_user(ts.tv_sec, &tc->tv_sec) ||
  1522. get_user(ts.tv_usec, &tc->tv_usec) ||
  1523. put_user(ts.tv_sec, &tn->tv_sec) ||
  1524. put_user(ts.tv_usec, &tn->tv_usec))
  1525. return -EFAULT;
  1526. return sys_ioctl(fd, cmd, (unsigned long)tn);
  1527. }
  1528. /* on ia32 l_start is on a 32-bit boundary */
  1529. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  1530. struct space_resv_32 {
  1531. __s16 l_type;
  1532. __s16 l_whence;
  1533. __s64 l_start __attribute__((packed));
  1534. /* len == 0 means until end of file */
  1535. __s64 l_len __attribute__((packed));
  1536. __s32 l_sysid;
  1537. __u32 l_pid;
  1538. __s32 l_pad[4]; /* reserve area */
  1539. };
  1540. #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
  1541. #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
  1542. /* just account for different alignment */
  1543. static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
  1544. {
  1545. struct space_resv_32 __user *p32 = (void __user *)arg;
  1546. struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
  1547. if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
  1548. copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
  1549. copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
  1550. copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
  1551. copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
  1552. copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
  1553. copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
  1554. return -EFAULT;
  1555. return ioctl_preallocate(file, p);
  1556. }
  1557. #endif
  1558. typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
  1559. unsigned long, struct file *);
  1560. struct ioctl_trans {
  1561. unsigned long cmd;
  1562. ioctl_trans_handler_t handler;
  1563. struct ioctl_trans *next;
  1564. };
  1565. #define HANDLE_IOCTL(cmd,handler) \
  1566. { (cmd), (ioctl_trans_handler_t)(handler) },
  1567. /* pointer to compatible structure or no argument */
  1568. #define COMPATIBLE_IOCTL(cmd) \
  1569. { (cmd), do_ioctl32_pointer },
  1570. /* argument is an unsigned long integer, not a pointer */
  1571. #define ULONG_IOCTL(cmd) \
  1572. { (cmd), (ioctl_trans_handler_t)sys_ioctl },
  1573. /* ioctl should not be warned about even if it's not implemented.
  1574. Valid reasons to use this:
  1575. - It is implemented with ->compat_ioctl on some device, but programs
  1576. call it on others too.
  1577. - The ioctl is not implemented in the native kernel, but programs
  1578. call it commonly anyways.
  1579. Most other reasons are not valid. */
  1580. #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
  1581. static struct ioctl_trans ioctl_start[] = {
  1582. /* compatible ioctls first */
  1583. COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
  1584. COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
  1585. /* Big T */
  1586. COMPATIBLE_IOCTL(TCGETA)
  1587. COMPATIBLE_IOCTL(TCSETA)
  1588. COMPATIBLE_IOCTL(TCSETAW)
  1589. COMPATIBLE_IOCTL(TCSETAF)
  1590. COMPATIBLE_IOCTL(TCSBRK)
  1591. ULONG_IOCTL(TCSBRKP)
  1592. COMPATIBLE_IOCTL(TCXONC)
  1593. COMPATIBLE_IOCTL(TCFLSH)
  1594. COMPATIBLE_IOCTL(TCGETS)
  1595. COMPATIBLE_IOCTL(TCSETS)
  1596. COMPATIBLE_IOCTL(TCSETSW)
  1597. COMPATIBLE_IOCTL(TCSETSF)
  1598. COMPATIBLE_IOCTL(TIOCLINUX)
  1599. COMPATIBLE_IOCTL(TIOCSBRK)
  1600. COMPATIBLE_IOCTL(TIOCCBRK)
  1601. ULONG_IOCTL(TIOCMIWAIT)
  1602. COMPATIBLE_IOCTL(TIOCGICOUNT)
  1603. /* Little t */
  1604. COMPATIBLE_IOCTL(TIOCGETD)
  1605. COMPATIBLE_IOCTL(TIOCSETD)
  1606. COMPATIBLE_IOCTL(TIOCEXCL)
  1607. COMPATIBLE_IOCTL(TIOCNXCL)
  1608. COMPATIBLE_IOCTL(TIOCCONS)
  1609. COMPATIBLE_IOCTL(TIOCGSOFTCAR)
  1610. COMPATIBLE_IOCTL(TIOCSSOFTCAR)
  1611. COMPATIBLE_IOCTL(TIOCSWINSZ)
  1612. COMPATIBLE_IOCTL(TIOCGWINSZ)
  1613. COMPATIBLE_IOCTL(TIOCMGET)
  1614. COMPATIBLE_IOCTL(TIOCMBIC)
  1615. COMPATIBLE_IOCTL(TIOCMBIS)
  1616. COMPATIBLE_IOCTL(TIOCMSET)
  1617. COMPATIBLE_IOCTL(TIOCPKT)
  1618. COMPATIBLE_IOCTL(TIOCNOTTY)
  1619. COMPATIBLE_IOCTL(TIOCSTI)
  1620. COMPATIBLE_IOCTL(TIOCOUTQ)
  1621. COMPATIBLE_IOCTL(TIOCSPGRP)
  1622. COMPATIBLE_IOCTL(TIOCGPGRP)
  1623. ULONG_IOCTL(TIOCSCTTY)
  1624. COMPATIBLE_IOCTL(TIOCGPTN)
  1625. COMPATIBLE_IOCTL(TIOCSPTLCK)
  1626. COMPATIBLE_IOCTL(TIOCSERGETLSR)
  1627. #ifdef TCGETS2
  1628. COMPATIBLE_IOCTL(TCGETS2)
  1629. COMPATIBLE_IOCTL(TCSETS2)
  1630. COMPATIBLE_IOCTL(TCSETSW2)
  1631. COMPATIBLE_IOCTL(TCSETSF2)
  1632. #endif
  1633. /* Little f */
  1634. COMPATIBLE_IOCTL(FIOCLEX)
  1635. COMPATIBLE_IOCTL(FIONCLEX)
  1636. COMPATIBLE_IOCTL(FIOASYNC)
  1637. COMPATIBLE_IOCTL(FIONBIO)
  1638. COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
  1639. /* 0x00 */
  1640. COMPATIBLE_IOCTL(FIBMAP)
  1641. COMPATIBLE_IOCTL(FIGETBSZ)
  1642. /* 'X' - originally XFS but some now in the VFS */
  1643. COMPATIBLE_IOCTL(FIFREEZE)
  1644. COMPATIBLE_IOCTL(FITHAW)
  1645. /* RAID */
  1646. COMPATIBLE_IOCTL(RAID_VERSION)
  1647. COMPATIBLE_IOCTL(GET_ARRAY_INFO)
  1648. COMPATIBLE_IOCTL(GET_DISK_INFO)
  1649. COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
  1650. COMPATIBLE_IOCTL(RAID_AUTORUN)
  1651. COMPATIBLE_IOCTL(CLEAR_ARRAY)
  1652. COMPATIBLE_IOCTL(ADD_NEW_DISK)
  1653. ULONG_IOCTL(HOT_REMOVE_DISK)
  1654. COMPATIBLE_IOCTL(SET_ARRAY_INFO)
  1655. COMPATIBLE_IOCTL(SET_DISK_INFO)
  1656. COMPATIBLE_IOCTL(WRITE_RAID_INFO)
  1657. COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
  1658. COMPATIBLE_IOCTL(PROTECT_ARRAY)
  1659. ULONG_IOCTL(HOT_ADD_DISK)
  1660. ULONG_IOCTL(SET_DISK_FAULTY)
  1661. COMPATIBLE_IOCTL(RUN_ARRAY)
  1662. COMPATIBLE_IOCTL(STOP_ARRAY)
  1663. COMPATIBLE_IOCTL(STOP_ARRAY_RO)
  1664. COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
  1665. COMPATIBLE_IOCTL(GET_BITMAP_FILE)
  1666. ULONG_IOCTL(SET_BITMAP_FILE)
  1667. /* Big K */
  1668. COMPATIBLE_IOCTL(PIO_FONT)
  1669. COMPATIBLE_IOCTL(GIO_FONT)
  1670. COMPATIBLE_IOCTL(PIO_CMAP)
  1671. COMPATIBLE_IOCTL(GIO_CMAP)
  1672. ULONG_IOCTL(KDSIGACCEPT)
  1673. COMPATIBLE_IOCTL(KDGETKEYCODE)
  1674. COMPATIBLE_IOCTL(KDSETKEYCODE)
  1675. ULONG_IOCTL(KIOCSOUND)
  1676. ULONG_IOCTL(KDMKTONE)
  1677. COMPATIBLE_IOCTL(KDGKBTYPE)
  1678. ULONG_IOCTL(KDSETMODE)
  1679. COMPATIBLE_IOCTL(KDGETMODE)
  1680. ULONG_IOCTL(KDSKBMODE)
  1681. COMPATIBLE_IOCTL(KDGKBMODE)
  1682. ULONG_IOCTL(KDSKBMETA)
  1683. COMPATIBLE_IOCTL(KDGKBMETA)
  1684. COMPATIBLE_IOCTL(KDGKBENT)
  1685. COMPATIBLE_IOCTL(KDSKBENT)
  1686. COMPATIBLE_IOCTL(KDGKBSENT)
  1687. COMPATIBLE_IOCTL(KDSKBSENT)
  1688. COMPATIBLE_IOCTL(KDGKBDIACR)
  1689. COMPATIBLE_IOCTL(KDSKBDIACR)
  1690. COMPATIBLE_IOCTL(KDKBDREP)
  1691. COMPATIBLE_IOCTL(KDGKBLED)
  1692. ULONG_IOCTL(KDSKBLED)
  1693. COMPATIBLE_IOCTL(KDGETLED)
  1694. ULONG_IOCTL(KDSETLED)
  1695. COMPATIBLE_IOCTL(GIO_SCRNMAP)
  1696. COMPATIBLE_IOCTL(PIO_SCRNMAP)
  1697. COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
  1698. COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
  1699. COMPATIBLE_IOCTL(PIO_FONTRESET)
  1700. COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
  1701. #ifdef CONFIG_BLOCK
  1702. /* Big S */
  1703. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
  1704. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
  1705. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
  1706. COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
  1707. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
  1708. COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
  1709. COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
  1710. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
  1711. #endif
  1712. /* Big T */
  1713. COMPATIBLE_IOCTL(TUNSETNOCSUM)
  1714. COMPATIBLE_IOCTL(TUNSETDEBUG)
  1715. COMPATIBLE_IOCTL(TUNSETPERSIST)
  1716. COMPATIBLE_IOCTL(TUNSETOWNER)
  1717. COMPATIBLE_IOCTL(TUNSETLINK)
  1718. COMPATIBLE_IOCTL(TUNSETGROUP)
  1719. COMPATIBLE_IOCTL(TUNGETFEATURES)
  1720. COMPATIBLE_IOCTL(TUNSETOFFLOAD)
  1721. COMPATIBLE_IOCTL(TUNSETTXFILTER)
  1722. COMPATIBLE_IOCTL(TUNGETSNDBUF)
  1723. COMPATIBLE_IOCTL(TUNSETSNDBUF)
  1724. /* Big V */
  1725. COMPATIBLE_IOCTL(VT_SETMODE)
  1726. COMPATIBLE_IOCTL(VT_GETMODE)
  1727. COMPATIBLE_IOCTL(VT_GETSTATE)
  1728. COMPATIBLE_IOCTL(VT_OPENQRY)
  1729. ULONG_IOCTL(VT_ACTIVATE)
  1730. ULONG_IOCTL(VT_WAITACTIVE)
  1731. ULONG_IOCTL(VT_RELDISP)
  1732. ULONG_IOCTL(VT_DISALLOCATE)
  1733. COMPATIBLE_IOCTL(VT_RESIZE)
  1734. COMPATIBLE_IOCTL(VT_RESIZEX)
  1735. COMPATIBLE_IOCTL(VT_LOCKSWITCH)
  1736. COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
  1737. COMPATIBLE_IOCTL(VT_GETHIFONTMASK)
  1738. /* Little p (/dev/rtc, /dev/envctrl, etc.) */
  1739. COMPATIBLE_IOCTL(RTC_AIE_ON)
  1740. COMPATIBLE_IOCTL(RTC_AIE_OFF)
  1741. COMPATIBLE_IOCTL(RTC_UIE_ON)
  1742. COMPATIBLE_IOCTL(RTC_UIE_OFF)
  1743. COMPATIBLE_IOCTL(RTC_PIE_ON)
  1744. COMPATIBLE_IOCTL(RTC_PIE_OFF)
  1745. COMPATIBLE_IOCTL(RTC_WIE_ON)
  1746. COMPATIBLE_IOCTL(RTC_WIE_OFF)
  1747. COMPATIBLE_IOCTL(RTC_ALM_SET)
  1748. COMPATIBLE_IOCTL(RTC_ALM_READ)
  1749. COMPATIBLE_IOCTL(RTC_RD_TIME)
  1750. COMPATIBLE_IOCTL(RTC_SET_TIME)
  1751. COMPATIBLE_IOCTL(RTC_WKALM_SET)
  1752. COMPATIBLE_IOCTL(RTC_WKALM_RD)
  1753. /*
  1754. * These two are only for the sbus rtc driver, but
  1755. * hwclock tries them on every rtc device first when
  1756. * running on sparc. On other architectures the entries
  1757. * are useless but harmless.
  1758. */
  1759. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  1760. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  1761. /* Little m */
  1762. COMPATIBLE_IOCTL(MTIOCTOP)
  1763. /* Socket level stuff */
  1764. COMPATIBLE_IOCTL(FIOQSIZE)
  1765. COMPATIBLE_IOCTL(FIOSETOWN)
  1766. COMPATIBLE_IOCTL(SIOCSPGRP)
  1767. COMPATIBLE_IOCTL(FIOGETOWN)
  1768. COMPATIBLE_IOCTL(SIOCGPGRP)
  1769. COMPATIBLE_IOCTL(SIOCATMARK)
  1770. COMPATIBLE_IOCTL(SIOCSIFLINK)
  1771. COMPATIBLE_IOCTL(SIOCSIFENCAP)
  1772. COMPATIBLE_IOCTL(SIOCGIFENCAP)
  1773. COMPATIBLE_IOCTL(SIOCSIFNAME)
  1774. COMPATIBLE_IOCTL(SIOCSARP)
  1775. COMPATIBLE_IOCTL(SIOCGARP)
  1776. COMPATIBLE_IOCTL(SIOCDARP)
  1777. COMPATIBLE_IOCTL(SIOCSRARP)
  1778. COMPATIBLE_IOCTL(SIOCGRARP)
  1779. COMPATIBLE_IOCTL(SIOCDRARP)
  1780. COMPATIBLE_IOCTL(SIOCADDDLCI)
  1781. COMPATIBLE_IOCTL(SIOCDELDLCI)
  1782. COMPATIBLE_IOCTL(SIOCGMIIPHY)
  1783. COMPATIBLE_IOCTL(SIOCGMIIREG)
  1784. COMPATIBLE_IOCTL(SIOCSMIIREG)
  1785. COMPATIBLE_IOCTL(SIOCGIFVLAN)
  1786. COMPATIBLE_IOCTL(SIOCSIFVLAN)
  1787. COMPATIBLE_IOCTL(SIOCBRADDBR)
  1788. COMPATIBLE_IOCTL(SIOCBRDELBR)
  1789. #ifdef CONFIG_BLOCK
  1790. /* SG stuff */
  1791. COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
  1792. COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
  1793. COMPATIBLE_IOCTL(SG_EMULATED_HOST)
  1794. ULONG_IOCTL(SG_SET_TRANSFORM)
  1795. COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
  1796. COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
  1797. COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
  1798. COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
  1799. COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
  1800. COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
  1801. COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
  1802. COMPATIBLE_IOCTL(SG_GET_PACK_ID)
  1803. COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
  1804. COMPATIBLE_IOCTL(SG_SET_DEBUG)
  1805. COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
  1806. COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
  1807. COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
  1808. COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
  1809. COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
  1810. COMPATIBLE_IOCTL(SG_SCSI_RESET)
  1811. COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
  1812. COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
  1813. COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
  1814. #endif
  1815. /* PPP stuff */
  1816. COMPATIBLE_IOCTL(PPPIOCGFLAGS)
  1817. COMPATIBLE_IOCTL(PPPIOCSFLAGS)
  1818. COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
  1819. COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
  1820. COMPATIBLE_IOCTL(PPPIOCGUNIT)
  1821. COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
  1822. COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
  1823. COMPATIBLE_IOCTL(PPPIOCGMRU)
  1824. COMPATIBLE_IOCTL(PPPIOCSMRU)
  1825. COMPATIBLE_IOCTL(PPPIOCSMAXCID)
  1826. COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
  1827. COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
  1828. COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
  1829. /* PPPIOCSCOMPRESS is translated */
  1830. COMPATIBLE_IOCTL(PPPIOCGNPMODE)
  1831. COMPATIBLE_IOCTL(PPPIOCSNPMODE)
  1832. COMPATIBLE_IOCTL(PPPIOCGDEBUG)
  1833. COMPATIBLE_IOCTL(PPPIOCSDEBUG)
  1834. /* PPPIOCSPASS is translated */
  1835. /* PPPIOCSACTIVE is translated */
  1836. /* PPPIOCGIDLE is translated */
  1837. COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
  1838. COMPATIBLE_IOCTL(PPPIOCATTACH)
  1839. COMPATIBLE_IOCTL(PPPIOCDETACH)
  1840. COMPATIBLE_IOCTL(PPPIOCSMRRU)
  1841. COMPATIBLE_IOCTL(PPPIOCCONNECT)
  1842. COMPATIBLE_IOCTL(PPPIOCDISCONN)
  1843. COMPATIBLE_IOCTL(PPPIOCATTCHAN)
  1844. COMPATIBLE_IOCTL(PPPIOCGCHAN)
  1845. /* PPPOX */
  1846. COMPATIBLE_IOCTL(PPPOEIOCSFWD)
  1847. COMPATIBLE_IOCTL(PPPOEIOCDFWD)
  1848. /* LP */
  1849. COMPATIBLE_IOCTL(LPGETSTATUS)
  1850. /* ppdev */
  1851. COMPATIBLE_IOCTL(PPSETMODE)
  1852. COMPATIBLE_IOCTL(PPRSTATUS)
  1853. COMPATIBLE_IOCTL(PPRCONTROL)
  1854. COMPATIBLE_IOCTL(PPWCONTROL)
  1855. COMPATIBLE_IOCTL(PPFCONTROL)
  1856. COMPATIBLE_IOCTL(PPRDATA)
  1857. COMPATIBLE_IOCTL(PPWDATA)
  1858. COMPATIBLE_IOCTL(PPCLAIM)
  1859. COMPATIBLE_IOCTL(PPRELEASE)
  1860. COMPATIBLE_IOCTL(PPYIELD)
  1861. COMPATIBLE_IOCTL(PPEXCL)
  1862. COMPATIBLE_IOCTL(PPDATADIR)
  1863. COMPATIBLE_IOCTL(PPNEGOT)
  1864. COMPATIBLE_IOCTL(PPWCTLONIRQ)
  1865. COMPATIBLE_IOCTL(PPCLRIRQ)
  1866. COMPATIBLE_IOCTL(PPSETPHASE)
  1867. COMPATIBLE_IOCTL(PPGETMODES)
  1868. COMPATIBLE_IOCTL(PPGETMODE)
  1869. COMPATIBLE_IOCTL(PPGETPHASE)
  1870. COMPATIBLE_IOCTL(PPGETFLAGS)
  1871. COMPATIBLE_IOCTL(PPSETFLAGS)
  1872. /* pktcdvd */
  1873. COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
  1874. /* Big A */
  1875. /* sparc only */
  1876. /* Big Q for sound/OSS */
  1877. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
  1878. COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
  1879. COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
  1880. COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
  1881. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
  1882. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
  1883. COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
  1884. COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
  1885. COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
  1886. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
  1887. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
  1888. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
  1889. COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
  1890. COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
  1891. COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
  1892. COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
  1893. COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
  1894. COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
  1895. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
  1896. COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
  1897. COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
  1898. COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
  1899. /* Big T for sound/OSS */
  1900. COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
  1901. COMPATIBLE_IOCTL(SNDCTL_TMR_START)
  1902. COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
  1903. COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
  1904. COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
  1905. COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
  1906. COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
  1907. COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
  1908. /* Little m for sound/OSS */
  1909. COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
  1910. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
  1911. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
  1912. /* Big P for sound/OSS */
  1913. COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
  1914. COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
  1915. COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
  1916. COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
  1917. COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
  1918. COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
  1919. COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
  1920. COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
  1921. COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
  1922. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
  1923. COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
  1924. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
  1925. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
  1926. COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
  1927. COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
  1928. COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
  1929. COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
  1930. COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
  1931. COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
  1932. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
  1933. /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
  1934. /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
  1935. COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
  1936. COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
  1937. COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
  1938. COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
  1939. COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
  1940. COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
  1941. COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
  1942. COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
  1943. /* Big C for sound/OSS */
  1944. COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
  1945. COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
  1946. COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
  1947. COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
  1948. COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
  1949. COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
  1950. COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
  1951. COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
  1952. COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
  1953. COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
  1954. /* Big M for sound/OSS */
  1955. COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
  1956. COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
  1957. COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
  1958. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
  1959. COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
  1960. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
  1961. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
  1962. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
  1963. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
  1964. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
  1965. COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
  1966. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
  1967. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
  1968. COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
  1969. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
  1970. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
  1971. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
  1972. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
  1973. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
  1974. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
  1975. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
  1976. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
  1977. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
  1978. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
  1979. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
  1980. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
  1981. /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
  1982. /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
  1983. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
  1984. COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
  1985. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
  1986. COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
  1987. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
  1988. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
  1989. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
  1990. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
  1991. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
  1992. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
  1993. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
  1994. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
  1995. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
  1996. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
  1997. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
  1998. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
  1999. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
  2000. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
  2001. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
  2002. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
  2003. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
  2004. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
  2005. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
  2006. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
  2007. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
  2008. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
  2009. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
  2010. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
  2011. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
  2012. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
  2013. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
  2014. /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
  2015. /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
  2016. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
  2017. COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
  2018. COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
  2019. COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
  2020. COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
  2021. COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
  2022. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
  2023. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
  2024. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
  2025. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
  2026. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
  2027. COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
  2028. COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
  2029. COMPATIBLE_IOCTL(OSS_GETVERSION)
  2030. /* AUTOFS */
  2031. ULONG_IOCTL(AUTOFS_IOC_READY)
  2032. ULONG_IOCTL(AUTOFS_IOC_FAIL)
  2033. COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
  2034. COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
  2035. COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
  2036. COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
  2037. COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
  2038. COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
  2039. /* Raw devices */
  2040. COMPATIBLE_IOCTL(RAW_SETBIND)
  2041. COMPATIBLE_IOCTL(RAW_GETBIND)
  2042. /* SMB ioctls which do not need any translations */
  2043. COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
  2044. /* Little a */
  2045. COMPATIBLE_IOCTL(ATMSIGD_CTRL)
  2046. COMPATIBLE_IOCTL(ATMARPD_CTRL)
  2047. COMPATIBLE_IOCTL(ATMLEC_CTRL)
  2048. COMPATIBLE_IOCTL(ATMLEC_MCAST)
  2049. COMPATIBLE_IOCTL(ATMLEC_DATA)
  2050. COMPATIBLE_IOCTL(ATM_SETSC)
  2051. COMPATIBLE_IOCTL(SIOCSIFATMTCP)
  2052. COMPATIBLE_IOCTL(SIOCMKCLIP)
  2053. COMPATIBLE_IOCTL(ATMARP_MKIP)
  2054. COMPATIBLE_IOCTL(ATMARP_SETENTRY)
  2055. COMPATIBLE_IOCTL(ATMARP_ENCAP)
  2056. COMPATIBLE_IOCTL(ATMTCP_CREATE)
  2057. COMPATIBLE_IOCTL(ATMTCP_REMOVE)
  2058. COMPATIBLE_IOCTL(ATMMPC_CTRL)
  2059. COMPATIBLE_IOCTL(ATMMPC_DATA)
  2060. /* Watchdog */
  2061. COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
  2062. COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
  2063. COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
  2064. COMPATIBLE_IOCTL(WDIOC_GETTEMP)
  2065. COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
  2066. COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
  2067. COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
  2068. COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
  2069. /* Big R */
  2070. COMPATIBLE_IOCTL(RNDGETENTCNT)
  2071. COMPATIBLE_IOCTL(RNDADDTOENTCNT)
  2072. COMPATIBLE_IOCTL(RNDGETPOOL)
  2073. COMPATIBLE_IOCTL(RNDADDENTROPY)
  2074. COMPATIBLE_IOCTL(RNDZAPENTCNT)
  2075. COMPATIBLE_IOCTL(RNDCLEARPOOL)
  2076. /* Bluetooth */
  2077. COMPATIBLE_IOCTL(HCIDEVUP)
  2078. COMPATIBLE_IOCTL(HCIDEVDOWN)
  2079. COMPATIBLE_IOCTL(HCIDEVRESET)
  2080. COMPATIBLE_IOCTL(HCIDEVRESTAT)
  2081. COMPATIBLE_IOCTL(HCIGETDEVLIST)
  2082. COMPATIBLE_IOCTL(HCIGETDEVINFO)
  2083. COMPATIBLE_IOCTL(HCIGETCONNLIST)
  2084. COMPATIBLE_IOCTL(HCIGETCONNINFO)
  2085. COMPATIBLE_IOCTL(HCIGETAUTHINFO)
  2086. COMPATIBLE_IOCTL(HCISETRAW)
  2087. COMPATIBLE_IOCTL(HCISETSCAN)
  2088. COMPATIBLE_IOCTL(HCISETAUTH)
  2089. COMPATIBLE_IOCTL(HCISETENCRYPT)
  2090. COMPATIBLE_IOCTL(HCISETPTYPE)
  2091. COMPATIBLE_IOCTL(HCISETLINKPOL)
  2092. COMPATIBLE_IOCTL(HCISETLINKMODE)
  2093. COMPATIBLE_IOCTL(HCISETACLMTU)
  2094. COMPATIBLE_IOCTL(HCISETSCOMTU)
  2095. COMPATIBLE_IOCTL(HCIINQUIRY)
  2096. COMPATIBLE_IOCTL(HCIUARTSETPROTO)
  2097. COMPATIBLE_IOCTL(HCIUARTGETPROTO)
  2098. COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
  2099. COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
  2100. COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
  2101. COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
  2102. COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
  2103. COMPATIBLE_IOCTL(BNEPCONNADD)
  2104. COMPATIBLE_IOCTL(BNEPCONNDEL)
  2105. COMPATIBLE_IOCTL(BNEPGETCONNLIST)
  2106. COMPATIBLE_IOCTL(BNEPGETCONNINFO)
  2107. COMPATIBLE_IOCTL(CMTPCONNADD)
  2108. COMPATIBLE_IOCTL(CMTPCONNDEL)
  2109. COMPATIBLE_IOCTL(CMTPGETCONNLIST)
  2110. COMPATIBLE_IOCTL(CMTPGETCONNINFO)
  2111. COMPATIBLE_IOCTL(HIDPCONNADD)
  2112. COMPATIBLE_IOCTL(HIDPCONNDEL)
  2113. COMPATIBLE_IOCTL(HIDPGETCONNLIST)
  2114. COMPATIBLE_IOCTL(HIDPGETCONNINFO)
  2115. /* CAPI */
  2116. COMPATIBLE_IOCTL(CAPI_REGISTER)
  2117. COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
  2118. COMPATIBLE_IOCTL(CAPI_GET_VERSION)
  2119. COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
  2120. COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
  2121. COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
  2122. COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
  2123. COMPATIBLE_IOCTL(CAPI_INSTALLED)
  2124. COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
  2125. COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
  2126. COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
  2127. COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
  2128. COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
  2129. /* Siemens Gigaset */
  2130. COMPATIBLE_IOCTL(GIGASET_REDIR)
  2131. COMPATIBLE_IOCTL(GIGASET_CONFIG)
  2132. COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
  2133. COMPATIBLE_IOCTL(GIGASET_VERSION)
  2134. /* Misc. */
  2135. COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
  2136. COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
  2137. COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
  2138. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
  2139. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
  2140. COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
  2141. /* USB */
  2142. COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
  2143. COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
  2144. COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
  2145. COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
  2146. COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
  2147. COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
  2148. COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
  2149. COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
  2150. COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
  2151. COMPATIBLE_IOCTL(USBDEVFS_RESET)
  2152. COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
  2153. COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
  2154. COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
  2155. COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
  2156. /* NBD */
  2157. ULONG_IOCTL(NBD_SET_SOCK)
  2158. ULONG_IOCTL(NBD_SET_BLKSIZE)
  2159. ULONG_IOCTL(NBD_SET_SIZE)
  2160. COMPATIBLE_IOCTL(NBD_DO_IT)
  2161. COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
  2162. COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
  2163. COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
  2164. ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
  2165. COMPATIBLE_IOCTL(NBD_DISCONNECT)
  2166. /* i2c */
  2167. COMPATIBLE_IOCTL(I2C_SLAVE)
  2168. COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
  2169. COMPATIBLE_IOCTL(I2C_TENBIT)
  2170. COMPATIBLE_IOCTL(I2C_PEC)
  2171. COMPATIBLE_IOCTL(I2C_RETRIES)
  2172. COMPATIBLE_IOCTL(I2C_TIMEOUT)
  2173. /* hiddev */
  2174. COMPATIBLE_IOCTL(HIDIOCGVERSION)
  2175. COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
  2176. COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
  2177. COMPATIBLE_IOCTL(HIDIOCGSTRING)
  2178. COMPATIBLE_IOCTL(HIDIOCINITREPORT)
  2179. COMPATIBLE_IOCTL(HIDIOCGREPORT)
  2180. COMPATIBLE_IOCTL(HIDIOCSREPORT)
  2181. COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
  2182. COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
  2183. COMPATIBLE_IOCTL(HIDIOCGUSAGE)
  2184. COMPATIBLE_IOCTL(HIDIOCSUSAGE)
  2185. COMPATIBLE_IOCTL(HIDIOCGUCODE)
  2186. COMPATIBLE_IOCTL(HIDIOCGFLAG)
  2187. COMPATIBLE_IOCTL(HIDIOCSFLAG)
  2188. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
  2189. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
  2190. /* dvb */
  2191. COMPATIBLE_IOCTL(AUDIO_STOP)
  2192. COMPATIBLE_IOCTL(AUDIO_PLAY)
  2193. COMPATIBLE_IOCTL(AUDIO_PAUSE)
  2194. COMPATIBLE_IOCTL(AUDIO_CONTINUE)
  2195. COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
  2196. COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
  2197. COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
  2198. COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
  2199. COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
  2200. COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
  2201. COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
  2202. COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
  2203. COMPATIBLE_IOCTL(AUDIO_SET_ID)
  2204. COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
  2205. COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
  2206. COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
  2207. COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
  2208. COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
  2209. COMPATIBLE_IOCTL(DMX_START)
  2210. COMPATIBLE_IOCTL(DMX_STOP)
  2211. COMPATIBLE_IOCTL(DMX_SET_FILTER)
  2212. COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
  2213. COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
  2214. COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
  2215. COMPATIBLE_IOCTL(DMX_GET_CAPS)
  2216. COMPATIBLE_IOCTL(DMX_SET_SOURCE)
  2217. COMPATIBLE_IOCTL(DMX_GET_STC)
  2218. COMPATIBLE_IOCTL(FE_GET_INFO)
  2219. COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
  2220. COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
  2221. COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
  2222. COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
  2223. COMPATIBLE_IOCTL(FE_SET_TONE)
  2224. COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
  2225. COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
  2226. COMPATIBLE_IOCTL(FE_READ_STATUS)
  2227. COMPATIBLE_IOCTL(FE_READ_BER)
  2228. COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
  2229. COMPATIBLE_IOCTL(FE_READ_SNR)
  2230. COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
  2231. COMPATIBLE_IOCTL(FE_SET_FRONTEND)
  2232. COMPATIBLE_IOCTL(FE_GET_FRONTEND)
  2233. COMPATIBLE_IOCTL(FE_GET_EVENT)
  2234. COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
  2235. COMPATIBLE_IOCTL(VIDEO_STOP)
  2236. COMPATIBLE_IOCTL(VIDEO_PLAY)
  2237. COMPATIBLE_IOCTL(VIDEO_FREEZE)
  2238. COMPATIBLE_IOCTL(VIDEO_CONTINUE)
  2239. COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
  2240. COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
  2241. COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
  2242. COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
  2243. COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
  2244. COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
  2245. COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
  2246. COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
  2247. COMPATIBLE_IOCTL(VIDEO_SET_ID)
  2248. COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
  2249. COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
  2250. COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
  2251. COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
  2252. COMPATIBLE_IOCTL(VIDEO_SET_SPU)
  2253. COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
  2254. COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
  2255. COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
  2256. COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
  2257. /* joystick */
  2258. COMPATIBLE_IOCTL(JSIOCGVERSION)
  2259. COMPATIBLE_IOCTL(JSIOCGAXES)
  2260. COMPATIBLE_IOCTL(JSIOCGBUTTONS)
  2261. COMPATIBLE_IOCTL(JSIOCGNAME(0))
  2262. /* now things that need handlers */
  2263. #ifdef CONFIG_NET
  2264. HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
  2265. HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
  2266. HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
  2267. HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
  2268. HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
  2269. HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
  2270. HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
  2271. HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
  2272. HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
  2273. HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
  2274. HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
  2275. HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
  2276. HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
  2277. HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
  2278. HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
  2279. HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
  2280. HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
  2281. HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
  2282. HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
  2283. HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
  2284. HANDLE_IOCTL(SIOCSHWTSTAMP, dev_ifsioc)
  2285. /* ioctls used by appletalk ddp.c */
  2286. HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
  2287. HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
  2288. HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
  2289. HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
  2290. HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
  2291. HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
  2292. HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
  2293. HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
  2294. HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
  2295. HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
  2296. HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
  2297. HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
  2298. HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
  2299. HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
  2300. HANDLE_IOCTL(TUNSETIFF, dev_ifsioc)
  2301. HANDLE_IOCTL(TUNGETIFF, dev_ifsioc)
  2302. HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
  2303. HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
  2304. HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
  2305. HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
  2306. HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
  2307. HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
  2308. HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
  2309. HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
  2310. HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
  2311. HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
  2312. HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
  2313. /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
  2314. HANDLE_IOCTL(SIOCRTMSG, ret_einval)
  2315. HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
  2316. HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
  2317. #endif
  2318. #ifdef CONFIG_BLOCK
  2319. HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
  2320. HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
  2321. #endif
  2322. HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
  2323. HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
  2324. HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
  2325. HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
  2326. #ifdef CONFIG_BLOCK
  2327. HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
  2328. HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
  2329. #endif
  2330. #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
  2331. HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
  2332. #ifdef CONFIG_VT
  2333. HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
  2334. HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
  2335. HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
  2336. HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
  2337. HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
  2338. #endif
  2339. /* One SMB ioctl needs translations. */
  2340. #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
  2341. HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
  2342. HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
  2343. HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
  2344. HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
  2345. HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
  2346. HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
  2347. HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
  2348. HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
  2349. HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
  2350. HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
  2351. HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
  2352. HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
  2353. HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
  2354. HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
  2355. HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
  2356. HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
  2357. HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
  2358. HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
  2359. HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
  2360. HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
  2361. HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
  2362. HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
  2363. HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
  2364. HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
  2365. HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
  2366. HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
  2367. /* block stuff */
  2368. #ifdef CONFIG_BLOCK
  2369. /* loop */
  2370. IGNORE_IOCTL(LOOP_CLR_FD)
  2371. /* Raw devices */
  2372. HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
  2373. HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
  2374. #endif
  2375. /* Serial */
  2376. HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
  2377. HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
  2378. #ifdef TIOCGLTC
  2379. COMPATIBLE_IOCTL(TIOCGLTC)
  2380. COMPATIBLE_IOCTL(TIOCSLTC)
  2381. #endif
  2382. #ifdef TIOCSTART
  2383. /*
  2384. * For these two we have defintions in ioctls.h and/or termios.h on
  2385. * some architectures but no actual implemention. Some applications
  2386. * like bash call them if they are defined in the headers, so we provide
  2387. * entries here to avoid syslog message spew.
  2388. */
  2389. COMPATIBLE_IOCTL(TIOCSTART)
  2390. COMPATIBLE_IOCTL(TIOCSTOP)
  2391. #endif
  2392. /* Usbdevfs */
  2393. HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
  2394. HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
  2395. HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
  2396. COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
  2397. /* i2c */
  2398. HANDLE_IOCTL(I2C_FUNCS, w_long)
  2399. HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
  2400. HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
  2401. /* bridge */
  2402. HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
  2403. HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
  2404. /* Not implemented in the native kernel */
  2405. IGNORE_IOCTL(SIOCGIFCOUNT)
  2406. HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
  2407. HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
  2408. HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
  2409. HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
  2410. /* dvb */
  2411. HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
  2412. HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
  2413. HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
  2414. /* parport */
  2415. COMPATIBLE_IOCTL(LPTIME)
  2416. COMPATIBLE_IOCTL(LPCHAR)
  2417. COMPATIBLE_IOCTL(LPABORTOPEN)
  2418. COMPATIBLE_IOCTL(LPCAREFUL)
  2419. COMPATIBLE_IOCTL(LPWAIT)
  2420. COMPATIBLE_IOCTL(LPSETIRQ)
  2421. COMPATIBLE_IOCTL(LPGETSTATUS)
  2422. COMPATIBLE_IOCTL(LPGETSTATUS)
  2423. COMPATIBLE_IOCTL(LPRESET)
  2424. /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
  2425. COMPATIBLE_IOCTL(LPGETFLAGS)
  2426. HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
  2427. /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
  2428. but we don't want warnings on other file systems. So declare
  2429. them as compatible here. */
  2430. #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
  2431. #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
  2432. IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
  2433. IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
  2434. #ifdef CONFIG_SPARC
  2435. /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
  2436. IGNORE_IOCTL(FBIOGTYPE)
  2437. IGNORE_IOCTL(FBIOSATTR)
  2438. IGNORE_IOCTL(FBIOGATTR)
  2439. IGNORE_IOCTL(FBIOSVIDEO)
  2440. IGNORE_IOCTL(FBIOGVIDEO)
  2441. IGNORE_IOCTL(FBIOSCURPOS)
  2442. IGNORE_IOCTL(FBIOGCURPOS)
  2443. IGNORE_IOCTL(FBIOGCURMAX)
  2444. IGNORE_IOCTL(FBIOPUTCMAP32)
  2445. IGNORE_IOCTL(FBIOGETCMAP32)
  2446. IGNORE_IOCTL(FBIOSCURSOR32)
  2447. IGNORE_IOCTL(FBIOGCURSOR32)
  2448. #endif
  2449. };
  2450. #define IOCTL_HASHSIZE 256
  2451. static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
  2452. static inline unsigned long ioctl32_hash(unsigned long cmd)
  2453. {
  2454. return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
  2455. }
  2456. static void compat_ioctl_error(struct file *filp, unsigned int fd,
  2457. unsigned int cmd, unsigned long arg)
  2458. {
  2459. char buf[10];
  2460. char *fn = "?";
  2461. char *path;
  2462. /* find the name of the device. */
  2463. path = (char *)__get_free_page(GFP_KERNEL);
  2464. if (path) {
  2465. fn = d_path(&filp->f_path, path, PAGE_SIZE);
  2466. if (IS_ERR(fn))
  2467. fn = "?";
  2468. }
  2469. sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
  2470. if (!isprint(buf[1]))
  2471. sprintf(buf, "%02x", buf[1]);
  2472. compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
  2473. "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
  2474. current->comm, current->pid,
  2475. (int)fd, (unsigned int)cmd, buf,
  2476. (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
  2477. (unsigned int)arg, fn);
  2478. if (path)
  2479. free_page((unsigned long)path);
  2480. }
  2481. asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
  2482. unsigned long arg)
  2483. {
  2484. struct file *filp;
  2485. int error = -EBADF;
  2486. struct ioctl_trans *t;
  2487. int fput_needed;
  2488. filp = fget_light(fd, &fput_needed);
  2489. if (!filp)
  2490. goto out;
  2491. /* RED-PEN how should LSM module know it's handling 32bit? */
  2492. error = security_file_ioctl(filp, cmd, arg);
  2493. if (error)
  2494. goto out_fput;
  2495. /*
  2496. * To allow the compat_ioctl handlers to be self contained
  2497. * we need to check the common ioctls here first.
  2498. * Just handle them with the standard handlers below.
  2499. */
  2500. switch (cmd) {
  2501. case FIOCLEX:
  2502. case FIONCLEX:
  2503. case FIONBIO:
  2504. case FIOASYNC:
  2505. case FIOQSIZE:
  2506. break;
  2507. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  2508. case FS_IOC_RESVSP_32:
  2509. case FS_IOC_RESVSP64_32:
  2510. error = compat_ioctl_preallocate(filp, arg);
  2511. goto out_fput;
  2512. #else
  2513. case FS_IOC_RESVSP:
  2514. case FS_IOC_RESVSP64:
  2515. error = ioctl_preallocate(filp, (void __user *)arg);
  2516. goto out_fput;
  2517. #endif
  2518. case FIBMAP:
  2519. case FIGETBSZ:
  2520. case FIONREAD:
  2521. if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
  2522. break;
  2523. /*FALL THROUGH*/
  2524. default:
  2525. if (filp->f_op && filp->f_op->compat_ioctl) {
  2526. error = filp->f_op->compat_ioctl(filp, cmd, arg);
  2527. if (error != -ENOIOCTLCMD)
  2528. goto out_fput;
  2529. }
  2530. if (!filp->f_op ||
  2531. (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
  2532. goto do_ioctl;
  2533. break;
  2534. }
  2535. for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
  2536. if (t->cmd == cmd)
  2537. goto found_handler;
  2538. }
  2539. #ifdef CONFIG_NET
  2540. if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) &&
  2541. cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
  2542. error = siocdevprivate_ioctl(fd, cmd, arg);
  2543. } else
  2544. #endif
  2545. {
  2546. static int count;
  2547. if (++count <= 50)
  2548. compat_ioctl_error(filp, fd, cmd, arg);
  2549. error = -EINVAL;
  2550. }
  2551. goto out_fput;
  2552. found_handler:
  2553. if (t->handler) {
  2554. lock_kernel();
  2555. error = t->handler(fd, cmd, arg, filp);
  2556. unlock_kernel();
  2557. goto out_fput;
  2558. }
  2559. do_ioctl:
  2560. error = do_vfs_ioctl(filp, fd, cmd, arg);
  2561. out_fput:
  2562. fput_light(filp, fput_needed);
  2563. out:
  2564. return error;
  2565. }
  2566. static void ioctl32_insert_translation(struct ioctl_trans *trans)
  2567. {
  2568. unsigned long hash;
  2569. struct ioctl_trans *t;
  2570. hash = ioctl32_hash (trans->cmd);
  2571. if (!ioctl32_hash_table[hash])
  2572. ioctl32_hash_table[hash] = trans;
  2573. else {
  2574. t = ioctl32_hash_table[hash];
  2575. while (t->next)
  2576. t = t->next;
  2577. trans->next = NULL;
  2578. t->next = trans;
  2579. }
  2580. }
  2581. static int __init init_sys32_ioctl(void)
  2582. {
  2583. int i;
  2584. for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
  2585. if (ioctl_start[i].next) {
  2586. printk("ioctl translation %d bad\n",i);
  2587. return -1;
  2588. }
  2589. ioctl32_insert_translation(&ioctl_start[i]);
  2590. }
  2591. return 0;
  2592. }
  2593. __initcall(init_sys32_ioctl);