compat_ioctl.c 80 KB

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