Annotation of sys/compat/hpux/hpux_file.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: hpux_file.c,v 1.18 2007/03/15 10:22:30 art Exp $ */
! 2: /* $NetBSD: hpux_file.c,v 1.5 1997/04/27 21:40:48 thorpej Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1995, 1997 Jason R. Thorpe. All rights reserved.
! 6: * Copyright (c) 1988 University of Utah.
! 7: * Copyright (c) 1990, 1993
! 8: * The Regents of the University of California. All rights reserved.
! 9: *
! 10: * This code is derived from software contributed to Berkeley by
! 11: * the Systems Programming Group of the University of Utah Computer
! 12: * Science Department.
! 13: *
! 14: * Redistribution and use in source and binary forms, with or without
! 15: * modification, are permitted provided that the following conditions
! 16: * are met:
! 17: * 1. Redistributions of source code must retain the above copyright
! 18: * notice, this list of conditions and the following disclaimer.
! 19: * 2. Redistributions in binary form must reproduce the above copyright
! 20: * notice, this list of conditions and the following disclaimer in the
! 21: * documentation and/or other materials provided with the distribution.
! 22: * 3. Neither the name of the University nor the names of its contributors
! 23: * may be used to endorse or promote products derived from this software
! 24: * without specific prior written permission.
! 25: *
! 26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 36: * SUCH DAMAGE.
! 37: *
! 38: * from: Utah $Hdr: hpux_compat.c 1.64 93/08/05$
! 39: *
! 40: * @(#)hpux_compat.c 8.4 (Berkeley) 2/13/94
! 41: */
! 42:
! 43: /*
! 44: * File-related routines for HP-UX binary compatibility. Partially
! 45: * modeled after sys/compat/linux/linux_file.c
! 46: */
! 47:
! 48: #include <sys/param.h>
! 49: #include <sys/systm.h>
! 50: #include <sys/signalvar.h>
! 51: #include <sys/kernel.h>
! 52: #include <sys/filedesc.h>
! 53: #include <sys/proc.h>
! 54: #include <sys/buf.h>
! 55: #include <sys/wait.h>
! 56: #include <sys/file.h>
! 57: #include <sys/namei.h>
! 58: #include <sys/vnode.h>
! 59: #include <sys/ioctl.h>
! 60: #include <sys/ptrace.h>
! 61: #include <sys/stat.h>
! 62: #include <sys/syslog.h>
! 63: #include <sys/malloc.h>
! 64: #include <sys/mount.h>
! 65: #include <sys/ipc.h>
! 66: #include <sys/user.h>
! 67: #include <sys/mman.h>
! 68:
! 69: #include <machine/cpu.h>
! 70: #include <machine/reg.h>
! 71: #include <machine/psl.h>
! 72: #include <machine/vmparam.h>
! 73:
! 74: #include <sys/syscallargs.h>
! 75:
! 76: #include <compat/hpux/hpux.h>
! 77: #include <compat/hpux/hpux_util.h>
! 78: #include <compat/hpux/hpux_termio.h>
! 79: #include <compat/hpux/hpux_syscall.h>
! 80: #include <compat/hpux/hpux_syscallargs.h>
! 81:
! 82: #include <machine/hpux_machdep.h>
! 83:
! 84: int hpux_stat1(struct proc *, void *, register_t *, int);
! 85: void bsd_to_hpux_stat(struct stat *, struct hpux_stat *);
! 86: void bsd_to_hpux_ostat(struct stat *, struct hpux_ostat *);
! 87:
! 88: /*
! 89: * HP-UX creat(2) system call.
! 90: *
! 91: * Just call open(2) with the TRUNC, CREAT and WRONLY flags.
! 92: */
! 93: int
! 94: hpux_sys_creat(p, v, retval)
! 95: struct proc *p;
! 96: void *v;
! 97: register_t *retval;
! 98: {
! 99: struct hpux_sys_creat_args /* {
! 100: syscallarg(char *) path;
! 101: syscallarg(int) mode;
! 102: } */ *uap = v;
! 103:
! 104: struct sys_open_args oa;
! 105: caddr_t sg;
! 106:
! 107: sg = stackgap_init(p->p_emul);
! 108: HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
! 109:
! 110: SCARG(&oa, path) = SCARG(uap, path);
! 111: SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
! 112: SCARG(&oa, mode) = SCARG(uap, mode);
! 113:
! 114: return sys_open(p, &oa, retval);
! 115: }
! 116:
! 117: /*
! 118: * HP-UX open(2) system call.
! 119: *
! 120: * We need to remap some of the bits in the mode mask:
! 121: *
! 122: * - O_CREAT, O_TRUNC, and O_EXCL must me remapped.
! 123: * - O_NONBLOCK is remapped and remembered.
! 124: * - O_FNDELAY is remembered.
! 125: * - O_SYNCIO is removed entirely.
! 126: */
! 127: int
! 128: hpux_sys_open(p, v, retval)
! 129: struct proc *p;
! 130: void *v;
! 131: register_t *retval;
! 132: {
! 133: struct hpux_sys_open_args /* {
! 134: syscallarg(char *) path;
! 135: syscallarg(int) flags;
! 136: syscallarg(int) mode;
! 137: } */ *uap = v;
! 138: struct sys_open_args oa;
! 139: int flags, nflags, error;
! 140: caddr_t sg;
! 141:
! 142: sg = stackgap_init(p->p_emul);
! 143:
! 144: /*
! 145: * Deal with the mode flags first, since they will affect
! 146: * how we check for the alternate path.
! 147: */
! 148: flags = SCARG(uap, flags);
! 149: nflags =
! 150: flags & ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFEXCL|HPUXFTRUNC|HPUXFCREAT);
! 151: if (flags & HPUXFCREAT) {
! 152: /*
! 153: * Simulate the pre-NFS behavior that opening a
! 154: * file for READ+CREATE ignores the CREATE (unless
! 155: * EXCL is set in which case we will return the
! 156: * proper error).
! 157: */
! 158: if ((flags & HPUXFEXCL) || (FFLAGS(flags) & FWRITE))
! 159: nflags |= O_CREAT;
! 160: }
! 161: if (flags & HPUXFTRUNC)
! 162: nflags |= O_TRUNC;
! 163: if (flags & HPUXFEXCL)
! 164: nflags |= O_EXCL;
! 165: if (flags & HPUXNONBLOCK)
! 166: nflags |= O_NDELAY;
! 167:
! 168: /*
! 169: * Do the alternate pathname check.
! 170: */
! 171: if (SCARG(&oa, flags) & O_CREAT)
! 172: HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
! 173: else
! 174: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 175:
! 176: /*
! 177: * Fill in the new arguments and call the NetBSD open(2).
! 178: */
! 179: SCARG(&oa, path) = SCARG(uap, path);
! 180: SCARG(&oa, flags) = nflags;
! 181: SCARG(&oa, mode) = SCARG(uap, mode);
! 182:
! 183: error = sys_open(p, &oa, retval);
! 184:
! 185: /*
! 186: * Record non-blocking mode for fcntl, read, write, etc.
! 187: */
! 188: if ((error == 0) && (nflags & O_NDELAY))
! 189: p->p_fd->fd_ofileflags[*retval] |=
! 190: (flags & HPUXNONBLOCK) ?
! 191: HPUX_UF_NONBLOCK_ON : HPUX_UF_FNDELAY_ON;
! 192:
! 193: return (error);
! 194: }
! 195:
! 196: /*
! 197: * HP-UX fcntl(2) system call.
! 198: */
! 199: int
! 200: hpux_sys_fcntl(p, v, retval)
! 201: struct proc *p;
! 202: void *v;
! 203: register_t *retval;
! 204: {
! 205: struct hpux_sys_fcntl_args /* {
! 206: syscallarg(int) fd;
! 207: syscallarg(int) cmd;
! 208: syscallarg(int) arg;
! 209: } */ *uap = v;
! 210: int arg, mode, error, flg = F_POSIX;
! 211: struct file *fp;
! 212: char *pop;
! 213: struct hpux_flock hfl;
! 214: struct flock fl;
! 215: struct vnode *vp;
! 216: struct sys_fcntl_args fa;
! 217: struct filedesc *fdp = p->p_fd;
! 218:
! 219: if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
! 220: return (EBADF);
! 221: FREF(fp);
! 222:
! 223: pop = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
! 224: arg = SCARG(uap, arg);
! 225:
! 226: switch (SCARG(uap, cmd)) {
! 227: case F_SETFL:
! 228: if (arg & HPUXNONBLOCK)
! 229: *pop |= HPUX_UF_NONBLOCK_ON;
! 230: else
! 231: *pop &= ~HPUX_UF_NONBLOCK_ON;
! 232:
! 233: if (arg & HPUXNDELAY)
! 234: *pop |= HPUX_UF_FNDELAY_ON;
! 235: else
! 236: *pop &= ~HPUX_UF_FNDELAY_ON;
! 237:
! 238: if (*pop & (HPUX_UF_NONBLOCK_ON|HPUX_UF_FNDELAY_ON|HPUX_UF_FIONBIO_ON))
! 239: arg |= FNONBLOCK;
! 240: else
! 241: arg &= ~FNONBLOCK;
! 242:
! 243: arg &= ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFREMOTE);
! 244: break;
! 245:
! 246: case F_GETFL:
! 247: case F_DUPFD:
! 248: case F_GETFD:
! 249: case F_SETFD:
! 250: break;
! 251:
! 252: case HPUXF_SETLKW:
! 253: flg |= F_WAIT;
! 254: /* Fall into F_SETLK */
! 255:
! 256: case HPUXF_SETLK:
! 257: if (fp->f_type != DTYPE_VNODE) {
! 258: error = EBADF;
! 259: goto out;
! 260: }
! 261:
! 262: vp = (struct vnode *)fp->f_data;
! 263:
! 264: /* Copy in the lock structure */
! 265: error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
! 266: sizeof (hfl));
! 267: if (error)
! 268: goto out;
! 269:
! 270: fl.l_start = hfl.hl_start;
! 271: fl.l_len = hfl.hl_len;
! 272: fl.l_pid = hfl.hl_pid;
! 273: fl.l_type = hfl.hl_type;
! 274: fl.l_whence = hfl.hl_whence;
! 275: if (fl.l_whence == SEEK_CUR)
! 276: fl.l_start += fp->f_offset;
! 277:
! 278: switch (fl.l_type) {
! 279: case F_RDLCK:
! 280: if ((fp->f_flag & FREAD) == 0) {
! 281: error = EBADF;
! 282: goto out;
! 283: }
! 284:
! 285: atomic_setbits_int(&p->p_flag, P_ADVLOCK);
! 286: error = VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg);
! 287: goto out;
! 288:
! 289: case F_WRLCK:
! 290: if ((fp->f_flag & FWRITE) == 0) {
! 291: error = EBADF;
! 292: goto out;
! 293: }
! 294: atomic_setbits_int(&p->p_flag, P_ADVLOCK);
! 295: error = VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg);
! 296: goto out;
! 297:
! 298: case F_UNLCK:
! 299: error = VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl,
! 300: F_POSIX);
! 301: goto out;
! 302:
! 303: default:
! 304: error = EINVAL;
! 305: goto out;
! 306: }
! 307: /* NOTREACHED */
! 308:
! 309: case F_GETLK:
! 310: if (fp->f_type != DTYPE_VNODE) {
! 311: error = EBADF;
! 312: goto out;
! 313: }
! 314:
! 315: vp = (struct vnode *)fp->f_data;
! 316:
! 317: /* Copy in the lock structure */
! 318: error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
! 319: sizeof (hfl));
! 320: if (error)
! 321: goto out;
! 322:
! 323: fl.l_start = hfl.hl_start;
! 324: fl.l_len = hfl.hl_len;
! 325: fl.l_pid = hfl.hl_pid;
! 326: fl.l_type = hfl.hl_type;
! 327: fl.l_whence = hfl.hl_whence;
! 328: if (fl.l_whence == SEEK_CUR)
! 329: fl.l_start += fp->f_offset;
! 330:
! 331: if ((error =
! 332: VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX)))
! 333: goto out;
! 334:
! 335: hfl.hl_start = fl.l_start;
! 336: hfl.hl_len = fl.l_len;
! 337: hfl.hl_pid = fl.l_pid;
! 338: hfl.hl_type = fl.l_type;
! 339: hfl.hl_whence = fl.l_whence;
! 340: error = copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg),
! 341: sizeof (hfl));
! 342: goto out;
! 343:
! 344: default:
! 345: error = EINVAL;
! 346: goto out;
! 347: }
! 348:
! 349: /*
! 350: * Pass whatever's left on to the NetBSD fcntl(2).
! 351: */
! 352: SCARG(&fa, fd) = SCARG(uap, fd);
! 353: SCARG(&fa, cmd) = SCARG(uap, cmd);
! 354: SCARG(&fa, arg) = (void *)arg;
! 355:
! 356: error = sys_fcntl(p, &fa, retval);
! 357:
! 358: if ((error == 0) && (SCARG(&fa, cmd) == F_GETFL)) {
! 359: mode = *retval;
! 360: *retval &= ~(O_CREAT|O_TRUNC|O_EXCL);
! 361: if (mode & FNONBLOCK) {
! 362: if (*pop & HPUX_UF_NONBLOCK_ON)
! 363: *retval |= HPUXNONBLOCK;
! 364:
! 365: if ((*pop & HPUX_UF_FNDELAY_ON) == 0)
! 366: *retval &= ~HPUXNDELAY;
! 367: }
! 368: if (mode & O_CREAT)
! 369: *retval |= HPUXFCREAT;
! 370:
! 371: if (mode & O_TRUNC)
! 372: *retval |= HPUXFTRUNC;
! 373:
! 374: if (mode & O_EXCL)
! 375: *retval |= HPUXFEXCL;
! 376: }
! 377: out:
! 378: FRELE(fp);
! 379: return (error);
! 380: }
! 381:
! 382: /*
! 383: * HP-UX fstat(2) system call.
! 384: */
! 385: int
! 386: hpux_sys_fstat(p, v, retval)
! 387: struct proc *p;
! 388: void *v;
! 389: register_t *retval;
! 390: {
! 391: struct hpux_sys_fstat_args /* {
! 392: syscallarg(int) fd;
! 393: syscallarg(struct hpux_stat *) sb;
! 394: } */ *uap = v;
! 395: struct sys_fstat_args fsa;
! 396: struct hpux_stat tmphst;
! 397: struct stat *st, tmpst;
! 398: caddr_t sg;
! 399: int error;
! 400:
! 401: sg = stackgap_init(p->p_emul);
! 402:
! 403: st = stackgap_alloc(&sg, sizeof (struct stat));
! 404:
! 405: SCARG(&fsa, fd) = SCARG(uap, fd);
! 406: SCARG(&fsa, sb) = st;
! 407:
! 408: if ((error = sys_fstat(p, &fsa, retval)))
! 409: return (error);
! 410:
! 411: if ((error = copyin(st, &tmpst, sizeof(tmpst))))
! 412: return (error);
! 413:
! 414: bsd_to_hpux_stat(&tmpst, &tmphst);
! 415:
! 416: return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_stat)));
! 417: }
! 418:
! 419: /*
! 420: * HP-UX stat(2) system call.
! 421: */
! 422: int
! 423: hpux_sys_stat(p, v, retval)
! 424: struct proc *p;
! 425: void *v;
! 426: register_t *retval;
! 427: {
! 428:
! 429: return (hpux_stat1(p, v, retval, 0));
! 430: }
! 431:
! 432: /*
! 433: * HP-UX lstat(2) system call.
! 434: */
! 435: int
! 436: hpux_sys_lstat(p, v, retval)
! 437: struct proc *p;
! 438: void *v;
! 439: register_t *retval;
! 440: {
! 441:
! 442: return (hpux_stat1(p, v, retval, 1));
! 443: }
! 444:
! 445: /*
! 446: * Do the meat of stat(2) and lstat(2).
! 447: */
! 448: int
! 449: hpux_stat1(p, v, retval, dolstat)
! 450: struct proc *p;
! 451: void *v;
! 452: register_t *retval;
! 453: int dolstat;
! 454: {
! 455: struct hpux_sys_stat_args /* {
! 456: syscallarg(char *) path;
! 457: syscallarg(struct hpux_stat *) sb;
! 458: } */ *uap = v;
! 459: struct sys_stat_args sa;
! 460: struct hpux_stat tmphst;
! 461: struct stat *st, tmpst;
! 462: caddr_t sg;
! 463: int error;
! 464:
! 465: sg = stackgap_init(p->p_emul);
! 466:
! 467: st = stackgap_alloc(&sg, sizeof (struct stat));
! 468: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 469:
! 470: SCARG(&sa, ub) = st;
! 471: SCARG(&sa, path) = SCARG(uap, path);
! 472:
! 473: if (dolstat)
! 474: error = sys_lstat(p, &sa, retval);
! 475: else
! 476: error = sys_stat(p, &sa, retval);
! 477:
! 478: if (error)
! 479: return (error);
! 480:
! 481: if ((error = copyin(st, &tmpst, sizeof(tmpst))))
! 482: return (error);
! 483:
! 484: bsd_to_hpux_stat(&tmpst, &tmphst);
! 485:
! 486: return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_stat)));
! 487: }
! 488:
! 489: #ifndef __hppa__
! 490: /*
! 491: * The old HP-UX fstat(2) system call.
! 492: */
! 493: int
! 494: hpux_sys_fstat_6x(p, v, retval)
! 495: struct proc *p;
! 496: void *v;
! 497: register_t *retval;
! 498: {
! 499: struct hpux_sys_fstat_6x_args /* {
! 500: syscallarg(int) fd;
! 501: syscallarg(struct hpux_ostat *) sb;
! 502: } */ *uap = v;
! 503: struct sys_fstat_args fsa;
! 504: struct hpux_ostat tmphst;
! 505: struct stat *st, tmpst;
! 506: caddr_t sg;
! 507: int error;
! 508:
! 509: sg = stackgap_init(p->p_emul);
! 510:
! 511: st = stackgap_alloc(&sg, sizeof (struct stat));
! 512:
! 513: SCARG(&fsa, fd) = SCARG(uap, fd);
! 514: SCARG(&fsa, sb) = st;
! 515:
! 516: if ((error = sys_fstat(p, &fsa, retval)))
! 517: return (error);
! 518:
! 519: if ((error = copyin(st, &tmpst, sizeof(tmpst))))
! 520: return (error);
! 521:
! 522: bsd_to_hpux_ostat(&tmpst, &tmphst);
! 523:
! 524: return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_ostat)));
! 525: }
! 526:
! 527: /*
! 528: * The old HP-UX stat(2) system call.
! 529: */
! 530: int
! 531: hpux_sys_stat_6x(p, v, retval)
! 532: struct proc *p;
! 533: void *v;
! 534: register_t *retval;
! 535: {
! 536: struct hpux_sys_stat_6x_args /* {
! 537: syscallarg(char *) path;
! 538: syscallarg(struct hpux_ostat *) sb;
! 539: } */ *uap = v;
! 540: struct sys_stat_args sa;
! 541: struct hpux_ostat tmphst;
! 542: struct stat *st, tmpst;
! 543: caddr_t sg;
! 544: int error;
! 545:
! 546: sg = stackgap_init(p->p_emul);
! 547:
! 548: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 549:
! 550: st = stackgap_alloc(&sg, sizeof (struct stat));
! 551: SCARG(&sa, ub) = st;
! 552: SCARG(&sa, path) = SCARG(uap, path);
! 553:
! 554: if ((error = sys_stat(p, &sa, retval)))
! 555: return (error);
! 556:
! 557: if ((error = copyin(st, &tmpst, sizeof(tmpst))))
! 558: return (error);
! 559:
! 560: bsd_to_hpux_ostat(&tmpst, &tmphst);
! 561:
! 562: return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_ostat)));
! 563: }
! 564:
! 565: /*
! 566: * Convert a NetBSD stat structure to an old-style HP-UX stat structure.
! 567: */
! 568: void
! 569: bsd_to_hpux_ostat(sb, hsb)
! 570: struct stat *sb;
! 571: struct hpux_ostat *hsb;
! 572: {
! 573:
! 574: bzero(hsb, sizeof(struct hpux_ostat));
! 575: hsb->hst_dev = (u_short)sb->st_dev;
! 576: hsb->hst_ino = (u_short)sb->st_ino;
! 577: hsb->hst_mode = (u_short)sb->st_mode;
! 578: hsb->hst_nlink = (u_short)sb->st_nlink;
! 579: hsb->hst_uid = (u_short)sb->st_uid;
! 580: hsb->hst_gid = (u_short)sb->st_gid;
! 581: hsb->hst_rdev = (u_short)sb->st_rdev;
! 582: if (sb->st_size < (off_t)(((off_t)1) << 32))
! 583: hsb->hst_size = (int)sb->st_size;
! 584: else
! 585: hsb->hst_size = -2;
! 586: hsb->hst_atime = (int)sb->st_atime;
! 587: hsb->hst_mtime = (int)sb->st_mtime;
! 588: hsb->hst_ctime = (int)sb->st_ctime;
! 589: }
! 590: #endif
! 591:
! 592: /*
! 593: * Convert a NetBSD stat structure to an HP-UX stat structure.
! 594: */
! 595: void
! 596: bsd_to_hpux_stat(sb, hsb)
! 597: struct stat *sb;
! 598: struct hpux_stat *hsb;
! 599: {
! 600:
! 601: bzero((caddr_t)hsb, sizeof(struct hpux_stat));
! 602: hsb->hst_dev = (long)sb->st_dev;
! 603: hsb->hst_ino = (u_long)sb->st_ino;
! 604: hsb->hst_mode = (u_short)sb->st_mode;
! 605: hsb->hst_nlink = (u_short)sb->st_nlink;
! 606: hsb->hst_uid = (u_long)sb->st_uid;
! 607: hsb->hst_gid = (u_long)sb->st_gid;
! 608: hsb->hst_rdev = (long)bsdtohpuxdev(sb->st_rdev);
! 609: /*
! 610: * XXX Let's just hope that the old binary doesn't lose.
! 611: */
! 612: hsb->hst_old_uid = (u_short)sb->st_uid;
! 613: hsb->hst_old_gid = (u_short)sb->st_gid;
! 614:
! 615: if (sb->st_size < (off_t)(((off_t)1) << 32))
! 616: hsb->hst_size = (long)sb->st_size;
! 617: else
! 618: hsb->hst_size = -2;
! 619: hsb->hst_atime = (long)sb->st_atime;
! 620: hsb->hst_mtime = (long)sb->st_mtime;
! 621: hsb->hst_ctime = (long)sb->st_ctime;
! 622: hsb->hst_blksize = (long)sb->st_blksize;
! 623: hsb->hst_blocks = (long)sb->st_blocks;
! 624: }
! 625:
! 626: /*
! 627: * HP-UX access(2) system call.
! 628: */
! 629: int
! 630: hpux_sys_access(p, v, retval)
! 631: struct proc *p;
! 632: void *v;
! 633: register_t *retval;
! 634: {
! 635: struct hpux_sys_access_args /* {
! 636: syscallarg(char *) path;
! 637: syscallarg(int) flags;
! 638: } */ *uap = v;
! 639: caddr_t sg = stackgap_init(p->p_emul);
! 640:
! 641: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 642:
! 643: return (sys_access(p, uap, retval));
! 644: }
! 645:
! 646: /*
! 647: * HP-UX unlink(2) system call.
! 648: */
! 649: int
! 650: hpux_sys_unlink(p, v, retval)
! 651: struct proc *p;
! 652: void *v;
! 653: register_t *retval;
! 654: {
! 655: struct hpux_sys_unlink_args /* {
! 656: syscallarg(char *) path;
! 657: } */ *uap = v;
! 658: caddr_t sg = stackgap_init(p->p_emul);
! 659:
! 660: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 661:
! 662: return (sys_unlink(p, uap, retval));
! 663: }
! 664:
! 665: /*
! 666: * HP-UX chdir(2) system call.
! 667: */
! 668: int
! 669: hpux_sys_chdir(p, v, retval)
! 670: struct proc *p;
! 671: void *v;
! 672: register_t *retval;
! 673: {
! 674: struct hpux_sys_chdir_args /* {
! 675: syscallarg(char *) path;
! 676: } */ *uap = v;
! 677: caddr_t sg = stackgap_init(p->p_emul);
! 678:
! 679: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 680:
! 681: return (sys_chdir(p, uap, retval));
! 682: }
! 683:
! 684: /*
! 685: * HP-UX mknod(2) system call.
! 686: */
! 687: int
! 688: hpux_sys_mknod(p, v, retval)
! 689: struct proc *p;
! 690: void *v;
! 691: register_t *retval;
! 692: {
! 693: struct hpux_sys_mknod_args /* {
! 694: syscallarg(char *) path;
! 695: syscallarg(int) mode;
! 696: syscallarf(int) dev;
! 697: } */ *uap = v;
! 698: caddr_t sg = stackgap_init(p->p_emul);
! 699: struct sys_mkfifo_args bma;
! 700:
! 701: HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
! 702:
! 703: /*
! 704: * BSD handles FIFOs separately.
! 705: */
! 706: if (S_ISFIFO(SCARG(uap, mode))) {
! 707: SCARG(&bma, path) = SCARG(uap, path);
! 708: SCARG(&bma, mode) = SCARG(uap, mode);
! 709: return (sys_mkfifo(p, uap, retval));
! 710: } else
! 711: return (sys_mknod(p, uap, retval));
! 712: }
! 713:
! 714: /*
! 715: * HP-UX chmod(2) system call.
! 716: */
! 717: int
! 718: hpux_sys_chmod(p, v, retval)
! 719: struct proc *p;
! 720: void *v;
! 721: register_t *retval;
! 722: {
! 723: struct hpux_sys_chmod_args /* {
! 724: syscallarg(char *) path;
! 725: syscallarg(int) mode;
! 726: } */ *uap = v;
! 727: caddr_t sg = stackgap_init(p->p_emul);
! 728:
! 729: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 730:
! 731: return (sys_chmod(p, uap, retval));
! 732: }
! 733:
! 734: /*
! 735: * HP-UX chown(2) system call.
! 736: */
! 737: int
! 738: hpux_sys_chown(p, v, retval)
! 739: struct proc *p;
! 740: void *v;
! 741: register_t *retval;
! 742: {
! 743: struct hpux_sys_chown_args /* {
! 744: syscallarg(char *) path;
! 745: syscallarg(int) uid;
! 746: syscallarg(int) gid;
! 747: } */ *uap = v;
! 748: caddr_t sg = stackgap_init(p->p_emul);
! 749:
! 750: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 751:
! 752: /* XXX What about older HP-UX executables? */
! 753:
! 754: return (sys_lchown(p, uap, retval));
! 755: }
! 756:
! 757: /*
! 758: * HP-UX rename(2) system call.
! 759: */
! 760: int
! 761: hpux_sys_rename(p, v, retval)
! 762: struct proc *p;
! 763: void *v;
! 764: register_t *retval;
! 765: {
! 766: struct hpux_sys_rename_args /* {
! 767: syscallarg(char *) from;
! 768: syscallarg(char *) to;
! 769: } */ *uap = v;
! 770: caddr_t sg = stackgap_init(p->p_emul);
! 771:
! 772: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
! 773: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, to));
! 774:
! 775: return (sys_rename(p, uap, retval));
! 776: }
! 777:
! 778: /*
! 779: * HP-UX mkdir(2) system call.
! 780: */
! 781: int
! 782: hpux_sys_mkdir(p, v, retval)
! 783: struct proc *p;
! 784: void *v;
! 785: register_t *retval;
! 786: {
! 787: struct hpux_sys_mkdir_args /* {
! 788: syscallarg(char *) path;
! 789: syscallarg(int) mode;
! 790: } */ *uap = v;
! 791: caddr_t sg = stackgap_init(p->p_emul);
! 792:
! 793: HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
! 794:
! 795: return (sys_mkdir(p, uap, retval));
! 796: }
! 797:
! 798: /*
! 799: * HP-UX rmdir(2) system call.
! 800: */
! 801: int
! 802: hpux_sys_rmdir(p, v, retval)
! 803: struct proc *p;
! 804: void *v;
! 805: register_t *retval;
! 806: {
! 807: struct hpux_sys_rmdir_args /* {
! 808: syscallarg(char *) path;
! 809: } */ *uap = v;
! 810: caddr_t sg = stackgap_init(p->p_emul);
! 811:
! 812: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 813:
! 814: return (sys_rmdir(p, uap, retval));
! 815: }
! 816:
! 817: /*
! 818: * HP-UX symlink(2) system call.
! 819: */
! 820: int
! 821: hpux_sys_symlink(p, v, retval)
! 822: struct proc *p;
! 823: void *v;
! 824: register_t *retval;
! 825: {
! 826: struct hpux_sys_symlink_args /* {
! 827: syscallarg(char *) path;
! 828: syscallarg(char *) link;
! 829: } */ *uap = v;
! 830: caddr_t sg = stackgap_init(p->p_emul);
! 831:
! 832: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 833: HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
! 834:
! 835: return (sys_symlink(p, uap, retval));
! 836: }
! 837:
! 838: /*
! 839: * HP-UX readlink(2) system call.
! 840: */
! 841: int
! 842: hpux_sys_readlink(p, v, retval)
! 843: struct proc *p;
! 844: void *v;
! 845: register_t *retval;
! 846: {
! 847: struct hpux_sys_readlink_args /* {
! 848: syscallarg(char *) path;
! 849: syscallarg(char *) buf;
! 850: syscallarg(int) count;
! 851: } */ *uap = v;
! 852: caddr_t sg = stackgap_init(p->p_emul);
! 853:
! 854: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 855:
! 856: return (sys_readlink(p, uap, retval));
! 857: }
! 858:
! 859: /*
! 860: * HP-UX truncate(2) system call.
! 861: */
! 862: int
! 863: hpux_sys_truncate(p, v, retval)
! 864: struct proc *p;
! 865: void *v;
! 866: register_t *retval;
! 867: {
! 868: struct hpux_sys_truncate_args /* {
! 869: syscallarg(char *) path;
! 870: syscallarg(long) length;
! 871: } */ *uap = v;
! 872: caddr_t sg = stackgap_init(p->p_emul);
! 873:
! 874: HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
! 875:
! 876: return (compat_43_sys_truncate(p, uap, retval));
! 877: }
CVSweb