[Box Backup] Cygwin build

Ben Summers boxbackup@fluffy.co.uk
Fri, 16 Apr 2004 10:34:59 +0100


On 16 Apr 2004, at 10:14, Paul Arch wrote:

>>
>> SecondsToBoxTime(value)
> BackupQueries.cpp:964: error: call of overloaded 
> `SecondsToBoxTime(unsigned
> int)' is ambiguous
>>
>> do
>> SecondsToBoxTime((uint32_t)value)
>>
> Done, did the trick for the above (bbackupctl), but there seems to be 
> other
> instances of this occuring when compiling bbackupd.  Is it worth 
> casting to
> fix, or can it be done somewhere else ?

I'm not sure why it's doing that. Maybe some odd compiler thing?

Maybe add a signed variant too?

inline box_time_t SecondsToBoxTime(int32_t Seconds)
{
	return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
}

?

>
>> You must never alter system headers. Programs compiled with them won't
>> work.
>
> np, I have a cygwin installation esp. for getting boxbackup going, but
> thanks for advice :)

There's just no point in modifying the system headers, it won't alter 
the libraries which use them. And if you add stuff to the end, you'll 
end up overwriting important stuff.

>
>> 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.
>>
> OK, will have to give this a go.
>
>> 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.
>>
> ;) looking better now from Cygwin
> Apr 16 17:32:30 sdmgbackup bbstored[2230]: Send
> LoginConfirmed(0x0,0x2,0x7d000,0xbb800)
> Apr 16 17:32:31 sdmgbackup bbstored[2230]: Receive
> ListDirectory(0x1,0xffffffff,0xc,true)
> Apr 16 17:32:31 sdmgbackup bbstored[2230]: Send Success(0x1)
> Apr 16 17:32:31 sdmgbackup bbstored[2230]: Sending stream, size 40
>
> Testrun a backup gives ( syslogd for cygwin goes to Event Log in 
> windows ):
> <snip>
> following information is part of the event: bbackupd : PID 1520 : File
> statistics: total file size uploaded 18560926, bytes already on server 
> 0,
> encoded size 4855465.
>
> **yay**
>
> Backups seem to be happening to linux server.

Yes, I would agree that this appears to work.

>  But, I cannot use "compare"
> for verify, probably has something to do with FILE/DIR stat stuff as 
> noted
> previously.

Here's a snippet of code for BackupQueries::Compare which should work 
on Cygwin:

	std::string fn(rLocalDir);
	fn += '/';
	fn += localDirEn->d_name;
	struct stat st;
	if(::lstat(fn.c_str(), &st) != 0)
	{
		THROW_EXCEPTION(CommonException, OSFileError)
	}
	// Entry -- file or dir?
	if(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
	{
		// File or symbolic link
		localFiles.insert(std::string(localDirEn->d_name));
	}
	else if(S_ISDIR(st.st_mode))
	{
		// Directory
		localDirs.insert(std::string(localDirEn->d_name));
	}

It should be obvious where it goes, search for "Entry -- file or dir".

Ben