The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/puffs/puffs_msgif.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: puffs_msgif.h,v 1.10 2006/12/01 12:48:31 pooka Exp $   */
    2 
    3 /*
    4  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
    5  *
    6  * Development of this software was supported by the
    7  * Google Summer of Code program and the Ulla Tuominen Foundation.
    8  * The Google SoC project was mentored by Bill Studenmund.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. The name of the company nor the name of the author may be used to
   19  *    endorse or promote products derived from this software without specific
   20  *    prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   23  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   25  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  */
   34 
   35 #ifndef _PUFFS_MSGIF_H_
   36 #define _PUFFS_MSGIF_H_
   37 
   38 #include <sys/param.h>
   39 #include <sys/time.h>
   40 #include <sys/ioccom.h>
   41 #include <sys/uio.h>
   42 #include <sys/vnode.h>
   43 #include <sys/ucred.h>
   44 #include <sys/statvfs.h>
   45 #include <sys/dirent.h>
   46 #include <sys/fcntl.h>
   47 
   48 #define PUFFSOP_VFS     1
   49 #define PUFFSOP_VN      2
   50 #define PUFFSOPFLAG_FAF 0x10    /* fire-and-forget */
   51 
   52 #define PUFFSOP_OPCMASK         0x03
   53 #define PUFFSOP_OPCLASS(a)      ((a) & PUFFSOP_OPCMASK)
   54 #define PUFFSOP_WANTREPLY(a)    (((a) & PUFFSOPFLAG_FAF) == 0)
   55 
   56 /* XXX: we don't need everything */
   57 enum {
   58         PUFFS_VFS_MOUNT,        PUFFS_VFS_START,        PUFFS_VFS_UNMOUNT,
   59         PUFFS_VFS_ROOT,         PUFFS_VFS_STATVFS,      PUFFS_VFS_SYNC,
   60         PUFFS_VFS_VGET,         PUFFS_VFS_FHTOVP,       PUFFS_VFS_VPTOFH,
   61         PUFFS_VFS_INIT,         PUFFS_VFS_DONE,         PUFFS_VFS_SNAPSHOT,
   62         PUFFS_VFS_EXTATTCTL
   63 };
   64 #define PUFFS_VFS_MAX PUFFS_VFS_EXTATTCTL
   65 
   66 /* moreXXX: we don't need everything here either */
   67 enum {
   68         PUFFS_VN_LOOKUP,        PUFFS_VN_CREATE,        PUFFS_VN_MKNOD,
   69         PUFFS_VN_OPEN,          PUFFS_VN_CLOSE,         PUFFS_VN_ACCESS,
   70         PUFFS_VN_GETATTR,       PUFFS_VN_SETATTR,       PUFFS_VN_READ,
   71         PUFFS_VN_WRITE,         PUFFS_VN_IOCTL,         PUFFS_VN_FCNTL,
   72         PUFFS_VN_POLL,          PUFFS_VN_KQFILTER,      PUFFS_VN_REVOKE,
   73         PUFFS_VN_MMAP,          PUFFS_VN_FSYNC,         PUFFS_VN_SEEK,
   74         PUFFS_VN_REMOVE,        PUFFS_VN_LINK,          PUFFS_VN_RENAME,
   75         PUFFS_VN_MKDIR,         PUFFS_VN_RMDIR,         PUFFS_VN_SYMLINK,
   76         PUFFS_VN_READDIR,       PUFFS_VN_READLINK,      PUFFS_VN_ABORTOP,
   77         PUFFS_VN_INACTIVE,      PUFFS_VN_RECLAIM,       PUFFS_VN_LOCK,
   78         PUFFS_VN_UNLOCK,        PUFFS_VN_BMAP,          PUFFS_VN_STRATEGY,
   79         PUFFS_VN_PRINT,         PUFFS_VN_ISLOCKED,      PUFFS_VN_PATHCONF,
   80         PUFFS_VN_ADVLOCK,       PUFFS_VN_LEASE,         PUFFS_VN_WHITEOUT,
   81         PUFFS_VN_GETPAGES,      PUFFS_VN_PUTPAGES,      PUFFS_VN_GETEXTATTR,
   82         PUFFS_VN_LISTEXTATTR,   PUFFS_VN_OPENEXTATTR,   PUFFS_VN_DELETEEXTATTR,
   83         PUFFS_VN_SETEXTATTR
   84 };
   85 #define PUFFS_VN_MAX PUFFS_VN_SETEXTATTR
   86 
   87 #define PUFFSVERSION    0       /* meaning: *NO* versioning yet */
   88 #define PUFFSNAMESIZE   32
   89 struct puffs_args {
   90         int             pa_vers;
   91         int             pa_fd;
   92         uint32_t        pa_flags;
   93         size_t          pa_maxreqlen;
   94         char            pa_name[PUFFSNAMESIZE]; /* name for puffs type  */
   95         uint8_t         pa_vnopmask[PUFFS_VN_MAX];
   96 };
   97 #define PUFFS_KFLAG_ALLOWCTL    0x01    /* ioctl/fcntl commands allowed */
   98 #define PUFFS_KFLAG_NOCACHE     0x02    /* flush page cache immediately */
   99 #define PUFFS_KFLAG_ALLOPS      0x04    /* ignore pa_vnopmask, send all */
  100 #define PUFFS_KFLAG_MASK        0x07
  101 
  102 /*
  103  * This is the device minor number for the cloning device.  Make it
  104  * a high number "just in case", even though we don't want to open
  105  * any specific devices currently.
  106  */
  107 #define PUFFS_CLONER 0x7ffff
  108 
  109 /*
  110  * This is the structure that travels on the user-kernel interface.
  111  * It is used to deliver ops to the user server and bring the results back
  112  */
  113 struct puffs_req {
  114         uint64_t        preq_id;                /* OUT/IN       */
  115         uint8_t         preq_opclass;           /* OUT          */
  116         uint8_t         preq_optype;            /* OUT          */
  117 
  118         int             preq_rv;                /* IN           */
  119 
  120         /*
  121          * preq_cookie is the node cookie associated with the request.
  122          * It always maps 1:1 to a vnode and should map to a userspace
  123          * struct puffs_node.  The cookie usually describes the first
  124          * vnode argument of the VOP_POP() in question.
  125          */
  126         void    *preq_cookie;                   /* OUT          */
  127 
  128         /* these come in from userspace twice (getop and putop) */
  129         void    *preq_aux;                      /* IN/IN        */
  130         size_t  preq_auxlen;                    /* IN/IN        */
  131 };
  132 
  133 #define PUFFS_REQFLAG_ADJBUF    0x01
  134 
  135 /*
  136  * Some operations have unknown size requirements.  So as the first
  137  * stab at handling it, do an extra bounce between the kernel and
  138  * userspace.
  139  */
  140 struct puffs_sizeop {
  141         uint64_t        pso_reqid;
  142 
  143         uint8_t         *pso_userbuf;
  144         size_t          pso_bufsize;
  145 };
  146 
  147 /*
  148  * Credentials for an operation.  Can be either struct uucred for
  149  * ops called from a credential context or NOCRED/FSCRED for ops
  150  * called from within the kernel.  It is up to the implementation
  151  * if it makes a difference between these two and the super-user.
  152  */
  153 struct puffs_cred {
  154         struct uucred   pcr_uuc;
  155         uint8_t         pcr_type;
  156         uint8_t         pcr_internal;
  157 };
  158 #define PUFFCRED_TYPE_UUC       1
  159 #define PUFFCRED_TYPE_INTERNAL  2
  160 
  161 #define PUFFCRED_CRED_NOCRED    1
  162 #define PUFFCRED_CRED_FSCRED    2
  163 
  164 
  165 #define PUFFSSTARTOP    _IOWR('p', 1, struct puffs_startreq)
  166 #define PUFFSGETOP      _IOWR('p', 2, struct puffs_req)
  167 #define PUFFSPUTOP      _IOWR('p', 3, struct puffs_req)
  168 #define PUFFSSIZEOP     _IOWR('p', 4, struct puffs_sizeop)
  169 
  170 /*
  171  * 4x MAXPHYS is the max size the system will attempt to copy,
  172  * else treated as garbage
  173  */
  174 #define PUFFS_REQ_MAXSIZE       4*MAXPHYS
  175 #define PUFFS_REQSTRUCT_MAX     4096 /* XXX: approxkludge */
  176 
  177 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_req_maxsize - PUFFS_REQSTRUCT_MAX))
  178 
  179 /* puffs struct componentname, for userspace */
  180 struct puffs_cn {
  181         /* args */
  182         u_long                  pcn_nameiop;    /* namei operation      */
  183         u_long                  pcn_flags;      /* flags                */
  184         pid_t                   pcn_pid;        /* caller pid           */
  185         struct puffs_cred       pcn_cred;       /* caller creds         */
  186 
  187         /* shared */
  188         char pcn_name[MAXPATHLEN];              /* path to lookup       */
  189         long pcn_namelen;                       /* length of path       */
  190 };
  191 
  192 /*
  193  * XXX: figure out what to do with these, copied from namei.h for now
  194  */
  195 #define PUFFSLOOKUP_LOOKUP      0       /* perform name lookup only */
  196 #define PUFFSLOOKUP_CREATE      1       /* setup for file creation */
  197 #define PUFFSLOOKUP_DELETE      2       /* setup for file deletion */
  198 #define PUFFSLOOKUP_RENAME      3       /* setup for file renaming */
  199 #define PUFFSLOOKUP_OPMASK      3       /* mask for operation */
  200 
  201 #define PUFFSLOOKUP_FOLLOW      0x04    /* follow symlinks */
  202 #define PUFFSLOOKUP_NOFOLLOW    0x08    /* don't follow symlinks */
  203 #define PUFFSLOOKUP_OPTIONS     0x0c
  204 
  205 
  206 struct puffs_startreq {
  207         void            *psr_cookie;    /* IN: root node cookie */
  208         struct statvfs  psr_sb;         /* IN: statvfs buffer */
  209 };
  210 
  211 /*
  212  * aux structures for vfs operations.
  213  */
  214 struct puffs_vfsreq_unmount {
  215         int                     pvfsr_flags;
  216         pid_t                   pvfsr_pid;
  217 };
  218 
  219 struct puffs_vfsreq_statvfs {
  220         struct statvfs          pvfsr_sb;
  221         pid_t                   pvfsr_pid;
  222 };
  223 
  224 struct puffs_vfsreq_sync {
  225         struct puffs_cred       pvfsr_cred;
  226         pid_t                   pvfsr_pid;
  227         int                     pvfsr_waitfor;
  228 };
  229 
  230 /*
  231  * aux structures for vnode operations.
  232  */
  233 
  234 struct puffs_vnreq_lookup {
  235         struct puffs_cn         pvnr_cn;                /* OUT  */
  236         void                    *pvnr_newnode;          /* IN   */
  237         enum vtype              pvnr_vtype;             /* IN   */
  238         voff_t                  pvnr_size;              /* IN   */
  239         dev_t                   pvnr_rdev;              /* IN   */
  240 };
  241 
  242 struct puffs_vnreq_create {
  243         struct puffs_cn         pvnr_cn;                /* OUT  */
  244         struct vattr            pvnr_va;                /* OUT  */
  245         void                    *pvnr_newnode;          /* IN   */
  246 };
  247 
  248 struct puffs_vnreq_mknod {
  249         struct puffs_cn         pvnr_cn;                /* OUT  */
  250         struct vattr            pvnr_va;                /* OUT  */
  251         void                    *pvnr_newnode;          /* IN   */
  252 };
  253 
  254 struct puffs_vnreq_open {
  255         struct puffs_cred       pvnr_cred;              /* OUT  */
  256         pid_t                   pvnr_pid;               /* OUT  */
  257         int                     pvnr_mode;              /* OUT  */
  258 };
  259 
  260 struct puffs_vnreq_close {
  261         struct puffs_cred       pvnr_cred;              /* OUT  */
  262         pid_t                   pvnr_pid;               /* OUT  */
  263         int                     pvnr_fflag;             /* OUT  */
  264 };
  265 
  266 struct puffs_vnreq_access {
  267         struct puffs_cred       pvnr_cred;              /* OUT  */
  268         pid_t                   pvnr_pid;               /* OUT  */
  269         int                     pvnr_mode;              /* OUT  */
  270 };
  271 
  272 #define puffs_vnreq_setattr puffs_vnreq_setgetattr
  273 #define puffs_vnreq_getattr puffs_vnreq_setgetattr
  274 struct puffs_vnreq_setgetattr {
  275         struct puffs_cred       pvnr_cred;              /* OUT  */
  276         struct vattr            pvnr_va;                /* IN/OUT (op depend) */
  277         pid_t                   pvnr_pid;               /* OUT  */
  278 };
  279 
  280 #define puffs_vnreq_read puffs_vnreq_readwrite
  281 #define puffs_vnreq_write puffs_vnreq_readwrite
  282 struct puffs_vnreq_readwrite {
  283         struct puffs_cred       pvnr_cred;              /* OUT    */
  284         off_t                   pvnr_offset;            /* OUT    */
  285         size_t                  pvnr_resid;             /* IN/OUT */
  286         int                     pvnr_ioflag;            /* OUT    */
  287 
  288         uint8_t                 pvnr_data[0];           /* IN/OUT (wr/rd) */
  289 };
  290 
  291 #define puffs_vnreq_ioctl puffs_vnreq_fcnioctl
  292 #define puffs_vnreq_fcntl puffs_vnreq_fcnioctl
  293 struct puffs_vnreq_fcnioctl {
  294         struct puffs_cred       pvnr_cred;
  295         u_long                  pvnr_command;
  296         pid_t                   pvnr_pid;
  297         int                     pvnr_fflag;
  298 
  299         void                    *pvnr_data;
  300         size_t                  pvnr_datalen;
  301         int                     pvnr_copyback;
  302 };
  303 
  304 struct puffs_vnreq_poll {
  305         int                     pvnr_events;            /* OUT  */
  306         pid_t                   pvnr_pid;               /* OUT  */
  307 };
  308 
  309 struct puffs_vnreq_revoke {
  310         int                     pvnr_flags;             /* OUT  */
  311 };
  312 
  313 struct puffs_vnreq_fsync {
  314         struct puffs_cred       pvnr_cred;              /* OUT  */
  315         off_t                   pvnr_offlo;             /* OUT  */
  316         off_t                   pvnr_offhi;             /* OUT  */
  317         pid_t                   pvnr_pid;               /* OUT  */
  318         int                     pvnr_flags;             /* OUT  */
  319 };
  320 
  321 struct puffs_vnreq_seek {
  322         struct puffs_cred       pvnr_cred;              /* OUT  */
  323         off_t                   pvnr_oldoff;            /* OUT  */
  324         off_t                   pvnr_newoff;            /* OUT  */
  325 };
  326 
  327 struct puffs_vnreq_remove {
  328         struct puffs_cn         pvnr_cn;                /* OUT  */
  329         void                    *pvnr_cookie_targ;      /* OUT  */
  330 };
  331 
  332 struct puffs_vnreq_mkdir {
  333         struct puffs_cn         pvnr_cn;                /* OUT  */
  334         struct vattr            pvnr_va;                /* OUT  */
  335         void                    *pvnr_newnode;          /* IN   */
  336 };
  337 
  338 struct puffs_vnreq_rmdir {
  339         struct puffs_cn         pvnr_cn;                /* OUT  */
  340         void                    *pvnr_cookie_targ;      /* OUT  */
  341 };
  342 
  343 struct puffs_vnreq_link {
  344         struct puffs_cn         pvnr_cn;                /* OUT */
  345         void                    *pvnr_cookie_targ;      /* OUT */
  346 };
  347 
  348 struct puffs_vnreq_rename {
  349         struct puffs_cn         pvnr_cn_src;            /* OUT  */
  350         struct puffs_cn         pvnr_cn_targ;           /* OUT  */
  351         void                    *pvnr_cookie_src;       /* OUT  */
  352         void                    *pvnr_cookie_targ;      /* OUT  */
  353         void                    *pvnr_cookie_targdir;   /* OUT  */
  354 };
  355 
  356 struct puffs_vnreq_symlink {
  357         struct puffs_cn         pvnr_cn;                /* OUT  */
  358         struct vattr            pvnr_va;                /* OUT  */
  359         void                    *pvnr_newnode;          /* IN   */
  360         char                    pvnr_link[MAXPATHLEN];  /* OUT  */
  361 };
  362 
  363 struct puffs_vnreq_readdir {
  364         struct puffs_cred       pvnr_cred;              /* OUT    */
  365         off_t                   pvnr_offset;            /* IN/OUT */
  366         size_t                  pvnr_resid;             /* IN/OUT */
  367 
  368         struct dirent           pvnr_dent[0];           /* IN      */
  369 };
  370 
  371 struct puffs_vnreq_readlink {
  372         struct puffs_cred       pvnr_cred;              /* OUT */
  373         size_t                  pvnr_linklen;           /* IN  */
  374         char                    pvnr_link[MAXPATHLEN];  /* IN, XXX  */
  375 };
  376 
  377 struct puffs_vnreq_reclaim {
  378         pid_t                   pvnr_pid;               /* OUT  */
  379 };
  380 
  381 struct puffs_vnreq_inactive {
  382         pid_t                   pvnr_pid;               /* OUT  */
  383         int                     pvnr_backendrefs;       /* IN   */
  384 };
  385 
  386 /* XXX: get rid of alltogether */
  387 struct puffs_vnreq_print {
  388         /* empty */
  389 };
  390 
  391 struct puffs_vnreq_pathconf {
  392         int                     pvnr_name;              /* OUT  */
  393         int                     pvnr_retval;            /* IN   */
  394 };
  395 
  396 struct puffs_vnreq_advlock {
  397         struct flock            pvnr_fl;                /* OUT  */
  398         void                    *pvnr_id;               /* OUT  */
  399         int                     pvnr_op;                /* OUT  */
  400         int                     pvnr_flags;             /* OUT  */
  401 };
  402 
  403 /* notyet */
  404 #if 0
  405 struct puffs_vnreq_kqfilter { };
  406 struct puffs_vnreq_islocked { };
  407 struct puffs_vnreq_lease { };
  408 #endif
  409 struct puffs_vnreq_getpages { };
  410 struct puffs_vnreq_putpages { };
  411 struct puffs_vnreq_mmap { };
  412 struct puffs_vnreq_getextattr { };
  413 struct puffs_vnreq_setextattr { };
  414 struct puffs_vnreq_listextattr { };
  415 
  416 #ifdef _KERNEL
  417 #define PUFFS_VFSREQ(a)                                                 \
  418         struct puffs_vfsreq_##a a##_arg;                                \
  419         memset(&a##_arg, 0, sizeof(struct puffs_vfsreq_##a))
  420 
  421 #define PUFFS_VNREQ(a)                                                  \
  422         struct puffs_vnreq_##a a##_arg;                                 \
  423         memset(&a##_arg, 0, sizeof(struct puffs_vnreq_##a))
  424 #endif
  425 
  426 #endif /* _PUFFS_MSGIF_H_ */

Cache object: aba0e0999ff54a2c01edb9bd1d5c58a3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.