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/pseudofs/pseudofs.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 /*-
    2  * Copyright (c) 2001 Dag-Erling Coïdan Smørgrav
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer
   10  *    in this position and unchanged.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  *
   28  *      $FreeBSD: releng/5.0/sys/fs/pseudofs/pseudofs.h 105988 2002-10-26 14:38:24Z rwatson $
   29  */
   30 
   31 #ifndef _PSEUDOFS_H_INCLUDED
   32 #define _PSEUDOFS_H_INCLUDED
   33 
   34 /*
   35  * Opaque structures
   36  */
   37 struct mount;
   38 struct nameidata;
   39 struct proc;
   40 struct sbuf;
   41 struct statfs;
   42 struct thread;
   43 struct uio;
   44 struct vfsconf;
   45 struct vnode;
   46 
   47 /*
   48  * Limits and constants
   49  */
   50 #define PFS_NAMELEN             24
   51 #define PFS_FSNAMELEN           16      /* equal to MFSNAMELEN */
   52 #define PFS_DELEN               (8 + PFS_NAMELEN)
   53 
   54 typedef enum {
   55         pfstype_none = 0,
   56         pfstype_root,
   57         pfstype_dir,
   58         pfstype_this,
   59         pfstype_parent,
   60         pfstype_file,
   61         pfstype_symlink,
   62         pfstype_procdir
   63 } pfs_type_t;
   64 
   65 /*
   66  * Flags
   67  */
   68 #define PFS_RD          0x0001  /* readable */
   69 #define PFS_WR          0x0002  /* writeable */
   70 #define PFS_RDWR        (PFS_RD|PFS_WR)
   71 #define PFS_RAWRD       0x0004  /* raw reader */
   72 #define PFS_RAWWR       0x0008  /* raw writer */
   73 #define PFS_RAW         (PFS_RAWRD|PFS_RAWWR)
   74 #define PFS_PROCDEP     0x0010  /* process-dependent */
   75 #define PFS_DISABLED    0x8000  /* node is disabled */
   76 
   77 /*
   78  * Data structures
   79  */
   80 struct pfs_info;
   81 struct pfs_node;
   82 struct pfs_bitmap;
   83 
   84 /*
   85  * Init / uninit callback
   86  */
   87 #define PFS_INIT_ARGS \
   88         struct pfs_info *pi, struct vfsconf *vfc
   89 #define PFS_INIT_PROTO(name) \
   90         int name(PFS_INIT_ARGS);
   91 typedef int (*pfs_init_t)(PFS_INIT_ARGS);
   92 
   93 /*
   94  * Filler callback
   95  */
   96 #define PFS_FILL_ARGS \
   97         struct thread *td, struct proc *p, struct pfs_node *pn, \
   98         struct sbuf *sb, struct uio *uio
   99 #define PFS_FILL_PROTO(name) \
  100         int name(PFS_FILL_ARGS);
  101 typedef int (*pfs_fill_t)(PFS_FILL_ARGS);
  102 
  103 /*
  104  * Attribute callback
  105  */
  106 struct vattr;
  107 #define PFS_ATTR_ARGS \
  108         struct thread *td, struct proc *p, struct pfs_node *pn, \
  109         struct vattr *vap
  110 #define PFS_ATTR_PROTO(name) \
  111         int name(PFS_ATTR_ARGS);
  112 typedef int (*pfs_attr_t)(PFS_ATTR_ARGS);
  113 
  114 struct pfs_bitmap;              /* opaque */
  115 
  116 /*
  117  * Visibility callback
  118  */
  119 #define PFS_VIS_ARGS \
  120         struct thread *td, struct proc *p, struct pfs_node *pn
  121 #define PFS_VIS_PROTO(name) \
  122         int name(PFS_VIS_ARGS);
  123 typedef int (*pfs_vis_t)(PFS_VIS_ARGS);
  124 
  125 /*
  126  * Ioctl callback
  127  */
  128 #define PFS_IOCTL_ARGS \
  129         struct thread *td, struct proc *p, struct pfs_node *pn, \
  130         unsigned long cmd, caddr_t data
  131 #define PFS_IOCTL_PROTO(name) \
  132         int name(PFS_IOCTL_ARGS);
  133 typedef int (*pfs_ioctl_t)(PFS_IOCTL_ARGS);
  134 
  135 /*
  136  * Getextattr callback
  137  */
  138 #define PFS_GETEXTATTR_ARGS \
  139         struct thread *td, struct proc *p, struct pfs_node *pn, \
  140         int attrnamespace, const char *name, struct uio *uio,   \
  141         size_t *size, struct ucred *cred
  142 #define PFS_GETEXTATTR_PROTO(name) \
  143         int name(PFS_GETEXTATTR_ARGS);
  144 struct ucred;
  145 typedef int (*pfs_getextattr_t)(PFS_GETEXTATTR_ARGS);
  146 
  147 /*
  148  * Last-close callback
  149  */
  150 #define PFS_CLOSE_ARGS \
  151         struct thread *td, struct proc *p, struct pfs_node *pn
  152 #define PFS_CLOSE_PROTO(name) \
  153         int name(PFS_CLOSE_ARGS);
  154 typedef int (*pfs_close_t)(PFS_CLOSE_ARGS);
  155 
  156 /*
  157  * pfs_info: describes a pseudofs instance
  158  */
  159 struct pfs_info {
  160         char                     pi_name[PFS_FSNAMELEN];
  161         pfs_init_t               pi_init;
  162         pfs_init_t               pi_uninit;
  163         /* members below this line aren't initialized */
  164         struct pfs_node         *pi_root;
  165         /* currently, the mutex is only used to protect the bitmap */
  166         struct mtx               pi_mutex;
  167         struct pfs_bitmap       *pi_bitmap;
  168 };
  169 
  170 /*
  171  * pfs_node: describes a node (file or directory) within a pseudofs
  172  */
  173 struct pfs_node {
  174         char                     pn_name[PFS_NAMELEN];
  175         pfs_type_t               pn_type;
  176         union {
  177                 void            *_pn_dummy;
  178                 pfs_fill_t       _pn_func;
  179                 struct pfs_node *_pn_nodes;
  180         } u1;
  181 #define pn_func         u1._pn_func
  182 #define pn_nodes        u1._pn_nodes
  183         pfs_ioctl_t              pn_ioctl;
  184         pfs_close_t              pn_close;
  185         pfs_attr_t               pn_attr;
  186         pfs_vis_t                pn_vis;
  187         pfs_getextattr_t         pn_getextattr;
  188         void                    *pn_data;
  189         int                      pn_flags;
  190 
  191         struct pfs_info         *pn_info;
  192         struct pfs_node         *pn_parent;
  193         struct pfs_node         *pn_next;
  194         u_int32_t                pn_fileno;
  195 };
  196 
  197 /*
  198  * VFS interface
  199  */
  200 int              pfs_mount      (struct pfs_info *pi, struct mount *mp,
  201                                  struct nameidata *ndp, struct thread *td);
  202 int              pfs_unmount    (struct mount *mp, int mntflags,
  203                                  struct thread *td);
  204 int              pfs_root       (struct mount *mp, struct vnode **vpp);
  205 int              pfs_statfs     (struct mount *mp, struct statfs *sbp,
  206                                  struct thread *td);
  207 int              pfs_init       (struct pfs_info *pi, struct vfsconf *vfc);
  208 int              pfs_uninit     (struct pfs_info *pi, struct vfsconf *vfc);
  209 
  210 /*
  211  * Directory structure construction and manipulation
  212  */
  213 struct pfs_node *pfs_create_dir (struct pfs_node *parent, char *name,
  214                                  pfs_attr_t attr, pfs_vis_t vis, int flags);
  215 struct pfs_node *pfs_create_file(struct pfs_node *parent, char *name,
  216                                  pfs_fill_t fill, pfs_attr_t attr,
  217                                  pfs_vis_t vis, int flags);
  218 struct pfs_node *pfs_create_link(struct pfs_node *parent, char *name,
  219                                  pfs_fill_t fill, pfs_attr_t attr,
  220                                  pfs_vis_t vis, int flags);
  221 int              pfs_disable    (struct pfs_node *pn);
  222 int              pfs_enable     (struct pfs_node *pn);
  223 int              pfs_destroy    (struct pfs_node *pn);
  224 
  225 /*
  226  * Now for some initialization magic...
  227  */
  228 #define PSEUDOFS(name, version)                                         \
  229                                                                         \
  230 static struct pfs_info name##_info = {                                  \
  231         #name,                                                          \
  232         name##_init,                                                    \
  233         name##_uninit,                                                  \
  234 };                                                                      \
  235                                                                         \
  236 static int                                                              \
  237 _##name##_mount(struct mount *mp, struct nameidata *ndp,                \
  238              struct thread *td) {                                       \
  239         return pfs_mount(&name##_info, mp, ndp, td);                    \
  240 }                                                                       \
  241                                                                         \
  242 static int                                                              \
  243 _##name##_init(struct vfsconf *vfc) {                                   \
  244         return pfs_init(&name##_info, vfc);                             \
  245 }                                                                       \
  246                                                                         \
  247 static int                                                              \
  248 _##name##_uninit(struct vfsconf *vfc) {                                 \
  249         return pfs_uninit(&name##_info, vfc);                           \
  250 }                                                                       \
  251                                                                         \
  252 static struct vfsops name##_vfsops = {                                  \
  253         NULL,                                                           \
  254         vfs_stdstart,                                                   \
  255         pfs_unmount,                                                    \
  256         pfs_root,                                                       \
  257         vfs_stdquotactl,                                                \
  258         pfs_statfs,                                                     \
  259         vfs_stdsync,                                                    \
  260         vfs_stdvget,                                                    \
  261         vfs_stdfhtovp,                                                  \
  262         vfs_stdcheckexp,                                                \
  263         vfs_stdvptofh,                                                  \
  264         _##name##_init,                                                 \
  265         _##name##_uninit,                                               \
  266         vfs_stdextattrctl,                                              \
  267         _##name##_mount,                                                \
  268 };                                                                      \
  269 VFS_SET(name##_vfsops, name, VFCF_SYNTHETIC);                           \
  270 MODULE_VERSION(name, version);                                          \
  271 MODULE_DEPEND(name, pseudofs, 1, 1, 1);
  272 
  273 #endif

Cache object: cd24482c5b10c643bca5a4d31c635178


[ 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.