devfs_int.h revision 256281
1284285Sjkim/*-
2110010Smarkm * Copyright (c) 2005 Poul-Henning Kamp.  All rights reserved.
3110010Smarkm *
4160819Ssimon * Redistribution and use in source and binary forms, with or without
5110010Smarkm * modification, are permitted provided that the following conditions
6110010Smarkm * are met:
7110010Smarkm * 1. Redistributions of source code must retain the above copyright
8110010Smarkm *    notice, this list of conditions and the following disclaimer.
9110010Smarkm * 2. Neither the name of the University nor the names of its contributors
10110010Smarkm *    may be used to endorse or promote products derived from this software
11110010Smarkm *    without specific prior written permission.
12110010Smarkm *
13110010Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14110010Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15110010Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16110010Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17110010Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18110010Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19110010Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20215698Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21215698Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22215698Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23215698Ssimon * SUCH DAMAGE.
24215698Ssimon *
25110010Smarkm * $FreeBSD: stable/10/sys/fs/devfs/devfs_int.h 240539 2012-09-15 19:28:54Z ed $
26110010Smarkm */
27110010Smarkm
28110010Smarkm/*
29110010Smarkm * This file documents a private interface and it SHALL only be used
30110010Smarkm * by kern/kern_conf.c and fs/devfs/...
31110010Smarkm */
32110010Smarkm
33110010Smarkm#ifndef _FS_DEVFS_DEVFS_INT_H_
34110010Smarkm#define	_FS_DEVFS_DEVFS_INT_H_
35110010Smarkm
36110010Smarkm#include <sys/queue.h>
37110010Smarkm
38110010Smarkm#ifdef _KERNEL
39110010Smarkm
40110010Smarkmstruct devfs_dirent;
41276864Sjkimstruct devfs_mount;
42276864Sjkim
43110010Smarkmstruct cdev_privdata {
44110010Smarkm	struct file		*cdpd_fp;
45215698Ssimon	void			*cdpd_data;
46215698Ssimon	void			(*cdpd_dtr)(void *);
47215698Ssimon	LIST_ENTRY(cdev_privdata) cdpd_list;
48215698Ssimon};
49160819Ssimon
50215698Ssimonstruct cdev_priv {
51160819Ssimon	struct cdev		cdp_c;
52160819Ssimon	TAILQ_ENTRY(cdev_priv)	cdp_list;
53276864Sjkim
54276864Sjkim	u_int			cdp_inode;
55276864Sjkim
56110010Smarkm	u_int			cdp_flags;
57276864Sjkim#define CDP_ACTIVE		(1 << 0)
58276864Sjkim#define CDP_SCHED_DTR		(1 << 1)
59276864Sjkim
60276864Sjkim	u_int			cdp_inuse;
61276864Sjkim	u_int			cdp_maxdirent;
62276864Sjkim	struct devfs_dirent	**cdp_dirents;
63215698Ssimon	struct devfs_dirent	*cdp_dirent0;
64276864Sjkim
65276864Sjkim	TAILQ_ENTRY(cdev_priv)	cdp_dtr_list;
66276864Sjkim	void			(*cdp_dtr_cb)(void *);
67276864Sjkim	void			*cdp_dtr_cb_arg;
68276864Sjkim
69215698Ssimon	LIST_HEAD(, cdev_privdata) cdp_fdpriv;
70276864Sjkim};
71110010Smarkm
72110010Smarkm#define	cdev2priv(c)	__containerof(c, struct cdev_priv, cdp_c)
73110010Smarkm
74110010Smarkmstruct cdev	*devfs_alloc(int);
75110010Smarkmint	devfs_dev_exists(const char *);
76110010Smarkmvoid	devfs_free(struct cdev *);
77110010Smarkmvoid	devfs_create(struct cdev *);
78110010Smarkmvoid	devfs_destroy(struct cdev *);
79110010Smarkmvoid	devfs_destroy_cdevpriv(struct cdev_privdata *);
80110010Smarkm
81110010Smarkmint	devfs_dir_find(const char *);
82110010Smarkmvoid	devfs_dir_ref_de(struct devfs_mount *, struct devfs_dirent *);
83110010Smarkmvoid	devfs_dir_unref_de(struct devfs_mount *, struct devfs_dirent *);
84110010Smarkmint	devfs_pathpath(const char *, const char *);
85110010Smarkm
86110010Smarkmextern struct unrhdr *devfs_inos;
87110010Smarkmextern struct mtx devmtx;
88110010Smarkmextern struct mtx devfs_de_interlock;
89110010Smarkmextern struct sx clone_drain_lock;
90110010Smarkmextern struct mtx cdevpriv_mtx;
91110010Smarkmextern TAILQ_HEAD(cdev_priv_list, cdev_priv) cdevp_list;
92110010Smarkm
93110010Smarkm#endif /* _KERNEL */
94110010Smarkm
95110010Smarkm#endif /* !_FS_DEVFS_DEVFS_INT_H_ */
96110010Smarkm