diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-08-25 13:45:30 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-08-25 13:45:30 +0000 |
commit | 0d324900255062edd3f7661adb1969a4c71b591c (patch) | |
tree | cc359690115769657f0f2f3fb771d547458be99f /cpukit/libfs/src/devfs/devfs_eval.c | |
parent | 2009-08-24 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-0d324900255062edd3f7661adb1969a4c71b591c.tar.bz2 |
2009-08-25 Joel Sherrill <joel.sherrill@OARcorp.com>
* 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.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libfs/src/devfs/devfs_eval.c | 55 |
1 files changed, 31 insertions, 24 deletions
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 ); } |