[Box Backup] Cygwin build

Ben Summers boxbackup at fluffy.co.uk
Fri Apr 16 09:27:22 BST 2004

On 16 Apr 2004, at 02:34, Paul Arch wrote:
>> That's possibly me making a tiny mistake. Try changing the function to
>> read
>> box_time_t GetCurrentBoxTime()
>> {
>> ASSERT(sizeof(uint32_t) == sizeof(time_t));
>> return SecondsToBoxTime((uint32_t)time(0));
>> }
> Yep that worked.  But I also had another problem, I added this to 
> BoxTime.h
> to resolve ( please advise ? )
> typedef unsigned int int32;
> inline box_time_t SecondsToBoxTime(int32 Seconds)
> {
>  return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
> }

What problems did this resolve? If it's a compile error in another 
file, it's best done by casting, for example if this doesn't work:




>> Looks promising!
> With the above changes, and some more includes etc, I have compiled
> successfully :
>     bbackupctl
>     bbackupd
> I am currently tracking down issues in:
>     bbackupquery
>     bbstored
>     bbstoreaccounts
>  I seem to be having this problem (which relates to LinuxWorkaround 
> somehow
> ? )
> RaidFileRead.cpp: In static member function `static bool
>    RaidFileRead::ReadDirectoryContents(int, const std::string&, int,
>    std::vector<std::string, std::allocator<std::string> >&)':
> RaidFileRead.cpp:1597: error: 'struct dirent' has no member named 
> 'd_type'
> RaidFileRead.cpp:1597: error: `DT_REG' undeclared (first use this 
> function)
> RaidFileRead.cpp:1597: error: (Each undeclared identifier is reported 
> only
> once
>    for each function it appears in.)
> RaidFileRead.cpp:1625: error: 'struct dirent' has no member named 
> 'd_type'
> RaidFileRead.cpp:1625: error: `DT_DIR' undeclared (first use this 
> function)
> make[1]: *** [../../debug/lib/raidfile/RaidFileRead.o] Error 1
> make[1]: Leaving directory `/boxbackup-0.05/lib/raidfile'
> make: *** [dep_modules] Error 2
> Urgh ! Something to do with Cygwin and it determining difference 
> between DIR
> and FILEs.

Linux has a "bug" where it doesn't conform to standards, and omits to 
actually fill in the dirent structure. The Linux types implementing 
Cygwyn obviously took this a step further, and omitted the field 

The LinuxWorkaround_FinishDirentStruct finishes the structure by doing 
a stat(), and adjusting this field accordingly. This obviously won't 
work if the field is there.

> Anyway, I added a definition for "d_type" ( ** WARNING - I DONT KNOW 
> AM DOING ;) )for my dirent structure in /usr/include/sys/dirent.h, 
> since it
> didnt seem to exist, and LinuxWorkaround_FinishDirentStruct was 
> attempting
> to set it.

You must never alter system headers. Programs compiled with them won't 

>  I do believe this is correct, I have read elsewhere you need to
> use 'stat' within cygwin for DIR/FILE type.
> struct dirent
> {
>   long d_version;
>   ino_t d_ino;
>   long d_fd;
>   unsigned long __ino32;
>   char d_name[256];
>   int d_type;
> };

You should actually just alter the code in bbackupquery to use stat to 
work out which is which. As a #define with PLATFORM_CYGWYN, of course, 
wouldn't want to spoil it for the other platforms.

> So, it looks like **EVERYTHING** seems to compile **OK**.
> I do get these warnings :
> warning: ISO C requires whitespace after the macro name
> warning: extra tokens at end of #ifdef directive

Which line and file?

> I will now setup server on linux box (actually upgrade to v0.05 from
> 0.03PLUS2), and try running the backup client.  If this works, I have
> achieved what I have
> set out to do.  I am reluctant to try running the server, especially 
> because
> of the DIR/FILE issue. Shall keep you posted ;)

In the other message, you said it didn't, but as you've identified from 
the logs, you're having problems with 64 bit network byte order 
swapping -- in that it isn't swapping the order, so the server gets 
spurious values to work with. Other swaps seem to work though. You'll 
need to make sure that the hton64 and ntoh64 defines do actually swap 
stuff. It looks like the __cpu_to_be64 and __be64_to_cpu functions 
don't do anything on Cygwin.


More information about the Boxbackup mailing list