Home | History | Annotate | Line # | Download | only in tmpfs
tmpfs.h revision 1.39.2.1
      1  1.39.2.1    jruoho /*	$NetBSD: tmpfs.h,v 1.39.2.1 2011/06/06 09:09:24 jruoho Exp $	*/
      2       1.1      jmmv 
      3       1.1      jmmv /*
      4      1.30        ad  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
      5       1.1      jmmv  * All rights reserved.
      6       1.1      jmmv  *
      7       1.1      jmmv  * This code is derived from software contributed to The NetBSD Foundation
      8       1.6      jmmv  * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
      9       1.6      jmmv  * 2005 program.
     10       1.1      jmmv  *
     11       1.1      jmmv  * Redistribution and use in source and binary forms, with or without
     12       1.1      jmmv  * modification, are permitted provided that the following conditions
     13       1.1      jmmv  * are met:
     14       1.1      jmmv  * 1. Redistributions of source code must retain the above copyright
     15       1.1      jmmv  *    notice, this list of conditions and the following disclaimer.
     16       1.1      jmmv  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1      jmmv  *    notice, this list of conditions and the following disclaimer in the
     18       1.1      jmmv  *    documentation and/or other materials provided with the distribution.
     19       1.1      jmmv  *
     20       1.1      jmmv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21       1.1      jmmv  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22       1.1      jmmv  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23       1.1      jmmv  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24       1.1      jmmv  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25       1.1      jmmv  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26       1.1      jmmv  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27       1.1      jmmv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28       1.1      jmmv  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29       1.1      jmmv  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30       1.1      jmmv  * POSSIBILITY OF SUCH DAMAGE.
     31       1.1      jmmv  */
     32       1.1      jmmv 
     33      1.10  christos #ifndef _FS_TMPFS_TMPFS_H_
     34      1.10  christos #define _FS_TMPFS_TMPFS_H_
     35       1.1      jmmv 
     36  1.39.2.1    jruoho #if !defined(_KERNEL) && !defined(_KMEMUSER)
     37  1.39.2.1    jruoho #error "not supposed to be exposed to userland"
     38  1.39.2.1    jruoho #endif
     39  1.39.2.1    jruoho 
     40       1.1      jmmv #include <sys/dirent.h>
     41       1.1      jmmv #include <sys/mount.h>
     42      1.38     rmind #include <sys/pool.h>
     43       1.1      jmmv #include <sys/queue.h>
     44       1.1      jmmv #include <sys/vnode.h>
     45       1.1      jmmv 
     46      1.37     pooka /*
     47      1.37     pooka  * Internal representation of a tmpfs directory entry.
     48  1.39.2.1    jruoho  *
     49  1.39.2.1    jruoho  * All fields are protected by vnode lock.
     50      1.37     pooka  */
     51  1.39.2.1    jruoho typedef struct tmpfs_dirent {
     52      1.37     pooka 	TAILQ_ENTRY(tmpfs_dirent)	td_entries;
     53      1.37     pooka 
     54  1.39.2.1    jruoho 	/* Pointer to the inode this entry refers to. */
     55  1.39.2.1    jruoho 	struct tmpfs_node *		td_node;
     56      1.37     pooka 
     57  1.39.2.1    jruoho 	/* Name and its length. */
     58      1.37     pooka 	char *				td_name;
     59  1.39.2.1    jruoho 	uint16_t			td_namelen;
     60  1.39.2.1    jruoho } tmpfs_dirent_t;
     61      1.37     pooka 
     62      1.37     pooka TAILQ_HEAD(tmpfs_dir, tmpfs_dirent);
     63      1.37     pooka 
     64      1.37     pooka #if defined(_KERNEL)
     65  1.39.2.1    jruoho 
     66  1.39.2.1    jruoho /* Validate maximum td_namelen length. */
     67  1.39.2.1    jruoho CTASSERT(MAXNAMLEN < UINT16_MAX);
     68  1.39.2.1    jruoho 
     69       1.4      yamt #define	TMPFS_DIRCOOKIE_DOT	0
     70       1.4      yamt #define	TMPFS_DIRCOOKIE_DOTDOT	1
     71       1.4      yamt #define	TMPFS_DIRCOOKIE_EOF	2
     72  1.39.2.1    jruoho 
     73  1.39.2.1    jruoho /*
     74  1.39.2.1    jruoho  * Each entry in a directory has a cookie that identifies it.  Cookies
     75  1.39.2.1    jruoho  * supersede offsets within directories, as tmpfs has no offsets as such.
     76  1.39.2.1    jruoho  *
     77  1.39.2.1    jruoho  * The '.', '..' and the end of directory markers have fixed cookies,
     78  1.39.2.1    jruoho  * which cannot collide with the cookies generated by other entries.
     79  1.39.2.1    jruoho  *
     80  1.39.2.1    jruoho  * The cookies for the other entries are generated based on the memory
     81  1.39.2.1    jruoho  * address of their representative meta-data structure.
     82  1.39.2.1    jruoho  *
     83  1.39.2.1    jruoho  * XXX: Truncating directory cookies to 31 bits now - workaround for
     84  1.39.2.1    jruoho  * problem with Linux compat, see PR/32034.
     85  1.39.2.1    jruoho  */
     86  1.39.2.1    jruoho static inline off_t
     87  1.39.2.1    jruoho tmpfs_dircookie(tmpfs_dirent_t *de)
     88      1.22      jmmv {
     89      1.22      jmmv 	off_t cookie;
     90      1.22      jmmv 
     91      1.22      jmmv 	cookie = ((off_t)(uintptr_t)de >> 1) & 0x7FFFFFFF;
     92      1.22      jmmv 	KASSERT(cookie != TMPFS_DIRCOOKIE_DOT);
     93      1.22      jmmv 	KASSERT(cookie != TMPFS_DIRCOOKIE_DOTDOT);
     94      1.22      jmmv 	KASSERT(cookie != TMPFS_DIRCOOKIE_EOF);
     95      1.22      jmmv 
     96      1.22      jmmv 	return cookie;
     97      1.22      jmmv }
     98  1.39.2.1    jruoho #endif
     99       1.1      jmmv 
    100      1.37     pooka /*
    101  1.39.2.1    jruoho  * Internal representation of a tmpfs file system node -- inode.
    102      1.37     pooka  *
    103      1.37     pooka  * This structure is splitted in two parts: one holds attributes common
    104      1.37     pooka  * to all file types and the other holds data that is only applicable to
    105  1.39.2.1    jruoho  * a particular type.
    106  1.39.2.1    jruoho  *
    107  1.39.2.1    jruoho  * All fields are protected by vnode lock.  The vnode association itself
    108  1.39.2.1    jruoho  * is protected by tmpfs_node_t::tn_vlock.
    109      1.37     pooka  */
    110  1.39.2.1    jruoho typedef struct tmpfs_node {
    111      1.37     pooka 	LIST_ENTRY(tmpfs_node)	tn_entries;
    112      1.37     pooka 
    113  1.39.2.1    jruoho 	/*
    114  1.39.2.1    jruoho 	 * Each inode has a corresponding vnode.  It is a bi-directional
    115  1.39.2.1    jruoho 	 * association.  Whenever vnode is allocated, its v_data field is
    116  1.39.2.1    jruoho 	 * set to the inode it reference, and tmpfs_node_t::tn_vnode is
    117  1.39.2.1    jruoho 	 * set to point to the said vnode.
    118  1.39.2.1    jruoho 	 *
    119  1.39.2.1    jruoho 	 * Further attempts to allocate a vnode for this same node will
    120  1.39.2.1    jruoho 	 * result in returning a new reference to the value stored in
    121  1.39.2.1    jruoho 	 * tn_vnode.  It may be NULL when the node is unused (that is,
    122  1.39.2.1    jruoho 	 * no vnode has been allocated or it has been reclaimed).
    123  1.39.2.1    jruoho 	 */
    124  1.39.2.1    jruoho 	kmutex_t		tn_vlock;
    125  1.39.2.1    jruoho 	vnode_t *		tn_vnode;
    126  1.39.2.1    jruoho 
    127  1.39.2.1    jruoho 	/* Directory entry.  Only a hint, since hard link can have multiple. */
    128  1.39.2.1    jruoho 	tmpfs_dirent_t *	tn_dirent_hint;
    129  1.39.2.1    jruoho 
    130  1.39.2.1    jruoho 	/* The inode type: VBLK, VCHR, VDIR, VFIFO, VLNK, VREG or VSOCK. */
    131      1.37     pooka 	enum vtype		tn_type;
    132      1.37     pooka 
    133  1.39.2.1    jruoho 	/* Inode identifier and generation number. */
    134      1.37     pooka 	ino_t			tn_id;
    135  1.39.2.1    jruoho 	unsigned long		tn_gen;
    136      1.37     pooka 
    137  1.39.2.1    jruoho 	/* Inode status flags (for operations in delayed manner). */
    138      1.37     pooka 	int			tn_status;
    139      1.37     pooka 
    140  1.39.2.1    jruoho 	/* The inode size. */
    141      1.37     pooka 	off_t			tn_size;
    142      1.37     pooka 
    143      1.37     pooka 	/* Generic node attributes. */
    144      1.37     pooka 	uid_t			tn_uid;
    145      1.37     pooka 	gid_t			tn_gid;
    146      1.37     pooka 	mode_t			tn_mode;
    147      1.37     pooka 	int			tn_flags;
    148      1.37     pooka 	nlink_t			tn_links;
    149      1.37     pooka 	struct timespec		tn_atime;
    150      1.37     pooka 	struct timespec		tn_mtime;
    151      1.37     pooka 	struct timespec		tn_ctime;
    152      1.37     pooka 	struct timespec		tn_birthtime;
    153      1.37     pooka 
    154      1.37     pooka 	/* Head of byte-level lock list (used by tmpfs_advlock). */
    155      1.37     pooka 	struct lockf *		tn_lockf;
    156      1.37     pooka 
    157      1.37     pooka 	union {
    158  1.39.2.1    jruoho 		/* Type case: VBLK or VCHR. */
    159      1.37     pooka 		struct {
    160      1.37     pooka 			dev_t			tn_rdev;
    161      1.37     pooka 		} tn_dev;
    162      1.37     pooka 
    163  1.39.2.1    jruoho 		/* Type case: VDIR. */
    164      1.37     pooka 		struct {
    165  1.39.2.1    jruoho 			/* Parent directory (root inode points to itself). */
    166      1.37     pooka 			struct tmpfs_node *	tn_parent;
    167      1.37     pooka 
    168  1.39.2.1    jruoho 			/* List of directory entries. */
    169      1.37     pooka 			struct tmpfs_dir	tn_dir;
    170      1.37     pooka 
    171  1.39.2.1    jruoho 			/*
    172  1.39.2.1    jruoho 			 * Number and pointer of the last directory entry
    173  1.39.2.1    jruoho 			 * returned by the readdir(3) operation.
    174  1.39.2.1    jruoho 			 */
    175      1.37     pooka 			off_t			tn_readdir_lastn;
    176      1.37     pooka 			struct tmpfs_dirent *	tn_readdir_lastp;
    177      1.37     pooka 		} tn_dir;
    178      1.37     pooka 
    179  1.39.2.1    jruoho 		/* Type case: VLNK. */
    180      1.37     pooka 		struct tn_lnk {
    181  1.39.2.1    jruoho 			/* The link's target. */
    182      1.37     pooka 			char *			tn_link;
    183      1.37     pooka 		} tn_lnk;
    184      1.37     pooka 
    185  1.39.2.1    jruoho 		/* Type case: VREG. */
    186      1.37     pooka 		struct tn_reg {
    187  1.39.2.1    jruoho 			/* Underlying UVM object to store contents. */
    188      1.37     pooka 			struct uvm_object *	tn_aobj;
    189      1.37     pooka 			size_t			tn_aobj_pages;
    190      1.37     pooka 		} tn_reg;
    191      1.37     pooka 	} tn_spec;
    192  1.39.2.1    jruoho } tmpfs_node_t;
    193      1.37     pooka 
    194      1.37     pooka #if defined(_KERNEL)
    195  1.39.2.1    jruoho 
    196       1.1      jmmv LIST_HEAD(tmpfs_node_list, tmpfs_node);
    197       1.1      jmmv 
    198  1.39.2.1    jruoho /* Status flags. */
    199  1.39.2.1    jruoho #define	TMPFS_NODE_ACCESSED	0x01
    200  1.39.2.1    jruoho #define	TMPFS_NODE_MODIFIED	0x02
    201  1.39.2.1    jruoho #define	TMPFS_NODE_CHANGED	0x04
    202  1.39.2.1    jruoho 
    203  1.39.2.1    jruoho #define	TMPFS_NODE_STATUSALL	\
    204  1.39.2.1    jruoho     (TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED)
    205  1.39.2.1    jruoho 
    206  1.39.2.1    jruoho /*
    207  1.39.2.1    jruoho  * Bit indicating vnode reclamation.
    208  1.39.2.1    jruoho  * We abuse tmpfs_node_t::tn_gen for that.
    209  1.39.2.1    jruoho  */
    210  1.39.2.1    jruoho #define	TMPFS_NODE_GEN_MASK	(~0UL >> 1)
    211  1.39.2.1    jruoho #define	TMPFS_RECLAIMING_BIT	(~TMPFS_NODE_GEN_MASK)
    212  1.39.2.1    jruoho 
    213  1.39.2.1    jruoho #define	TMPFS_NODE_RECLAIMING(node) \
    214  1.39.2.1    jruoho     (((node)->tn_gen & TMPFS_RECLAIMING_BIT) != 0)
    215  1.39.2.1    jruoho 
    216  1.39.2.1    jruoho #define	TMPFS_NODE_GEN(node) \
    217  1.39.2.1    jruoho     ((node)->tn_gen & TMPFS_NODE_GEN_MASK)
    218  1.39.2.1    jruoho 
    219  1.39.2.1    jruoho /* White-out inode indicator. */
    220  1.39.2.1    jruoho #define	TMPFS_NODE_WHITEOUT	((tmpfs_node_t *)-1)
    221       1.1      jmmv 
    222       1.1      jmmv /*
    223       1.6      jmmv  * Internal representation of a tmpfs mount point.
    224       1.1      jmmv  */
    225  1.39.2.1    jruoho typedef struct tmpfs_mount {
    226      1.38     rmind 	/* Limit and number of bytes in use by the file system. */
    227      1.38     rmind 	uint64_t		tm_mem_limit;
    228      1.38     rmind 	uint64_t		tm_bytes_used;
    229      1.38     rmind 	kmutex_t		tm_acc_lock;
    230       1.1      jmmv 
    231  1.39.2.1    jruoho 	/* Pointer to the root inode. */
    232  1.39.2.1    jruoho 	tmpfs_node_t *		tm_root;
    233  1.39.2.1    jruoho 
    234  1.39.2.1    jruoho 	/* Maximum number of possible nodes for this file system. */
    235      1.32      jmmv 	unsigned int		tm_nodes_max;
    236       1.6      jmmv 
    237  1.39.2.1    jruoho 	/* Number of nodes currently allocated. */
    238      1.32      jmmv 	unsigned int		tm_nodes_cnt;
    239       1.6      jmmv 
    240  1.39.2.1    jruoho 	/* List of inodes and the lock protecting it. */
    241      1.30        ad 	kmutex_t		tm_lock;
    242      1.30        ad 	struct tmpfs_node_list	tm_nodes;
    243  1.39.2.1    jruoho } tmpfs_mount_t;
    244       1.1      jmmv 
    245       1.1      jmmv /*
    246       1.1      jmmv  * This structure maps a file identifier to a tmpfs node.  Used by the
    247       1.1      jmmv  * NFS code.
    248       1.1      jmmv  */
    249  1.39.2.1    jruoho typedef struct tmpfs_fid {
    250       1.1      jmmv 	uint16_t		tf_len;
    251       1.1      jmmv 	uint16_t		tf_pad;
    252      1.18       riz 	uint32_t		tf_gen;
    253       1.1      jmmv 	ino_t			tf_id;
    254  1.39.2.1    jruoho } tmpfs_fid_t;
    255       1.1      jmmv 
    256       1.1      jmmv /*
    257       1.1      jmmv  * Prototypes for tmpfs_subr.c.
    258       1.1      jmmv  */
    259       1.1      jmmv 
    260  1.39.2.1    jruoho int		tmpfs_alloc_node(tmpfs_mount_t *, enum vtype, uid_t, gid_t,
    261  1.39.2.1    jruoho 		    mode_t, char *, dev_t, tmpfs_node_t **);
    262  1.39.2.1    jruoho void		tmpfs_free_node(tmpfs_mount_t *, tmpfs_node_t *);
    263  1.39.2.1    jruoho 
    264  1.39.2.1    jruoho int		tmpfs_alloc_file(vnode_t *, vnode_t **, struct vattr *,
    265  1.39.2.1    jruoho 		    struct componentname *, char *);
    266  1.39.2.1    jruoho 
    267  1.39.2.1    jruoho int		tmpfs_vnode_get(struct mount *, tmpfs_node_t *, vnode_t **);
    268  1.39.2.1    jruoho 
    269  1.39.2.1    jruoho int		tmpfs_alloc_dirent(tmpfs_mount_t *, const char *, uint16_t,
    270  1.39.2.1    jruoho 		    tmpfs_dirent_t **);
    271  1.39.2.1    jruoho void		tmpfs_free_dirent(tmpfs_mount_t *, tmpfs_dirent_t *);
    272  1.39.2.1    jruoho void		tmpfs_dir_attach(vnode_t *, tmpfs_dirent_t *, tmpfs_node_t *);
    273  1.39.2.1    jruoho void		tmpfs_dir_detach(vnode_t *, tmpfs_dirent_t *);
    274  1.39.2.1    jruoho 
    275  1.39.2.1    jruoho tmpfs_dirent_t *tmpfs_dir_lookup(tmpfs_node_t *, struct componentname *);
    276  1.39.2.1    jruoho tmpfs_dirent_t *tmpfs_dir_cached(tmpfs_node_t *);
    277  1.39.2.1    jruoho 
    278  1.39.2.1    jruoho int		tmpfs_dir_getdotdent(tmpfs_node_t *, struct uio *);
    279  1.39.2.1    jruoho int		tmpfs_dir_getdotdotdent(tmpfs_node_t *, struct uio *);
    280  1.39.2.1    jruoho tmpfs_dirent_t *tmpfs_dir_lookupbycookie(tmpfs_node_t *, off_t);
    281  1.39.2.1    jruoho int		tmpfs_dir_getdents(tmpfs_node_t *, struct uio *, off_t *);
    282  1.39.2.1    jruoho 
    283  1.39.2.1    jruoho int		tmpfs_reg_resize(vnode_t *, off_t);
    284  1.39.2.1    jruoho int		tmpfs_truncate(vnode_t *, off_t);
    285  1.39.2.1    jruoho 
    286  1.39.2.1    jruoho int		tmpfs_chflags(vnode_t *, int, kauth_cred_t, lwp_t *);
    287  1.39.2.1    jruoho int		tmpfs_chmod(vnode_t *, mode_t, kauth_cred_t, lwp_t *);
    288  1.39.2.1    jruoho int		tmpfs_chown(vnode_t *, uid_t, gid_t, kauth_cred_t, lwp_t *);
    289  1.39.2.1    jruoho int		tmpfs_chsize(vnode_t *, u_quad_t, kauth_cred_t, lwp_t *);
    290  1.39.2.1    jruoho int		tmpfs_chtimes(vnode_t *, const struct timespec *,
    291  1.39.2.1    jruoho 		    const struct timespec *, const struct timespec *, int,
    292  1.39.2.1    jruoho 		    kauth_cred_t, lwp_t *);
    293  1.39.2.1    jruoho void		tmpfs_update(vnode_t *, const struct timespec *,
    294  1.39.2.1    jruoho 		    const struct timespec *, const struct timespec *, int);
    295       1.9      yamt 
    296      1.38     rmind /*
    297      1.38     rmind  * Prototypes for tmpfs_mem.c.
    298      1.38     rmind  */
    299      1.38     rmind 
    300  1.39.2.1    jruoho void		tmpfs_mntmem_init(tmpfs_mount_t *, uint64_t);
    301  1.39.2.1    jruoho void		tmpfs_mntmem_destroy(tmpfs_mount_t *);
    302      1.38     rmind 
    303      1.38     rmind size_t		tmpfs_mem_info(bool);
    304  1.39.2.1    jruoho uint64_t	tmpfs_bytes_max(tmpfs_mount_t *);
    305  1.39.2.1    jruoho size_t		tmpfs_pages_avail(tmpfs_mount_t *);
    306  1.39.2.1    jruoho bool		tmpfs_mem_incr(tmpfs_mount_t *, size_t);
    307  1.39.2.1    jruoho void		tmpfs_mem_decr(tmpfs_mount_t *, size_t);
    308      1.38     rmind 
    309  1.39.2.1    jruoho tmpfs_dirent_t *tmpfs_dirent_get(tmpfs_mount_t *);
    310  1.39.2.1    jruoho void		tmpfs_dirent_put(tmpfs_mount_t *, tmpfs_dirent_t *);
    311      1.38     rmind 
    312  1.39.2.1    jruoho tmpfs_node_t *	tmpfs_node_get(tmpfs_mount_t *);
    313  1.39.2.1    jruoho void		tmpfs_node_put(tmpfs_mount_t *, tmpfs_node_t *);
    314      1.38     rmind 
    315  1.39.2.1    jruoho char *		tmpfs_strname_alloc(tmpfs_mount_t *, size_t);
    316  1.39.2.1    jruoho void		tmpfs_strname_free(tmpfs_mount_t *, char *, size_t);
    317      1.38     rmind bool		tmpfs_strname_neqlen(struct componentname *, struct componentname *);
    318      1.38     rmind 
    319       1.1      jmmv /*
    320       1.1      jmmv  * Ensures that the node pointed by 'node' is a directory and that its
    321       1.1      jmmv  * contents are consistent with respect to directories.
    322       1.1      jmmv  */
    323       1.1      jmmv #define TMPFS_VALIDATE_DIR(node) \
    324       1.1      jmmv     KASSERT((node)->tn_type == VDIR); \
    325  1.39.2.1    jruoho     KASSERT((node)->tn_size % sizeof(tmpfs_dirent_t) == 0); \
    326      1.15      jmmv     KASSERT((node)->tn_spec.tn_dir.tn_readdir_lastp == NULL || \
    327      1.22      jmmv         tmpfs_dircookie((node)->tn_spec.tn_dir.tn_readdir_lastp) == \
    328      1.15      jmmv         (node)->tn_spec.tn_dir.tn_readdir_lastn);
    329       1.1      jmmv 
    330       1.1      jmmv /*
    331       1.1      jmmv  * Memory management stuff.
    332       1.1      jmmv  */
    333       1.1      jmmv 
    334  1.39.2.1    jruoho /* Amount of memory pages to reserve for the system. */
    335  1.39.2.1    jruoho #define	TMPFS_PAGES_RESERVED	(4 * 1024 * 1024 / PAGE_SIZE)
    336       1.1      jmmv 
    337       1.1      jmmv /*
    338  1.39.2.1    jruoho  * Routines to convert VFS structures to tmpfs internal ones.
    339       1.1      jmmv  */
    340       1.1      jmmv 
    341  1.39.2.1    jruoho static inline tmpfs_mount_t *
    342       1.1      jmmv VFS_TO_TMPFS(struct mount *mp)
    343       1.1      jmmv {
    344  1.39.2.1    jruoho 	tmpfs_mount_t *tmp = mp->mnt_data;
    345       1.1      jmmv 
    346  1.39.2.1    jruoho 	KASSERT(tmp != NULL);
    347       1.1      jmmv 	return tmp;
    348       1.1      jmmv }
    349       1.1      jmmv 
    350  1.39.2.1    jruoho static inline tmpfs_node_t *
    351  1.39.2.1    jruoho VP_TO_TMPFS_DIR(vnode_t *vp)
    352      1.37     pooka {
    353  1.39.2.1    jruoho 	tmpfs_node_t *node = vp->v_data;
    354      1.37     pooka 
    355  1.39.2.1    jruoho 	KASSERT(node != NULL);
    356  1.39.2.1    jruoho 	TMPFS_VALIDATE_DIR(node);
    357      1.37     pooka 	return node;
    358      1.37     pooka }
    359      1.37     pooka 
    360  1.39.2.1    jruoho #endif /* defined(_KERNEL) */
    361      1.37     pooka 
    362  1.39.2.1    jruoho static __inline tmpfs_node_t *
    363  1.39.2.1    jruoho VP_TO_TMPFS_NODE(vnode_t *vp)
    364       1.1      jmmv {
    365  1.39.2.1    jruoho 	tmpfs_node_t *node = vp->v_data;
    366      1.14  christos #ifdef KASSERT
    367  1.39.2.1    jruoho 	KASSERT(node != NULL);
    368      1.14  christos #endif
    369       1.1      jmmv 	return node;
    370       1.1      jmmv }
    371      1.37     pooka 
    372      1.10  christos #endif /* _FS_TMPFS_TMPFS_H_ */
    373