Print this page
OS-5591 Double flock(3C) causes undue block
OS-5585 fcntl(F_OFD_GETLK) should return EINVAL on bad parameters
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
OS-4098 move open, close and fcntl into the kernel

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/syscall/fcntl.c
          +++ new/usr/src/uts/common/syscall/fcntl.c
↓ open down ↓ 46 lines elided ↑ open up ↑
  47   47  #include <sys/mode.h>
  48   48  #include <sys/proc.h>
  49   49  #include <sys/filio.h>
  50   50  #include <sys/share.h>
  51   51  #include <sys/debug.h>
  52   52  #include <sys/rctl.h>
  53   53  #include <sys/nbmlock.h>
  54   54  
  55   55  #include <sys/cmn_err.h>
  56   56  
  57      -static int flock_check(vnode_t *, flock64_t *, offset_t, offset_t);
       57 +/* This is global so that it can be used by brand emulation. */
       58 +int flock_check(vnode_t *, flock64_t *, offset_t, offset_t);
  58   59  static int flock_get_start(vnode_t *, flock64_t *, offset_t, u_offset_t *);
  59   60  static void fd_too_big(proc_t *);
  60   61  
  61   62  /*
  62   63   * File control.
  63   64   */
  64   65  int
  65   66  fcntl(int fdes, int cmd, intptr_t arg)
  66   67  {
  67   68          int iarg;
↓ open down ↓ 290 lines elided ↑ open up ↑
 358  359                              bf.l_len != 0) {
 359  360                                  error = EINVAL;
 360  361                                  break;
 361  362                          }
 362  363                          if (bf.l_type < F_RDLCK || bf.l_type > F_UNLCK) {
 363  364                                  error = EINVAL;
 364  365                                  break;
 365  366                          }
 366  367                  }
 367  368  
 368      -                if (cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW) {
      369 +                if (cmd == F_OFD_GETLK || cmd == F_OFD_SETLK ||
      370 +                    cmd == F_OFD_SETLKW) {
 369  371                          /*
 370  372                           * TBD OFD-style locking is currently limited to
 371  373                           * covering the entire file.
 372  374                           */
 373  375                          if (bf.l_whence != 0 || bf.l_start != 0 ||
 374  376                              bf.l_len != 0) {
 375  377                                  error = EINVAL;
 376  378                                  break;
 377  379                          }
 378  380                  }
↓ open down ↓ 562 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX