diff --git a/headers/posix/sys/utsname.h b/headers/posix/sys/utsname.h index 43fd413871..f59196e612 100644 --- a/headers/posix/sys/utsname.h +++ b/headers/posix/sys/utsname.h @@ -6,7 +6,7 @@ #define _SYS_UTSNAME_H -#define _SYS_NAMELEN 32 +#define _SYS_NAMELEN 128 struct utsname { char sysname[_SYS_NAMELEN]; /* Name of the OS */ diff --git a/headers/private/kernel/ksystem_info.h b/headers/private/kernel/ksystem_info.h index e22d0142fd..9ff900cd33 100644 --- a/headers/private/kernel/ksystem_info.h +++ b/headers/private/kernel/ksystem_info.h @@ -19,7 +19,7 @@ extern "C" { status_t system_info_init(struct kernel_args *args); status_t system_notifications_init(); -uint32 get_haiku_revision(void); +const char* get_haiku_revision(void); status_t _user_get_system_info(system_info *userInfo, size_t size); status_t _user_get_system_info_etc(int32 id, void *buffer, diff --git a/src/system/kernel/debug/debug.cpp b/src/system/kernel/debug/debug.cpp index ceda5adaee..56b3261bfb 100644 --- a/src/system/kernel/debug/debug.cpp +++ b/src/system/kernel/debug/debug.cpp @@ -1402,7 +1402,7 @@ syslog_init_post_vm(struct kernel_args* args) char revisionBuffer[64]; length = snprintf(revisionBuffer, sizeof(revisionBuffer), - "Welcome to syslog debug output!\nHaiku revision: %lu\n", + "Welcome to syslog debug output!\nHaiku revision: %s\n", get_haiku_revision()); syslog_write(revisionBuffer, std::min(length, (ssize_t)sizeof(revisionBuffer) - 1), false); diff --git a/src/system/kernel/main.cpp b/src/system/kernel/main.cpp index eca43c7398..34fd5ee5a5 100644 --- a/src/system/kernel/main.cpp +++ b/src/system/kernel/main.cpp @@ -111,7 +111,7 @@ _start(kernel_args *bootKernelArgs, int currentCPU) debug_init(&sKernelArgs); set_dprintf_enabled(true); dprintf("Welcome to kernel debugger output!\n"); - dprintf("Haiku revision: %lu\n", get_haiku_revision()); + dprintf("Haiku revision: %s\n", get_haiku_revision()); // init modules TRACE("init CPU\n"); diff --git a/src/system/kernel/system_info.cpp b/src/system/kernel/system_info.cpp index 1b01ad67a8..a29b59625d 100644 --- a/src/system/kernel/system_info.cpp +++ b/src/system/kernel/system_info.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,8 @@ const static char *kKernelName = "kernel_" HAIKU_ARCH; // Haiku SVN revision. Will be set when copying the kernel to the image. // Lives in a separate section so that it can easily be found. -static uint32 sHaikuRevision __attribute__((section("_haiku_revision"))); +static char sHaikuRevision[_SYS_NAMELEN] + __attribute__((section("_haiku_revision"))); static int @@ -52,7 +54,7 @@ dump_info(int argc, char **argv) { kprintf("kernel build: %s %s (gcc%d %s)\n", __DATE__, __TIME__, __GNUC__, __VERSION__); - kprintf("SVN revision: %lu\n\n", sHaikuRevision); + kprintf("SVN revision: %s\n\n", sHaikuRevision); kprintf("cpu count: %ld, active times:\n", smp_get_num_cpus()); @@ -466,7 +468,7 @@ system_notifications_init() } -uint32 +const char* get_haiku_revision(void) { return sHaikuRevision; diff --git a/src/system/libroot/posix/sys/uname.c b/src/system/libroot/posix/sys/uname.c index 4f09407b58..c4e1d08f93 100644 --- a/src/system/libroot/posix/sys/uname.c +++ b/src/system/libroot/posix/sys/uname.c @@ -16,8 +16,8 @@ // Haiku SVN revision. Will be set when copying libroot.so to the image. // Lives in a separate section so that it can easily be found. -static uint32 sHaikuRevision __attribute__((section("_haiku_revision"))); -static uint32 sHaikuRevision = 0; +static char sHaikuRevision[_SYS_NAMELEN] + __attribute__((section("_haiku_revision"))); int @@ -35,11 +35,10 @@ uname(struct utsname *info) strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); - info->version[0] = '\0'; - if (sHaikuRevision) { - snprintf(info->version, sizeof(info->version), "r%ld ", - sHaikuRevision); - } + if (sHaikuRevision[0] != '\0') + snprintf(info->version, sizeof(info->version), "r%s ", sHaikuRevision); + else + info->version[0] = '\0'; strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); strlcat(info->version, " ", sizeof(info->version)); strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); diff --git a/src/tools/set_haiku_revision.cpp b/src/tools/set_haiku_revision.cpp index 2cbd31208d..44f9f7f964 100644 --- a/src/tools/set_haiku_revision.cpp +++ b/src/tools/set_haiku_revision.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -304,11 +305,11 @@ public: fFileSize = FileSize(); if (fFileSize < 0) throw Exception("Failed to get the file size."); - + // read ELF header Elf32_Ehdr fileHeader; Read(0, &fileHeader, sizeof(Elf32_Ehdr), "Failed to read ELF header."); - + // check data encoding (endianess) switch (fileHeader.e_ident[EI_DATA]) { case ELFDATA2LSB: @@ -322,14 +323,14 @@ public: throw Exception(EIO, "Unsupported ELF data encoding."); break; } - + // get the header values fELFHeaderSize = GetUInt16(fileHeader.e_ehsize); fSectionHeaderTableOffset = GetUInt32(fileHeader.e_shoff); fSectionHeaderSize = GetUInt16(fileHeader.e_shentsize); fSectionHeaderCount = GetUInt16(fileHeader.e_shnum); bool hasSectionHeaderTable = (fSectionHeaderTableOffset != 0); - + // check the sanity of the header values // ELF header size if (fELFHeaderSize < sizeof(Elf32_Ehdr) || fELFHeaderSize > kMaxELFHeaderSize) { @@ -570,7 +571,6 @@ main(int argc, const char* const* argv) // parameters const char* fileName = argv[1]; const char* revisionString = argv[2]; - uint32_t revision = atol(revisionString); try { ELFObject elfObject; @@ -583,9 +583,9 @@ main(int argc, const char* const* argv) exit(1); } - // convert revision number to object endianess and write to section - uint32_t revisionBuffer = elfObject.GetUInt32(revision); - elfObject.Write(info.offset, &revisionBuffer, sizeof(revisionBuffer), + // write revision string to section + elfObject.Write(info.offset, revisionString, + std::min(sizeof(utsname::version), strlen(revisionString) + 1), "Failed to write revision."); } catch (Exception exception) { @@ -596,7 +596,7 @@ main(int argc, const char* const* argv) strerror(exception.Error())); } exit(1); - } + } return 0; }