+ int ret = 0;
+ tDevFS_Driver *dev;
+
+ SHORTLOCK( &glDevFS_ListLock );
+
+ // Check if the device is already registered or the name is taken
+ for( dev = gDevFS_Drivers; dev; dev = dev->Next )
+ {
+ if(dev == Device) break;
+ if(strcmp(dev->Name, Device->Name) == 0) break;
+ }
+
+ if(dev) {
+ if(dev == Device)
+ Log_Warning("DevFS", "Device %p '%s' attempted to register itself twice",
+ dev, dev->Name);
+ else
+ Log_Warning("DevFS", "Device %p attempted to register '%s' which was owned by %p",
+ Device, dev->Name, dev);
+ ret = 0; // Error
+ }
+ else {
+ Device->Next = gDevFS_Drivers;
+ gDevFS_Drivers = Device;
+ gDevFS_RootNode.Size ++;
+ ret = giDevFS_NextID ++;
+ }
+ SHORTREL( &glDevFS_ListLock );
+
+ return ret;
+}
+
+/**
+ * \brief Delete a device from the DevFS folder
+ */
+void DevFS_DelDevice(tDevFS_Driver *Device)
+{
+ tDevFS_Driver *prev = NULL, *dev;
+
+ SHORTLOCK( &glDevFS_ListLock );
+ // Search list for device
+ for(dev = gDevFS_Drivers;
+ dev && dev != Device;
+ prev = dev, dev = dev->Next
+ );
+
+ // Check if it was found
+ if(dev)
+ {
+ if(prev)
+ prev->Next = Device->Next;
+ else
+ gDevFS_Drivers = Device->Next;
+ }
+ else
+ Log_Warning("DevFS", "Attempted to unregister device %p '%s' which was not registered",
+ Device, Device->Name);
+
+ SHORTREL( &glDevFS_ListLock );