From de49e34927ea27d282f6e85c866db5073df379af Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 5 Oct 2013 01:32:44 +0200 Subject: [PATCH] Add symbol versioning for find_directory() Should already have been done back when the semantics for the B_COMMON_*DIRECTORY constants was changed. Currently old and new version behave the same. So this is just a contingency measure ATM. --- .../private/system/find_directory_private.h | 1 + .../private/system/find_directory_private.h | 24 +++++++++++++++++++ src/build/libroot/find_directory.cpp | 9 +++++++ .../kernel/device_manager/legacy_drivers.cpp | 9 +++---- src/system/kernel/kernel_versions | 3 +++ src/system/kernel/main.cpp | 3 ++- src/system/kernel/module.cpp | 11 +++++---- src/system/kernel/team.cpp | 3 ++- src/system/kernel/util/hostname.cpp | 3 ++- src/system/libroot/libroot_versions | 3 +++ src/system/libroot/os/driver_settings.cpp | 4 +++- src/system/libroot/os/find_directory.cpp | 18 +++++++++++++- src/system/libroot/posix/unistd/hostname.cpp | 3 ++- 13 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 headers/build/private/system/find_directory_private.h create mode 100644 headers/private/system/find_directory_private.h diff --git a/headers/build/private/system/find_directory_private.h b/headers/build/private/system/find_directory_private.h new file mode 100644 index 0000000000..81fd07591e --- /dev/null +++ b/headers/build/private/system/find_directory_private.h @@ -0,0 +1 @@ +#include <../private/system/find_directory_private.h> diff --git a/headers/private/system/find_directory_private.h b/headers/private/system/find_directory_private.h new file mode 100644 index 0000000000..1fed4d298a --- /dev/null +++ b/headers/private/system/find_directory_private.h @@ -0,0 +1,24 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_FIND_DIRECTORY_PRIVATE_H +#define _SYSTEM_FIND_DIRECTORY_PRIVATE_H + + +#include + +#include + + +__BEGIN_DECLS + + +status_t __find_directory(directory_which which, dev_t device, bool createIt, + char *returnedPath, int32 pathLength); + + +__END_DECLS + + +#endif /* _SYSTEM_FIND_DIRECTORY_PRIVATE_H */ diff --git a/src/build/libroot/find_directory.cpp b/src/build/libroot/find_directory.cpp index 5c42b26915..0fce36a072 100644 --- a/src/build/libroot/find_directory.cpp +++ b/src/build/libroot/find_directory.cpp @@ -17,6 +17,8 @@ #include +#include + #ifndef HAIKU_BUILD_GENERATED_DIRECTORY # error HAIKU_BUILD_GENERATED_DIRECTORY not defined! @@ -95,3 +97,10 @@ find_directory(directory_which which, dev_t device, bool createIt, return error; } + +status_t +__find_directory(directory_which which, dev_t device, bool createIt, + char *returnedPath, int32 pathLength) +{ + return find_directory(which, device, createIt, returnedPath, pathLength); +} diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp b/src/system/kernel/device_manager/legacy_drivers.cpp index 164bed8d3d..f71c902fbd 100644 --- a/src/system/kernel/device_manager/legacy_drivers.cpp +++ b/src/system/kernel/device_manager/legacy_drivers.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -515,7 +516,7 @@ get_priority(const char* path) for (uint32 index = 0; index < sizeof(whichPath) / sizeof(whichPath[0]); index++) { - if (find_directory(whichPath[index], gBootDevice, false, + if (__find_directory(whichPath[index], gBootDevice, false, pathBuffer.LockBuffer(), pathBuffer.BufferSize()) == B_OK) { pathBuffer.UnlockBuffer(); if (!strncmp(pathBuffer.Path(), path, pathBuffer.BufferSize())) @@ -954,7 +955,7 @@ DirectoryIterator::SetTo(const char* path, const char* subPath, bool recursive) if (i < 2 && disableUserAddOns) continue; - if (find_directory(whichPath[i], gBootDevice, true, + if (__find_directory(whichPath[i], gBootDevice, true, pathBuffer.LockBuffer(), pathBuffer.BufferSize()) == B_OK) { pathBuffer.UnlockBuffer(); pathBuffer.Append("kernel"); @@ -1388,7 +1389,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_BEOS_ADDONS_DIRECTORY, gBootDevice, false, basePath.LockBuffer(), basePath.BufferSize()); if (status != B_OK) { dprintf("legacy_driver_add_preloaded: find_directory() failed: " @@ -1496,7 +1497,7 @@ legacy_driver_probe(const char* subPath) if (i < 2 && disableUserAddOns) continue; - if (find_directory(whichPath[i], gBootDevice, true, + if (__find_directory(whichPath[i], gBootDevice, true, path.LockBuffer(), path.BufferSize()) == B_OK) { path.UnlockBuffer(); path.Append("kernel/drivers"); diff --git a/src/system/kernel/kernel_versions b/src/system/kernel/kernel_versions index 9b4daf51e5..0ebda38323 100644 --- a/src/system/kernel/kernel_versions +++ b/src/system/kernel/kernel_versions @@ -11,3 +11,6 @@ KERNEL_1_ALPHA3 { KERNEL_1_ALPHA4 { } KERNEL_1_ALPHA3; + +KERNEL_1_ALPHA5 { +} KERNEL_1_ALPHA4; diff --git a/src/system/kernel/main.cpp b/src/system/kernel/main.cpp index 6ce9648e39..ef34cfeae4 100644 --- a/src/system/kernel/main.cpp +++ b/src/system/kernel/main.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -341,7 +342,7 @@ main2(void *unused) // start the init process { KPath bootScriptPath; - status_t status = find_directory(B_SYSTEM_BOOT_DIRECTORY, gBootDevice, + status_t status = __find_directory(B_SYSTEM_BOOT_DIRECTORY, gBootDevice, false, bootScriptPath.LockBuffer(), bootScriptPath.BufferSize()); if (status != B_OK) dprintf("main2: find_directory() failed: %s\n", strerror(status)); diff --git a/src/system/kernel/module.cpp b/src/system/kernel/module.cpp index 23abbca6b5..13c4ac21a6 100644 --- a/src/system/kernel/module.cpp +++ b/src/system/kernel/module.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -639,7 +640,7 @@ search_module(const char* name, module_image** _moduleImage) // let the VFS find that module for us KPath basePath; - if (find_directory(kModulePaths[i], gBootDevice, true, + if (__find_directory(kModulePaths[i], gBootDevice, true, basePath.LockBuffer(), basePath.BufferSize()) != B_OK) continue; @@ -1436,7 +1437,7 @@ ModuleNotificationService::_AddDirectory(const char* prefix) break; KPath pathBuffer; - if (find_directory(kModulePaths[i], gBootDevice, true, + if (__find_directory(kModulePaths[i], gBootDevice, true, pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK) continue; @@ -1607,7 +1608,7 @@ ModuleNotificationService::_Notify(int32 opcode, dev_t device, ino_t directory, for (uint32 i = 0; i < kNumModulePaths; i++) { KPath modulePath; - if (find_directory(kModulePaths[i], gBootDevice, true, + if (__find_directory(kModulePaths[i], gBootDevice, true, modulePath.LockBuffer(), modulePath.BufferSize()) != B_OK) continue; @@ -1889,7 +1890,7 @@ module_init_post_boot_device(bool bootingFromBootLoaderVolume) if (sDisableUserAddOns && i >= kFirstNonSystemModulePath) continue; - if (find_directory(kModulePaths[i], gBootDevice, true, + if (__find_directory(kModulePaths[i], gBootDevice, true, pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK) { pathBuffer.UnlockBuffer(); @@ -2008,7 +2009,7 @@ open_module_list_etc(const char* prefix, const char* suffix) break; KPath pathBuffer; - if (find_directory(kModulePaths[i], gBootDevice, true, + if (__find_directory(kModulePaths[i], gBootDevice, true, pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK) continue; diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index c5b0f7e898..1913a41633 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1601,7 +1602,7 @@ team_create_thread_start_internal(void* args) { // find runtime_loader path KPath runtimeLoaderPath; - err = find_directory(B_SYSTEM_DIRECTORY, gBootDevice, false, + err = __find_directory(B_SYSTEM_DIRECTORY, gBootDevice, false, runtimeLoaderPath.LockBuffer(), runtimeLoaderPath.BufferSize()); if (err < B_OK) { TRACE(("team_create_thread_start: find_directory() failed: %s\n", diff --git a/src/system/kernel/util/hostname.cpp b/src/system/kernel/util/hostname.cpp index 4c76d87bd7..3a819733ee 100644 --- a/src/system/kernel/util/hostname.cpp +++ b/src/system/kernel/util/hostname.cpp @@ -13,12 +13,13 @@ #include #include +#include static status_t get_path(char *path, bool create) { - status_t status = find_directory(B_SYSTEM_SETTINGS_DIRECTORY, -1, create, + status_t status = __find_directory(B_SYSTEM_SETTINGS_DIRECTORY, -1, create, path, B_PATH_NAME_LENGTH); if (status != B_OK) return status; diff --git a/src/system/libroot/libroot_versions b/src/system/libroot/libroot_versions index 1a641baa27..4d8340247e 100644 --- a/src/system/libroot/libroot_versions +++ b/src/system/libroot/libroot_versions @@ -6,3 +6,6 @@ LIBROOT_1_ALPHA1 { LIBROOT_1_ALPHA4 { } LIBROOT_1_ALPHA1; + +LIBROOT_1_ALPHA5 { +} LIBROOT_1_ALPHA4; diff --git a/src/system/libroot/os/driver_settings.cpp b/src/system/libroot/os/driver_settings.cpp index 8307f56f27..4ac6356426 100644 --- a/src/system/libroot/os/driver_settings.cpp +++ b/src/system/libroot/os/driver_settings.cpp @@ -45,6 +45,8 @@ #ifdef _BOOT_MODE # include # include +#else +# include #endif #include @@ -767,7 +769,7 @@ load_driver_settings(const char *driverName) strcpy(path, kUserSettingsDirectory); #else // TODO: use B_SYSTEM_SETTINGS_DIRECTORY instead! - if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, path, + if (__find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, path, sizeof(path)) == B_OK) #endif { diff --git a/src/system/libroot/os/find_directory.cpp b/src/system/libroot/os/find_directory.cpp index 4412f71764..4f914db7ff 100644 --- a/src/system/libroot/os/find_directory.cpp +++ b/src/system/libroot/os/find_directory.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include /* use pwents to find home */ @@ -211,7 +213,7 @@ create_path(const char *path, mode_t mode) status_t -find_directory(directory_which which, dev_t device, bool createIt, +__find_directory(directory_which which, dev_t device, bool createIt, char *returnedPath, int32 pathLength) { status_t err = B_OK; @@ -443,3 +445,17 @@ find_directory(directory_which which, dev_t device, bool createIt, return err; } + +extern "C" status_t +__find_directory_alpha4(directory_which which, dev_t device, bool createIt, + char *returnedPath, int32 pathLength) +{ + return __find_directory(which, device, createIt, returnedPath, pathLength); +} + + +DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__find_directory_alpha4", + "find_directory@", "BASE"); + +DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__find_directory", "find_directory@@", + "1_ALPHA5"); diff --git a/src/system/libroot/posix/unistd/hostname.cpp b/src/system/libroot/posix/unistd/hostname.cpp index 4c76d87bd7..3a819733ee 100644 --- a/src/system/libroot/posix/unistd/hostname.cpp +++ b/src/system/libroot/posix/unistd/hostname.cpp @@ -13,12 +13,13 @@ #include #include +#include static status_t get_path(char *path, bool create) { - status_t status = find_directory(B_SYSTEM_SETTINGS_DIRECTORY, -1, create, + status_t status = __find_directory(B_SYSTEM_SETTINGS_DIRECTORY, -1, create, path, B_PATH_NAME_LENGTH); if (status != B_OK) return status;