* 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:
@@ -181,19 +181,25 @@ DeviceWatcher::_AddDevice(const char* path)
|
||||
{
|
||||
// printf("DeviceWatcher::_AddDevice(\"%s\");\n", path);
|
||||
|
||||
BEntry entry(path);
|
||||
if (! entry.IsFile())
|
||||
// Invalid path !
|
||||
return;
|
||||
|
||||
if ( fDeviceEndpointsMap.ContainsKey(path) )
|
||||
// Already known
|
||||
return;
|
||||
|
||||
int fd = open(path, O_RDWR | O_EXCL);
|
||||
if (fd < 0)
|
||||
BEntry entry(path);
|
||||
if (entry.IsDirectory())
|
||||
// Invalid path !
|
||||
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);
|
||||
_SetIcons(consumer);
|
||||
|
||||
Reference in New Issue
Block a user