From 0d324900255062edd3f7661adb1969a4c71b591c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 25 Aug 2009 13:45:30 +0000 Subject: 2009-08-25 Joel Sherrill * libfs/src/devfs/devfs_eval.c: Fix bug where use of strncmp() resulted in a partial match being considered a full name match. On ERC32, looking for /dev/console would match /dev/console_b first. --- cpukit/ChangeLog | 6 ++++ cpukit/libfs/src/devfs/devfs_eval.c | 55 +++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 24 deletions(-) (limited to 'cpukit') diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 52d48dc49e..6525c23c25 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2009-08-25 Joel Sherrill + + * libfs/src/devfs/devfs_eval.c: Fix bug where use of strncmp() resulted + in a partial match being considered a full name match. On ERC32, + looking for /dev/console would match /dev/console_b first. + 2009-08-21 Roxana Leontie * Makefile.am, preinstall.am, libmisc/Makefile.am: Changed the name of diff --git a/cpukit/libfs/src/devfs/devfs_eval.c b/cpukit/libfs/src/devfs/devfs_eval.c index dd69fd802d..d86bd9eb8c 100644 --- a/cpukit/libfs/src/devfs/devfs_eval.c +++ b/cpukit/libfs/src/devfs/devfs_eval.c @@ -22,33 +22,40 @@ int devFS_evaluate_path( rtems_filesystem_location_info_t *pathloc ) { - int i; - rtems_device_name_t *device_name_table; + int i; + rtems_device_name_t *device_name_table; - /* see if 'flags' is valid */ - if ( !rtems_libio_is_valid_perms( flags ) ) { - assert( 0 ); - rtems_set_errno_and_return_minus_one( EIO ); - } + /* see if 'flags' is valid */ + if ( !rtems_libio_is_valid_perms( flags ) ) { + assert( 0 ); + rtems_set_errno_and_return_minus_one( EIO ); + } - /* get the device name table */ - device_name_table = (rtems_device_name_t *)pathloc->node_access; - if (!device_name_table) - rtems_set_errno_and_return_minus_one( EFAULT ); + /* get the device name table */ + device_name_table = (rtems_device_name_t *)pathloc->node_access; + if (!device_name_table) + rtems_set_errno_and_return_minus_one( EFAULT ); - for (i = 0; i < rtems_device_table_size; i++){ - if ((device_name_table[i].device_name) && - (strncmp(pathname, device_name_table[i].device_name, pathnamelen) == 0)){ - /* find the device, set proper values */ - pathloc->node_access = (void *)&device_name_table[i]; - pathloc->handlers = &devFS_file_handlers; - pathloc->ops = &devFS_ops; - pathloc->mt_entry = rtems_filesystem_root.mt_entry; - return 0; - } - } - /* no such file or directory */ - rtems_set_errno_and_return_minus_one( ENOENT ); + for (i = 0; i < rtems_device_table_size; i++) { + if (!device_name_table[i].device_name) + continue; + + if (strncmp(pathname, device_name_table[i].device_name, pathnamelen) != 0) + continue; + + if (device_name_table[i].device_name[pathnamelen] != '\0') + continue; + + /* find the device, set proper values */ + pathloc->node_access = (void *)&device_name_table[i]; + pathloc->handlers = &devFS_file_handlers; + pathloc->ops = &devFS_ops; + pathloc->mt_entry = rtems_filesystem_root.mt_entry; + return 0; + } + + /* no such file or directory */ + rtems_set_errno_and_return_minus_one( ENOENT ); } -- cgit v1.2.3