compat_ioctl.c 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964
  1. /*
  2. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  3. *
  4. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  5. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
  7. * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
  8. *
  9. * These routines maintain argument size conversion between 32bit and 64bit
  10. * ioctls.
  11. */
  12. #include <linux/joystick.h>
  13. #include <linux/types.h>
  14. #include <linux/compat.h>
  15. #include <linux/kernel.h>
  16. #include <linux/capability.h>
  17. #include <linux/compiler.h>
  18. #include <linux/sched.h>
  19. #include <linux/smp.h>
  20. #include <linux/smp_lock.h>
  21. #include <linux/ioctl.h>
  22. #include <linux/if.h>
  23. #include <linux/if_bridge.h>
  24. #include <linux/slab.h>
  25. #include <linux/raid/md_u.h>
  26. #include <linux/kd.h>
  27. #include <linux/route.h>
  28. #include <linux/in6.h>
  29. #include <linux/ipv6_route.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/netlink.h>
  32. #include <linux/vt.h>
  33. #include <linux/falloc.h>
  34. #include <linux/fs.h>
  35. #include <linux/file.h>
  36. #include <linux/ppp_defs.h>
  37. #include <linux/if_ppp.h>
  38. #include <linux/if_pppox.h>
  39. #include <linux/mtio.h>
  40. #include <linux/auto_fs.h>
  41. #include <linux/auto_fs4.h>
  42. #include <linux/tty.h>
  43. #include <linux/vt_kern.h>
  44. #include <linux/fb.h>
  45. #include <linux/videodev.h>
  46. #include <linux/netdevice.h>
  47. #include <linux/raw.h>
  48. #include <linux/smb_fs.h>
  49. #include <linux/blkdev.h>
  50. #include <linux/elevator.h>
  51. #include <linux/rtc.h>
  52. #include <linux/pci.h>
  53. #include <linux/module.h>
  54. #include <linux/serial.h>
  55. #include <linux/if_tun.h>
  56. #include <linux/ctype.h>
  57. #include <linux/syscalls.h>
  58. #include <linux/i2c.h>
  59. #include <linux/i2c-dev.h>
  60. #include <linux/atalk.h>
  61. #include <net/bluetooth/bluetooth.h>
  62. #include <net/bluetooth/hci.h>
  63. #include <net/bluetooth/rfcomm.h>
  64. #include <linux/capi.h>
  65. #include <linux/gigaset_dev.h>
  66. #ifdef CONFIG_BLOCK
  67. #include <linux/loop.h>
  68. #include <scsi/scsi.h>
  69. #include <scsi/scsi_ioctl.h>
  70. #include <scsi/sg.h>
  71. #endif
  72. #include <asm/uaccess.h>
  73. #include <linux/ethtool.h>
  74. #include <linux/mii.h>
  75. #include <linux/if_bonding.h>
  76. #include <linux/watchdog.h>
  77. #include <linux/soundcard.h>
  78. #include <linux/lp.h>
  79. #include <linux/ppdev.h>
  80. #include <linux/atm.h>
  81. #include <linux/atmarp.h>
  82. #include <linux/atmclip.h>
  83. #include <linux/atmdev.h>
  84. #include <linux/atmioc.h>
  85. #include <linux/atmlec.h>
  86. #include <linux/atmmpc.h>
  87. #include <linux/atmsvc.h>
  88. #include <linux/atm_tcp.h>
  89. #include <linux/sonet.h>
  90. #include <linux/atm_suni.h>
  91. #include <linux/usb.h>
  92. #include <linux/usbdevice_fs.h>
  93. #include <linux/nbd.h>
  94. #include <linux/random.h>
  95. #include <linux/filter.h>
  96. #include <linux/pktcdvd.h>
  97. #include <linux/hiddev.h>
  98. #include <linux/dvb/audio.h>
  99. #include <linux/dvb/dmx.h>
  100. #include <linux/dvb/frontend.h>
  101. #include <linux/dvb/video.h>
  102. #ifdef CONFIG_SPARC
  103. #include <asm/fbio.h>
  104. #endif
  105. static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
  106. unsigned long arg, struct file *f)
  107. {
  108. return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
  109. }
  110. static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg)
  111. {
  112. mm_segment_t old_fs = get_fs();
  113. int err;
  114. unsigned long val;
  115. set_fs (KERNEL_DS);
  116. err = sys_ioctl(fd, cmd, (unsigned long)&val);
  117. set_fs (old_fs);
  118. if (!err && put_user(val, (u32 __user *)compat_ptr(arg)))
  119. return -EFAULT;
  120. return err;
  121. }
  122. static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg)
  123. {
  124. mm_segment_t old_fs = get_fs();
  125. u32 __user *argptr = compat_ptr(arg);
  126. int err;
  127. unsigned long val;
  128. if(get_user(val, argptr))
  129. return -EFAULT;
  130. set_fs (KERNEL_DS);
  131. err = sys_ioctl(fd, cmd, (unsigned long)&val);
  132. set_fs (old_fs);
  133. if (!err && put_user(val, argptr))
  134. return -EFAULT;
  135. return err;
  136. }
  137. struct compat_video_event {
  138. int32_t type;
  139. compat_time_t timestamp;
  140. union {
  141. video_size_t size;
  142. unsigned int frame_rate;
  143. } u;
  144. };
  145. static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
  146. {
  147. struct video_event kevent;
  148. mm_segment_t old_fs = get_fs();
  149. int err;
  150. set_fs(KERNEL_DS);
  151. err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
  152. set_fs(old_fs);
  153. if (!err) {
  154. struct compat_video_event __user *up = compat_ptr(arg);
  155. err = put_user(kevent.type, &up->type);
  156. err |= put_user(kevent.timestamp, &up->timestamp);
  157. err |= put_user(kevent.u.size.w, &up->u.size.w);
  158. err |= put_user(kevent.u.size.h, &up->u.size.h);
  159. err |= put_user(kevent.u.size.aspect_ratio,
  160. &up->u.size.aspect_ratio);
  161. if (err)
  162. err = -EFAULT;
  163. }
  164. return err;
  165. }
  166. struct compat_video_still_picture {
  167. compat_uptr_t iFrame;
  168. int32_t size;
  169. };
  170. static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
  171. {
  172. struct compat_video_still_picture __user *up;
  173. struct video_still_picture __user *up_native;
  174. compat_uptr_t fp;
  175. int32_t size;
  176. int err;
  177. up = (struct compat_video_still_picture __user *) arg;
  178. err = get_user(fp, &up->iFrame);
  179. err |= get_user(size, &up->size);
  180. if (err)
  181. return -EFAULT;
  182. up_native =
  183. compat_alloc_user_space(sizeof(struct video_still_picture));
  184. err = put_user(compat_ptr(fp), &up_native->iFrame);
  185. err |= put_user(size, &up_native->size);
  186. if (err)
  187. return -EFAULT;
  188. err = sys_ioctl(fd, cmd, (unsigned long) up_native);
  189. return err;
  190. }
  191. struct compat_video_spu_palette {
  192. int length;
  193. compat_uptr_t palette;
  194. };
  195. static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
  196. {
  197. struct compat_video_spu_palette __user *up;
  198. struct video_spu_palette __user *up_native;
  199. compat_uptr_t palp;
  200. int length, err;
  201. up = (struct compat_video_spu_palette __user *) arg;
  202. err = get_user(palp, &up->palette);
  203. err |= get_user(length, &up->length);
  204. up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
  205. err = put_user(compat_ptr(palp), &up_native->palette);
  206. err |= put_user(length, &up_native->length);
  207. if (err)
  208. return -EFAULT;
  209. err = sys_ioctl(fd, cmd, (unsigned long) up_native);
  210. return err;
  211. }
  212. #ifdef CONFIG_BLOCK
  213. typedef struct sg_io_hdr32 {
  214. compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
  215. compat_int_t dxfer_direction; /* [i] data transfer direction */
  216. unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
  217. unsigned char mx_sb_len; /* [i] max length to write to sbp */
  218. unsigned short iovec_count; /* [i] 0 implies no scatter gather */
  219. compat_uint_t dxfer_len; /* [i] byte count of data transfer */
  220. compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
  221. or scatter gather list */
  222. compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
  223. compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
  224. compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
  225. compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
  226. compat_int_t pack_id; /* [i->o] unused internally (normally) */
  227. compat_uptr_t usr_ptr; /* [i->o] unused internally */
  228. unsigned char status; /* [o] scsi status */
  229. unsigned char masked_status; /* [o] shifted, masked scsi status */
  230. unsigned char msg_status; /* [o] messaging level data (optional) */
  231. unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
  232. unsigned short host_status; /* [o] errors from host adapter */
  233. unsigned short driver_status; /* [o] errors from software driver */
  234. compat_int_t resid; /* [o] dxfer_len - actual_transferred */
  235. compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
  236. compat_uint_t info; /* [o] auxiliary information */
  237. } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
  238. typedef struct sg_iovec32 {
  239. compat_uint_t iov_base;
  240. compat_uint_t iov_len;
  241. } sg_iovec32_t;
  242. static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
  243. {
  244. sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
  245. sg_iovec32_t __user *iov32 = dxferp;
  246. int i;
  247. for (i = 0; i < iovec_count; i++) {
  248. u32 base, len;
  249. if (get_user(base, &iov32[i].iov_base) ||
  250. get_user(len, &iov32[i].iov_len) ||
  251. put_user(compat_ptr(base), &iov[i].iov_base) ||
  252. put_user(len, &iov[i].iov_len))
  253. return -EFAULT;
  254. }
  255. if (put_user(iov, &sgio->dxferp))
  256. return -EFAULT;
  257. return 0;
  258. }
  259. static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  260. {
  261. sg_io_hdr_t __user *sgio;
  262. sg_io_hdr32_t __user *sgio32;
  263. u16 iovec_count;
  264. u32 data;
  265. void __user *dxferp;
  266. int err;
  267. sgio32 = compat_ptr(arg);
  268. if (get_user(iovec_count, &sgio32->iovec_count))
  269. return -EFAULT;
  270. {
  271. void __user *top = compat_alloc_user_space(0);
  272. void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
  273. (iovec_count * sizeof(sg_iovec_t)));
  274. if (new > top)
  275. return -EINVAL;
  276. sgio = new;
  277. }
  278. /* Ok, now construct. */
  279. if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
  280. (2 * sizeof(int)) +
  281. (2 * sizeof(unsigned char)) +
  282. (1 * sizeof(unsigned short)) +
  283. (1 * sizeof(unsigned int))))
  284. return -EFAULT;
  285. if (get_user(data, &sgio32->dxferp))
  286. return -EFAULT;
  287. dxferp = compat_ptr(data);
  288. if (iovec_count) {
  289. if (sg_build_iovec(sgio, dxferp, iovec_count))
  290. return -EFAULT;
  291. } else {
  292. if (put_user(dxferp, &sgio->dxferp))
  293. return -EFAULT;
  294. }
  295. {
  296. unsigned char __user *cmdp;
  297. unsigned char __user *sbp;
  298. if (get_user(data, &sgio32->cmdp))
  299. return -EFAULT;
  300. cmdp = compat_ptr(data);
  301. if (get_user(data, &sgio32->sbp))
  302. return -EFAULT;
  303. sbp = compat_ptr(data);
  304. if (put_user(cmdp, &sgio->cmdp) ||
  305. put_user(sbp, &sgio->sbp))
  306. return -EFAULT;
  307. }
  308. if (copy_in_user(&sgio->timeout, &sgio32->timeout,
  309. 3 * sizeof(int)))
  310. return -EFAULT;
  311. if (get_user(data, &sgio32->usr_ptr))
  312. return -EFAULT;
  313. if (put_user(compat_ptr(data), &sgio->usr_ptr))
  314. return -EFAULT;
  315. err = sys_ioctl(fd, cmd, (unsigned long) sgio);
  316. if (err >= 0) {
  317. void __user *datap;
  318. if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
  319. sizeof(int)) ||
  320. get_user(datap, &sgio->usr_ptr) ||
  321. put_user((u32)(unsigned long)datap,
  322. &sgio32->usr_ptr) ||
  323. copy_in_user(&sgio32->status, &sgio->status,
  324. (4 * sizeof(unsigned char)) +
  325. (2 * sizeof(unsigned short)) +
  326. (3 * sizeof(int))))
  327. err = -EFAULT;
  328. }
  329. return err;
  330. }
  331. struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
  332. char req_state;
  333. char orphan;
  334. char sg_io_owned;
  335. char problem;
  336. int pack_id;
  337. compat_uptr_t usr_ptr;
  338. unsigned int duration;
  339. int unused;
  340. };
  341. static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  342. {
  343. int err, i;
  344. sg_req_info_t __user *r;
  345. struct compat_sg_req_info __user *o = (void __user *)arg;
  346. r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
  347. err = sys_ioctl(fd,cmd,(unsigned long)r);
  348. if (err < 0)
  349. return err;
  350. for (i = 0; i < SG_MAX_QUEUE; i++) {
  351. void __user *ptr;
  352. int d;
  353. if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
  354. get_user(ptr, &r[i].usr_ptr) ||
  355. get_user(d, &r[i].duration) ||
  356. put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
  357. put_user(d, &o[i].duration))
  358. return -EFAULT;
  359. }
  360. return err;
  361. }
  362. #endif /* CONFIG_BLOCK */
  363. struct sock_fprog32 {
  364. unsigned short len;
  365. compat_caddr_t filter;
  366. };
  367. #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
  368. #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
  369. static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  370. {
  371. struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg);
  372. struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
  373. void __user *fptr64;
  374. u32 fptr32;
  375. u16 flen;
  376. if (get_user(flen, &u_fprog32->len) ||
  377. get_user(fptr32, &u_fprog32->filter))
  378. return -EFAULT;
  379. fptr64 = compat_ptr(fptr32);
  380. if (put_user(flen, &u_fprog64->len) ||
  381. put_user(fptr64, &u_fprog64->filter))
  382. return -EFAULT;
  383. if (cmd == PPPIOCSPASS32)
  384. cmd = PPPIOCSPASS;
  385. else
  386. cmd = PPPIOCSACTIVE;
  387. return sys_ioctl(fd, cmd, (unsigned long) u_fprog64);
  388. }
  389. struct ppp_option_data32 {
  390. compat_caddr_t ptr;
  391. u32 length;
  392. compat_int_t transmit;
  393. };
  394. #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
  395. struct ppp_idle32 {
  396. compat_time_t xmit_idle;
  397. compat_time_t recv_idle;
  398. };
  399. #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
  400. static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg)
  401. {
  402. struct ppp_idle __user *idle;
  403. struct ppp_idle32 __user *idle32;
  404. __kernel_time_t xmit, recv;
  405. int err;
  406. idle = compat_alloc_user_space(sizeof(*idle));
  407. idle32 = compat_ptr(arg);
  408. err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
  409. if (!err) {
  410. if (get_user(xmit, &idle->xmit_idle) ||
  411. get_user(recv, &idle->recv_idle) ||
  412. put_user(xmit, &idle32->xmit_idle) ||
  413. put_user(recv, &idle32->recv_idle))
  414. err = -EFAULT;
  415. }
  416. return err;
  417. }
  418. static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg)
  419. {
  420. struct ppp_option_data __user *odata;
  421. struct ppp_option_data32 __user *odata32;
  422. __u32 data;
  423. void __user *datap;
  424. odata = compat_alloc_user_space(sizeof(*odata));
  425. odata32 = compat_ptr(arg);
  426. if (get_user(data, &odata32->ptr))
  427. return -EFAULT;
  428. datap = compat_ptr(data);
  429. if (put_user(datap, &odata->ptr))
  430. return -EFAULT;
  431. if (copy_in_user(&odata->length, &odata32->length,
  432. sizeof(__u32) + sizeof(int)))
  433. return -EFAULT;
  434. return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata);
  435. }
  436. static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  437. {
  438. int err;
  439. switch (cmd) {
  440. case PPPIOCGIDLE32:
  441. err = ppp_gidle(fd, cmd, arg);
  442. break;
  443. case PPPIOCSCOMPRESS32:
  444. err = ppp_scompress(fd, cmd, arg);
  445. break;
  446. default:
  447. do {
  448. static int count;
  449. if (++count <= 20)
  450. printk("ppp_ioctl: Unknown cmd fd(%d) "
  451. "cmd(%08x) arg(%08x)\n",
  452. (int)fd, (unsigned int)cmd, (unsigned int)arg);
  453. } while(0);
  454. err = -EINVAL;
  455. break;
  456. };
  457. return err;
  458. }
  459. #ifdef CONFIG_BLOCK
  460. struct mtget32 {
  461. compat_long_t mt_type;
  462. compat_long_t mt_resid;
  463. compat_long_t mt_dsreg;
  464. compat_long_t mt_gstat;
  465. compat_long_t mt_erreg;
  466. compat_daddr_t mt_fileno;
  467. compat_daddr_t mt_blkno;
  468. };
  469. #define MTIOCGET32 _IOR('m', 2, struct mtget32)
  470. struct mtpos32 {
  471. compat_long_t mt_blkno;
  472. };
  473. #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
  474. static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  475. {
  476. mm_segment_t old_fs = get_fs();
  477. struct mtget get;
  478. struct mtget32 __user *umget32;
  479. struct mtpos pos;
  480. struct mtpos32 __user *upos32;
  481. unsigned long kcmd;
  482. void *karg;
  483. int err = 0;
  484. switch(cmd) {
  485. case MTIOCPOS32:
  486. kcmd = MTIOCPOS;
  487. karg = &pos;
  488. break;
  489. case MTIOCGET32:
  490. kcmd = MTIOCGET;
  491. karg = &get;
  492. break;
  493. default:
  494. do {
  495. static int count;
  496. if (++count <= 20)
  497. printk("mt_ioctl: Unknown cmd fd(%d) "
  498. "cmd(%08x) arg(%08x)\n",
  499. (int)fd, (unsigned int)cmd, (unsigned int)arg);
  500. } while(0);
  501. return -EINVAL;
  502. }
  503. set_fs (KERNEL_DS);
  504. err = sys_ioctl (fd, kcmd, (unsigned long)karg);
  505. set_fs (old_fs);
  506. if (err)
  507. return err;
  508. switch (cmd) {
  509. case MTIOCPOS32:
  510. upos32 = compat_ptr(arg);
  511. err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
  512. break;
  513. case MTIOCGET32:
  514. umget32 = compat_ptr(arg);
  515. err = __put_user(get.mt_type, &umget32->mt_type);
  516. err |= __put_user(get.mt_resid, &umget32->mt_resid);
  517. err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
  518. err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
  519. err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
  520. err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
  521. err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
  522. break;
  523. }
  524. return err ? -EFAULT: 0;
  525. }
  526. #endif /* CONFIG_BLOCK */
  527. static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
  528. {
  529. mm_segment_t old_fs = get_fs();
  530. __kernel_uid_t kuid;
  531. int err;
  532. cmd = SMB_IOC_GETMOUNTUID;
  533. set_fs(KERNEL_DS);
  534. err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
  535. set_fs(old_fs);
  536. if (err >= 0)
  537. err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
  538. return err;
  539. }
  540. static __used int
  541. ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
  542. {
  543. return -EINVAL;
  544. }
  545. static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
  546. {
  547. return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg);
  548. }
  549. /* Bluetooth ioctls */
  550. #define HCIUARTSETPROTO _IOW('U', 200, int)
  551. #define HCIUARTGETPROTO _IOR('U', 201, int)
  552. #define BNEPCONNADD _IOW('B', 200, int)
  553. #define BNEPCONNDEL _IOW('B', 201, int)
  554. #define BNEPGETCONNLIST _IOR('B', 210, int)
  555. #define BNEPGETCONNINFO _IOR('B', 211, int)
  556. #define CMTPCONNADD _IOW('C', 200, int)
  557. #define CMTPCONNDEL _IOW('C', 201, int)
  558. #define CMTPGETCONNLIST _IOR('C', 210, int)
  559. #define CMTPGETCONNINFO _IOR('C', 211, int)
  560. #define HIDPCONNADD _IOW('H', 200, int)
  561. #define HIDPCONNDEL _IOW('H', 201, int)
  562. #define HIDPGETCONNLIST _IOR('H', 210, int)
  563. #define HIDPGETCONNINFO _IOR('H', 211, int)
  564. #ifdef CONFIG_BLOCK
  565. struct raw32_config_request
  566. {
  567. compat_int_t raw_minor;
  568. __u64 block_major;
  569. __u64 block_minor;
  570. } __attribute__((packed));
  571. static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
  572. {
  573. int ret;
  574. if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
  575. return -EFAULT;
  576. ret = __get_user(req->raw_minor, &user_req->raw_minor);
  577. ret |= __get_user(req->block_major, &user_req->block_major);
  578. ret |= __get_user(req->block_minor, &user_req->block_minor);
  579. return ret ? -EFAULT : 0;
  580. }
  581. static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
  582. {
  583. int ret;
  584. if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
  585. return -EFAULT;
  586. ret = __put_user(req->raw_minor, &user_req->raw_minor);
  587. ret |= __put_user(req->block_major, &user_req->block_major);
  588. ret |= __put_user(req->block_minor, &user_req->block_minor);
  589. return ret ? -EFAULT : 0;
  590. }
  591. static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  592. {
  593. int ret;
  594. switch (cmd) {
  595. case RAW_SETBIND:
  596. case RAW_GETBIND: {
  597. struct raw_config_request req;
  598. struct raw32_config_request __user *user_req = compat_ptr(arg);
  599. mm_segment_t oldfs = get_fs();
  600. if ((ret = get_raw32_request(&req, user_req)))
  601. return ret;
  602. set_fs(KERNEL_DS);
  603. ret = sys_ioctl(fd,cmd,(unsigned long)&req);
  604. set_fs(oldfs);
  605. if ((!ret) && (cmd == RAW_GETBIND)) {
  606. ret = set_raw32_request(&req, user_req);
  607. }
  608. break;
  609. }
  610. default:
  611. ret = sys_ioctl(fd, cmd, arg);
  612. break;
  613. }
  614. return ret;
  615. }
  616. #endif /* CONFIG_BLOCK */
  617. struct serial_struct32 {
  618. compat_int_t type;
  619. compat_int_t line;
  620. compat_uint_t port;
  621. compat_int_t irq;
  622. compat_int_t flags;
  623. compat_int_t xmit_fifo_size;
  624. compat_int_t custom_divisor;
  625. compat_int_t baud_base;
  626. unsigned short close_delay;
  627. char io_type;
  628. char reserved_char[1];
  629. compat_int_t hub6;
  630. unsigned short closing_wait; /* time to wait before closing */
  631. unsigned short closing_wait2; /* no longer used... */
  632. compat_uint_t iomem_base;
  633. unsigned short iomem_reg_shift;
  634. unsigned int port_high;
  635. /* compat_ulong_t iomap_base FIXME */
  636. compat_int_t reserved[1];
  637. };
  638. static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  639. {
  640. typedef struct serial_struct SS;
  641. typedef struct serial_struct32 SS32;
  642. struct serial_struct32 __user *ss32 = compat_ptr(arg);
  643. int err;
  644. struct serial_struct ss;
  645. mm_segment_t oldseg = get_fs();
  646. __u32 udata;
  647. unsigned int base;
  648. if (cmd == TIOCSSERIAL) {
  649. if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
  650. return -EFAULT;
  651. if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
  652. return -EFAULT;
  653. if (__get_user(udata, &ss32->iomem_base))
  654. return -EFAULT;
  655. ss.iomem_base = compat_ptr(udata);
  656. if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  657. __get_user(ss.port_high, &ss32->port_high))
  658. return -EFAULT;
  659. ss.iomap_base = 0UL;
  660. }
  661. set_fs(KERNEL_DS);
  662. err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
  663. set_fs(oldseg);
  664. if (cmd == TIOCGSERIAL && err >= 0) {
  665. if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
  666. return -EFAULT;
  667. if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
  668. return -EFAULT;
  669. base = (unsigned long)ss.iomem_base >> 32 ?
  670. 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
  671. if (__put_user(base, &ss32->iomem_base) ||
  672. __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
  673. __put_user(ss.port_high, &ss32->port_high))
  674. return -EFAULT;
  675. }
  676. return err;
  677. }
  678. struct usbdevfs_ctrltransfer32 {
  679. u8 bRequestType;
  680. u8 bRequest;
  681. u16 wValue;
  682. u16 wIndex;
  683. u16 wLength;
  684. u32 timeout; /* in milliseconds */
  685. compat_caddr_t data;
  686. };
  687. #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
  688. static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
  689. {
  690. struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg);
  691. struct usbdevfs_ctrltransfer __user *p;
  692. __u32 udata;
  693. p = compat_alloc_user_space(sizeof(*p));
  694. if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
  695. get_user(udata, &p32->data) ||
  696. put_user(compat_ptr(udata), &p->data))
  697. return -EFAULT;
  698. return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p);
  699. }
  700. struct usbdevfs_bulktransfer32 {
  701. compat_uint_t ep;
  702. compat_uint_t len;
  703. compat_uint_t timeout; /* in milliseconds */
  704. compat_caddr_t data;
  705. };
  706. #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
  707. static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
  708. {
  709. struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg);
  710. struct usbdevfs_bulktransfer __user *p;
  711. compat_uint_t n;
  712. compat_caddr_t addr;
  713. p = compat_alloc_user_space(sizeof(*p));
  714. if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
  715. get_user(n, &p32->len) || put_user(n, &p->len) ||
  716. get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
  717. get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
  718. return -EFAULT;
  719. return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p);
  720. }
  721. /*
  722. * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY
  723. * are handled in usbdevfs core. -Christopher Li
  724. */
  725. struct usbdevfs_disconnectsignal32 {
  726. compat_int_t signr;
  727. compat_caddr_t context;
  728. };
  729. #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
  730. static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
  731. {
  732. struct usbdevfs_disconnectsignal kdis;
  733. struct usbdevfs_disconnectsignal32 __user *udis;
  734. mm_segment_t old_fs;
  735. u32 uctx;
  736. int err;
  737. udis = compat_ptr(arg);
  738. if (get_user(kdis.signr, &udis->signr) ||
  739. __get_user(uctx, &udis->context))
  740. return -EFAULT;
  741. kdis.context = compat_ptr(uctx);
  742. old_fs = get_fs();
  743. set_fs(KERNEL_DS);
  744. err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
  745. set_fs(old_fs);
  746. return err;
  747. }
  748. /*
  749. * I2C layer ioctls
  750. */
  751. struct i2c_msg32 {
  752. u16 addr;
  753. u16 flags;
  754. u16 len;
  755. compat_caddr_t buf;
  756. };
  757. struct i2c_rdwr_ioctl_data32 {
  758. compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
  759. u32 nmsgs;
  760. };
  761. struct i2c_smbus_ioctl_data32 {
  762. u8 read_write;
  763. u8 command;
  764. u32 size;
  765. compat_caddr_t data; /* union i2c_smbus_data *data */
  766. };
  767. struct i2c_rdwr_aligned {
  768. struct i2c_rdwr_ioctl_data cmd;
  769. struct i2c_msg msgs[0];
  770. };
  771. static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  772. {
  773. struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg);
  774. struct i2c_rdwr_aligned __user *tdata;
  775. struct i2c_msg __user *tmsgs;
  776. struct i2c_msg32 __user *umsgs;
  777. compat_caddr_t datap;
  778. int nmsgs, i;
  779. if (get_user(nmsgs, &udata->nmsgs))
  780. return -EFAULT;
  781. if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
  782. return -EINVAL;
  783. if (get_user(datap, &udata->msgs))
  784. return -EFAULT;
  785. umsgs = compat_ptr(datap);
  786. tdata = compat_alloc_user_space(sizeof(*tdata) +
  787. nmsgs * sizeof(struct i2c_msg));
  788. tmsgs = &tdata->msgs[0];
  789. if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
  790. put_user(tmsgs, &tdata->cmd.msgs))
  791. return -EFAULT;
  792. for (i = 0; i < nmsgs; i++) {
  793. if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
  794. return -EFAULT;
  795. if (get_user(datap, &umsgs[i].buf) ||
  796. put_user(compat_ptr(datap), &tmsgs[i].buf))
  797. return -EFAULT;
  798. }
  799. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  800. }
  801. static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
  802. {
  803. struct i2c_smbus_ioctl_data __user *tdata;
  804. struct i2c_smbus_ioctl_data32 __user *udata;
  805. compat_caddr_t datap;
  806. tdata = compat_alloc_user_space(sizeof(*tdata));
  807. if (tdata == NULL)
  808. return -ENOMEM;
  809. if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
  810. return -EFAULT;
  811. udata = compat_ptr(arg);
  812. if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
  813. return -EFAULT;
  814. if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
  815. return -EFAULT;
  816. if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
  817. return -EFAULT;
  818. if (__get_user(datap, &udata->data) ||
  819. __put_user(compat_ptr(datap), &tdata->data))
  820. return -EFAULT;
  821. return sys_ioctl(fd, cmd, (unsigned long)tdata);
  822. }
  823. #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
  824. #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
  825. #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
  826. #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
  827. static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
  828. {
  829. mm_segment_t oldfs = get_fs();
  830. compat_ulong_t val32;
  831. unsigned long kval;
  832. int ret;
  833. switch (cmd) {
  834. case RTC_IRQP_READ32:
  835. case RTC_EPOCH_READ32:
  836. set_fs(KERNEL_DS);
  837. ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ?
  838. RTC_IRQP_READ : RTC_EPOCH_READ,
  839. (unsigned long)&kval);
  840. set_fs(oldfs);
  841. if (ret)
  842. return ret;
  843. val32 = kval;
  844. return put_user(val32, (unsigned int __user *)arg);
  845. case RTC_IRQP_SET32:
  846. return sys_ioctl(fd, RTC_IRQP_SET, arg);
  847. case RTC_EPOCH_SET32:
  848. return sys_ioctl(fd, RTC_EPOCH_SET, arg);
  849. default:
  850. /* unreached */
  851. return -ENOIOCTLCMD;
  852. }
  853. }
  854. static int
  855. lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
  856. {
  857. struct compat_timeval __user *tc = (struct compat_timeval __user *)arg;
  858. struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval));
  859. struct timeval ts;
  860. if (get_user(ts.tv_sec, &tc->tv_sec) ||
  861. get_user(ts.tv_usec, &tc->tv_usec) ||
  862. put_user(ts.tv_sec, &tn->tv_sec) ||
  863. put_user(ts.tv_usec, &tn->tv_usec))
  864. return -EFAULT;
  865. return sys_ioctl(fd, cmd, (unsigned long)tn);
  866. }
  867. /* on ia32 l_start is on a 32-bit boundary */
  868. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  869. struct space_resv_32 {
  870. __s16 l_type;
  871. __s16 l_whence;
  872. __s64 l_start __attribute__((packed));
  873. /* len == 0 means until end of file */
  874. __s64 l_len __attribute__((packed));
  875. __s32 l_sysid;
  876. __u32 l_pid;
  877. __s32 l_pad[4]; /* reserve area */
  878. };
  879. #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
  880. #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
  881. /* just account for different alignment */
  882. static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
  883. {
  884. struct space_resv_32 __user *p32 = compat_ptr(arg);
  885. struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
  886. if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
  887. copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
  888. copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
  889. copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
  890. copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
  891. copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
  892. copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
  893. return -EFAULT;
  894. return ioctl_preallocate(file, p);
  895. }
  896. #endif
  897. typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
  898. unsigned long, struct file *);
  899. struct ioctl_trans {
  900. unsigned long cmd;
  901. ioctl_trans_handler_t handler;
  902. struct ioctl_trans *next;
  903. };
  904. #define HANDLE_IOCTL(cmd,handler) \
  905. { (cmd), (ioctl_trans_handler_t)(handler) },
  906. /* pointer to compatible structure or no argument */
  907. #define COMPATIBLE_IOCTL(cmd) \
  908. { (cmd), do_ioctl32_pointer },
  909. /* argument is an unsigned long integer, not a pointer */
  910. #define ULONG_IOCTL(cmd) \
  911. { (cmd), (ioctl_trans_handler_t)sys_ioctl },
  912. /* ioctl should not be warned about even if it's not implemented.
  913. Valid reasons to use this:
  914. - It is implemented with ->compat_ioctl on some device, but programs
  915. call it on others too.
  916. - The ioctl is not implemented in the native kernel, but programs
  917. call it commonly anyways.
  918. Most other reasons are not valid. */
  919. #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
  920. static struct ioctl_trans ioctl_start[] = {
  921. /* compatible ioctls first */
  922. COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
  923. COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
  924. /* Big T */
  925. COMPATIBLE_IOCTL(TCGETA)
  926. COMPATIBLE_IOCTL(TCSETA)
  927. COMPATIBLE_IOCTL(TCSETAW)
  928. COMPATIBLE_IOCTL(TCSETAF)
  929. COMPATIBLE_IOCTL(TCSBRK)
  930. ULONG_IOCTL(TCSBRKP)
  931. COMPATIBLE_IOCTL(TCXONC)
  932. COMPATIBLE_IOCTL(TCFLSH)
  933. COMPATIBLE_IOCTL(TCGETS)
  934. COMPATIBLE_IOCTL(TCSETS)
  935. COMPATIBLE_IOCTL(TCSETSW)
  936. COMPATIBLE_IOCTL(TCSETSF)
  937. COMPATIBLE_IOCTL(TIOCLINUX)
  938. COMPATIBLE_IOCTL(TIOCSBRK)
  939. COMPATIBLE_IOCTL(TIOCCBRK)
  940. ULONG_IOCTL(TIOCMIWAIT)
  941. COMPATIBLE_IOCTL(TIOCGICOUNT)
  942. /* Little t */
  943. COMPATIBLE_IOCTL(TIOCGETD)
  944. COMPATIBLE_IOCTL(TIOCSETD)
  945. COMPATIBLE_IOCTL(TIOCEXCL)
  946. COMPATIBLE_IOCTL(TIOCNXCL)
  947. COMPATIBLE_IOCTL(TIOCCONS)
  948. COMPATIBLE_IOCTL(TIOCGSOFTCAR)
  949. COMPATIBLE_IOCTL(TIOCSSOFTCAR)
  950. COMPATIBLE_IOCTL(TIOCSWINSZ)
  951. COMPATIBLE_IOCTL(TIOCGWINSZ)
  952. COMPATIBLE_IOCTL(TIOCMGET)
  953. COMPATIBLE_IOCTL(TIOCMBIC)
  954. COMPATIBLE_IOCTL(TIOCMBIS)
  955. COMPATIBLE_IOCTL(TIOCMSET)
  956. COMPATIBLE_IOCTL(TIOCPKT)
  957. COMPATIBLE_IOCTL(TIOCNOTTY)
  958. COMPATIBLE_IOCTL(TIOCSTI)
  959. COMPATIBLE_IOCTL(TIOCOUTQ)
  960. COMPATIBLE_IOCTL(TIOCSPGRP)
  961. COMPATIBLE_IOCTL(TIOCGPGRP)
  962. ULONG_IOCTL(TIOCSCTTY)
  963. COMPATIBLE_IOCTL(TIOCGPTN)
  964. COMPATIBLE_IOCTL(TIOCSPTLCK)
  965. COMPATIBLE_IOCTL(TIOCSERGETLSR)
  966. #ifdef TCGETS2
  967. COMPATIBLE_IOCTL(TCGETS2)
  968. COMPATIBLE_IOCTL(TCSETS2)
  969. COMPATIBLE_IOCTL(TCSETSW2)
  970. COMPATIBLE_IOCTL(TCSETSF2)
  971. #endif
  972. /* Little f */
  973. COMPATIBLE_IOCTL(FIOCLEX)
  974. COMPATIBLE_IOCTL(FIONCLEX)
  975. COMPATIBLE_IOCTL(FIOASYNC)
  976. COMPATIBLE_IOCTL(FIONBIO)
  977. COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
  978. COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
  979. /* 0x00 */
  980. COMPATIBLE_IOCTL(FIBMAP)
  981. COMPATIBLE_IOCTL(FIGETBSZ)
  982. /* 'X' - originally XFS but some now in the VFS */
  983. COMPATIBLE_IOCTL(FIFREEZE)
  984. COMPATIBLE_IOCTL(FITHAW)
  985. /* RAID */
  986. COMPATIBLE_IOCTL(RAID_VERSION)
  987. COMPATIBLE_IOCTL(GET_ARRAY_INFO)
  988. COMPATIBLE_IOCTL(GET_DISK_INFO)
  989. COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
  990. COMPATIBLE_IOCTL(RAID_AUTORUN)
  991. COMPATIBLE_IOCTL(CLEAR_ARRAY)
  992. COMPATIBLE_IOCTL(ADD_NEW_DISK)
  993. ULONG_IOCTL(HOT_REMOVE_DISK)
  994. COMPATIBLE_IOCTL(SET_ARRAY_INFO)
  995. COMPATIBLE_IOCTL(SET_DISK_INFO)
  996. COMPATIBLE_IOCTL(WRITE_RAID_INFO)
  997. COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
  998. COMPATIBLE_IOCTL(PROTECT_ARRAY)
  999. ULONG_IOCTL(HOT_ADD_DISK)
  1000. ULONG_IOCTL(SET_DISK_FAULTY)
  1001. COMPATIBLE_IOCTL(RUN_ARRAY)
  1002. COMPATIBLE_IOCTL(STOP_ARRAY)
  1003. COMPATIBLE_IOCTL(STOP_ARRAY_RO)
  1004. COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
  1005. COMPATIBLE_IOCTL(GET_BITMAP_FILE)
  1006. ULONG_IOCTL(SET_BITMAP_FILE)
  1007. /* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */
  1008. ULONG_IOCTL(KDSIGACCEPT)
  1009. COMPATIBLE_IOCTL(KDGETKEYCODE)
  1010. COMPATIBLE_IOCTL(KDSETKEYCODE)
  1011. ULONG_IOCTL(KIOCSOUND)
  1012. ULONG_IOCTL(KDMKTONE)
  1013. COMPATIBLE_IOCTL(KDGKBTYPE)
  1014. ULONG_IOCTL(KDSETMODE)
  1015. COMPATIBLE_IOCTL(KDGETMODE)
  1016. ULONG_IOCTL(KDSKBMODE)
  1017. COMPATIBLE_IOCTL(KDGKBMODE)
  1018. ULONG_IOCTL(KDSKBMETA)
  1019. COMPATIBLE_IOCTL(KDGKBMETA)
  1020. COMPATIBLE_IOCTL(KDGKBENT)
  1021. COMPATIBLE_IOCTL(KDSKBENT)
  1022. COMPATIBLE_IOCTL(KDGKBSENT)
  1023. COMPATIBLE_IOCTL(KDSKBSENT)
  1024. COMPATIBLE_IOCTL(KDGKBDIACR)
  1025. COMPATIBLE_IOCTL(KDSKBDIACR)
  1026. COMPATIBLE_IOCTL(KDKBDREP)
  1027. COMPATIBLE_IOCTL(KDGKBLED)
  1028. ULONG_IOCTL(KDSKBLED)
  1029. COMPATIBLE_IOCTL(KDGETLED)
  1030. ULONG_IOCTL(KDSETLED)
  1031. #ifdef CONFIG_BLOCK
  1032. /* Big S */
  1033. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
  1034. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
  1035. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
  1036. COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
  1037. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
  1038. COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
  1039. COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
  1040. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
  1041. #endif
  1042. /* Little p (/dev/rtc, /dev/envctrl, etc.) */
  1043. COMPATIBLE_IOCTL(RTC_AIE_ON)
  1044. COMPATIBLE_IOCTL(RTC_AIE_OFF)
  1045. COMPATIBLE_IOCTL(RTC_UIE_ON)
  1046. COMPATIBLE_IOCTL(RTC_UIE_OFF)
  1047. COMPATIBLE_IOCTL(RTC_PIE_ON)
  1048. COMPATIBLE_IOCTL(RTC_PIE_OFF)
  1049. COMPATIBLE_IOCTL(RTC_WIE_ON)
  1050. COMPATIBLE_IOCTL(RTC_WIE_OFF)
  1051. COMPATIBLE_IOCTL(RTC_ALM_SET)
  1052. COMPATIBLE_IOCTL(RTC_ALM_READ)
  1053. COMPATIBLE_IOCTL(RTC_RD_TIME)
  1054. COMPATIBLE_IOCTL(RTC_SET_TIME)
  1055. COMPATIBLE_IOCTL(RTC_WKALM_SET)
  1056. COMPATIBLE_IOCTL(RTC_WKALM_RD)
  1057. /*
  1058. * These two are only for the sbus rtc driver, but
  1059. * hwclock tries them on every rtc device first when
  1060. * running on sparc. On other architectures the entries
  1061. * are useless but harmless.
  1062. */
  1063. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  1064. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  1065. /* Little m */
  1066. COMPATIBLE_IOCTL(MTIOCTOP)
  1067. /* Socket level stuff */
  1068. COMPATIBLE_IOCTL(FIOQSIZE)
  1069. #ifdef CONFIG_BLOCK
  1070. /* SG stuff */
  1071. COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
  1072. COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
  1073. COMPATIBLE_IOCTL(SG_EMULATED_HOST)
  1074. ULONG_IOCTL(SG_SET_TRANSFORM)
  1075. COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
  1076. COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
  1077. COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
  1078. COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
  1079. COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
  1080. COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
  1081. COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
  1082. COMPATIBLE_IOCTL(SG_GET_PACK_ID)
  1083. COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
  1084. COMPATIBLE_IOCTL(SG_SET_DEBUG)
  1085. COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
  1086. COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
  1087. COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
  1088. COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
  1089. COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
  1090. COMPATIBLE_IOCTL(SG_SCSI_RESET)
  1091. COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
  1092. COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
  1093. COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
  1094. #endif
  1095. /* PPP stuff */
  1096. COMPATIBLE_IOCTL(PPPIOCGFLAGS)
  1097. COMPATIBLE_IOCTL(PPPIOCSFLAGS)
  1098. COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
  1099. COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
  1100. COMPATIBLE_IOCTL(PPPIOCGUNIT)
  1101. COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
  1102. COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
  1103. COMPATIBLE_IOCTL(PPPIOCGMRU)
  1104. COMPATIBLE_IOCTL(PPPIOCSMRU)
  1105. COMPATIBLE_IOCTL(PPPIOCSMAXCID)
  1106. COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
  1107. COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
  1108. COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
  1109. /* PPPIOCSCOMPRESS is translated */
  1110. COMPATIBLE_IOCTL(PPPIOCGNPMODE)
  1111. COMPATIBLE_IOCTL(PPPIOCSNPMODE)
  1112. COMPATIBLE_IOCTL(PPPIOCGDEBUG)
  1113. COMPATIBLE_IOCTL(PPPIOCSDEBUG)
  1114. /* PPPIOCSPASS is translated */
  1115. /* PPPIOCSACTIVE is translated */
  1116. /* PPPIOCGIDLE is translated */
  1117. COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
  1118. COMPATIBLE_IOCTL(PPPIOCATTACH)
  1119. COMPATIBLE_IOCTL(PPPIOCDETACH)
  1120. COMPATIBLE_IOCTL(PPPIOCSMRRU)
  1121. COMPATIBLE_IOCTL(PPPIOCCONNECT)
  1122. COMPATIBLE_IOCTL(PPPIOCDISCONN)
  1123. COMPATIBLE_IOCTL(PPPIOCATTCHAN)
  1124. COMPATIBLE_IOCTL(PPPIOCGCHAN)
  1125. /* PPPOX */
  1126. COMPATIBLE_IOCTL(PPPOEIOCSFWD)
  1127. COMPATIBLE_IOCTL(PPPOEIOCDFWD)
  1128. /* LP */
  1129. COMPATIBLE_IOCTL(LPGETSTATUS)
  1130. /* ppdev */
  1131. COMPATIBLE_IOCTL(PPSETMODE)
  1132. COMPATIBLE_IOCTL(PPRSTATUS)
  1133. COMPATIBLE_IOCTL(PPRCONTROL)
  1134. COMPATIBLE_IOCTL(PPWCONTROL)
  1135. COMPATIBLE_IOCTL(PPFCONTROL)
  1136. COMPATIBLE_IOCTL(PPRDATA)
  1137. COMPATIBLE_IOCTL(PPWDATA)
  1138. COMPATIBLE_IOCTL(PPCLAIM)
  1139. COMPATIBLE_IOCTL(PPRELEASE)
  1140. COMPATIBLE_IOCTL(PPYIELD)
  1141. COMPATIBLE_IOCTL(PPEXCL)
  1142. COMPATIBLE_IOCTL(PPDATADIR)
  1143. COMPATIBLE_IOCTL(PPNEGOT)
  1144. COMPATIBLE_IOCTL(PPWCTLONIRQ)
  1145. COMPATIBLE_IOCTL(PPCLRIRQ)
  1146. COMPATIBLE_IOCTL(PPSETPHASE)
  1147. COMPATIBLE_IOCTL(PPGETMODES)
  1148. COMPATIBLE_IOCTL(PPGETMODE)
  1149. COMPATIBLE_IOCTL(PPGETPHASE)
  1150. COMPATIBLE_IOCTL(PPGETFLAGS)
  1151. COMPATIBLE_IOCTL(PPSETFLAGS)
  1152. /* pktcdvd */
  1153. COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
  1154. /* Big A */
  1155. /* sparc only */
  1156. /* Big Q for sound/OSS */
  1157. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
  1158. COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
  1159. COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
  1160. COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
  1161. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
  1162. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
  1163. COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
  1164. COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
  1165. COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
  1166. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
  1167. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
  1168. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
  1169. COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
  1170. COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
  1171. COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
  1172. COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
  1173. COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
  1174. COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
  1175. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
  1176. COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
  1177. COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
  1178. COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
  1179. /* Big T for sound/OSS */
  1180. COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
  1181. COMPATIBLE_IOCTL(SNDCTL_TMR_START)
  1182. COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
  1183. COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
  1184. COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
  1185. COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
  1186. COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
  1187. COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
  1188. /* Little m for sound/OSS */
  1189. COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
  1190. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
  1191. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
  1192. /* Big P for sound/OSS */
  1193. COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
  1194. COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
  1195. COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
  1196. COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
  1197. COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
  1198. COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
  1199. COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
  1200. COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
  1201. COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
  1202. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
  1203. COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
  1204. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
  1205. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
  1206. COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
  1207. COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
  1208. COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
  1209. COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
  1210. COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
  1211. COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
  1212. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
  1213. /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
  1214. /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
  1215. COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
  1216. COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
  1217. COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
  1218. COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
  1219. COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
  1220. COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
  1221. COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
  1222. COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
  1223. /* Big C for sound/OSS */
  1224. COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
  1225. COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
  1226. COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
  1227. COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
  1228. COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
  1229. COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
  1230. COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
  1231. COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
  1232. COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
  1233. COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
  1234. /* Big M for sound/OSS */
  1235. COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
  1236. COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
  1237. COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
  1238. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
  1239. COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
  1240. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
  1241. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
  1242. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
  1243. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
  1244. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
  1245. COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
  1246. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
  1247. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
  1248. COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
  1249. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
  1250. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
  1251. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
  1252. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
  1253. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
  1254. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
  1255. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
  1256. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
  1257. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
  1258. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
  1259. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
  1260. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
  1261. /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
  1262. /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
  1263. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
  1264. COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
  1265. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
  1266. COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
  1267. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
  1268. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
  1269. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
  1270. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
  1271. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
  1272. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
  1273. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
  1274. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
  1275. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
  1276. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
  1277. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
  1278. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
  1279. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
  1280. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
  1281. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
  1282. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
  1283. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
  1284. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
  1285. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
  1286. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
  1287. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
  1288. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
  1289. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
  1290. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
  1291. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
  1292. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
  1293. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
  1294. /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
  1295. /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
  1296. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
  1297. COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
  1298. COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
  1299. COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
  1300. COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
  1301. COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
  1302. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
  1303. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
  1304. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
  1305. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
  1306. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
  1307. COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
  1308. COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
  1309. COMPATIBLE_IOCTL(OSS_GETVERSION)
  1310. /* AUTOFS */
  1311. ULONG_IOCTL(AUTOFS_IOC_READY)
  1312. ULONG_IOCTL(AUTOFS_IOC_FAIL)
  1313. COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
  1314. COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
  1315. COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
  1316. COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
  1317. COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOSUBVER)
  1318. COMPATIBLE_IOCTL(AUTOFS_IOC_ASKUMOUNT)
  1319. /* Raw devices */
  1320. COMPATIBLE_IOCTL(RAW_SETBIND)
  1321. COMPATIBLE_IOCTL(RAW_GETBIND)
  1322. /* SMB ioctls which do not need any translations */
  1323. COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
  1324. /* Watchdog */
  1325. COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
  1326. COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
  1327. COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
  1328. COMPATIBLE_IOCTL(WDIOC_GETTEMP)
  1329. COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
  1330. COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
  1331. COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
  1332. COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
  1333. /* Big R */
  1334. COMPATIBLE_IOCTL(RNDGETENTCNT)
  1335. COMPATIBLE_IOCTL(RNDADDTOENTCNT)
  1336. COMPATIBLE_IOCTL(RNDGETPOOL)
  1337. COMPATIBLE_IOCTL(RNDADDENTROPY)
  1338. COMPATIBLE_IOCTL(RNDZAPENTCNT)
  1339. COMPATIBLE_IOCTL(RNDCLEARPOOL)
  1340. /* Bluetooth */
  1341. COMPATIBLE_IOCTL(HCIDEVUP)
  1342. COMPATIBLE_IOCTL(HCIDEVDOWN)
  1343. COMPATIBLE_IOCTL(HCIDEVRESET)
  1344. COMPATIBLE_IOCTL(HCIDEVRESTAT)
  1345. COMPATIBLE_IOCTL(HCIGETDEVLIST)
  1346. COMPATIBLE_IOCTL(HCIGETDEVINFO)
  1347. COMPATIBLE_IOCTL(HCIGETCONNLIST)
  1348. COMPATIBLE_IOCTL(HCIGETCONNINFO)
  1349. COMPATIBLE_IOCTL(HCIGETAUTHINFO)
  1350. COMPATIBLE_IOCTL(HCISETRAW)
  1351. COMPATIBLE_IOCTL(HCISETSCAN)
  1352. COMPATIBLE_IOCTL(HCISETAUTH)
  1353. COMPATIBLE_IOCTL(HCISETENCRYPT)
  1354. COMPATIBLE_IOCTL(HCISETPTYPE)
  1355. COMPATIBLE_IOCTL(HCISETLINKPOL)
  1356. COMPATIBLE_IOCTL(HCISETLINKMODE)
  1357. COMPATIBLE_IOCTL(HCISETACLMTU)
  1358. COMPATIBLE_IOCTL(HCISETSCOMTU)
  1359. COMPATIBLE_IOCTL(HCIINQUIRY)
  1360. COMPATIBLE_IOCTL(HCIUARTSETPROTO)
  1361. COMPATIBLE_IOCTL(HCIUARTGETPROTO)
  1362. COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
  1363. COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
  1364. COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
  1365. COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
  1366. COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
  1367. COMPATIBLE_IOCTL(BNEPCONNADD)
  1368. COMPATIBLE_IOCTL(BNEPCONNDEL)
  1369. COMPATIBLE_IOCTL(BNEPGETCONNLIST)
  1370. COMPATIBLE_IOCTL(BNEPGETCONNINFO)
  1371. COMPATIBLE_IOCTL(CMTPCONNADD)
  1372. COMPATIBLE_IOCTL(CMTPCONNDEL)
  1373. COMPATIBLE_IOCTL(CMTPGETCONNLIST)
  1374. COMPATIBLE_IOCTL(CMTPGETCONNINFO)
  1375. COMPATIBLE_IOCTL(HIDPCONNADD)
  1376. COMPATIBLE_IOCTL(HIDPCONNDEL)
  1377. COMPATIBLE_IOCTL(HIDPGETCONNLIST)
  1378. COMPATIBLE_IOCTL(HIDPGETCONNINFO)
  1379. /* CAPI */
  1380. COMPATIBLE_IOCTL(CAPI_REGISTER)
  1381. COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
  1382. COMPATIBLE_IOCTL(CAPI_GET_VERSION)
  1383. COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
  1384. COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
  1385. COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
  1386. COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
  1387. COMPATIBLE_IOCTL(CAPI_INSTALLED)
  1388. COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
  1389. COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
  1390. COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
  1391. COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
  1392. COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
  1393. /* Siemens Gigaset */
  1394. COMPATIBLE_IOCTL(GIGASET_REDIR)
  1395. COMPATIBLE_IOCTL(GIGASET_CONFIG)
  1396. COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
  1397. COMPATIBLE_IOCTL(GIGASET_VERSION)
  1398. /* Misc. */
  1399. COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
  1400. COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
  1401. COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
  1402. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
  1403. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
  1404. COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
  1405. /* USB */
  1406. COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
  1407. COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
  1408. COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION)
  1409. COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER)
  1410. COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB)
  1411. COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE)
  1412. COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE)
  1413. COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
  1414. COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
  1415. COMPATIBLE_IOCTL(USBDEVFS_RESET)
  1416. COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
  1417. COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
  1418. COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
  1419. COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
  1420. /* NBD */
  1421. ULONG_IOCTL(NBD_SET_SOCK)
  1422. ULONG_IOCTL(NBD_SET_BLKSIZE)
  1423. ULONG_IOCTL(NBD_SET_SIZE)
  1424. COMPATIBLE_IOCTL(NBD_DO_IT)
  1425. COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
  1426. COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
  1427. COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
  1428. ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
  1429. COMPATIBLE_IOCTL(NBD_DISCONNECT)
  1430. /* i2c */
  1431. COMPATIBLE_IOCTL(I2C_SLAVE)
  1432. COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
  1433. COMPATIBLE_IOCTL(I2C_TENBIT)
  1434. COMPATIBLE_IOCTL(I2C_PEC)
  1435. COMPATIBLE_IOCTL(I2C_RETRIES)
  1436. COMPATIBLE_IOCTL(I2C_TIMEOUT)
  1437. /* hiddev */
  1438. COMPATIBLE_IOCTL(HIDIOCGVERSION)
  1439. COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
  1440. COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
  1441. COMPATIBLE_IOCTL(HIDIOCGSTRING)
  1442. COMPATIBLE_IOCTL(HIDIOCINITREPORT)
  1443. COMPATIBLE_IOCTL(HIDIOCGREPORT)
  1444. COMPATIBLE_IOCTL(HIDIOCSREPORT)
  1445. COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
  1446. COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
  1447. COMPATIBLE_IOCTL(HIDIOCGUSAGE)
  1448. COMPATIBLE_IOCTL(HIDIOCSUSAGE)
  1449. COMPATIBLE_IOCTL(HIDIOCGUCODE)
  1450. COMPATIBLE_IOCTL(HIDIOCGFLAG)
  1451. COMPATIBLE_IOCTL(HIDIOCSFLAG)
  1452. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
  1453. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
  1454. /* dvb */
  1455. COMPATIBLE_IOCTL(AUDIO_STOP)
  1456. COMPATIBLE_IOCTL(AUDIO_PLAY)
  1457. COMPATIBLE_IOCTL(AUDIO_PAUSE)
  1458. COMPATIBLE_IOCTL(AUDIO_CONTINUE)
  1459. COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
  1460. COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
  1461. COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
  1462. COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
  1463. COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
  1464. COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
  1465. COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
  1466. COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
  1467. COMPATIBLE_IOCTL(AUDIO_SET_ID)
  1468. COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
  1469. COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
  1470. COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
  1471. COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
  1472. COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
  1473. COMPATIBLE_IOCTL(DMX_START)
  1474. COMPATIBLE_IOCTL(DMX_STOP)
  1475. COMPATIBLE_IOCTL(DMX_SET_FILTER)
  1476. COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
  1477. COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
  1478. COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
  1479. COMPATIBLE_IOCTL(DMX_GET_CAPS)
  1480. COMPATIBLE_IOCTL(DMX_SET_SOURCE)
  1481. COMPATIBLE_IOCTL(DMX_GET_STC)
  1482. COMPATIBLE_IOCTL(FE_GET_INFO)
  1483. COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
  1484. COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
  1485. COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
  1486. COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
  1487. COMPATIBLE_IOCTL(FE_SET_TONE)
  1488. COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
  1489. COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
  1490. COMPATIBLE_IOCTL(FE_READ_STATUS)
  1491. COMPATIBLE_IOCTL(FE_READ_BER)
  1492. COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
  1493. COMPATIBLE_IOCTL(FE_READ_SNR)
  1494. COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
  1495. COMPATIBLE_IOCTL(FE_SET_FRONTEND)
  1496. COMPATIBLE_IOCTL(FE_GET_FRONTEND)
  1497. COMPATIBLE_IOCTL(FE_GET_EVENT)
  1498. COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
  1499. COMPATIBLE_IOCTL(VIDEO_STOP)
  1500. COMPATIBLE_IOCTL(VIDEO_PLAY)
  1501. COMPATIBLE_IOCTL(VIDEO_FREEZE)
  1502. COMPATIBLE_IOCTL(VIDEO_CONTINUE)
  1503. COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
  1504. COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
  1505. COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
  1506. COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
  1507. COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
  1508. COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
  1509. COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
  1510. COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
  1511. COMPATIBLE_IOCTL(VIDEO_SET_ID)
  1512. COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
  1513. COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
  1514. COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
  1515. COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
  1516. COMPATIBLE_IOCTL(VIDEO_SET_SPU)
  1517. COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
  1518. COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
  1519. COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
  1520. COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
  1521. /* joystick */
  1522. COMPATIBLE_IOCTL(JSIOCGVERSION)
  1523. COMPATIBLE_IOCTL(JSIOCGAXES)
  1524. COMPATIBLE_IOCTL(JSIOCGBUTTONS)
  1525. COMPATIBLE_IOCTL(JSIOCGNAME(0))
  1526. /* now things that need handlers */
  1527. #ifdef CONFIG_BLOCK
  1528. HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
  1529. HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
  1530. #endif
  1531. HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
  1532. HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
  1533. HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
  1534. HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans)
  1535. #ifdef CONFIG_BLOCK
  1536. HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans)
  1537. HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
  1538. #endif
  1539. #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
  1540. HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
  1541. /* One SMB ioctl needs translations. */
  1542. #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
  1543. HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
  1544. /* block stuff */
  1545. #ifdef CONFIG_BLOCK
  1546. /* loop */
  1547. IGNORE_IOCTL(LOOP_CLR_FD)
  1548. /* Raw devices */
  1549. HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
  1550. HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
  1551. #endif
  1552. /* Serial */
  1553. HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
  1554. HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
  1555. #ifdef TIOCGLTC
  1556. COMPATIBLE_IOCTL(TIOCGLTC)
  1557. COMPATIBLE_IOCTL(TIOCSLTC)
  1558. #endif
  1559. #ifdef TIOCSTART
  1560. /*
  1561. * For these two we have definitions in ioctls.h and/or termios.h on
  1562. * some architectures but no actual implemention. Some applications
  1563. * like bash call them if they are defined in the headers, so we provide
  1564. * entries here to avoid syslog message spew.
  1565. */
  1566. COMPATIBLE_IOCTL(TIOCSTART)
  1567. COMPATIBLE_IOCTL(TIOCSTOP)
  1568. #endif
  1569. /* Usbdevfs */
  1570. HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
  1571. HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
  1572. HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
  1573. COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
  1574. /* i2c */
  1575. HANDLE_IOCTL(I2C_FUNCS, w_long)
  1576. HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
  1577. HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
  1578. /* Not implemented in the native kernel */
  1579. HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
  1580. HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
  1581. HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
  1582. HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
  1583. /* dvb */
  1584. HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
  1585. HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
  1586. HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
  1587. /* parport */
  1588. COMPATIBLE_IOCTL(LPTIME)
  1589. COMPATIBLE_IOCTL(LPCHAR)
  1590. COMPATIBLE_IOCTL(LPABORTOPEN)
  1591. COMPATIBLE_IOCTL(LPCAREFUL)
  1592. COMPATIBLE_IOCTL(LPWAIT)
  1593. COMPATIBLE_IOCTL(LPSETIRQ)
  1594. COMPATIBLE_IOCTL(LPGETSTATUS)
  1595. COMPATIBLE_IOCTL(LPGETSTATUS)
  1596. COMPATIBLE_IOCTL(LPRESET)
  1597. /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/
  1598. COMPATIBLE_IOCTL(LPGETFLAGS)
  1599. HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
  1600. /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
  1601. but we don't want warnings on other file systems. So declare
  1602. them as compatible here. */
  1603. #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
  1604. #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
  1605. IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
  1606. IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
  1607. #ifdef CONFIG_SPARC
  1608. /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
  1609. IGNORE_IOCTL(FBIOGTYPE)
  1610. IGNORE_IOCTL(FBIOSATTR)
  1611. IGNORE_IOCTL(FBIOGATTR)
  1612. IGNORE_IOCTL(FBIOSVIDEO)
  1613. IGNORE_IOCTL(FBIOGVIDEO)
  1614. IGNORE_IOCTL(FBIOSCURPOS)
  1615. IGNORE_IOCTL(FBIOGCURPOS)
  1616. IGNORE_IOCTL(FBIOGCURMAX)
  1617. IGNORE_IOCTL(FBIOPUTCMAP32)
  1618. IGNORE_IOCTL(FBIOGETCMAP32)
  1619. IGNORE_IOCTL(FBIOSCURSOR32)
  1620. IGNORE_IOCTL(FBIOGCURSOR32)
  1621. #endif
  1622. };
  1623. #define IOCTL_HASHSIZE 256
  1624. static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
  1625. static inline unsigned long ioctl32_hash(unsigned long cmd)
  1626. {
  1627. return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
  1628. }
  1629. static void compat_ioctl_error(struct file *filp, unsigned int fd,
  1630. unsigned int cmd, unsigned long arg)
  1631. {
  1632. char buf[10];
  1633. char *fn = "?";
  1634. char *path;
  1635. /* find the name of the device. */
  1636. path = (char *)__get_free_page(GFP_KERNEL);
  1637. if (path) {
  1638. fn = d_path(&filp->f_path, path, PAGE_SIZE);
  1639. if (IS_ERR(fn))
  1640. fn = "?";
  1641. }
  1642. sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
  1643. if (!isprint(buf[1]))
  1644. sprintf(buf, "%02x", buf[1]);
  1645. compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
  1646. "cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
  1647. current->comm, current->pid,
  1648. (int)fd, (unsigned int)cmd, buf,
  1649. (cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
  1650. (unsigned int)arg, fn);
  1651. if (path)
  1652. free_page((unsigned long)path);
  1653. }
  1654. asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
  1655. unsigned long arg)
  1656. {
  1657. struct file *filp;
  1658. int error = -EBADF;
  1659. struct ioctl_trans *t;
  1660. int fput_needed;
  1661. filp = fget_light(fd, &fput_needed);
  1662. if (!filp)
  1663. goto out;
  1664. /* RED-PEN how should LSM module know it's handling 32bit? */
  1665. error = security_file_ioctl(filp, cmd, arg);
  1666. if (error)
  1667. goto out_fput;
  1668. /*
  1669. * To allow the compat_ioctl handlers to be self contained
  1670. * we need to check the common ioctls here first.
  1671. * Just handle them with the standard handlers below.
  1672. */
  1673. switch (cmd) {
  1674. case FIOCLEX:
  1675. case FIONCLEX:
  1676. case FIONBIO:
  1677. case FIOASYNC:
  1678. case FIOQSIZE:
  1679. break;
  1680. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  1681. case FS_IOC_RESVSP_32:
  1682. case FS_IOC_RESVSP64_32:
  1683. error = compat_ioctl_preallocate(filp, arg);
  1684. goto out_fput;
  1685. #else
  1686. case FS_IOC_RESVSP:
  1687. case FS_IOC_RESVSP64:
  1688. error = ioctl_preallocate(filp, compat_ptr(arg));
  1689. goto out_fput;
  1690. #endif
  1691. case FIBMAP:
  1692. case FIGETBSZ:
  1693. case FIONREAD:
  1694. if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
  1695. break;
  1696. /*FALL THROUGH*/
  1697. default:
  1698. if (filp->f_op && filp->f_op->compat_ioctl) {
  1699. error = filp->f_op->compat_ioctl(filp, cmd, arg);
  1700. if (error != -ENOIOCTLCMD)
  1701. goto out_fput;
  1702. }
  1703. if (!filp->f_op ||
  1704. (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
  1705. goto do_ioctl;
  1706. break;
  1707. }
  1708. for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
  1709. if (t->cmd == cmd)
  1710. goto found_handler;
  1711. }
  1712. {
  1713. static int count;
  1714. if (++count <= 50)
  1715. compat_ioctl_error(filp, fd, cmd, arg);
  1716. error = -EINVAL;
  1717. }
  1718. goto out_fput;
  1719. found_handler:
  1720. if (t->handler) {
  1721. error = t->handler(fd, cmd, arg, filp);
  1722. goto out_fput;
  1723. }
  1724. do_ioctl:
  1725. error = do_vfs_ioctl(filp, fd, cmd, arg);
  1726. out_fput:
  1727. fput_light(filp, fput_needed);
  1728. out:
  1729. return error;
  1730. }
  1731. static void ioctl32_insert_translation(struct ioctl_trans *trans)
  1732. {
  1733. unsigned long hash;
  1734. struct ioctl_trans *t;
  1735. hash = ioctl32_hash (trans->cmd);
  1736. if (!ioctl32_hash_table[hash])
  1737. ioctl32_hash_table[hash] = trans;
  1738. else {
  1739. t = ioctl32_hash_table[hash];
  1740. while (t->next)
  1741. t = t->next;
  1742. trans->next = NULL;
  1743. t->next = trans;
  1744. }
  1745. }
  1746. static int __init init_sys32_ioctl(void)
  1747. {
  1748. int i;
  1749. for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) {
  1750. if (ioctl_start[i].next) {
  1751. printk("ioctl translation %d bad\n",i);
  1752. return -1;
  1753. }
  1754. ioctl32_insert_translation(&ioctl_start[i]);
  1755. }
  1756. return 0;
  1757. }
  1758. __initcall(init_sys32_ioctl);