compat_ioctl.c 84 KB

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