summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/sys/fs/devfs/devfs_devs.c
diff options
context:
space:
mode:
authorKevin Kirspel <kevin-kirspel@idexx.com>2016-12-21 11:01:28 -0800
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-12-23 08:26:14 +0100
commitb1580fb039a62cbc82c3c205e82c7aaea538875e (patch)
tree892848b8782046cf06764949a02c74cd1576c332 /rtemsbsd/sys/fs/devfs/devfs_devs.c
parentPIPE(2): Import from FreeBSD (diff)
downloadrtems-libbsd-b1580fb039a62cbc82c3c205e82c7aaea538875e.tar.bz2
PIPE(2): Port to RTEMS
Diffstat (limited to 'rtemsbsd/sys/fs/devfs/devfs_devs.c')
-rwxr-xr-x[-rw-r--r--]rtemsbsd/sys/fs/devfs/devfs_devs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/rtemsbsd/sys/fs/devfs/devfs_devs.c b/rtemsbsd/sys/fs/devfs/devfs_devs.c
index a38bb4d2..75c9e270 100644..100755
--- a/rtemsbsd/sys/fs/devfs/devfs_devs.c
+++ b/rtemsbsd/sys/fs/devfs/devfs_devs.c
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/conf.h>
+#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <stdlib.h>
@@ -45,8 +46,12 @@
#include <rtems/imfs.h>
+#define DEVFS_ROOTINO 2
+
const char rtems_cdev_directory[] = RTEMS_CDEV_DIRECTORY;
+struct unrhdr *devfs_inos;
+
static struct cdev *
devfs_imfs_get_context_by_iop(rtems_libio_t *iop)
{
@@ -325,3 +330,27 @@ devfs_dev_exists(const char *name)
else
return 0;
}
+
+ino_t
+devfs_alloc_cdp_inode(void)
+{
+
+ return (alloc_unr(devfs_inos));
+}
+
+void
+devfs_free_cdp_inode(ino_t ino)
+{
+
+ if (ino > 0)
+ free_unr(devfs_inos, ino);
+}
+
+static void
+ devfs_devs_init(void *junk __unused)
+{
+
+ devfs_inos = new_unrhdr(DEVFS_ROOTINO + 1, INT_MAX, &devmtx);
+}
+
+SYSINIT(devfs_devs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_devs_init, NULL);