From 9a1e02770bef0e324f1da908865fef8e3f1abfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 29 Nov 2004 15:46:34 +0000 Subject: [PATCH] config_ioctl() now returns the actual error as returned by the config manager, as pointed out by Jerome. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10284 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/misc/config.c | 41 +++++++++++------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/add-ons/kernel/drivers/misc/config.c b/src/add-ons/kernel/drivers/misc/config.c index f7bdff4f50..c66e12e306 100644 --- a/src/add-ons/kernel/drivers/misc/config.c +++ b/src/add-ons/kernel/drivers/misc/config.c @@ -1,18 +1,18 @@ /* config driver -** provides userland access to the device configuration manager -** -** Copyright 2002, Axel Doerfler. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * provides userland access to the device configuration manager + * + * Copyright 2002-2004, Axel Doerfler. All rights reserved. + * Distributed under the terms of the MIT License. + */ -//#include #include #include #include #include "config_driver.h" + #define DEVICE_NAME "misc/config" int32 api_version = B_CUR_DRIVER_API_VERSION; @@ -54,38 +54,33 @@ config_ioctl(void *cookie, uint32 op, void *buffer, size_t len) if (params == NULL || params->magic != op) return B_BAD_VALUE; + // ToDo: the access of the params is not safe! + switch (op) { case CM_GET_NEXT_DEVICE_INFO: - gConfigManager->get_next_device_info(params->bus, ¶ms->cookie, + return gConfigManager->get_next_device_info(params->bus, ¶ms->cookie, (struct device_info *)params->data, params->data_len); - break; case CM_GET_DEVICE_INFO_FOR: - gConfigManager->get_device_info_for(params->cookie, + return gConfigManager->get_device_info_for(params->cookie, (struct device_info *)params->data, params->data_len); - break; case CM_GET_SIZE_OF_CURRENT_CONFIGURATION_FOR: - gConfigManager->get_size_of_current_configuration_for(params->cookie); - break; + return gConfigManager->get_size_of_current_configuration_for(params->cookie); case CM_GET_CURRENT_CONFIGURATION_FOR: - gConfigManager->get_current_configuration_for(params->cookie, + return gConfigManager->get_current_configuration_for(params->cookie, (struct device_configuration *)params->data, params->data_len); - break; case CM_GET_SIZE_OF_POSSIBLE_CONFIGURATIONS_FOR: - gConfigManager->get_size_of_possible_configurations_for(params->cookie); - break; + return gConfigManager->get_size_of_possible_configurations_for(params->cookie); case CM_GET_POSSIBLE_CONFIGURATIONS_FOR: - gConfigManager->get_possible_configurations_for(params->cookie, + return gConfigManager->get_possible_configurations_for(params->cookie, (struct possible_device_configurations *)params->data, params->data_len); - break; case CM_COUNT_RESOURCE_DESCRIPTORS_OF_TYPE: - gConfigManager->count_resource_descriptors_of_type(params->config, params->type); - break; + return gConfigManager->count_resource_descriptors_of_type(params->config, params->type); case CM_GET_NTH_RESOURCE_DESCRIPTOR_OF_TYPE: - gConfigManager->get_nth_resource_descriptor_of_type(params->config, params->n, + return gConfigManager->get_nth_resource_descriptor_of_type(params->config, params->n, params->type, (resource_descriptor *)params->data, params->data_len); - break; } - return B_NOT_ALLOWED; + + return B_BAD_VALUE; }