[PATCH 1/1] DEVFS mknod stored path pointer, now path is copied instead

Daniel Hellstrom daniel at gaisler.com
Thu Sep 19 12:27:47 UTC 2013


On 09/18/2013 08:52 PM, Chris Johns wrote:
> Daniel Hellstrom wrote:
>> ---
>>   For RTEMS 4.10 branch.
>>
>>   cpukit/libfs/src/devfs/devfs_mknod.c |    9 +++++++--
>>   1 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpukit/libfs/src/devfs/devfs_mknod.c b/cpukit/libfs/src/devfs/devfs_mknod.c
>> index d8e5a30..6df84a4 100644
>> --- a/cpukit/libfs/src/devfs/devfs_mknod.c
>> +++ b/cpukit/libfs/src/devfs/devfs_mknod.c
>> @@ -29,6 +29,7 @@ int devFS_mknod(
>>   {
>>     int                       i;
>>     int                       slot;
>> +  int                       len;
>>     rtems_device_name_t      *device_name_table;
>>     rtems_device_major_number major;
>>     rtems_device_minor_number minor;
>> @@ -69,8 +70,12 @@ int devFS_mknod(
>>         rtems_set_errno_and_return_minus_one( ENOMEM );
>>
>>     _ISR_Disable(level);
>> -  device_name_table[slot].device_name  = (char *)path;
>> -  device_name_table[slot].device_name_length = strlen(path);
>> +  len = strlen(path);
>> +  device_name_table[slot].device_name  = (char *)malloc(len);
>
> Is there a free if the node is deleted ?

I believe that unlinking nodes are not supported by devFS today.

Daniel

>
>> +  if (!device_name_table[slot].device_name)
>> +      rtems_set_errno_and_return_minus_one(ENOMEM);
>> +  strcpy(device_name_table[slot].device_name, (char *)path);
>> +  device_name_table[slot].device_name_length = len;
>>     device_name_table[slot].major = major;
>>     device_name_table[slot].minor = minor;
>>     device_name_table[slot].mode  = mode;




More information about the devel mailing list