From 3499cb75912725c8b4d3ac1623d295472e5dff4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 2 May 2007 19:05:57 +0000 Subject: [PATCH] now creates the monitored directories if they don't exist (0755) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20984 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/input/DeviceManager.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/servers/input/DeviceManager.cpp b/src/servers/input/DeviceManager.cpp index 150e1ed7f6..746a1c5bab 100644 --- a/src/servers/input/DeviceManager.cpp +++ b/src/servers/input/DeviceManager.cpp @@ -163,12 +163,28 @@ DeviceManager::StartMonitoringDevice(_BDeviceAddOn_ *addon, node_ref nref; BDirectory directory; BPath path("/dev"); - if (((err = path.Append(device)) != B_OK) - || ((err = directory.SetTo(path.Path())) != B_OK) - || ((err = directory.GetNodeRef(&nref)) != B_OK)) { - PRINTERR(("DeviceManager::StartMonitoringDevice error %s: %s\n", path.Path(), strerror(err))); + if ((err = path.Append(device)) != B_OK) { + PRINTERR(("DeviceManager::StartMonitoringDevice BPath::Append() error %s: %s\n", path.Path(), strerror(err))); return err; } + + if ((err = directory.SetTo(path.Path())) != B_OK) { + if (err != B_ENTRY_NOT_FOUND) { + PRINTERR(("DeviceManager::StartMonitoringDevice SetTo error %s: %s\n", path.Path(), strerror(err))); + return err; + } + if ((err = create_directory(path.Path(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) != B_OK + || (err = directory.SetTo(path.Path())) != B_OK) { + PRINTERR(("DeviceManager::StartMonitoringDevice CreateDirectory error %s: %s\n", path.Path(), strerror(err))); + return err; + } + } + + if ((err = directory.GetNodeRef(&nref)) != B_OK) { + PRINTERR(("DeviceManager::StartMonitoringDevice GetNodeRef error %s: %s\n", path.Path(), strerror(err))); + return err; + } + // test if already monitored bool alreadyMonitored = false; _BDeviceAddOn_ *tmpaddon = NULL;