* check if the device path is already known first.

* check the path is NOT a directory or a symlink to a directory.
  regular or char/block device are considered both valid path to read 
  from and write to. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33257 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin
2009-09-23 20:55:08 +00:00
parent 4cbc2061fd
commit c6989ed912
+13 -7
View File
@@ -181,19 +181,25 @@ DeviceWatcher::_AddDevice(const char* path)
{ {
// printf("DeviceWatcher::_AddDevice(\"%s\");\n", path); // printf("DeviceWatcher::_AddDevice(\"%s\");\n", path);
BEntry entry(path);
if (! entry.IsFile())
// Invalid path !
return;
if ( fDeviceEndpointsMap.ContainsKey(path) ) if ( fDeviceEndpointsMap.ContainsKey(path) )
// Already known // Already known
return; return;
int fd = open(path, O_RDWR | O_EXCL); BEntry entry(path);
if (fd < 0) if (entry.IsDirectory())
// Invalid path !
return; return;
if (entry.IsSymLink()) {
BEntry symlink(path, true);
if (symlink.IsDirectory())
// Invalid path!
return;
}
int fd = open(path, O_RDWR | O_EXCL);
if (fd < 0)
return;
MidiPortConsumer* consumer = new MidiPortConsumer(fd, path); MidiPortConsumer* consumer = new MidiPortConsumer(fd, path);
_SetIcons(consumer); _SetIcons(consumer);