[BACK]Return to puffs_sys.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / puffs

Annotation of src/sys/fs/puffs/puffs_sys.h, Revision 1.26

1.26    ! pooka       1: /*     $NetBSD: puffs_sys.h,v 1.25 2007/02/27 23:43:23 pooka Exp $     */
1.1       pooka       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_SYS_H_
                     36: #define _PUFFS_SYS_H_
                     37:
                     38: #include <sys/param.h>
                     39: #include <sys/select.h>
                     40: #include <sys/kauth.h>
                     41: #include <sys/lock.h>
                     42: #include <sys/queue.h>
1.4       pooka      43: #include <sys/pool.h>
1.1       pooka      44:
                     45: #include <fs/puffs/puffs_msgif.h>
                     46:
1.6       pooka      47: #include <miscfs/genfs/genfs_node.h>
                     48:
1.2       pooka      49: extern int (**puffs_vnodeop_p)(void *);
                     50: extern int (**puffs_specop_p)(void *);
1.3       pooka      51: extern int (**puffs_fifoop_p)(void *);
1.2       pooka      52:
                     53: extern const struct vnodeopv_desc puffs_vnodeop_opv_desc;
                     54: extern const struct vnodeopv_desc puffs_specop_opv_desc;
1.3       pooka      55: extern const struct vnodeopv_desc puffs_fifoop_opv_desc;
1.10      pooka      56: extern const struct vnodeopv_desc puffs_msgop_opv_desc;
1.2       pooka      57:
1.4       pooka      58: extern struct pool puffs_pnpool;
                     59:
1.17      pooka      60: #define PUFFS_NAMEPREFIX "puffs:"
                     61:
1.1       pooka      62: /*
                     63:  * While a request is going to userspace, park the caller within the
                     64:  * kernel.  This is the kernel counterpart of "struct puffs_req".
                     65:  */
                     66: struct puffs_park {
1.12      pooka      67:        struct puffs_req        *park_preq;     /* req followed by buf  */
1.25      pooka      68:        uint64_t                park_id;        /* duplicate of preq_id */
                     69:
1.12      pooka      70:        size_t                  park_copylen;   /* userspace copylength */
1.26    ! pooka      71:        size_t                  park_maxlen;    /* max size, ADJUSTABLE */
        !            72:        struct buf              *park_bp;       /* bp, ASYNCBIOREAD     */
1.1       pooka      73:
1.25      pooka      74:        int                     park_flags;
1.1       pooka      75:
                     76:        TAILQ_ENTRY(puffs_park) park_entries;
                     77: };
1.26    ! pooka      78:
1.25      pooka      79: #define PUFFS_PARKFLAG_PROCESSING      0x01
                     80: #define PUFFS_PARKFLAG_RQUEUE          0x02
                     81: #define PUFFS_PARKFLAG_RECVREPLY       0x04
                     82: #define PUFFS_PARKFLAG_DONE            0x08
                     83: #define PUFFS_PARKFLAG_WAITERGONE      0x10
                     84: #define PUFFS_PARKFLAG_ADJUSTABLE      0x20
1.26    ! pooka      85: #define PUFFS_PARKFLAG_ASYNCBIOREAD    0x40
1.1       pooka      86:
                     87: #define PUFFS_SIZEOPREQ_UIO_IN 1
                     88: #define PUFFS_SIZEOPREQ_UIO_OUT 2
                     89: #define PUFFS_SIZEOPREQ_BUF_IN 3
                     90: #define PUFFS_SIZEOPREQ_BUF_OUT 4
                     91:
                     92: #define PUFFS_SIZEOP_UIO(a)    \
                     93:        (((a)==PUFFS_SIZEOPREQ_UIO_IN)||(a)==PUFFS_SIZEOPREQ_UIO_OUT)
                     94: #define PUFFS_SIZEOP_BUF(a)    \
                     95:        (((a)==PUFFS_SIZEOPREQ_BUF_IN)||(a)==PUFFS_SIZEOPREQ_BUF_OUT)
                     96:
                     97: /* XXX: alignment-optimization */
                     98: struct puffs_sizepark {
                     99:        uint64_t        pkso_reqid;
                    100:        uint8_t         pkso_reqtype;
                    101:
                    102:        struct uio      *pkso_uio;
                    103:        void            *pkso_copybuf;
                    104:        size_t          pkso_bufsize;
                    105:
                    106:        TAILQ_ENTRY(puffs_sizepark) pkso_entries;
                    107: };
                    108:
1.12      pooka     109: #ifdef DEBUG
1.24      pooka     110: #ifndef PUFFSDEBUG
                    111: #define PUFFSDEBUG
                    112: #endif
                    113: #endif
                    114:
                    115: #ifdef PUFFSDEBUG
1.12      pooka     116: extern int puffsdebug; /* puffs_subr.c */
                    117: #define DPRINTF(x) if (puffsdebug > 0) printf x
                    118: #define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
                    119: #else
1.1       pooka     120: #define DPRINTF(x)
1.10      pooka     121: #define DPRINTF_VERBOSE(x)
1.12      pooka     122: #endif
1.1       pooka     123:
                    124: #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
                    125: #define PMPTOMP(pmp) (pmp->pmp_mp)
                    126: #define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
                    127: #define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
                    128: #define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
                    129: #define FPTOPMP(fp) (((struct puffs_instance *)fp->f_data)->pi_pmp)
                    130: #define FPTOPI(fp) ((struct puffs_instance *)fp->f_data)
                    131:
1.10      pooka     132: #define EXISTSOP(pmp, op) \
1.11      pooka     133:  (((pmp)->pmp_flags&PUFFS_KFLAG_ALLOPS) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
1.10      pooka     134:
1.16      pooka     135: #define PUFFS_DOCACHE(pmp)     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE) == 0)
                    136:
1.1       pooka     137: TAILQ_HEAD(puffs_wq, puffs_park);
1.20      pooka     138: LIST_HEAD(puffs_node_hashlist, puffs_node);
1.1       pooka     139: struct puffs_mount {
                    140:        struct simplelock               pmp_lock;
                    141:
                    142:        struct puffs_args               pmp_args;
1.10      pooka     143: #define pmp_flags pmp_args.pa_flags
                    144: #define pmp_vnopmask pmp_args.pa_vnopmask
1.1       pooka     145:
                    146:        struct puffs_wq                 pmp_req_touser;
                    147:        size_t                          pmp_req_touser_waiters;
                    148:        size_t                          pmp_req_maxsize;
                    149:
                    150:        struct puffs_wq                 pmp_req_replywait;
                    151:        TAILQ_HEAD(, puffs_sizepark)    pmp_req_sizepark;
                    152:
1.20      pooka     153:        struct puffs_node_hashlist      *pmp_pnodehash;
                    154:        size_t                          pmp_npnodehash;
1.1       pooka     155:
                    156:        struct mount                    *pmp_mp;
                    157:        struct vnode                    *pmp_root;
                    158:        void                            *pmp_rootcookie;
                    159:        struct selinfo                  *pmp_sel;       /* in puffs_instance */
                    160:
1.20      pooka     161:        uint64_t                        pmp_nextreq;
1.1       pooka     162:        uint8_t                         pmp_status;
1.14      pooka     163:        uint8_t                         pmp_unmounting;
1.22      pooka     164:        uint8_t                         pmp_suspend;
1.1       pooka     165: };
1.8       pooka     166:
1.1       pooka     167: #define PUFFSTAT_BEFOREINIT    0
                    168: #define PUFFSTAT_MOUNTING      1
                    169: #define PUFFSTAT_RUNNING       2
1.14      pooka     170: #define PUFFSTAT_DYING         3 /* Do you want your possessions identified? */
1.1       pooka     171:
1.22      pooka     172: #define PNODE_NOREFS   0x01    /* vnode inactive, no backend reference */
                    173: #define PNODE_SUSPEND  0x02    /* issue all operations as FAF          */
1.21      pooka     174: #if 0
                    175: #define PNODE_LOCKED   0x0
                    176: #define PNODE_WANTED   0x0
                    177: #endif
1.1       pooka     178: struct puffs_node {
1.6       pooka     179:        struct genfs_node pn_gnode;     /* genfs glue                   */
                    180:
1.1       pooka     181:        void            *pn_cookie;     /* userspace pnode cookie       */
                    182:        struct vnode    *pn_vp;         /* backpointer to vnode         */
                    183:        uint32_t        pn_stat;        /* node status                  */
                    184:
1.20      pooka     185:        LIST_ENTRY(puffs_node) pn_hashent;
1.1       pooka     186: };
                    187:
1.7       pooka     188: int    puffs_start2(struct puffs_mount *, struct puffs_startreq *);
1.1       pooka     189:
                    190: int    puffs_vfstouser(struct puffs_mount *, int, void *, size_t);
1.22      pooka     191: void   puffs_suspendtouser(struct puffs_mount *, int);
1.1       pooka     192: int    puffs_vntouser(struct puffs_mount *, int, void *, size_t, void *,
                    193:                       struct vnode *, struct vnode *);
1.6       pooka     194: void   puffs_vntouser_faf(struct puffs_mount *, int, void *, size_t, void *);
1.26    ! pooka     195: void   puffs_vntouser_bioread_async(struct puffs_mount *, void *,
        !           196:                                     size_t, off_t, struct buf *,
        !           197:                                     struct vnode *, struct vnode *);
1.1       pooka     198: int    puffs_vntouser_req(struct puffs_mount *, int, void *, size_t,
1.6       pooka     199:                           void *, uint64_t, struct vnode *, struct vnode *);
1.1       pooka     200: int    puffs_vntouser_adjbuf(struct puffs_mount *, int, void **, size_t *,
                    201:                              size_t, void *, struct vnode *, struct vnode *);
                    202:
1.6       pooka     203: int    puffs_getvnode(struct mount *, void *, enum vtype, voff_t, dev_t,
1.2       pooka     204:                       struct vnode **);
1.1       pooka     205: int    puffs_newnode(struct mount *, struct vnode *, struct vnode **,
1.2       pooka     206:                      void *, struct componentname *, enum vtype, dev_t);
1.1       pooka     207: void   puffs_putvnode(struct vnode *);
1.18      pooka     208: struct vnode *puffs_pnode2vnode(struct puffs_mount *, void *, int);
1.15      pooka     209: void   puffs_makecn(struct puffs_kcn *, const struct componentname *);
1.1       pooka     210: void   puffs_credcvt(struct puffs_cred *, kauth_cred_t);
                    211: pid_t  puffs_lwp2pid(struct lwp *);
                    212:
1.6       pooka     213: void   puffs_updatenode(struct vnode *, int);
                    214: #define PUFFS_UPDATEATIME      0x01
                    215: #define PUFFS_UPDATECTIME      0x02
                    216: #define PUFFS_UPDATEMTIME      0x04
                    217: #define PUFFS_UPDATESIZE       0x08
1.9       pooka     218: void   puffs_updatevpsize(struct vnode *);
1.6       pooka     219:
1.1       pooka     220: int    puffs_setpmp(pid_t, int, struct puffs_mount *);
                    221: void   puffs_nukebypmp(struct puffs_mount *);
                    222:
1.25      pooka     223: uint64_t               puffs_getreqid(struct puffs_mount *);
                    224: void                   puffs_userdead(struct puffs_mount *);
                    225: struct puffs_park *    puffs_reqtofaf(struct puffs_park *);
1.1       pooka     226:
1.13      pooka     227: /* get/put called by ioctl handler */
                    228: int    puffs_getop(struct puffs_mount *, struct puffs_reqh_get *, int);
                    229: int    puffs_putop(struct puffs_mount *, struct puffs_reqh_put *);
                    230:
1.1       pooka     231: extern int (**puffs_vnodeop_p)(void *);
                    232:
                    233: MALLOC_DECLARE(M_PUFFS);
                    234:
                    235: #endif /* _PUFFS_SYS_H_ */

CVSweb <webmaster@jp.NetBSD.org>