compat_ioctl.c 45 KB

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