/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2005 Poul-Henning Kamp. All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Neither the name of the University nor the names of its contributors11* may be used to endorse or promote products derived from this software12* without specific prior written permission.13*14* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627/*28* This file documents a private interface and it SHALL only be used29* by kern/kern_conf.c and fs/devfs/...30*/3132#ifndef _FS_DEVFS_DEVFS_INT_H_33#define _FS_DEVFS_DEVFS_INT_H_3435#include <sys/queue.h>3637struct devfs_dirent;38struct devfs_mount;3940struct cdev_privdata {41struct file *cdpd_fp;42void *cdpd_data;43void (*cdpd_dtr)(void *);44LIST_ENTRY(cdev_privdata) cdpd_list;45};4647struct cdev_priv {48struct cdev cdp_c;49TAILQ_ENTRY(cdev_priv) cdp_list;5051u_int cdp_inode;5253u_int cdp_flags;54#define CDP_ACTIVE (1 << 0)55#define CDP_SCHED_DTR (1 << 1)56#define CDP_UNREF_DTR (1 << 2)57#define CDP_ON_ACTIVE_LIST (1 << 3)5859u_int cdp_inuse;60u_int cdp_maxdirent;61struct devfs_dirent **cdp_dirents;62struct devfs_dirent *cdp_dirent0;6364TAILQ_ENTRY(cdev_priv) cdp_dtr_list;65void (*cdp_dtr_cb)(void *);66void *cdp_dtr_cb_arg;6768LIST_HEAD(, cdev_privdata) cdp_fdpriv;6970struct mtx cdp_threadlock;71};7273#define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c)7475#ifdef _KERNEL7677struct cdev *devfs_alloc(int);78int devfs_dev_exists(const char *);79void devfs_free(struct cdev *);80void devfs_create(struct cdev *);81void devfs_destroy(struct cdev *);82void devfs_destroy_cdevpriv(struct cdev_privdata *);8384int devfs_dir_find(const char *);85void devfs_dir_ref_de(struct devfs_mount *, struct devfs_dirent *);86void devfs_dir_unref_de(struct devfs_mount *, struct devfs_dirent *);87int devfs_pathpath(const char *, const char *);8889extern struct unrhdr *devfs_inos;90extern struct mtx devmtx;91extern struct mtx devfs_de_interlock;92extern struct mtx cdevpriv_mtx;93extern TAILQ_HEAD(cdev_priv_list, cdev_priv) cdevp_list;9495#define dev_lock_assert_locked() mtx_assert(&devmtx, MA_OWNED)96#define dev_lock_assert_unlocked() mtx_assert(&devmtx, MA_NOTOWNED)9798#endif /* _KERNEL */99100#endif /* !_FS_DEVFS_DEVFS_INT_H_ */101102103