compat_ioctl.c 81 KB

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