[haiku-commits] haiku: hrev52760 - src/system/kernel/device_manager

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 14 Jan 2019 16:21:05 -0500 (EST)

hrev52760 adds 3 changesets to branch 'master'
old head: b3470a55cf580aad0168695a335619d1554574a0
new head: 56583ffb3ac1f57960631a953fcebf8d85d65d51
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=56583ffb3ac1+%5Eb3470a55cf58

----------------------------------------------------------------------------

8e9c7a36ebc1: kernel: B_BEOS_* -> B_SYSTEM_* for directory constants.
  
  Also clean up legacy_drivers' usage of them a bit.

fb95946e4486: kernel: Don't watch the "dev" legacy driver directory.
  
  We don't watch its children, and most drivers within it are within
  subdirectories. Further, all drivers in it are really symlinks to "bin",
  which we also watch. So there is really not much purpose in watching
  "dev" directly.
  
  Should fix #4638.

56583ffb3ac1: kernel/legacy_drivers: Make asterisk style consistent.
  
  Most of the file used space after asterisk, but some of it used spaces
  before the asterisk. Now it's consistently after.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 49 insertions(+), 55 deletions(-)
.../kernel/device_manager/legacy_drivers.cpp     | 102 +++++++++----------
src/system/kernel/module.cpp                     |   2 +-

############################################################################

Commit:      8e9c7a36ebc1e26e0a4d22efb4e69b498ca17462
URL:         https://git.haiku-os.org/haiku/commit/?id=8e9c7a36ebc1
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Jan 14 20:51:42 2019 UTC

kernel: B_BEOS_* -> B_SYSTEM_* for directory constants.

Also clean up legacy_drivers' usage of them a bit.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp 
b/src/system/kernel/device_manager/legacy_drivers.cpp
index cbd792c2a6..7af573302f 100644
--- a/src/system/kernel/device_manager/legacy_drivers.cpp
+++ b/src/system/kernel/device_manager/legacy_drivers.cpp
@@ -254,6 +254,13 @@ static status_t unload_driver(legacy_driver *driver);
 static status_t load_driver(legacy_driver *driver);
 
 
+static const directory_which kDriverPaths[] = {
+       B_USER_NONPACKAGED_ADDONS_DIRECTORY,
+       B_USER_ADDONS_DIRECTORY,
+       B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
+       B_SYSTEM_ADDONS_DIRECTORY
+};
+
 static DriverWatcher sDriverWatcher;
 static int32 sDriverEventsPending;
 static DriverEventList sDriverEvents;
@@ -514,7 +521,7 @@ get_priority(const char* path)
        // TODO: would it be better to initialize a static structure here
        // using find_directory()?
        const directory_which whichPath[] = {
-               B_BEOS_DIRECTORY,
+               B_SYSTEM_DIRECTORY,
                B_SYSTEM_NONPACKAGED_DIRECTORY,
                B_USER_DIRECTORY
        };
@@ -932,22 +939,16 @@ DirectoryIterator::SetTo(const char* path, const char* 
subPath, bool recursive)
 
        if (path == NULL) {
                // add default paths
-               const directory_which whichPath[] = {
-                       B_USER_NONPACKAGED_ADDONS_DIRECTORY,
-                       B_USER_ADDONS_DIRECTORY,
-                       B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
-                       B_BEOS_ADDONS_DIRECTORY
-               };
                KPath pathBuffer;
 
                bool disableUserAddOns = get_safemode_boolean(
                        B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
 
-               for (uint32 i = 0; i < sizeof(whichPath) / 
sizeof(whichPath[0]); i++) {
+               for (uint32 i = 0; i < sizeof(kDriverPaths) / 
sizeof(kDriverPaths[0]); i++) {
                        if (i < 2 && disableUserAddOns)
                                continue;
 
-                       if (__find_directory(whichPath[i], gBootDevice, true,
+                       if (__find_directory(kDriverPaths[i], gBootDevice, true,
                                        pathBuffer.LockBuffer(), 
pathBuffer.BufferSize()) == B_OK) {
                                pathBuffer.UnlockBuffer();
                                pathBuffer.Append("kernel");
@@ -1381,7 +1382,7 @@ legacy_driver_add_preloaded(kernel_args* args)
        // NOTE: The initialization success of the path objects is implicitely
        // checked by the immediately following functions.
        KPath basePath;
-       status_t status = __find_directory(B_BEOS_ADDONS_DIRECTORY,
+       status_t status = __find_directory(B_SYSTEM_ADDONS_DIRECTORY,
                gBootDevice, false, basePath.LockBuffer(), 
basePath.BufferSize());
        if (status != B_OK) {
                dprintf("legacy_driver_add_preloaded: find_directory() failed: "
@@ -1471,12 +1472,6 @@ legacy_driver_probe(const char* subPath)
        if (!sWatching && gBootDevice > 0) {
                // We're probing the actual boot volume for the first time,
                // let's watch its driver directories for changes
-               const directory_which whichPath[] = {
-                       B_USER_NONPACKAGED_ADDONS_DIRECTORY,
-                       B_USER_ADDONS_DIRECTORY,
-                       B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
-                       B_BEOS_ADDONS_DIRECTORY
-               };
                KPath path;
 
                new(&sDirectoryWatcher) DirectoryWatcher;
@@ -1484,11 +1479,11 @@ legacy_driver_probe(const char* subPath)
                bool disableUserAddOns = get_safemode_boolean(
                        B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
 
-               for (uint32 i = 0; i < sizeof(whichPath) / 
sizeof(whichPath[0]); i++) {
+               for (uint32 i = 0; i < sizeof(kDriverPaths) / 
sizeof(kDriverPaths[0]); i++) {
                        if (i < 2 && disableUserAddOns)
                                continue;
 
-                       if (__find_directory(whichPath[i], gBootDevice, true,
+                       if (__find_directory(kDriverPaths[i], gBootDevice, true,
                                        path.LockBuffer(), path.BufferSize()) 
== B_OK) {
                                path.UnlockBuffer();
                                path.Append("kernel/drivers");
diff --git a/src/system/kernel/module.cpp b/src/system/kernel/module.cpp
index 829c2513be..9affc41dba 100644
--- a/src/system/kernel/module.cpp
+++ b/src/system/kernel/module.cpp
@@ -334,7 +334,7 @@ using namespace Module;
  * first.
  */
 static const directory_which kModulePaths[] = {
-       B_BEOS_ADDONS_DIRECTORY,
+       B_SYSTEM_ADDONS_DIRECTORY,
        B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
        B_USER_ADDONS_DIRECTORY,
        B_USER_NONPACKAGED_ADDONS_DIRECTORY,

############################################################################

Commit:      fb95946e44868029d08b709f1fa4afac58629927
URL:         https://git.haiku-os.org/haiku/commit/?id=fb95946e4486
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Jan 14 21:00:20 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/4638

kernel: Don't watch the "dev" legacy driver directory.

We don't watch its children, and most drivers within it are within
subdirectories. Further, all drivers in it are really symlinks to "bin",
which we also watch. So there is really not much purpose in watching
"dev" directly.

Should fix #4638.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp 
b/src/system/kernel/device_manager/legacy_drivers.cpp
index 7af573302f..69d7dd6b55 100644
--- a/src/system/kernel/device_manager/legacy_drivers.cpp
+++ b/src/system/kernel/device_manager/legacy_drivers.cpp
@@ -1060,7 +1060,7 @@ DirectoryWatcher::EventOccurred(NotificationService& 
service,
        int32 opcode = event->GetInt32("opcode", -1);
        dev_t device = event->GetInt32("device", -1);
        ino_t directory = event->GetInt64("directory", -1);
-       const char *name = event->GetString("name", NULL);
+       const char* name = event->GetString("name", NULL);
 
        if (opcode == B_ENTRY_MOVED) {
                // Determine whether it's a move within, out of, or into one
@@ -1488,7 +1488,6 @@ legacy_driver_probe(const char* subPath)
                                path.UnlockBuffer();
                                path.Append("kernel/drivers");
 
-                               start_watching(path.Path(), "dev");
                                start_watching(path.Path(), "bin");
                        } else
                                path.UnlockBuffer();

############################################################################

Revision:    hrev52760
Commit:      56583ffb3ac1f57960631a953fcebf8d85d65d51
URL:         https://git.haiku-os.org/haiku/commit/?id=56583ffb3ac1
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Jan 14 21:06:34 2019 UTC

kernel/legacy_drivers: Make asterisk style consistent.

Most of the file used space after asterisk, but some of it used spaces
before the asterisk. Now it's consistently after.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp 
b/src/system/kernel/device_manager/legacy_drivers.cpp
index 69d7dd6b55..8649ac80d2 100644
--- a/src/system/kernel/device_manager/legacy_drivers.cpp
+++ b/src/system/kernel/device_manager/legacy_drivers.cpp
@@ -358,7 +358,7 @@ republish_driver(legacy_driver* driver)
 
 
 static status_t
-load_driver(legacy_driver *driver)
+load_driver(legacy_driver* driver)
 {
        status_t (*init_hardware)(void);
        status_t (*init_driver)(void);
@@ -376,9 +376,9 @@ load_driver(legacy_driver *driver)
 
        // For a valid device driver the following exports are required
 
-       int32 *apiVersion;
+       int32* apiVersion;
        if (get_image_symbol(image, "api_version", B_SYMBOL_TYPE_DATA,
-                       (void **)&apiVersion) == B_OK) {
+                       (void**)&apiVersion) == B_OK) {
 #if B_CUR_DRIVER_API_VERSION != 2
                // just in case someone decides to bump up the api version
 #error Add checks here for new vs old api version!
@@ -400,9 +400,9 @@ load_driver(legacy_driver *driver)
                dprintf("devfs: \"%s\" api_version missing\n", driver->name);
 
        if (get_image_symbol(image, "publish_devices", B_SYMBOL_TYPE_TEXT,
-                               (void **)&driver->publish_devices) != B_OK
+                               (void**)&driver->publish_devices) != B_OK
                || get_image_symbol(image, "find_device", B_SYMBOL_TYPE_TEXT,
-                               (void **)&driver->find_device) != B_OK) {
+                               (void**)&driver->find_device) != B_OK) {
                dprintf("devfs: \"%s\" mandatory driver symbol(s) missing!\n",
                        driver->name);
                status = B_BAD_VALUE;
@@ -412,7 +412,7 @@ load_driver(legacy_driver *driver)
        // Init the driver
 
        if (get_image_symbol(image, "init_hardware", B_SYMBOL_TYPE_TEXT,
-                       (void **)&init_hardware) == B_OK
+                       (void**)&init_hardware) == B_OK
                && (status = init_hardware()) != B_OK) {
                TRACE(("%s: init_hardware() failed: %s\n", driver->name,
                        strerror(status)));
@@ -421,7 +421,7 @@ load_driver(legacy_driver *driver)
        }
 
        if (get_image_symbol(image, "init_driver", B_SYMBOL_TYPE_TEXT,
-                       (void **)&init_driver) == B_OK
+                       (void**)&init_driver) == B_OK
                && (status = init_driver()) != B_OK) {
                TRACE(("%s: init_driver() failed: %s\n", driver->name,
                        strerror(status)));
@@ -431,10 +431,10 @@ load_driver(legacy_driver *driver)
 
        // resolve and cache those for the driver unload code
        if (get_image_symbol(image, "uninit_driver", B_SYMBOL_TYPE_TEXT,
-               (void **)&driver->uninit_driver) != B_OK)
+               (void**)&driver->uninit_driver) != B_OK)
                driver->uninit_driver = NULL;
        if (get_image_symbol(image, "uninit_hardware", B_SYMBOL_TYPE_TEXT,
-               (void **)&driver->uninit_hardware) != B_OK)
+               (void**)&driver->uninit_hardware) != B_OK)
                driver->uninit_hardware = NULL;
 
        // The driver has successfully been initialized, now we can
@@ -458,7 +458,7 @@ error1:
 
 
 static status_t
-unload_driver(legacy_driver *driver)
+unload_driver(legacy_driver* driver)
 {
        if (driver->image < 0) {
                // driver is not currently loaded
@@ -485,7 +485,7 @@ unload_driver(legacy_driver *driver)
 
 /*!    Unpublishes all devices belonging to the \a driver. */
 static void
-unpublish_driver(legacy_driver *driver)
+unpublish_driver(legacy_driver* driver)
 {
        while (LegacyDevice* device = driver->devices.RemoveHead()) {
                device->SetRemovedFromParent(true);
@@ -542,10 +542,10 @@ get_priority(const char* path)
 }
 
 
-static const char *
-get_leaf(const char *path)
+static const char*
+get_leaf(const char* path)
 {
-       const char *name = strrchr(path, '/');
+       const char* name = strrchr(path, '/');
        if (name == NULL)
                return path;
 
@@ -553,12 +553,12 @@ get_leaf(const char *path)
 }
 
 
-static legacy_driver *
+static legacy_driver*
 find_driver(dev_t device, ino_t node)
 {
        DriverTable::Iterator iterator(sDriverHash);
        while (iterator.HasNext()) {
-               legacy_driver *driver = iterator.Next();
+               legacy_driver* driver = iterator.Next();
                if (driver->device == device && driver->node == node)
                        return driver;
        }
@@ -568,7 +568,7 @@ find_driver(dev_t device, ino_t node)
 
 
 static status_t
-add_driver(const char *path, image_id image)
+add_driver(const char* path, image_id image)
 {
        // Check if we already know this driver
 
@@ -588,7 +588,7 @@ add_driver(const char *path, image_id image)
 
        RecursiveLocker _(sLock);
 
-       legacy_driver *driver = sDriverHash->Lookup(get_leaf(path));
+       legacy_driver* driver = sDriverHash->Lookup(get_leaf(path));
        if (driver != NULL) {
                // we know this driver
                if (strcmp(driver->path, path) != 0) {
@@ -620,7 +620,7 @@ add_driver(const char *path, image_id image)
 
        // we don't know this driver, create a new entry for it
 
-       driver = (legacy_driver *)malloc(sizeof(legacy_driver));
+       driver = (legacy_driver*)malloc(sizeof(legacy_driver));
        if (driver == NULL)
                return B_NO_MEMORY;
 
@@ -659,9 +659,9 @@ add_driver(const char *path, image_id image)
 /*!    This is no longer part of the public kernel API, so we just export the
        symbol
 */
-extern "C" status_t load_driver_symbols(const char *driverName);
+extern "C" status_t load_driver_symbols(const char* driverName);
 status_t
-load_driver_symbols(const char *driverName)
+load_driver_symbols(const char* driverName)
 {
        // This is done globally for the whole kernel via the settings file.
        // We don't have to do anything here.
@@ -671,7 +671,7 @@ load_driver_symbols(const char *driverName)
 
 
 static status_t
-reload_driver(legacy_driver *driver)
+reload_driver(legacy_driver* driver)
 {
        dprintf("devfs: reload driver \"%s\" (%" B_PRIdDEV ", %" B_PRIdINO 
")\n",
                driver->name, driver->device, driver->node);
@@ -699,7 +699,7 @@ reload_driver(legacy_driver *driver)
 
 
 static void
-handle_driver_events(void */*_fs*/, int /*iteration*/)
+handle_driver_events(void* /*_fs*/, int /*iteration*/)
 {
        if (atomic_and(&sDriverEventsPending, 0) == 0)
                return;
@@ -770,7 +770,7 @@ handle_driver_events(void */*_fs*/, int /*iteration*/)
 
        DriverTable::Iterator iterator(sDriverHash);
        while (iterator.HasNext()) {
-               legacy_driver *driver = iterator.Next();
+               legacy_driver* driver = iterator.Next();
 
                if (!driver->binary_updated || driver->devices_used != 0)
                        continue;
@@ -997,7 +997,7 @@ next_entry:
                goto next_entry;
 
        if (S_ISDIR(stat.st_mode) && fRecursive) {
-               KPath *nextPath = new(nothrow) KPath(path);
+               KPath* nextPath = new(nothrow) KPath(path);
                if (!nextPath)
                        return B_NO_MEMORY;
                if (fPaths.Push(nextPath) != B_OK)
@@ -1021,7 +1021,7 @@ DirectoryIterator::Unset()
        delete fBasePath;
        fBasePath = NULL;
 
-       KPath *path;
+       KPath* path;
        while (fPaths.Pop(&path))
                delete path;
 }
@@ -1030,7 +1030,7 @@ DirectoryIterator::Unset()
 void
 DirectoryIterator::AddPath(const char* basePath, const char* subPath)
 {
-       KPath *path = new(nothrow) KPath(basePath);
+       KPath* path = new(nothrow) KPath(basePath);
        if (!path)
                panic("out of memory");
        if (subPath != NULL)
@@ -1107,7 +1107,7 @@ DirectoryWatcher::EventOccurred(NotificationService& 
service,
 
 
 static void
-start_watching(const char *base, const char *sub)
+start_watching(const char* base, const char* sub)
 {
        KPath path(base);
        path.Append(sub);
@@ -1120,7 +1120,7 @@ start_watching(const char *base, const char *sub)
        add_node_listener(stat.st_dev, stat.st_ino, B_WATCH_DIRECTORY,
                sDirectoryWatcher);
 
-       directory_node_entry *entry = new(std::nothrow) directory_node_entry;
+       directory_node_entry* entry = new(std::nothrow) directory_node_entry;
        if (entry != NULL) {
                entry->node = stat.st_ino;
                sDirectoryNodeHash.Insert(entry);
@@ -1179,7 +1179,7 @@ try_drivers(DriverEntryList& list)
 
 
 static status_t
-probe_for_drivers(const char *type)
+probe_for_drivers(const char* type)
 {
        TRACE(("probe_for_drivers(type = %s)\n", type));
 
@@ -1199,7 +1199,7 @@ probe_for_drivers(const char *type)
                        add_node_listener(stat.st_dev, stat.st_ino, 
B_WATCH_DIRECTORY,
                                sDirectoryWatcher);
 
-                       directory_node_entry *entry
+                       directory_node_entry* entry
                                = new(std::nothrow) directory_node_entry;
                        if (entry != NULL) {
                                entry->node = stat.st_ino;
@@ -1220,7 +1220,7 @@ probe_for_drivers(const char *type)
                        continue;
                }
 
-               driver_entry *entry = new_driver_entry(path.Path(), stat.st_dev,
+               driver_entry* entry = new_driver_entry(path.Path(), stat.st_dev,
                        stat.st_ino);
                if (entry == NULL)
                        return B_NO_MEMORY;
@@ -1413,7 +1413,7 @@ legacy_driver_add_preloaded(kernel_args* args)
                        status = add_driver(imagePath.Path(), image->id);
                if (status != B_OK) {
                        dprintf("legacy_driver_add_preloaded: Failed to add 
\"%s\": %s\n",
-                               (char *)image->name, strerror(status));
+                               (char*)image->name, strerror(status));
                        unload_kernel_add_on(image->id);
                }
        }
@@ -1428,7 +1428,7 @@ legacy_driver_add(const char* path)
 
 
 extern "C" status_t
-legacy_driver_publish(const char *path, device_hooks *hooks)
+legacy_driver_publish(const char* path, device_hooks* hooks)
 {
        // we don't have a driver, just publish the hooks
        LegacyDevice* device = new(std::nothrow) LegacyDevice(NULL, path, 
hooks);


Other related posts:

  • » [haiku-commits] haiku: hrev52760 - src/system/kernel/device_manager - waddlesplash