Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/devfs/devfs_devs.c
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | devfs_alloc(int flags) | ||||
struct cdev *cdev; | struct cdev *cdev; | ||||
struct timespec ts; | struct timespec ts; | ||||
cdp = malloc(sizeof *cdp, M_CDEVP, M_ZERO | | cdp = malloc(sizeof *cdp, M_CDEVP, M_ZERO | | ||||
((flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK)); | ((flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK)); | ||||
if (cdp == NULL) | if (cdp == NULL) | ||||
return (NULL); | return (NULL); | ||||
mtx_init(&cdp->cdp_threadlock, "devthrd", NULL, MTX_DEF); | |||||
cdp->cdp_dirents = &cdp->cdp_dirent0; | cdp->cdp_dirents = &cdp->cdp_dirent0; | ||||
cdev = &cdp->cdp_c; | cdev = &cdp->cdp_c; | ||||
LIST_INIT(&cdev->si_children); | LIST_INIT(&cdev->si_children); | ||||
vfs_timestamp(&ts); | vfs_timestamp(&ts); | ||||
cdev->si_atime = cdev->si_mtime = cdev->si_ctime = ts; | cdev->si_atime = cdev->si_mtime = cdev->si_ctime = ts; | ||||
return (cdev); | return (cdev); | ||||
Show All 26 Lines | devfs_free(struct cdev *cdev) | ||||
struct cdev_priv *cdp; | struct cdev_priv *cdp; | ||||
cdp = cdev2priv(cdev); | cdp = cdev2priv(cdev); | ||||
if (cdev->si_cred != NULL) | if (cdev->si_cred != NULL) | ||||
crfree(cdev->si_cred); | crfree(cdev->si_cred); | ||||
devfs_free_cdp_inode(cdp->cdp_inode); | devfs_free_cdp_inode(cdp->cdp_inode); | ||||
if (cdp->cdp_maxdirent > 0) | if (cdp->cdp_maxdirent > 0) | ||||
free(cdp->cdp_dirents, M_DEVFS2); | free(cdp->cdp_dirents, M_DEVFS2); | ||||
mtx_destroy(&cdp->cdp_threadlock); | |||||
free(cdp, M_CDEVP); | free(cdp, M_CDEVP); | ||||
} | } | ||||
struct devfs_dirent * | struct devfs_dirent * | ||||
devfs_find(struct devfs_dirent *dd, const char *name, int namelen, int type) | devfs_find(struct devfs_dirent *dd, const char *name, int namelen, int type) | ||||
{ | { | ||||
struct devfs_dirent *de; | struct devfs_dirent *de; | ||||
▲ Show 20 Lines • Show All 551 Lines • Show Last 20 Lines |