[Boxbackup-dev] [Box Backup-commit] #72: Patch intercept.h and intercept.c for NetBSD 4 and 5

Jose Luis Rodriguez Garcia joseyluis at gmail.com
Tue Apr 13 02:17:45 BST 2010


On Tue, Apr 13, 2010 at 3:07 AM, Jose Luis Rodriguez Garcia
<joseyluis at gmail.com> wrote:
> On Sun, Apr 11, 2010 at 6:52 PM, James O'Gorman <james at netinertia.co.uk> wrote:
>> Hi,
>>
>> I've tested the patch and I can't see that it actually changes anything? On my test system (NetBSD/amd64 5.0.2) the results are the same with and without the patch:
>>
>> test-backupstore.log:FAILED: 2 tests failed (first at Test.cpp:291)
>> test-backupstorefix.log:FAILED: 2 tests failed (first at Test.cpp:291)
>> test-backupstorepatch.log:FAILED: 2 tests failed (first at Test.cpp:291)
>> test-basicserver.log:FAILED: Exception caught: Connection SocketConnectError
>> test-bbackupd.log:FAILED: 3 tests failed (first at Test.cpp:291)
>> test-common.log:ASSERT FAILED: [spTimers] at Timer.cpp(116)
>> test-common.log:ASSERT FAILED: [spTimers] at Timer.cpp(133)
>> test-common.log:ASSERT FAILED: [spTimers] at Timer.cpp(73)
>> test-common.log:ASSERT FAILED: [!spTimers] at Timer.cpp(43)
>> test-common.log:ASSERT FAILED: [spTimers] at Timer.cpp(73)
>> test-httpserver.log:FAILED: Exception caught: Common ConfigNoKey
>>
>> I can't see any mention anywhere of code needing to use __opendir30 instead of opendir (the man page doesn't mention it at all). Could you send the results from './runtest.pl ALL debug'?
>
> Search for RENAME in /usr/include/dirent.h:
> $ grep RENAME /usr/include/dirent.h
>
> DIR *opendir(const char *) __RENAME(__opendir30);
> struct dirent *readdir(DIR *) __RENAME(__readdir30);
>    struct dirent ** __restrict) __RENAME(__readdir_r30);
> DIR *__opendir2(const char *, int) __RENAME(__opendir230);
>    __RENAME(__scandir30);
> int getdents(int, char *, size_t) __RENAME(__getdents30);
> $
>
> It isn't documented  and it is ok. The functions __opendir30, etc are
> not intented for
> be used directly.
>
> If you follow the macro: DIR *opendir(const char *) __RENAME(__opendir30);
> It will be  substitued as this text:
> DIR *opendir(const char*) asm("__opendir30");
>
> It is a extension of gcc, and it changes all the  references from
> opendir to __opendir30.
> All the code that you write and compile using opendir will be
> substitued as _opendir30
> http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Asm-Labels.html#Asm-Labels
>
> Look also 3.2.6 in:
> http://www.netbsd.org/docs/internals/en/chap-processes.html#traps_syscalls
>
> A old binary program will do reference to opendir, not to __opendir30,
> and it will work with the old abi.
> The only problem with this solution is when you search the symbol in
> the library by its
> name as intercept.cpp:
>
> result = dlsym(RTLD_NEXT, pName);
>
> gcc can't identify the reference to opendir and it searches for the
> old implementation of readdir.
>
> I attach the outputs of runtest.pl ALL debug.
> With the patch all the tests sucess
>
> Without the patch:
> common: PASSED
> crypto: PASSED
> compress: PASSED
> raidfile: FAILED: Exception caught: RaidFile OSError
> basicserver: PASSED
> backupstore: PASSED
> backupstorefix: PASSED
> backupstorepatch: PASSED
> backupdiff: PASSED
> bbackupd: FAILED: 1 tests failed (first at testbbackupd.cpp:937)
> httpserver: PASSED
>
> Have you defined PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE ?
> Try to clean the sources after of apply the patches.
>
> It seems that NetBSD 5 has more errors that NetBSD 4.
>
>
>
> My  NetBSD Version is the last NetBSD 4 stable from cvs(2-3 weeks ago).
>
>>
>> I did manage to fix one thing on NetBSD though; nmake doesn't support the -C flag so I've committed a fix to cd into the Makefile directory rather than using -C.
> Yes I have observed that make failed and I had to do a cd. Thanks for the patch.
>
> I think that it also fails when you do a make clean.
>>
>> James
>>
>> On 11 Apr 2010, at 02:53, Box Backup wrote:
>>
>>> #72: Patch intercept.h and intercept.c for  NetBSD 4 and 5
>>> -----------------------+----------------------------------------------------
>>> Reporter:  joseyluis  |        Type:  defect
>>>   Status:  new        |    Priority:  normal
>>> Milestone:             |   Component:  test suite
>>>  Version:  trunk      |    Keywords:
>>> -----------------------+----------------------------------------------------
>>> With this test the test suite works with NetBSD 4 and 5 probably, I have
>>> tested it with NetBSD 4. Previously raidfile and bbackupd test didn't
>>> work.
>>>
>>> The problem is that in NetBSD 4/5 the readdir and openddir functions
>>> in libc library are called: __readdir30 and __opendir30.
>>> readdir and closedir exist for compatibility with these functions in
>>> NetBSD 3 and previous versions.
>>>
>>> There was a change in the ABI between the 3 and 4 version for use
>>> 64 bits inodes in kernel instead of 32 bits.
>>>
>>>
>>>
>>>
>>>
>>> --- intercept.h.orig    2010-04-04 01:58:54.000000000 +0200
>>> +++ intercept.h 2010-04-04 02:00:33.000000000 +0200
>>> @@ -13,6 +13,18 @@
>>>
>>>  #include <dirent.h>
>>>
>>> +#ifdef __NetBSD__  //__NetBSD_Version__ is defined in sys/param.h
>>> +#include <sys/param.h>
>>> +#endif
>>> +
>>> +#if defined __NetBSD_Version__ && __NetBSD_Version__ >= 399000800
>>> //3.99.8 vers.
>>> +#define FUNC_OPENDIR "__opendir30"
>>> +#define FUNC_READDIR "__readdir30"
>>> +#else
>>> +#define FUNC_OPENDIR "opendir"
>>> +#define FUNC_READDIR "readdir"
>>> +#endif
>>> +
>>>  #include <sys/types.h>
>>>  #include <sys/stat.h>
>>>
>>> --- intercept.cpp.orig  2010-04-04 01:58:54.000000000 +0200
>>> +++ intercept.cpp       2010-04-04 02:00:34.000000000 +0200
>>> @@ -514,7 +514,7 @@
>>>  {
>>>        if (opendir_real == NULL)
>>>        {
>>> -               opendir_real = (opendir_t*)find_function("opendir");
>>> +               opendir_real = (opendir_t*)find_function(FUNC_OPENDIR);
>>>        }
>>>
>>>        if (opendir_real == NULL)
>>> @@ -547,7 +547,7 @@
>>>
>>>        if (readdir_real == NULL)
>>>        {
>>> -               readdir_real = (readdir_t*)find_function("readdir");
>>> +               readdir_real = (readdir_t*)find_function(FUNC_READDIR);
>>>        }
>>>
>>>        if (readdir_real == NULL)
>>>
>>> --
>>> Ticket URL: <https://www.boxbackup.org/trac/ticket/72>
>>> Box Backup <http://www.boxbackup.org/>
>>> An open source, completely automatic on-line backup system for UNIX.
>>> _______________________________________________
>>> Boxbackup-commit mailing list
>>> Boxbackup-commit at boxbackup.org
>>> http://lists.boxbackup.org/cgi-bin/mailman/listinfo/boxbackup-commit
>>>
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runtest_ALL_debug_without_patch
Type: application/octet-stream
Size: 47463 bytes
Desc: not available
URL: <http://lists.boxbackup.org/pipermail/boxbackup-dev/attachments/20100413/d344e78f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runtest_ALL_debug_with_patch
Type: application/octet-stream
Size: 370518 bytes
Desc: not available
URL: <http://lists.boxbackup.org/pipermail/boxbackup-dev/attachments/20100413/d344e78f/attachment-0001.obj>


More information about the Boxbackup-dev mailing list