[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v4 5/5] lib/ukswrand: Clean-up devfs integration
This patch cleans up the devfs integration of ukswrand: - The config option is properly namespaced. - mwc_dev.c is actually independent of the random number generator MWC. We rename this file to dev.c - Turns the devfs registration function into an initcall. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> --- lib/ukswrand/Config.uk | 5 +++-- lib/ukswrand/Makefile.uk | 4 +--- lib/ukswrand/{mwc_dev.c => dev.c} | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) rename lib/ukswrand/{mwc_dev.c => dev.c} (89%) diff --git a/lib/ukswrand/Config.uk b/lib/ukswrand/Config.uk index a1a84bc5..c58371bb 100644 --- a/lib/ukswrand/Config.uk +++ b/lib/ukswrand/Config.uk @@ -18,9 +18,10 @@ config LIBUKSWRAND_INITIALSEED int "Initial random seed" default 23 -config DEV_RANDOM - bool "/dev/random device" +config LIBUKSWRAND_DEVFS + bool "Register random and urandom device to devfs" select LIBDEVFS + select LIBVFSCORE default n endif diff --git a/lib/ukswrand/Makefile.uk b/lib/ukswrand/Makefile.uk index 25247474..055699de 100644 --- a/lib/ukswrand/Makefile.uk +++ b/lib/ukswrand/Makefile.uk @@ -4,6 +4,4 @@ CINCLUDES-$(CONFIG_LIBUKSWRAND) += -I$(LIBUKSWRAND_BASE)/include CXXINCLUDES-$(CONFIG_LIBUKSWRAND) += -I$(LIBUKSWRAND_BASE)/include LIBUKSWRAND_SRCS-$(CONFIG_LIBUKSWRAND_MWC) += $(LIBUKSWRAND_BASE)/mwc.c -ifdef CONFIG_DEV_RANDOM -LIBUKSWRAND_SRCS-$(CONFIG_LIBUKSWRAND_MWC) += $(LIBUKSWRAND_BASE)/mwc_dev.c -endif +LIBUKSWRAND_SRCS-$(CONFIG_LIBUKSWRAND_DEVFS) += $(LIBUKSWRAND_BASE)/dev.c diff --git a/lib/ukswrand/mwc_dev.c b/lib/ukswrand/dev.c similarity index 89% rename from lib/ukswrand/mwc_dev.c rename to lib/ukswrand/dev.c index 5a4cb100..adca6566 100644 --- a/lib/ukswrand/mwc_dev.c +++ b/lib/ukswrand/dev.c @@ -101,19 +101,30 @@ static struct driver drv_urandom = { .name = DEV_URANDOM_NAME }; -__constructor_prio(102) static void _uk_dev_swrand_ctor(void) +static int devfs_register(void) { struct device *dev; - uk_pr_info("Add /dev/random and /dev/urandom\n"); + uk_pr_info("Register '%s' and '%s' to devfs\n", + DEV_URANDOM_NAME, DEV_RANDOM_NAME); /* register /dev/urandom */ dev = device_create(&drv_urandom, DEV_URANDOM_NAME, D_CHR); - if (dev == NULL) - uk_pr_info("Failed to register /dev/urandom\n"); + if (dev == NULL) { + uk_pr_err("Failed to register '%s' to devfs\n", + DEV_URANDOM_NAME); + return -1; + } /* register /dev/random */ dev = device_create(&drv_random, DEV_RANDOM_NAME, D_CHR); - if (dev == NULL) - uk_pr_info("Failed to register /dev/random\n"); + if (dev == NULL) { + uk_pr_err("Failed to register '%s' to devfs\n", + DEV_RANDOM_NAME); + return -1; + } + + return 0; } + +devfs_initcall(devfs_register); -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |