compat_ioctl.c 85 KB

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