Print this page
3882 remove xmod & friends

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/syscall/fcntl.c
          +++ new/usr/src/uts/common/syscall/fcntl.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22      -/* ONC_PLUS EXTRACT START */
  23   22  /*
  24   23   * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
  25   24   * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  26   25   */
  27   26  
  28   27  /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T     */
  29   28  /*        All Rights Reserved   */
  30   29  
  31   30  /*
  32   31   * Portions of this source code were derived from Berkeley 4.3 BSD
  33   32   * under license from the Regents of the University of California.
  34   33   */
  35   34  
  36   35  
  37      -/* ONC_PLUS EXTRACT END */
  38      -
  39   36  #include <sys/param.h>
  40   37  #include <sys/isa_defs.h>
  41   38  #include <sys/types.h>
  42   39  #include <sys/sysmacros.h>
  43   40  #include <sys/systm.h>
  44   41  #include <sys/errno.h>
  45   42  #include <sys/fcntl.h>
  46      -/* ONC_PLUS EXTRACT START */
  47   43  #include <sys/flock.h>
  48      -/* ONC_PLUS EXTRACT END */
  49   44  #include <sys/vnode.h>
  50   45  #include <sys/file.h>
  51   46  #include <sys/mode.h>
  52   47  #include <sys/proc.h>
  53   48  #include <sys/filio.h>
  54   49  #include <sys/share.h>
  55   50  #include <sys/debug.h>
  56   51  #include <sys/rctl.h>
  57   52  #include <sys/nbmlock.h>
  58   53  
  59   54  #include <sys/cmn_err.h>
  60   55  
  61      -/* ONC_PLUS EXTRACT START */
  62   56  static int flock_check(vnode_t *, flock64_t *, offset_t, offset_t);
  63   57  static int flock_get_start(vnode_t *, flock64_t *, offset_t, u_offset_t *);
  64   58  static void fd_too_big(proc_t *);
  65   59  
  66   60  /*
  67   61   * File control.
  68   62   */
  69   63  int
  70   64  fcntl(int fdes, int cmd, intptr_t arg)
  71   65  {
↓ open down ↓ 71 lines elided ↑ open up ↑
 143  137           * Second, for speed, deal with the subset of cases that
 144  138           * require getf() / releasef() but do not require copyin.
 145  139           */
 146  140          if ((fp = getf(fdes)) == NULL) {
 147  141                  error = EBADF;
 148  142                  goto out;
 149  143          }
 150  144          iarg = (int)arg;
 151  145  
 152  146          switch (cmd) {
 153      -/* ONC_PLUS EXTRACT END */
 154      -
 155  147          case F_DUPFD:
 156  148          case F_DUPFD_CLOEXEC:
 157  149                  p = curproc;
 158  150                  if ((uint_t)iarg >= p->p_fno_ctl) {
 159  151                          if (iarg >= 0)
 160  152                                  fd_too_big(p);
 161  153                          error = EINVAL;
 162  154                          goto done;
 163  155                  }
 164  156                  /*
↓ open down ↓ 103 lines elided ↑ open up ↑
 268  260  #if defined(_SYSCALL32_IMPL)
 269  261          if ((datamodel = get_udatamodel()) == DATAMODEL_ILP32)
 270  262                  maxoffset = MAXOFF32_T;
 271  263  #endif
 272  264  
 273  265          vp = fp->f_vnode;
 274  266          flag = fp->f_flag;
 275  267          offset = fp->f_offset;
 276  268  
 277  269          switch (cmd) {
 278      -/* ONC_PLUS EXTRACT START */
 279  270          /*
 280  271           * The file system and vnode layers understand and implement
 281  272           * locking with flock64 structures. So here once we pass through
 282  273           * the test for compatibility as defined by LFS API, (for F_SETLK,
 283  274           * F_SETLKW, F_GETLK, F_GETLKW, F_FREESP) we transform
 284  275           * the flock structure to a flock64 structure and send it to the
 285  276           * lower layers. Similarly in case of GETLK the returned flock64
 286  277           * structure is transformed to a flock structure if everything fits
 287  278           * in nicely, otherwise we return EOVERFLOW.
 288  279           */
↓ open down ↓ 154 lines elided ↑ open up ↑
 443  434                                  sbf32.l_len = (off32_t)bf.l_len;
 444  435                                  sbf32.l_sysid = (int32_t)bf.l_sysid;
 445  436                                  sbf32.l_pid = (pid32_t)bf.l_pid;
 446  437                                  if (copyout(&sbf32,
 447  438                                      (void *)arg, sizeof (sbf32)))
 448  439                                          error = EFAULT;
 449  440                          }
 450  441  #endif
 451  442                  }
 452  443                  break;
 453      -/* ONC_PLUS EXTRACT END */
 454  444  
 455  445          case F_CHKFL:
 456  446                  /*
 457  447                   * This is for internal use only, to allow the vnode layer
 458  448                   * to validate a flags setting before applying it.  User
 459  449                   * programs can't issue it.
 460  450                   */
 461  451                  error = EINVAL;
 462  452                  break;
 463  453  
↓ open down ↓ 126 lines elided ↑ open up ↑
 590  580                  if (cmd == F_ALLOCSP64)
 591  581                          cmd = F_ALLOCSP;
 592  582                  else if (cmd == F_FREESP64)
 593  583                          cmd = F_FREESP;
 594  584  
 595  585                  error = VOP_SPACE(vp, cmd, &bf, flag, offset, fp->f_cred, NULL);
 596  586  
 597  587                  break;
 598  588  
 599  589  #if !defined(_LP64) || defined(_SYSCALL32_IMPL)
 600      -/* ONC_PLUS EXTRACT START */
 601  590          case F_GETLK64:
 602  591          case F_SETLK64:
 603  592          case F_SETLKW64:
 604  593          case F_SETLK64_NBMAND:
 605  594                  /*
 606  595                   * Large Files: Here we set cmd as *LK and send it to
 607  596                   * lower layers. *LK64 is only for the user land.
 608  597                   * Most of the comments described above for F_SETLK
 609  598                   * applies here too.
 610  599                   * Large File support is only needed for ILP32 apps!
↓ open down ↓ 62 lines elided ↑ open up ↑
 673  662                          bf64_32.l_type = (int16_t)bf.l_type;
 674  663                          bf64_32.l_whence = (int16_t)bf.l_whence;
 675  664                          bf64_32.l_start = bf.l_start;
 676  665                          bf64_32.l_len = bf.l_len;
 677  666                          bf64_32.l_sysid = (int32_t)bf.l_sysid;
 678  667                          bf64_32.l_pid = (pid32_t)bf.l_pid;
 679  668                          if (copyout(&bf64_32, (void *)arg, sizeof (bf64_32)))
 680  669                                  error = EFAULT;
 681  670                  }
 682  671                  break;
 683      -/* ONC_PLUS EXTRACT END */
 684  672  #endif /* !defined(_LP64) || defined(_SYSCALL32_IMPL) */
 685  673  
 686      -/* ONC_PLUS EXTRACT START */
 687  674          case F_SHARE:
 688  675          case F_SHARE_NBMAND:
 689  676          case F_UNSHARE:
 690  677  
 691  678                  /*
 692  679                   * Copy in input fields only.
 693  680                   */
 694  681                  if (copyin((void *)arg, &fsh, sizeof (fsh))) {
 695  682                          error = EFAULT;
 696  683                          break;
↓ open down ↓ 4 lines elided ↑ open up ↑
 701  688                   */
 702  689                  shr.s_access = fsh.f_access;
 703  690                  shr.s_deny = fsh.f_deny;
 704  691                  shr.s_sysid = 0;
 705  692                  shr.s_pid = ttoproc(curthread)->p_pid;
 706  693                  shr_own.sl_pid = shr.s_pid;
 707  694                  shr_own.sl_id = fsh.f_id;
 708  695                  shr.s_own_len = sizeof (shr_own);
 709  696                  shr.s_owner = (caddr_t)&shr_own;
 710  697                  error = VOP_SHRLOCK(vp, cmd, &shr, flag, fp->f_cred, NULL);
 711      -/* ONC_PLUS EXTRACT END */
 712  698                  break;
 713  699  
 714  700          default:
 715  701                  error = EINVAL;
 716  702                  break;
 717  703          }
 718  704  
 719  705          if (in_crit)
 720  706                  nbl_end_crit(vp);
 721  707  
 722  708  done:
 723  709          releasef(fdes);
 724  710  out:
 725  711          if (error)
 726  712                  return (set_errno(error));
 727  713          return (retval);
 728  714  }
 729  715  
 730      -/* ONC_PLUS EXTRACT START */
 731  716  int
 732  717  flock_check(vnode_t *vp, flock64_t *flp, offset_t offset, offset_t max)
 733  718  {
 734  719          struct vattr    vattr;
 735  720          int     error;
 736  721          u_offset_t start, end;
 737  722  
 738  723          /*
 739  724           * Determine the starting point of the request
 740  725           */
↓ open down ↓ 91 lines elided ↑ open up ↑
 832  817   * Take rctl action when the requested file descriptor is too big.
 833  818   */
 834  819  static void
 835  820  fd_too_big(proc_t *p)
 836  821  {
 837  822          mutex_enter(&p->p_lock);
 838  823          (void) rctl_action(rctlproc_legacy[RLIMIT_NOFILE],
 839  824              p->p_rctls, p, RCA_SAFE);
 840  825          mutex_exit(&p->p_lock);
 841  826  }
 842      -/* ONC_PLUS EXTRACT END */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX