osf_sys.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/osf_sys.c
  4. *
  5. * Copyright (C) 1995 Linus Torvalds
  6. */
  7. /*
  8. * This file handles some of the stranger OSF/1 system call interfaces.
  9. * Some of the system calls expect a non-C calling standard, others have
  10. * special parameter blocks..
  11. */
  12. #include <linux/errno.h>
  13. #include <linux/sched/signal.h>
  14. #include <linux/sched/mm.h>
  15. #include <linux/sched/task_stack.h>
  16. #include <linux/sched/cputime.h>
  17. #include <linux/kernel.h>
  18. #include <linux/mm.h>
  19. #include <linux/smp.h>
  20. #include <linux/stddef.h>
  21. #include <linux/syscalls.h>
  22. #include <linux/unistd.h>
  23. #include <linux/ptrace.h>
  24. #include <linux/user.h>
  25. #include <linux/utsname.h>
  26. #include <linux/time.h>
  27. #include <linux/timex.h>
  28. #include <linux/major.h>
  29. #include <linux/stat.h>
  30. #include <linux/mman.h>
  31. #include <linux/shm.h>
  32. #include <linux/poll.h>
  33. #include <linux/file.h>
  34. #include <linux/types.h>
  35. #include <linux/ipc.h>
  36. #include <linux/namei.h>
  37. #include <linux/mount.h>
  38. #include <linux/uio.h>
  39. #include <linux/vfs.h>
  40. #include <linux/rcupdate.h>
  41. #include <linux/slab.h>
  42. #include <asm/fpu.h>
  43. #include <asm/io.h>
  44. #include <linux/uaccess.h>
  45. #include <asm/sysinfo.h>
  46. #include <asm/thread_info.h>
  47. #include <asm/hwrpb.h>
  48. #include <asm/processor.h>
  49. /*
  50. * Brk needs to return an error. Still support Linux's brk(0) query idiom,
  51. * which OSF programs just shouldn't be doing. We're still not quite
  52. * identical to OSF as we don't return 0 on success, but doing otherwise
  53. * would require changes to libc. Hopefully this is good enough.
  54. */
  55. SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
  56. {
  57. unsigned long retval = sys_brk(brk);
  58. if (brk && brk != retval)
  59. retval = -ENOMEM;
  60. return retval;
  61. }
  62. /*
  63. * This is pure guess-work..
  64. */
  65. SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
  66. unsigned long, text_len, unsigned long, bss_start,
  67. unsigned long, bss_len)
  68. {
  69. struct mm_struct *mm;
  70. mm = current->mm;
  71. mm->end_code = bss_start + bss_len;
  72. mm->start_brk = bss_start + bss_len;
  73. mm->brk = bss_start + bss_len;
  74. #if 0
  75. printk("set_program_attributes(%lx %lx %lx %lx)\n",
  76. text_start, text_len, bss_start, bss_len);
  77. #endif
  78. return 0;
  79. }
  80. /*
  81. * OSF/1 directory handling functions...
  82. *
  83. * The "getdents()" interface is much more sane: the "basep" stuff is
  84. * braindamage (it can't really handle filesystems where the directory
  85. * offset differences aren't the same as "d_reclen").
  86. */
  87. #define NAME_OFFSET offsetof (struct osf_dirent, d_name)
  88. struct osf_dirent {
  89. unsigned int d_ino;
  90. unsigned short d_reclen;
  91. unsigned short d_namlen;
  92. char d_name[1];
  93. };
  94. struct osf_dirent_callback {
  95. struct dir_context ctx;
  96. struct osf_dirent __user *dirent;
  97. long __user *basep;
  98. unsigned int count;
  99. int error;
  100. };
  101. static bool
  102. osf_filldir(struct dir_context *ctx, const char *name, int namlen,
  103. loff_t offset, u64 ino, unsigned int d_type)
  104. {
  105. struct osf_dirent __user *dirent;
  106. struct osf_dirent_callback *buf =
  107. container_of(ctx, struct osf_dirent_callback, ctx);
  108. unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
  109. unsigned int d_ino;
  110. buf->error = -EINVAL; /* only used if we fail */
  111. if (reclen > buf->count)
  112. return false;
  113. d_ino = ino;
  114. if (sizeof(d_ino) < sizeof(ino) && d_ino != ino) {
  115. buf->error = -EOVERFLOW;
  116. return false;
  117. }
  118. if (buf->basep) {
  119. if (put_user(offset, buf->basep))
  120. goto Efault;
  121. buf->basep = NULL;
  122. }
  123. dirent = buf->dirent;
  124. if (put_user(d_ino, &dirent->d_ino) ||
  125. put_user(namlen, &dirent->d_namlen) ||
  126. put_user(reclen, &dirent->d_reclen) ||
  127. copy_to_user(dirent->d_name, name, namlen) ||
  128. put_user(0, dirent->d_name + namlen))
  129. goto Efault;
  130. dirent = (void __user *)dirent + reclen;
  131. buf->dirent = dirent;
  132. buf->count -= reclen;
  133. return true;
  134. Efault:
  135. buf->error = -EFAULT;
  136. return false;
  137. }
  138. SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
  139. struct osf_dirent __user *, dirent, unsigned int, count,
  140. long __user *, basep)
  141. {
  142. int error;
  143. struct fd arg = fdget_pos(fd);
  144. struct osf_dirent_callback buf = {
  145. .ctx.actor = osf_filldir,
  146. .dirent = dirent,
  147. .basep = basep,
  148. .count = count
  149. };
  150. if (!arg.file)
  151. return -EBADF;
  152. error = iterate_dir(arg.file, &buf.ctx);
  153. if (error >= 0)
  154. error = buf.error;
  155. if (count != buf.count)
  156. error = count - buf.count;
  157. fdput_pos(arg);
  158. return error;
  159. }
  160. #undef NAME_OFFSET
  161. SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
  162. unsigned long, prot, unsigned long, flags, unsigned long, fd,
  163. unsigned long, off)
  164. {
  165. unsigned long ret = -EINVAL;
  166. #if 0
  167. if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
  168. printk("%s: unimplemented OSF mmap flags %04lx\n",
  169. current->comm, flags);
  170. #endif
  171. if ((off + PAGE_ALIGN(len)) < off)
  172. goto out;
  173. if (off & ~PAGE_MASK)
  174. goto out;
  175. ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
  176. out:
  177. return ret;
  178. }
  179. struct osf_stat {
  180. int st_dev;
  181. int st_pad1;
  182. unsigned st_mode;
  183. unsigned short st_nlink;
  184. short st_nlink_reserved;
  185. unsigned st_uid;
  186. unsigned st_gid;
  187. int st_rdev;
  188. int st_ldev;
  189. long st_size;
  190. int st_pad2;
  191. int st_uatime;
  192. int st_pad3;
  193. int st_umtime;
  194. int st_pad4;
  195. int st_uctime;
  196. int st_pad5;
  197. int st_pad6;
  198. unsigned st_flags;
  199. unsigned st_gen;
  200. long st_spare[4];
  201. unsigned st_ino;
  202. int st_ino_reserved;
  203. int st_atime;
  204. int st_atime_reserved;
  205. int st_mtime;
  206. int st_mtime_reserved;
  207. int st_ctime;
  208. int st_ctime_reserved;
  209. long st_blksize;
  210. long st_blocks;
  211. };
  212. /*
  213. * The OSF/1 statfs structure is much larger, but this should
  214. * match the beginning, at least.
  215. */
  216. struct osf_statfs {
  217. short f_type;
  218. short f_flags;
  219. int f_fsize;
  220. int f_bsize;
  221. int f_blocks;
  222. int f_bfree;
  223. int f_bavail;
  224. int f_files;
  225. int f_ffree;
  226. __kernel_fsid_t f_fsid;
  227. };
  228. struct osf_statfs64 {
  229. short f_type;
  230. short f_flags;
  231. int f_pad1;
  232. int f_pad2;
  233. int f_pad3;
  234. int f_pad4;
  235. int f_pad5;
  236. int f_pad6;
  237. int f_pad7;
  238. __kernel_fsid_t f_fsid;
  239. u_short f_namemax;
  240. short f_reserved1;
  241. int f_spare[8];
  242. char f_pad8[90];
  243. char f_pad9[90];
  244. long mount_info[10];
  245. u_long f_flags2;
  246. long f_spare2[14];
  247. long f_fsize;
  248. long f_bsize;
  249. long f_blocks;
  250. long f_bfree;
  251. long f_bavail;
  252. long f_files;
  253. long f_ffree;
  254. };
  255. static int
  256. linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat)
  257. {
  258. struct osf_stat tmp = { 0 };
  259. tmp.st_dev = lstat->dev;
  260. tmp.st_mode = lstat->mode;
  261. tmp.st_nlink = lstat->nlink;
  262. tmp.st_uid = from_kuid_munged(current_user_ns(), lstat->uid);
  263. tmp.st_gid = from_kgid_munged(current_user_ns(), lstat->gid);
  264. tmp.st_rdev = lstat->rdev;
  265. tmp.st_ldev = lstat->rdev;
  266. tmp.st_size = lstat->size;
  267. tmp.st_uatime = lstat->atime.tv_nsec / 1000;
  268. tmp.st_umtime = lstat->mtime.tv_nsec / 1000;
  269. tmp.st_uctime = lstat->ctime.tv_nsec / 1000;
  270. tmp.st_ino = lstat->ino;
  271. tmp.st_atime = lstat->atime.tv_sec;
  272. tmp.st_mtime = lstat->mtime.tv_sec;
  273. tmp.st_ctime = lstat->ctime.tv_sec;
  274. tmp.st_blksize = lstat->blksize;
  275. tmp.st_blocks = lstat->blocks;
  276. return copy_to_user(osf_stat, &tmp, sizeof(tmp)) ? -EFAULT : 0;
  277. }
  278. static int
  279. linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat,
  280. unsigned long bufsiz)
  281. {
  282. struct osf_statfs tmp_stat;
  283. tmp_stat.f_type = linux_stat->f_type;
  284. tmp_stat.f_flags = 0; /* mount flags */
  285. tmp_stat.f_fsize = linux_stat->f_frsize;
  286. tmp_stat.f_bsize = linux_stat->f_bsize;
  287. tmp_stat.f_blocks = linux_stat->f_blocks;
  288. tmp_stat.f_bfree = linux_stat->f_bfree;
  289. tmp_stat.f_bavail = linux_stat->f_bavail;
  290. tmp_stat.f_files = linux_stat->f_files;
  291. tmp_stat.f_ffree = linux_stat->f_ffree;
  292. tmp_stat.f_fsid = linux_stat->f_fsid;
  293. if (bufsiz > sizeof(tmp_stat))
  294. bufsiz = sizeof(tmp_stat);
  295. return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
  296. }
  297. static int
  298. linux_to_osf_statfs64(struct kstatfs *linux_stat, struct osf_statfs64 __user *osf_stat,
  299. unsigned long bufsiz)
  300. {
  301. struct osf_statfs64 tmp_stat = { 0 };
  302. tmp_stat.f_type = linux_stat->f_type;
  303. tmp_stat.f_fsize = linux_stat->f_frsize;
  304. tmp_stat.f_bsize = linux_stat->f_bsize;
  305. tmp_stat.f_blocks = linux_stat->f_blocks;
  306. tmp_stat.f_bfree = linux_stat->f_bfree;
  307. tmp_stat.f_bavail = linux_stat->f_bavail;
  308. tmp_stat.f_files = linux_stat->f_files;
  309. tmp_stat.f_ffree = linux_stat->f_ffree;
  310. tmp_stat.f_fsid = linux_stat->f_fsid;
  311. if (bufsiz > sizeof(tmp_stat))
  312. bufsiz = sizeof(tmp_stat);
  313. return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
  314. }
  315. SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname,
  316. struct osf_statfs __user *, buffer, unsigned long, bufsiz)
  317. {
  318. struct kstatfs linux_stat;
  319. int error = user_statfs(pathname, &linux_stat);
  320. if (!error)
  321. error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
  322. return error;
  323. }
  324. SYSCALL_DEFINE2(osf_stat, char __user *, name, struct osf_stat __user *, buf)
  325. {
  326. struct kstat stat;
  327. int error;
  328. error = vfs_stat(name, &stat);
  329. if (error)
  330. return error;
  331. return linux_to_osf_stat(&stat, buf);
  332. }
  333. SYSCALL_DEFINE2(osf_lstat, char __user *, name, struct osf_stat __user *, buf)
  334. {
  335. struct kstat stat;
  336. int error;
  337. error = vfs_lstat(name, &stat);
  338. if (error)
  339. return error;
  340. return linux_to_osf_stat(&stat, buf);
  341. }
  342. SYSCALL_DEFINE2(osf_fstat, int, fd, struct osf_stat __user *, buf)
  343. {
  344. struct kstat stat;
  345. int error;
  346. error = vfs_fstat(fd, &stat);
  347. if (error)
  348. return error;
  349. return linux_to_osf_stat(&stat, buf);
  350. }
  351. SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
  352. struct osf_statfs __user *, buffer, unsigned long, bufsiz)
  353. {
  354. struct kstatfs linux_stat;
  355. int error = fd_statfs(fd, &linux_stat);
  356. if (!error)
  357. error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
  358. return error;
  359. }
  360. SYSCALL_DEFINE3(osf_statfs64, char __user *, pathname,
  361. struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
  362. {
  363. struct kstatfs linux_stat;
  364. int error = user_statfs(pathname, &linux_stat);
  365. if (!error)
  366. error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
  367. return error;
  368. }
  369. SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
  370. struct osf_statfs64 __user *, buffer, unsigned long, bufsiz)
  371. {
  372. struct kstatfs linux_stat;
  373. int error = fd_statfs(fd, &linux_stat);
  374. if (!error)
  375. error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz);
  376. return error;
  377. }
  378. /*
  379. * Uhh.. OSF/1 mount parameters aren't exactly obvious..
  380. *
  381. * Although to be frank, neither are the native Linux/i386 ones..
  382. */
  383. struct ufs_args {
  384. char __user *devname;
  385. int flags;
  386. uid_t exroot;
  387. };
  388. struct cdfs_args {
  389. char __user *devname;
  390. int flags;
  391. uid_t exroot;
  392. /* This has lots more here, which Linux handles with the option block
  393. but I'm too lazy to do the translation into ASCII. */
  394. };
  395. struct procfs_args {
  396. char __user *devname;
  397. int flags;
  398. uid_t exroot;
  399. };
  400. /*
  401. * We can't actually handle ufs yet, so we translate UFS mounts to
  402. * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
  403. * layout is so braindead it's a major headache doing it.
  404. *
  405. * Just how long ago was it written? OTOH our UFS driver may be still
  406. * unhappy with OSF UFS. [CHECKME]
  407. */
  408. static int
  409. osf_ufs_mount(const char __user *dirname,
  410. struct ufs_args __user *args, int flags)
  411. {
  412. int retval;
  413. struct cdfs_args tmp;
  414. struct filename *devname;
  415. retval = -EFAULT;
  416. if (copy_from_user(&tmp, args, sizeof(tmp)))
  417. goto out;
  418. devname = getname(tmp.devname);
  419. retval = PTR_ERR(devname);
  420. if (IS_ERR(devname))
  421. goto out;
  422. retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
  423. putname(devname);
  424. out:
  425. return retval;
  426. }
  427. static int
  428. osf_cdfs_mount(const char __user *dirname,
  429. struct cdfs_args __user *args, int flags)
  430. {
  431. int retval;
  432. struct cdfs_args tmp;
  433. struct filename *devname;
  434. retval = -EFAULT;
  435. if (copy_from_user(&tmp, args, sizeof(tmp)))
  436. goto out;
  437. devname = getname(tmp.devname);
  438. retval = PTR_ERR(devname);
  439. if (IS_ERR(devname))
  440. goto out;
  441. retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
  442. putname(devname);
  443. out:
  444. return retval;
  445. }
  446. static int
  447. osf_procfs_mount(const char __user *dirname,
  448. struct procfs_args __user *args, int flags)
  449. {
  450. struct procfs_args tmp;
  451. if (copy_from_user(&tmp, args, sizeof(tmp)))
  452. return -EFAULT;
  453. return do_mount("", dirname, "proc", flags, NULL);
  454. }
  455. SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
  456. int, flag, void __user *, data)
  457. {
  458. int retval;
  459. switch (typenr) {
  460. case 1:
  461. retval = osf_ufs_mount(path, data, flag);
  462. break;
  463. case 6:
  464. retval = osf_cdfs_mount(path, data, flag);
  465. break;
  466. case 9:
  467. retval = osf_procfs_mount(path, data, flag);
  468. break;
  469. default:
  470. retval = -EINVAL;
  471. printk("osf_mount(%ld, %x)\n", typenr, flag);
  472. }
  473. return retval;
  474. }
  475. SYSCALL_DEFINE1(osf_utsname, char __user *, name)
  476. {
  477. char tmp[5 * 32];
  478. down_read(&uts_sem);
  479. memcpy(tmp + 0 * 32, utsname()->sysname, 32);
  480. memcpy(tmp + 1 * 32, utsname()->nodename, 32);
  481. memcpy(tmp + 2 * 32, utsname()->release, 32);
  482. memcpy(tmp + 3 * 32, utsname()->version, 32);
  483. memcpy(tmp + 4 * 32, utsname()->machine, 32);
  484. up_read(&uts_sem);
  485. if (copy_to_user(name, tmp, sizeof(tmp)))
  486. return -EFAULT;
  487. return 0;
  488. }
  489. SYSCALL_DEFINE0(getpagesize)
  490. {
  491. return PAGE_SIZE;
  492. }
  493. SYSCALL_DEFINE0(getdtablesize)
  494. {
  495. return sysctl_nr_open;
  496. }
  497. /*
  498. * For compatibility with OSF/1 only. Use utsname(2) instead.
  499. */
  500. SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
  501. {
  502. int len;
  503. char *kname;
  504. char tmp[32];
  505. if (namelen < 0 || namelen > 32)
  506. namelen = 32;
  507. down_read(&uts_sem);
  508. kname = utsname()->domainname;
  509. len = strnlen(kname, namelen);
  510. len = min(len + 1, namelen);
  511. memcpy(tmp, kname, len);
  512. up_read(&uts_sem);
  513. if (copy_to_user(name, tmp, len))
  514. return -EFAULT;
  515. return 0;
  516. }
  517. /*
  518. * The following stuff should move into a header file should it ever
  519. * be labeled "officially supported." Right now, there is just enough
  520. * support to avoid applications (such as tar) printing error
  521. * messages. The attributes are not really implemented.
  522. */
  523. /*
  524. * Values for Property list entry flag
  525. */
  526. #define PLE_PROPAGATE_ON_COPY 0x1 /* cp(1) will copy entry
  527. by default */
  528. #define PLE_FLAG_MASK 0x1 /* Valid flag values */
  529. #define PLE_FLAG_ALL -1 /* All flag value */
  530. struct proplistname_args {
  531. unsigned int pl_mask;
  532. unsigned int pl_numnames;
  533. char **pl_names;
  534. };
  535. union pl_args {
  536. struct setargs {
  537. char __user *path;
  538. long follow;
  539. long nbytes;
  540. char __user *buf;
  541. } set;
  542. struct fsetargs {
  543. long fd;
  544. long nbytes;
  545. char __user *buf;
  546. } fset;
  547. struct getargs {
  548. char __user *path;
  549. long follow;
  550. struct proplistname_args __user *name_args;
  551. long nbytes;
  552. char __user *buf;
  553. int __user *min_buf_size;
  554. } get;
  555. struct fgetargs {
  556. long fd;
  557. struct proplistname_args __user *name_args;
  558. long nbytes;
  559. char __user *buf;
  560. int __user *min_buf_size;
  561. } fget;
  562. struct delargs {
  563. char __user *path;
  564. long follow;
  565. struct proplistname_args __user *name_args;
  566. } del;
  567. struct fdelargs {
  568. long fd;
  569. struct proplistname_args __user *name_args;
  570. } fdel;
  571. };
  572. enum pl_code {
  573. PL_SET = 1, PL_FSET = 2,
  574. PL_GET = 3, PL_FGET = 4,
  575. PL_DEL = 5, PL_FDEL = 6
  576. };
  577. SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
  578. union pl_args __user *, args)
  579. {
  580. long error;
  581. int __user *min_buf_size_ptr;
  582. switch (code) {
  583. case PL_SET:
  584. if (get_user(error, &args->set.nbytes))
  585. error = -EFAULT;
  586. break;
  587. case PL_FSET:
  588. if (get_user(error, &args->fset.nbytes))
  589. error = -EFAULT;
  590. break;
  591. case PL_GET:
  592. error = get_user(min_buf_size_ptr, &args->get.min_buf_size);
  593. if (error)
  594. break;
  595. error = put_user(0, min_buf_size_ptr);
  596. break;
  597. case PL_FGET:
  598. error = get_user(min_buf_size_ptr, &args->fget.min_buf_size);
  599. if (error)
  600. break;
  601. error = put_user(0, min_buf_size_ptr);
  602. break;
  603. case PL_DEL:
  604. case PL_FDEL:
  605. error = 0;
  606. break;
  607. default:
  608. error = -EOPNOTSUPP;
  609. break;
  610. }
  611. return error;
  612. }
  613. SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
  614. struct sigstack __user *, uoss)
  615. {
  616. unsigned long usp = rdusp();
  617. unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
  618. unsigned long oss_os = on_sig_stack(usp);
  619. int error;
  620. if (uss) {
  621. void __user *ss_sp;
  622. error = -EFAULT;
  623. if (get_user(ss_sp, &uss->ss_sp))
  624. goto out;
  625. /* If the current stack was set with sigaltstack, don't
  626. swap stacks while we are on it. */
  627. error = -EPERM;
  628. if (current->sas_ss_sp && on_sig_stack(usp))
  629. goto out;
  630. /* Since we don't know the extent of the stack, and we don't
  631. track onstack-ness, but rather calculate it, we must
  632. presume a size. Ho hum this interface is lossy. */
  633. current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
  634. current->sas_ss_size = SIGSTKSZ;
  635. }
  636. if (uoss) {
  637. error = -EFAULT;
  638. if (put_user(oss_sp, &uoss->ss_sp) ||
  639. put_user(oss_os, &uoss->ss_onstack))
  640. goto out;
  641. }
  642. error = 0;
  643. out:
  644. return error;
  645. }
  646. SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
  647. {
  648. const char *sysinfo_table[] = {
  649. utsname()->sysname,
  650. utsname()->nodename,
  651. utsname()->release,
  652. utsname()->version,
  653. utsname()->machine,
  654. "alpha", /* instruction set architecture */
  655. "dummy", /* hardware serial number */
  656. "dummy", /* hardware manufacturer */
  657. "dummy", /* secure RPC domain */
  658. };
  659. unsigned long offset;
  660. const char *res;
  661. long len;
  662. char tmp[__NEW_UTS_LEN + 1];
  663. offset = command-1;
  664. if (offset >= ARRAY_SIZE(sysinfo_table)) {
  665. /* Digital UNIX has a few unpublished interfaces here */
  666. printk("sysinfo(%d)", command);
  667. return -EINVAL;
  668. }
  669. down_read(&uts_sem);
  670. res = sysinfo_table[offset];
  671. len = strlen(res)+1;
  672. if ((unsigned long)len > (unsigned long)count)
  673. len = count;
  674. memcpy(tmp, res, len);
  675. up_read(&uts_sem);
  676. if (copy_to_user(buf, tmp, len))
  677. return -EFAULT;
  678. return 0;
  679. }
  680. SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
  681. unsigned long, nbytes, int __user *, start, void __user *, arg)
  682. {
  683. unsigned long w;
  684. struct percpu_struct *cpu;
  685. switch (op) {
  686. case GSI_IEEE_FP_CONTROL:
  687. /* Return current software fp control & status bits. */
  688. /* Note that DU doesn't verify available space here. */
  689. w = current_thread_info()->ieee_state & IEEE_SW_MASK;
  690. w = swcr_update_status(w, rdfpcr());
  691. if (put_user(w, (unsigned long __user *) buffer))
  692. return -EFAULT;
  693. return 0;
  694. case GSI_IEEE_STATE_AT_SIGNAL:
  695. /*
  696. * Not sure anybody will ever use this weird stuff. These
  697. * ops can be used (under OSF/1) to set the fpcr that should
  698. * be used when a signal handler starts executing.
  699. */
  700. break;
  701. case GSI_UACPROC:
  702. if (nbytes < sizeof(unsigned int))
  703. return -EINVAL;
  704. w = current_thread_info()->status & UAC_BITMASK;
  705. if (put_user(w, (unsigned int __user *)buffer))
  706. return -EFAULT;
  707. return 1;
  708. case GSI_PROC_TYPE:
  709. if (nbytes < sizeof(unsigned long))
  710. return -EINVAL;
  711. cpu = (struct percpu_struct*)
  712. ((char*)hwrpb + hwrpb->processor_offset);
  713. w = cpu->type;
  714. if (put_user(w, (unsigned long __user*)buffer))
  715. return -EFAULT;
  716. return 1;
  717. case GSI_GET_HWRPB:
  718. if (nbytes > sizeof(*hwrpb))
  719. return -EINVAL;
  720. if (copy_to_user(buffer, hwrpb, nbytes) != 0)
  721. return -EFAULT;
  722. return 1;
  723. default:
  724. break;
  725. }
  726. return -EOPNOTSUPP;
  727. }
  728. SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
  729. unsigned long, nbytes, int __user *, start, void __user *, arg)
  730. {
  731. switch (op) {
  732. case SSI_IEEE_FP_CONTROL: {
  733. unsigned long swcr, fpcr;
  734. unsigned int *state;
  735. /*
  736. * Alpha Architecture Handbook 4.7.7.3:
  737. * To be fully IEEE compiant, we must track the current IEEE
  738. * exception state in software, because spurious bits can be
  739. * set in the trap shadow of a software-complete insn.
  740. */
  741. if (get_user(swcr, (unsigned long __user *)buffer))
  742. return -EFAULT;
  743. state = &current_thread_info()->ieee_state;
  744. /* Update software trap enable bits. */
  745. *state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK);
  746. /* Update the real fpcr. */
  747. fpcr = rdfpcr() & FPCR_DYN_MASK;
  748. fpcr |= ieee_swcr_to_fpcr(swcr);
  749. wrfpcr(fpcr);
  750. return 0;
  751. }
  752. case SSI_IEEE_RAISE_EXCEPTION: {
  753. unsigned long exc, swcr, fpcr, fex;
  754. unsigned int *state;
  755. if (get_user(exc, (unsigned long __user *)buffer))
  756. return -EFAULT;
  757. state = &current_thread_info()->ieee_state;
  758. exc &= IEEE_STATUS_MASK;
  759. /* Update software trap enable bits. */
  760. swcr = (*state & IEEE_SW_MASK) | exc;
  761. *state |= exc;
  762. /* Update the real fpcr. */
  763. fpcr = rdfpcr();
  764. fpcr |= ieee_swcr_to_fpcr(swcr);
  765. wrfpcr(fpcr);
  766. /* If any exceptions set by this call, and are unmasked,
  767. send a signal. Old exceptions are not signaled. */
  768. fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
  769. if (fex) {
  770. int si_code = FPE_FLTUNK;
  771. if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
  772. if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
  773. if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND;
  774. if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF;
  775. if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
  776. if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
  777. send_sig_fault_trapno(SIGFPE, si_code,
  778. (void __user *)NULL, /* FIXME */
  779. 0, current);
  780. }
  781. return 0;
  782. }
  783. case SSI_IEEE_STATE_AT_SIGNAL:
  784. case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
  785. /*
  786. * Not sure anybody will ever use this weird stuff. These
  787. * ops can be used (under OSF/1) to set the fpcr that should
  788. * be used when a signal handler starts executing.
  789. */
  790. break;
  791. case SSI_NVPAIRS: {
  792. unsigned __user *p = buffer;
  793. unsigned i;
  794. for (i = 0, p = buffer; i < nbytes; ++i, p += 2) {
  795. unsigned v, w, status;
  796. if (get_user(v, p) || get_user(w, p + 1))
  797. return -EFAULT;
  798. switch (v) {
  799. case SSIN_UACPROC:
  800. w &= UAC_BITMASK;
  801. status = current_thread_info()->status;
  802. status = (status & ~UAC_BITMASK) | w;
  803. current_thread_info()->status = status;
  804. break;
  805. default:
  806. return -EOPNOTSUPP;
  807. }
  808. }
  809. return 0;
  810. }
  811. case SSI_LMF:
  812. return 0;
  813. default:
  814. break;
  815. }
  816. return -EOPNOTSUPP;
  817. }
  818. /* Translations due to the fact that OSF's time_t is an int. Which
  819. affects all sorts of things, like timeval and itimerval. */
  820. extern struct timezone sys_tz;
  821. struct timeval32
  822. {
  823. int tv_sec, tv_usec;
  824. };
  825. struct itimerval32
  826. {
  827. struct timeval32 it_interval;
  828. struct timeval32 it_value;
  829. };
  830. static inline long
  831. get_tv32(struct timespec64 *o, struct timeval32 __user *i)
  832. {
  833. struct timeval32 tv;
  834. if (copy_from_user(&tv, i, sizeof(struct timeval32)))
  835. return -EFAULT;
  836. o->tv_sec = tv.tv_sec;
  837. o->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
  838. return 0;
  839. }
  840. static inline long
  841. put_tv32(struct timeval32 __user *o, struct timespec64 *i)
  842. {
  843. return copy_to_user(o, &(struct timeval32){
  844. .tv_sec = i->tv_sec,
  845. .tv_usec = i->tv_nsec / NSEC_PER_USEC},
  846. sizeof(struct timeval32));
  847. }
  848. static inline long
  849. put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
  850. {
  851. return copy_to_user(o, &(struct timeval32){
  852. .tv_sec = i->tv_sec,
  853. .tv_usec = i->tv_usec},
  854. sizeof(struct timeval32));
  855. }
  856. static inline void
  857. jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
  858. {
  859. value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
  860. value->tv_sec = jiffies / HZ;
  861. }
  862. SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
  863. struct timezone __user *, tz)
  864. {
  865. if (tv) {
  866. struct timespec64 kts;
  867. ktime_get_real_ts64(&kts);
  868. if (put_tv32(tv, &kts))
  869. return -EFAULT;
  870. }
  871. if (tz) {
  872. if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
  873. return -EFAULT;
  874. }
  875. return 0;
  876. }
  877. SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
  878. struct timezone __user *, tz)
  879. {
  880. struct timespec64 kts;
  881. struct timezone ktz;
  882. if (tv) {
  883. if (get_tv32(&kts, tv))
  884. return -EFAULT;
  885. }
  886. if (tz) {
  887. if (copy_from_user(&ktz, tz, sizeof(*tz)))
  888. return -EFAULT;
  889. }
  890. return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL);
  891. }
  892. asmlinkage long sys_ni_posix_timers(void);
  893. SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
  894. struct timeval32 __user *, tvs)
  895. {
  896. struct timespec64 tv[2];
  897. if (tvs) {
  898. if (get_tv32(&tv[0], &tvs[0]) ||
  899. get_tv32(&tv[1], &tvs[1]))
  900. return -EFAULT;
  901. if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 ||
  902. tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000)
  903. return -EINVAL;
  904. }
  905. return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
  906. }
  907. SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
  908. fd_set __user *, exp, struct timeval32 __user *, tvp)
  909. {
  910. struct timespec64 end_time, *to = NULL;
  911. if (tvp) {
  912. struct timespec64 tv;
  913. to = &end_time;
  914. if (get_tv32(&tv, tvp))
  915. return -EFAULT;
  916. if (tv.tv_sec < 0 || tv.tv_nsec < 0)
  917. return -EINVAL;
  918. if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec))
  919. return -EINVAL;
  920. }
  921. /* OSF does not copy back the remaining time. */
  922. return core_sys_select(n, inp, outp, exp, to);
  923. }
  924. struct rusage32 {
  925. struct timeval32 ru_utime; /* user time used */
  926. struct timeval32 ru_stime; /* system time used */
  927. long ru_maxrss; /* maximum resident set size */
  928. long ru_ixrss; /* integral shared memory size */
  929. long ru_idrss; /* integral unshared data size */
  930. long ru_isrss; /* integral unshared stack size */
  931. long ru_minflt; /* page reclaims */
  932. long ru_majflt; /* page faults */
  933. long ru_nswap; /* swaps */
  934. long ru_inblock; /* block input operations */
  935. long ru_oublock; /* block output operations */
  936. long ru_msgsnd; /* messages sent */
  937. long ru_msgrcv; /* messages received */
  938. long ru_nsignals; /* signals received */
  939. long ru_nvcsw; /* voluntary context switches */
  940. long ru_nivcsw; /* involuntary " */
  941. };
  942. SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
  943. {
  944. struct rusage32 r;
  945. u64 utime, stime;
  946. unsigned long utime_jiffies, stime_jiffies;
  947. if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
  948. return -EINVAL;
  949. memset(&r, 0, sizeof(r));
  950. switch (who) {
  951. case RUSAGE_SELF:
  952. task_cputime(current, &utime, &stime);
  953. utime_jiffies = nsecs_to_jiffies(utime);
  954. stime_jiffies = nsecs_to_jiffies(stime);
  955. jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
  956. jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
  957. r.ru_minflt = current->min_flt;
  958. r.ru_majflt = current->maj_flt;
  959. break;
  960. case RUSAGE_CHILDREN:
  961. utime_jiffies = nsecs_to_jiffies(current->signal->cutime);
  962. stime_jiffies = nsecs_to_jiffies(current->signal->cstime);
  963. jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
  964. jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
  965. r.ru_minflt = current->signal->cmin_flt;
  966. r.ru_majflt = current->signal->cmaj_flt;
  967. break;
  968. }
  969. return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
  970. }
  971. SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
  972. struct rusage32 __user *, ur)
  973. {
  974. struct rusage r;
  975. long err = kernel_wait4(pid, ustatus, options, &r);
  976. if (err <= 0)
  977. return err;
  978. if (!ur)
  979. return err;
  980. if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
  981. return -EFAULT;
  982. if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime))
  983. return -EFAULT;
  984. if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss,
  985. sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss)))
  986. return -EFAULT;
  987. return err;
  988. }
  989. /*
  990. * I don't know what the parameters are: the first one
  991. * seems to be a timeval pointer, and I suspect the second
  992. * one is the time remaining.. Ho humm.. No documentation.
  993. */
  994. SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
  995. struct timeval32 __user *, remain)
  996. {
  997. struct timespec64 tmp;
  998. unsigned long ticks;
  999. if (get_tv32(&tmp, sleep))
  1000. goto fault;
  1001. ticks = timespec64_to_jiffies(&tmp);
  1002. ticks = schedule_timeout_interruptible(ticks);
  1003. if (remain) {
  1004. jiffies_to_timespec64(ticks, &tmp);
  1005. if (put_tv32(remain, &tmp))
  1006. goto fault;
  1007. }
  1008. return 0;
  1009. fault:
  1010. return -EFAULT;
  1011. }
  1012. struct timex32 {
  1013. unsigned int modes; /* mode selector */
  1014. long offset; /* time offset (usec) */
  1015. long freq; /* frequency offset (scaled ppm) */
  1016. long maxerror; /* maximum error (usec) */
  1017. long esterror; /* estimated error (usec) */
  1018. int status; /* clock command/status */
  1019. long constant; /* pll time constant */
  1020. long precision; /* clock precision (usec) (read only) */
  1021. long tolerance; /* clock frequency tolerance (ppm)
  1022. * (read only)
  1023. */
  1024. struct timeval32 time; /* (read only) */
  1025. long tick; /* (modified) usecs between clock ticks */
  1026. long ppsfreq; /* pps frequency (scaled ppm) (ro) */
  1027. long jitter; /* pps jitter (us) (ro) */
  1028. int shift; /* interval duration (s) (shift) (ro) */
  1029. long stabil; /* pps stability (scaled ppm) (ro) */
  1030. long jitcnt; /* jitter limit exceeded (ro) */
  1031. long calcnt; /* calibration intervals (ro) */
  1032. long errcnt; /* calibration errors (ro) */
  1033. long stbcnt; /* stability limit exceeded (ro) */
  1034. int :32; int :32; int :32; int :32;
  1035. int :32; int :32; int :32; int :32;
  1036. int :32; int :32; int :32; int :32;
  1037. };
  1038. SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
  1039. {
  1040. struct __kernel_timex txc;
  1041. int ret;
  1042. /* copy relevant bits of struct timex. */
  1043. if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
  1044. copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) -
  1045. offsetof(struct timex32, tick)))
  1046. return -EFAULT;
  1047. ret = do_adjtimex(&txc);
  1048. if (ret < 0)
  1049. return ret;
  1050. /* copy back to timex32 */
  1051. if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
  1052. (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
  1053. offsetof(struct timex32, tick))) ||
  1054. (put_user(txc.time.tv_sec, &txc_p->time.tv_sec)) ||
  1055. (put_user(txc.time.tv_usec, &txc_p->time.tv_usec)))
  1056. return -EFAULT;
  1057. return ret;
  1058. }
  1059. /* Get an address range which is currently unmapped. Similar to the
  1060. generic version except that we know how to honor ADDR_LIMIT_32BIT. */
  1061. static unsigned long
  1062. arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
  1063. unsigned long limit)
  1064. {
  1065. struct vm_unmapped_area_info info;
  1066. info.flags = 0;
  1067. info.length = len;
  1068. info.low_limit = addr;
  1069. info.high_limit = limit;
  1070. info.align_mask = 0;
  1071. info.align_offset = 0;
  1072. return vm_unmapped_area(&info);
  1073. }
  1074. unsigned long
  1075. arch_get_unmapped_area(struct file *filp, unsigned long addr,
  1076. unsigned long len, unsigned long pgoff,
  1077. unsigned long flags)
  1078. {
  1079. unsigned long limit;
  1080. /* "32 bit" actually means 31 bit, since pointers sign extend. */
  1081. if (current->personality & ADDR_LIMIT_32BIT)
  1082. limit = 0x80000000;
  1083. else
  1084. limit = TASK_SIZE;
  1085. if (len > limit)
  1086. return -ENOMEM;
  1087. if (flags & MAP_FIXED)
  1088. return addr;
  1089. /* First, see if the given suggestion fits.
  1090. The OSF/1 loader (/sbin/loader) relies on us returning an
  1091. address larger than the requested if one exists, which is
  1092. a terribly broken way to program.
  1093. That said, I can see the use in being able to suggest not
  1094. merely specific addresses, but regions of memory -- perhaps
  1095. this feature should be incorporated into all ports? */
  1096. if (addr) {
  1097. addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
  1098. if (addr != (unsigned long) -ENOMEM)
  1099. return addr;
  1100. }
  1101. /* Next, try allocating at TASK_UNMAPPED_BASE. */
  1102. addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
  1103. len, limit);
  1104. if (addr != (unsigned long) -ENOMEM)
  1105. return addr;
  1106. /* Finally, try allocating in low memory. */
  1107. addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
  1108. return addr;
  1109. }
  1110. SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
  1111. {
  1112. int prio = sys_getpriority(which, who);
  1113. if (prio >= 0) {
  1114. /* Return value is the unbiased priority, i.e. 20 - prio.
  1115. This does result in negative return values, so signal
  1116. no error */
  1117. force_successful_syscall_return();
  1118. prio = 20 - prio;
  1119. }
  1120. return prio;
  1121. }
  1122. SYSCALL_DEFINE0(getxuid)
  1123. {
  1124. current_pt_regs()->r20 = sys_geteuid();
  1125. return sys_getuid();
  1126. }
  1127. SYSCALL_DEFINE0(getxgid)
  1128. {
  1129. current_pt_regs()->r20 = sys_getegid();
  1130. return sys_getgid();
  1131. }
  1132. SYSCALL_DEFINE0(getxpid)
  1133. {
  1134. current_pt_regs()->r20 = sys_getppid();
  1135. return sys_getpid();
  1136. }
  1137. SYSCALL_DEFINE0(alpha_pipe)
  1138. {
  1139. int fd[2];
  1140. int res = do_pipe_flags(fd, 0);
  1141. if (!res) {
  1142. /* The return values are in $0 and $20. */
  1143. current_pt_regs()->r20 = fd[1];
  1144. res = fd[0];
  1145. }
  1146. return res;
  1147. }
  1148. SYSCALL_DEFINE1(sethae, unsigned long, val)
  1149. {
  1150. current_pt_regs()->hae = val;
  1151. return 0;
  1152. }