Switch haiku-revision from uint32 to string, as that's going to be required soon, no matter if we switch to Git or Mercurial
* increase _SYS_NAMELEN defined in sys/utsname.h to 128 to allow long(ish) revisions * sHaikuRevision is now a static character array (in both libroot and kernel) * adjust build tool set_haiku_revision to write the revision as string git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c356b0477f
commit
6250297a08
@ -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 */
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <real_time_clock.h>
|
||||
#include <sem.h>
|
||||
#include <smp.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <team.h>
|
||||
#include <thread.h>
|
||||
#include <util/AutoLock.h>
|
||||
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user