Print this page
    
OS-4602 lxbrand support recvmsg(MSG_PEEK|MSG_TRUNC) behavior
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/uio.h
          +++ new/usr/src/uts/common/sys/uio.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  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   22   * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  23   23   *
  24   24   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  25   25   * Use is subject to license terms.
  26   26   *
  27   27   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  28   28   * Copyright (c) 2015, Joyent, Inc.  All rights reserved.
  29   29   */
  30   30  
  31   31  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  32   32  /*        All Rights Reserved   */
  33   33  
  34   34  /*
  35   35   * University Copyright- Copyright (c) 1982, 1986, 1988
  36   36   * The Regents of the University of California
  37   37   * All Rights Reserved
  38   38   *
  39   39   * University Acknowledgment- Portions of this document are derived from
  40   40   * software developed by the University of California, Berkeley, and its
  41   41   * contributors.
  42   42   */
  43   43  
  44   44  #ifndef _SYS_UIO_H
  45   45  #define _SYS_UIO_H
  46   46  
  47   47  #include <sys/feature_tests.h>
  48   48  
  49   49  #ifdef  __cplusplus
  50   50  extern "C" {
  51   51  #endif
  52   52  
  53   53  #include <sys/types.h>
  54   54  
  55   55  /*
  56   56   * I/O parameter information.  A uio structure describes the I/O which
  57   57   * is to be performed by an operation.  Typically the data movement will
  58   58   * be performed by a routine such as uiomove(), which updates the uio
  59   59   * structure to reflect what was done.
  60   60   */
  61   61  
  62   62  #if     defined(_XPG4_2)
  63   63  typedef struct iovec {
  64   64          void    *iov_base;
  65   65          size_t  iov_len;
  66   66  } iovec_t;
  67   67  #else
  68   68  typedef struct iovec {
  69   69          caddr_t iov_base;
  70   70  #if defined(_LP64)
  71   71          size_t  iov_len;
  72   72  #else
  73   73          long    iov_len;
  74   74  #endif
  75   75  } iovec_t;
  76   76  #endif  /* defined(_XPG4_2) */
  77   77  
  78   78  #if defined(_SYSCALL32)
  79   79  
  80   80  /* Kernel's view of user ILP32 iovec struct */
  81   81  
  82   82  typedef struct iovec32 {
  83   83          caddr32_t       iov_base;
  84   84          int32_t         iov_len;
  85   85  } iovec32_t;
  86   86  
  87   87  #endif  /* _SYSCALL32 */
  88   88  
  89   89  #if     !defined(_XPG4_2) || defined(__EXTENSIONS__)
  90   90  /*
  91   91   * Segment flag values.
  92   92   */
  93   93  typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t;
  94   94  
  95   95  typedef struct uio {
  96   96          iovec_t         *uio_iov;       /* pointer to array of iovecs */
  97   97          int             uio_iovcnt;     /* number of iovecs */
  98   98          lloff_t         _uio_offset;    /* file offset */
  99   99          uio_seg_t       uio_segflg;     /* address space (kernel or user) */
 100  100          uint16_t        uio_fmode;      /* file mode flags */
 101  101          uint16_t        uio_extflg;     /* extended flags */
 102  102          lloff_t         _uio_limit;     /* u-limit (maximum byte offset) */
 103  103          ssize_t         uio_resid;      /* residual count */
 104  104  } uio_t;
 105  105  
 106  106  /*
 107  107   * Extended uio_t uioa_t used for asynchronous uio.
 108  108   *
 109  109   * Note: UIOA_IOV_MAX is defined and used as it is in "fs/vncalls.c"
 110  110   *       as there isn't a formal definition of IOV_MAX for the kernel.
 111  111   */
 112  112  #define UIOA_IOV_MAX    16
 113  113  
 114  114  typedef struct uioa_page_s {            /* locked uio_iov state */
 115  115          int     uioa_pfncnt;            /* count of pfn_t(s) in *uioa_ppp */
 116  116          void    **uioa_ppp;             /* page_t or pfn_t arrary */
 117  117          caddr_t uioa_base;              /* address base */
 118  118          size_t  uioa_len;               /* span length */
 119  119  } uioa_page_t;
 120  120  
 121  121  typedef struct uioa_s {
 122  122          iovec_t         *uio_iov;       /* pointer to array of iovecs */
 123  123          int             uio_iovcnt;     /* number of iovecs */
 124  124          lloff_t         _uio_offset;    /* file offset */
 125  125          uio_seg_t       uio_segflg;     /* address space (kernel or user) */
 126  126          uint16_t        uio_fmode;      /* file mode flags */
 127  127          uint16_t        uio_extflg;     /* extended flags */
 128  128          lloff_t         _uio_limit;     /* u-limit (maximum byte offset) */
 129  129          ssize_t         uio_resid;      /* residual count */
 130  130          /*
 131  131           * uioa extended members.
 132  132           */
 133  133          uint32_t        uioa_state;     /* state of asynch i/o */
 134  134          ssize_t         uioa_mbytes;    /* bytes that have been uioamove()ed */
 135  135          uioa_page_t     *uioa_lcur;     /* pointer into uioa_locked[] */
 136  136          void            **uioa_lppp;    /* pointer into lcur->uioa_ppp[] */
 137  137          void            *uioa_hwst[4];  /* opaque hardware state */
  
    | 
      ↓ open down ↓ | 
    137 lines elided | 
    
      ↑ open up ↑ | 
  
 138  138          uioa_page_t     uioa_locked[UIOA_IOV_MAX]; /* Per iov locked pages */
 139  139  } uioa_t;
 140  140  
 141  141  /*
 142  142   * uio extensions
 143  143   *
 144  144   * PSARC 2009/478: Copy Reduction Interfaces
 145  145   */
 146  146  typedef enum xuio_type {
 147  147          UIOTYPE_ASYNCIO,
 148      -        UIOTYPE_ZEROCOPY
      148 +        UIOTYPE_ZEROCOPY,
      149 +        UIOTYPE_PEEKSIZE
 149  150  } xuio_type_t;
 150  151  
 151  152  typedef struct xuio {
 152  153          uio_t xu_uio;           /* Embedded UIO structure */
 153  154  
 154  155          /* Extended uio fields */
 155  156          enum xuio_type xu_type; /* What kind of uio structure? */
 156  157          union {
 157  158                  /* Async I/O Support, intend to replace uioa_t. */
 158  159                  struct {
 159  160                          uint32_t xu_a_state;    /* state of async i/o */
 160  161                          /* bytes that have been uioamove()ed */
 161  162                          ssize_t xu_a_mbytes;
 162  163                          uioa_page_t *xu_a_lcur; /* pointer into uioa_locked[] */
 163  164                          /* pointer into lcur->uioa_ppp[] */
 164  165                          void **xu_a_lppp;
 165  166                          void *xu_a_hwst[4];     /* opaque hardware state */
 166  167                          /* Per iov locked pages */
 167  168                          uioa_page_t xu_a_locked[UIOA_IOV_MAX];
  
    | 
      ↓ open down ↓ | 
    9 lines elided | 
    
      ↑ open up ↑ | 
  
 168  169                  } xu_aio;
 169  170  
 170  171                  /*
 171  172                   * Copy Reduction Support -- facilate loaning / returning of
 172  173                   * filesystem cache buffers.
 173  174                   */
 174  175                  struct {
 175  176                          int xu_zc_rw;   /* read or write buffer */
 176  177                          void *xu_zc_priv;       /* fs specific */
 177  178                  } xu_zc;
      179 +
      180 +                /*
      181 +                 * Peek Size Support -- facilitate peeking at the size of a
      182 +                 * waiting message on a socket.
      183 +                 */
      184 +                struct {
      185 +                        ssize_t xu_ps_size;     /* size of waiting msg */
      186 +                        boolean_t xu_ps_set;    /* was size calculated? */
      187 +                } xu_ps;
 178  188          } xu_ext;
 179  189  } xuio_t;
 180  190  
 181  191  #define XUIO_XUZC_PRIV(xuio)    xuio->xu_ext.xu_zc.xu_zc_priv
 182  192  #define XUIO_XUZC_RW(xuio)      xuio->xu_ext.xu_zc.xu_zc_rw
 183  193  
 184  194  #define UIOA_ALLOC      0x0001          /* allocated but not yet initialized */
 185  195  #define UIOA_INIT       0x0002          /* initialized but not yet enabled */
 186  196  #define UIOA_ENABLED    0x0004          /* enabled, asynch i/o active */
 187  197  #define UIOA_FINI       0x0008          /* finished waiting for uioafini() */
 188  198  
 189  199  #define UIOA_CLR        (~0x000F)       /* clear mutually exclusive bits */
 190  200  
 191  201  #define UIOA_POLL       0x0010          /* need dcopy_poll() */
 192  202  
 193  203  #define uio_loffset     _uio_offset._f
 194  204  #if !defined(_LP64)
 195  205  #define uio_offset      _uio_offset._p._l
 196  206  #else
 197  207  #define uio_offset      uio_loffset
 198  208  #endif
 199  209  
 200  210  #define uio_llimit      _uio_limit._f
 201  211  #if !defined(_LP64)
 202  212  #define uio_limit       _uio_limit._p._l
 203  213  #else
 204  214  #define uio_limit       uio_llimit
 205  215  #endif
 206  216  
 207  217  /*
 208  218   * I/O direction.
 209  219   */
 210  220  typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
 211  221  
 212  222  /*
 213  223   * uio_extflg: extended flags
 214  224   *
 215  225   * NOTE: This flag will be used in uiomove to determine if non-temporal
 216  226   * access, ie, access bypassing caches, should be used.  Filesystems that
 217  227   * don't initialize this field could experience suboptimal performance due to
 218  228   * the random data the field contains.
 219  229   *
 220  230   * NOTE: This flag is also used by uioasync callers to pass an extended
 221  231   * uio_t (uioa_t), to uioasync enabled consumers. Unlike above all
 222  232   * consumers of a uioa_t require the uio_extflg to be initialized.
 223  233   */
 224  234  #define UIO_COPY_DEFAULT        0x0000  /* no special options to copy */
 225  235  #define UIO_COPY_CACHED         0x0001  /* copy should not bypass caches */
 226  236  
 227  237  #define UIO_ASYNC               0x0002  /* uio_t is really a uioa_t */
 228  238  #define UIO_XUIO                0x0004  /* Structure is xuio_t */
 229  239  
 230  240  /*
 231  241   * Global uioasync capability shadow state.
 232  242   */
 233  243  typedef struct uioasync_s {
 234  244          boolean_t       enabled;        /* Is uioasync enabled? */
 235  245          size_t          mincnt;         /* Minimum byte count for use of */
 236  246  } uioasync_t;
 237  247  
 238  248  #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 239  249  
 240  250  #if defined(_KERNEL) || defined(_FAKE_KERNEL)
 241  251  
 242  252  int     uiomove(void *, size_t, enum uio_rw, uio_t *);
 243  253  void    uio_prefaultpages(ssize_t, uio_t *);
 244  254  int     uiocopy(void *, size_t, enum uio_rw, uio_t *, size_t *);
 245  255  int     ureadc(int, uio_t *);   /* should be errno_t in future */
 246  256  int     uwritec(struct uio *);
 247  257  void    uioskip(uio_t *, size_t);
 248  258  int     uiodup(uio_t *, uio_t *, iovec_t *, int);
 249  259  
 250  260  int     uioamove(void *, size_t, enum uio_rw, uioa_t *);
 251  261  int     uioainit(uio_t *, uioa_t *);
 252  262  int     uioafini(uio_t *, uioa_t *);
 253  263  extern  uioasync_t uioasync;
 254  264  
 255  265  #else   /* defined(_KERNEL) */
 256  266  
 257  267  extern ssize_t readv(int, const struct iovec *, int);
 258  268  extern ssize_t writev(int, const struct iovec *, int);
 259  269  
 260  270  /*
 261  271   * When in the large file compilation environment,
 262  272   * map preadv/pwritev to their 64 bit offset versions
 263  273   */
 264  274  #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
 265  275  #ifdef __PRAGMA_REDEFINE_EXTNAME
 266  276  #pragma redefine_extname        preadv  preadv64
 267  277  #pragma redefine_extname        pwritev pwritev64
 268  278  #else /* __PRAGMA_REDEFINE_EXTNAME */
 269  279  #define preadv  preadv64
 270  280  #define pwritev pwritev64
 271  281  #endif /* __PRAGMA_REDEFINE_EXTNAME */
 272  282  #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
 273  283  
 274  284  /* In the LP64 compilation environment, the APIs are already large file */
 275  285  #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
 276  286  #ifdef  __PRAGMA_REDEFINE_EXTNAME
 277  287  #pragma redefine_extname        preadv64        preadv
 278  288  #pragma redefine_extname        pwritev64       pwritev
 279  289  #else   /* __PRAGMA_REDEFINE_EXTNAME */
 280  290  #define preadv64        preadv
 281  291  #define pwritev64       pwritev
 282  292  #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 283  293  #endif  /* _LP64 && _LARGEFILE64_SOURCE */
 284  294  
 285  295  extern ssize_t preadv(int, const struct iovec *, int, off_t);
 286  296  extern ssize_t pwritev(int, const struct iovec *, int, off_t);
 287  297  
 288  298  /*
 289  299   * preadv64 and pwritev64 should be defined when:
 290  300   * - Using the transitional compilation environment, and not
 291  301   *     the large file compilation environment.
 292  302   */
 293  303  #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 294  304          !defined(__PRAGMA_REDEFINE_EXTNAME))
 295  305  extern ssize_t preadv64(int, const struct iovec *, int, off64_t);
 296  306  extern ssize_t pwritev64(int, const struct iovec *, int, off64_t);
 297  307  #endif /* _LARGEFILE64_SOURCE */
 298  308  
 299  309  #endif  /* defined(_KERNEL) */
 300  310  
 301  311  #ifdef  __cplusplus
 302  312  }
 303  313  #endif
 304  314  
 305  315  #endif  /* _SYS_UIO_H */
  
    | 
      ↓ open down ↓ | 
    118 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX