Re: [systemd-devel] [PATCH] systemd-journald: fix endianess bug

2012-03-02 Thread Frederic Crozat
Le jeudi 01 mars 2012 à 18:01 +0100, Frederic Crozat a écrit :
 Le mercredi 29 février 2012 à 13:54 +0100, Frederic Crozat a écrit :
  Le mercredi 29 février 2012 à 12:45 +0100, Dirk Eibach a écrit :
   ---
src/journal/journal-file.c |2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
   
   diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
   index 20ca3f6..275caea 100644
   --- a/src/journal/journal-file.c
   +++ b/src/journal/journal-file.c
   @@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, 
   uint64_t offset, uint64_t size)
if (fstat(f-fd, f-last_stat)  0)
return -errno;

   -f-header-arena_size = new_size - 
   htole64(f-header-arena_offset);
   +f-header-arena_size = htole64(new_size - 
   le64toh(f-header-arena_offset));

return 0;
}
  
  I confirm this patch fixes journald not starting properly on ppc
  architecture (got the report yesterday from folks in the office).
  
  But it looks like systemd-journalctl is still broken on this arch.
 
 So far, I think I found two different endianess errors in the code, but
 more are pending, since I'm getting assertion when trying to access a
 journal file created on x86 architecture, on a powerpc system (and now,
 I get similar errors with journal created on ppc, so maybe only the
 writing code need fixing ;).
 
 Please review my current patch carefully, I'm not 100% sure my fix are
 accurate (this part of journald is a bit tricky to get right ;)

Here is a new version of the patch, we are slowly getting there : I'm
able to read journal created on x86 on a ppc system. Unfortunately,
journal created on ppc is still broken (f-header-entry_array_offset
get a crazy value, probably in BE instead of LE).

-- 
Frederic Crozat fcro...@suse.com
SUSE
From 3b3267b3a488605317dbc116eafe5462b9d46beb Mon Sep 17 00:00:00 2001
From: Frederic Crozat fcro...@suse.com
Date: Thu, 1 Mar 2012 18:00:01 +0100
Subject: [PATCH] journal: fix endianness error

---
 src/journal/journal-file.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 275caea..90aa27e 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -771,14 +771,14 @@ static int journal_file_append_data(JournalFile *f, const void *data, uint64_t s
 
 uint64_t journal_file_entry_n_items(Object *o) {
 assert(o);
-assert(o-object.type == htole64(OBJECT_ENTRY));
+assert(o-object.type == OBJECT_ENTRY);
 
 return (le64toh(o-object.size) - offsetof(Object, entry.items)) / sizeof(EntryItem);
 }
 
 static uint64_t journal_file_entry_array_n_items(Object *o) {
 assert(o);
-assert(o-object.type == htole64(OBJECT_ENTRY_ARRAY));
+assert(o-object.type == OBJECT_ENTRY_ARRAY);
 
 return (le64toh(o-object.size) - offsetof(Object, entry_array.items)) / sizeof(uint64_t);
 }
@@ -833,7 +833,7 @@ static int link_entry_into_array(JournalFile *f,
 o-entry_array.items[i] = htole64(p);
 
 if (ap == 0)
-*first = q;
+*first = htole64(q);
 else {
 r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, ap, o);
 if (r  0)
@@ -866,7 +866,7 @@ static int link_entry_into_array_plus_one(JournalFile *f,
 else {
 uint64_t i;
 
-i = le64toh(*idx) - 1;
+i = htole64(le64toh(*idx) - 1);
 r = link_entry_into_array(f, first, i, p);
 if (r  0)
 return r;
-- 
1.7.7

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemd-journald: fix endianess bug

2012-03-01 Thread Frederic Crozat
Le mercredi 29 février 2012 à 13:54 +0100, Frederic Crozat a écrit :
 Le mercredi 29 février 2012 à 12:45 +0100, Dirk Eibach a écrit :
  ---
   src/journal/journal-file.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
  
  diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
  index 20ca3f6..275caea 100644
  --- a/src/journal/journal-file.c
  +++ b/src/journal/journal-file.c
  @@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, 
  uint64_t offset, uint64_t size)
   if (fstat(f-fd, f-last_stat)  0)
   return -errno;
   
  -f-header-arena_size = new_size - 
  htole64(f-header-arena_offset);
  +f-header-arena_size = htole64(new_size - 
  le64toh(f-header-arena_offset));
   
   return 0;
   }
 
 I confirm this patch fixes journald not starting properly on ppc
 architecture (got the report yesterday from folks in the office).
 
 But it looks like systemd-journalctl is still broken on this arch.

So far, I think I found two different endianess errors in the code, but
more are pending, since I'm getting assertion when trying to access a
journal file created on x86 architecture, on a powerpc system (and now,
I get similar errors with journal created on ppc, so maybe only the
writing code need fixing ;).

Please review my current patch carefully, I'm not 100% sure my fix are
accurate (this part of journald is a bit tricky to get right ;)

-- 
Frederic Crozat fcro...@suse.com
SUSE
From 440c1612ff63932435b23e9ea99ba23f12d0d851 Mon Sep 17 00:00:00 2001
From: Frederic Crozat fcro...@suse.com
Date: Thu, 1 Mar 2012 18:00:01 +0100
Subject: [PATCH] journal: fix endianness error

---
 src/journal/journal-file.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 275caea..fd8f23d 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -833,7 +833,7 @@ static int link_entry_into_array(JournalFile *f,
 o-entry_array.items[i] = htole64(p);
 
 if (ap == 0)
-*first = q;
+*first = htole64(q);
 else {
 r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, ap, o);
 if (r  0)
@@ -866,7 +866,7 @@ static int link_entry_into_array_plus_one(JournalFile *f,
 else {
 uint64_t i;
 
-i = le64toh(*idx) - 1;
+i = htole64(le64toh(*idx) - 1);
 r = link_entry_into_array(f, first, i, p);
 if (r  0)
 return r;
-- 
1.7.7

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] systemd-journald: fix endianess bug

2012-02-29 Thread Dirk Eibach
---
 src/journal/journal-file.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 20ca3f6..275caea 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t 
offset, uint64_t size)
 if (fstat(f-fd, f-last_stat)  0)
 return -errno;
 
-f-header-arena_size = new_size - htole64(f-header-arena_offset);
+f-header-arena_size = htole64(new_size - 
le64toh(f-header-arena_offset));
 
 return 0;
 }
-- 
1.7.2.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] systemd-journald: fix endianess bug

2012-02-29 Thread Dirk Eibach
---
 src/journal/journal-file.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 20ca3f6..275caea 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t 
offset, uint64_t size)
 if (fstat(f-fd, f-last_stat)  0)
 return -errno;
 
-f-header-arena_size = new_size - htole64(f-header-arena_offset);
+f-header-arena_size = htole64(new_size - 
le64toh(f-header-arena_offset));
 
 return 0;
 }
-- 
1.7.2.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemd-journald: fix endianess bug

2012-02-29 Thread Frederic Crozat
Le mercredi 29 février 2012 à 12:45 +0100, Dirk Eibach a écrit :
 ---
  src/journal/journal-file.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
 index 20ca3f6..275caea 100644
 --- a/src/journal/journal-file.c
 +++ b/src/journal/journal-file.c
 @@ -238,7 +238,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t 
 offset, uint64_t size)
  if (fstat(f-fd, f-last_stat)  0)
  return -errno;
  
 -f-header-arena_size = new_size - htole64(f-header-arena_offset);
 +f-header-arena_size = htole64(new_size - 
 le64toh(f-header-arena_offset));
  
  return 0;
  }

I confirm this patch fixes journald not starting properly on ppc
architecture (got the report yesterday from folks in the office).

But it looks like systemd-journalctl is still broken on this arch.

-- 
Frederic Crozat fcro...@suse.com
SUSE

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel