diff options
author | kib <kib@FreeBSD.org> | 2010-05-06 19:22:50 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-05-06 19:22:50 +0000 |
commit | 77dcee692636f8f049511471d8c21c5821ade009 (patch) | |
tree | 07045cda76ff8aacd7c407e9e4115ed99973521d /sys/fs | |
parent | fecc56fac19c93c470f79d1f557c149bd3c1e9b0 (diff) | |
download | FreeBSD-src-77dcee692636f8f049511471d8c21c5821ade009.zip FreeBSD-src-77dcee692636f8f049511471d8c21c5821ade009.tar.gz |
Add MAKEDEV_NOWAIT flag to make_dev_credf(9), to create a device node
in a no-sleep context. If resource allocation cannot be done without
sleep, make_dev_credf() fails and returns NULL.
Reviewed by: jh
MFC after: 2 weeks
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 9 | ||||
-rw-r--r-- | sys/fs/devfs/devfs_int.h | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 81b2752..4bd6728 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -115,17 +115,21 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, cdev_priv, CTLFLAG_RD, 0, sizeof(struct cdev_priv), "sizeof(struct cdev_priv)"); struct cdev * -devfs_alloc(void) +devfs_alloc(int flags) { struct cdev_priv *cdp; struct cdev *cdev; struct timespec ts; - cdp = malloc(sizeof *cdp, M_CDEVP, M_USE_RESERVE | M_ZERO | M_WAITOK); + cdp = malloc(sizeof *cdp, M_CDEVP, M_USE_RESERVE | M_ZERO | + ((flags & MAKEDEV_NOWAIT) ? M_NOWAIT : M_WAITOK)); + if (cdp == NULL) + return (NULL); cdp->cdp_dirents = &cdp->cdp_dirent0; cdp->cdp_dirent0 = NULL; cdp->cdp_maxdirent = 0; + cdp->cdp_inode = 0; cdev = &cdp->cdp_c; @@ -133,6 +137,7 @@ devfs_alloc(void) LIST_INIT(&cdev->si_children); vfs_timestamp(&ts); cdev->si_atime = cdev->si_mtime = cdev->si_ctime = ts; + cdev->si_cred = NULL; return (cdev); } diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h index 5a61dd4..f5612e1 100644 --- a/sys/fs/devfs/devfs_int.h +++ b/sys/fs/devfs/devfs_int.h @@ -70,7 +70,7 @@ struct cdev_priv { #define cdev2priv(c) member2struct(cdev_priv, cdp_c, c) -struct cdev *devfs_alloc(void); +struct cdev *devfs_alloc(int); void devfs_free(struct cdev *); void devfs_create(struct cdev *dev); void devfs_destroy(struct cdev *dev); |