faubackup2/src/common backup_control.cpp,1.21,1.22 common.cpp,1.5,1.6 common.hpp,1.2,1.3 fileinfo.cpp,1.11,1.12 fileinfo.hpp,1.6,1.7 int_handler.cpp,1.4,1.5 output_handling.hpp,1.5,1.6 system_calls.cpp,1.13,1.14 types.hpp,1.4,1.5
Erik Merkel <[email protected]> Fri, 04 Nov 2005 18:28:00 +0000
| Newsgroups | gmane.comp.sysutils.backup.faubackup.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/faubackup/faubackup2/src/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12667
Modified Files:
backup_control.cpp common.cpp common.hpp fileinfo.cpp
fileinfo.hpp int_handler.cpp output_handling.hpp
system_calls.cpp types.hpp
Log Message:
use boost format + small cleanup
Index: backup_control.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/backup_control.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** backup_control.cpp 6 Oct 2005 22:06:40 -0000 1.21
--- backup_control.cpp 4 Nov 2005 18:27:58 -0000 1.22
***************
*** 89,92 ****
--- 89,93 ----
}
+ /* local backups - two processes */
void local_local(string source, string destination)
{
***************
*** 195,199 ****
fd_in_remote, fd_out_remote);
bigBrother.register_ssh(pid);
! server(destination.directory, fdopen(fd_in_remote, "rb"), fdopen(fd_out_remote, "wb"));
}
--- 196,201 ----
fd_in_remote, fd_out_remote);
bigBrother.register_ssh(pid);
! server(destination.directory, fdopen(fd_in_remote, "rb"),
! fdopen(fd_out_remote, "wb"));
}
***************
*** 206,212 ****
void server(string destdir, FILE *fd_in, FILE *fd_out)
{
!
instance_name = "server";
output.information("server started", DEBUG_OUTPUT);
NetworkSender sender(fd_out);
NetworkReceiver receiver(fd_in);
--- 208,216 ----
void server(string destdir, FILE *fd_in, FILE *fd_out)
{
! /* set name for output */
instance_name = "server";
output.information("server started", DEBUG_OUTPUT);
+
+ /* set up network */
NetworkSender sender(fd_out);
NetworkReceiver receiver(fd_in);
***************
*** 214,220 ****
--- 218,228 ----
NetCommunication com_FileReceiver(receiver, sender, 2,2);
output.information("network online", DEBUG_OUTPUT);
+
+ /* get directory of last backup */
string lastbackupdir = dir_getlast(destdir, lastbackup);
output.information(F_("old backup dir: %s")
% lastbackupdir, DEBUG_OUTPUT);
+
+ /* send time of last backup to Client */
com_Distributor.sendInteger(lastbackup.year);
com_Distributor.sendInteger(lastbackup.month);
***************
*** 225,228 ****
--- 233,237 ----
com_Distributor.sendInteger(lastbackup.second);
+ /* send actual time to Client - don't trust client time */
actualbackup = getActualTime();
com_Distributor.sendInteger(actualbackup.year);
***************
*** 234,246 ****
com_Distributor.sendInteger(actualbackup.second);
!
tempdir = dir_create(destdir);
destinationdir = destdir;
! XThread *distri = server_distributor(tempdir, lastbackupdir, com_Distributor);
! XThread *receiv = server_file_recveiver(tempdir, lastbackupdir, com_FileReceiver);
if(distri)
distri->wait();
if(receiv)
receiv->wait();
output.adderrors(com_FileReceiver.readInteger());
output.information(F_("total bytes send: %d")
--- 243,263 ----
com_Distributor.sendInteger(actualbackup.second);
! /* create working directory */
tempdir = dir_create(destdir);
destinationdir = destdir;
!
! /* start threads for communication */
! XThread *distri = server_distributor(tempdir, lastbackupdir,
! com_Distributor);
! XThread *receiv = server_file_recveiver(tempdir, lastbackupdir,
! com_FileReceiver);
!
! /* wait for death of communication threads */
if(distri)
distri->wait();
if(receiv)
receiv->wait();
+
+ /* transfer statistics */
output.adderrors(com_FileReceiver.readInteger());
output.information(F_("total bytes send: %d")
***************
*** 248,263 ****
output.information(F_("total bytes read: %d")
% receiver.wait_for_finish(), NORMAL_OUTPUT);
dir_finalize(tempdir, destdir);
output.information("Server finished", DEBUG_OUTPUT);
delete distri;
delete receiv;
- //fclose(fd_in);
- //close(fd_out);
}
void client(string sourcedir, FILE *fd_in, FILE *fd_out)
{
instance_name = "client";
output.information("client started ", DEBUG_OUTPUT);
NetworkSender sender(fd_out);
NetworkReceiver receiver(fd_in);
--- 265,284 ----
output.information(F_("total bytes read: %d")
% receiver.wait_for_finish(), NORMAL_OUTPUT);
+
+ /* rename working dir to dir with backup timestamp in name */
dir_finalize(tempdir, destdir);
+
output.information("Server finished", DEBUG_OUTPUT);
delete distri;
delete receiv;
}
void client(string sourcedir, FILE *fd_in, FILE *fd_out)
{
+ /* set name for output */
instance_name = "client";
output.information("client started ", DEBUG_OUTPUT);
+
+ /* set up network */
NetworkSender sender(fd_out);
NetworkReceiver receiver(fd_in);
***************
*** 265,270 ****
NetCommunication com_FileSender(receiver, sender, 2,2);
output.information("network online", DEBUG_OUTPUT);
lastbackup.year = com_FileSender.readInteger();
- output.information("first", DEBUG_OUTPUT);
lastbackup.month = com_FileSender.readInteger();
lastbackup.day = com_FileSender.readInteger();
--- 286,292 ----
NetCommunication com_FileSender(receiver, sender, 2,2);
output.information("network online", DEBUG_OUTPUT);
+
+ /* read time of last backup from Server */
lastbackup.year = com_FileSender.readInteger();
lastbackup.month = com_FileSender.readInteger();
lastbackup.day = com_FileSender.readInteger();
***************
*** 274,277 ****
--- 296,300 ----
lastbackup.second = com_FileSender.readInteger();
+ /* read actual time from Server - don't trust client time */
actualbackup.year = com_FileSender.readInteger();
actualbackup.month = com_FileSender.readInteger();
***************
*** 291,310 ****
% actualbackup.minute, DEBUG_OUTPUT);
XThread * infos = client_information_sender(sourcedir, com_InfoSender);
XThread * files = client_file_sender(sourcedir, com_FileSender);
if(infos)
infos->wait();
if(files)
files->wait();
com_FileSender.sendInteger(output.howmanyerrors());
sender.finished_Client();
receiver.wait_for_finish();
output.information("Client finished", DEBUG_OUTPUT);
delete infos;
delete files;
- //fclose(fd_in);
- //close(fd_out);
-
}
--- 314,339 ----
% actualbackup.minute, DEBUG_OUTPUT);
+ /* start threads for communication */
XThread * infos = client_information_sender(sourcedir, com_InfoSender);
XThread * files = client_file_sender(sourcedir, com_FileSender);
+ /* wait for death of communication threads */
if(infos)
infos->wait();
if(files)
files->wait();
+
+ /* transfer statistics */
com_FileSender.sendInteger(output.howmanyerrors());
+
+ /* flush sender and send quit byte */
sender.finished_Client();
+
+ /* wait for quit byte */
receiver.wait_for_finish();
+
output.information("Client finished", DEBUG_OUTPUT);
delete infos;
delete files;
}
***************
*** 313,321 ****
output.information("client_information_sender started", DEBUG_OUTPUT);
! /* sending some dummy data to make sure connection is working */
com.sendInteger(4711);
com.sendByte(47);
InformationSender *sender = new InformationSender(com, sourcedir);
SettingsFileParser *globalConfig = NULL;
string conf_file = getEnvVar(CONF_ENV_VAR);
--- 342,352 ----
output.information("client_information_sender started", DEBUG_OUTPUT);
! /* sending some dummy data to make sure the connection is working */
com.sendInteger(4711);
com.sendByte(47);
InformationSender *sender = new InformationSender(com, sourcedir);
+
+ /* read global config file */
SettingsFileParser *globalConfig = NULL;
string conf_file = getEnvVar(CONF_ENV_VAR);
***************
*** 330,339 ****
globalConfig = NULL;
}
!
! /* int ret= chdir( sourcedir.c_str() );
! if( ret<0 ) {
! output.critical( "chdir(\"" + sourcedir + "\")" , errno);
! }
! */ DirectoryParser *parser = new DirectoryParser(sourcedir, globalConfig, sender);
XThread * thread = new XThread;
thread->start(*parser, &DirectoryParser::run);
--- 361,369 ----
globalConfig = NULL;
}
!
! /* create DirectoryParser threat which will send data through the
! InformationSender object */
! DirectoryParser *parser = new DirectoryParser(sourcedir, globalConfig,
! sender);
XThread * thread = new XThread;
thread->start(*parser, &DirectoryParser::run);
***************
*** 345,348 ****
--- 375,379 ----
output.information(F_("client_file_sender started: sourcedir %s")
% sourcedir , DEBUG_OUTPUT);
+
/* receiving and sending some dummy data to make sure connection
is working */
***************
*** 353,357 ****
XThread * thread = NULL;
! if(!do_nothing) {
FileSender *sender = new FileSender(com, sourcedir);
thread = new XThread;
--- 384,389 ----
XThread * thread = NULL;
! if(!do_nothing) { // if user does not specify command line switch
! /* create FileSender thread */
FileSender *sender = new FileSender(com, sourcedir);
thread = new XThread;
***************
*** 364,368 ****
NetCommunication &com)
{
-
output.information(F_("server_distributor started: destdir %s")
% lastbackupdir , DEBUG_OUTPUT);
--- 396,399 ----
***************
*** 375,380 ****
com.sendByte(blub);
Distributor *distributor = new Distributor(com, lastbackupdir, destdir);
-
XThread * thread = new XThread;
thread->start(*distributor, &Distributor::distribute);
--- 406,411 ----
com.sendByte(blub);
+ /* create Distributor thread */
Distributor *distributor = new Distributor(com, lastbackupdir, destdir);
XThread * thread = new XThread;
thread->start(*distributor, &Distributor::distribute);
***************
*** 387,397 ****
output.information(F_("server_file_recveiver started: destdir %s")
% destdir , DEBUG_OUTPUT);
int bla = com.readInteger();
char blub = com.readByte();
if((bla != 4711) || (blub != 47))
output.critical("protocol handshake failed", 0);
XThread * thread = NULL;
if(!do_nothing) {
! FileReceiver * receiver = new FileReceiver(destdir, lastbackupdir, com);
thread = new XThread;
thread->start(*receiver, &FileReceiver::receiveFiles);
--- 418,433 ----
output.information(F_("server_file_recveiver started: destdir %s")
% destdir , DEBUG_OUTPUT);
+ /* receiving some dummy data to make sure connection
+ is working */
int bla = com.readInteger();
char blub = com.readByte();
if((bla != 4711) || (blub != 47))
output.critical("protocol handshake failed", 0);
+
XThread * thread = NULL;
if(!do_nothing) {
! /* create Filereceiver thread */
! FileReceiver * receiver = new FileReceiver(destdir,
! lastbackupdir, com);
thread = new XThread;
thread->start(*receiver, &FileReceiver::receiveFiles);
Index: fileinfo.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/fileinfo.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** fileinfo.hpp 20 Sep 2005 14:50:38 -0000 1.6
--- fileinfo.hpp 4 Nov 2005 18:27:58 -0000 1.7
***************
*** 33,37 ****
bool fileExist;
-
public:
Fileinfo(string filename, string full_qualified_name);
--- 33,36 ----
***************
*** 55,59 ****
inline bool getExisting(){return fileExist;}
-
/** constructor for raw-data from Network */
Fileinfo(char *rawdata, unsigned int lengthOfData);
--- 54,57 ----
Index: output_handling.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/output_handling.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** output_handling.hpp 6 Oct 2005 01:49:54 -0000 1.5
--- output_handling.hpp 4 Nov 2005 18:27:58 -0000 1.6
***************
*** 56,60 ****
int howmanyerrors();
void adderrors(int no);
-
};
--- 56,59 ----
Index: fileinfo.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/fileinfo.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** fileinfo.cpp 20 Sep 2005 14:50:38 -0000 1.11
--- fileinfo.cpp 4 Nov 2005 18:27:58 -0000 1.12
***************
*** 16,20 ****
{
! /* constructor for raw-data from Network */
Fileinfo::Fileinfo(char *rawdata, unsigned int lengthOfData)
{
--- 16,20 ----
{
! /* constructor for raw-data from Network - deserialize */
Fileinfo::Fileinfo(char *rawdata, unsigned int lengthOfData)
{
***************
*** 24,30 ****
net_size = *((uint32_t *) rawdata);
unsigned int size = ntohl(net_size);
! if(size != lengthOfData)
! output.critical("wrong amount of data received for fileinfo",0);
!
unsigned int offset = 4;
memcpy(&byte_type , rawdata + offset, 1);
--- 24,29 ----
net_size = *((uint32_t *) rawdata);
unsigned int size = ntohl(net_size);
! assert(size == lengthOfData);
!
unsigned int offset = 4;
memcpy(&byte_type , rawdata + offset, 1);
***************
*** 45,51 ****
memcpy(filename_c , rawdata + offset, filename_size);
offset += filename_size;
! if(offset != size)
! output.critical(F_("internal error calculating Fileinfo from"
! "rawData: %d != %d") % offset % size, 0);
fileName = filename_c;
--- 44,48 ----
memcpy(filename_c , rawdata + offset, filename_size);
offset += filename_size;
! assert(offset == size);
fileName = filename_c;
***************
*** 57,60 ****
--- 54,58 ----
}
+ /* serialize data */
void *Fileinfo::getRawData()
{
***************
*** 94,105 ****
fileName.length() + 1);
offset += fileName.length() + 1;
! if(offset != size)
! output.critical(F_("internal error calculating Fileinfo "
! "rawData: %s != %s") % offset % size, 0);
!
return return_pointer;
}
! /* returns size of the char array */
int Fileinfo::getRawDataSize()
{
--- 92,100 ----
fileName.length() + 1);
offset += fileName.length() + 1;
! assert(offset == size);
return return_pointer;
}
! /* returns size of the serialized data */
int Fileinfo::getRawDataSize()
{
***************
*** 111,114 ****
--- 106,110 ----
}
+ /* check if two FileInfos are equal */
bool Fileinfo::equal(Fileinfo &info)
{
Index: int_handler.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/int_handler.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** int_handler.cpp 21 Jun 2005 09:16:45 -0000 1.4
--- int_handler.cpp 4 Nov 2005 18:27:58 -0000 1.5
***************
*** 25,28 ****
--- 25,29 ----
{
output.information(F_("signal %d") % intno, DEBUG_OUTPUT);
+ /* child process died */
if(intno == SIGCHLD) {
pid_t k_pid;
***************
*** 34,54 ****
break;
else
! perror("waitpid error\n");
}
if (k_pid == 0)
break;
if(WIFEXITED(state)) {
! if(WEXITSTATUS(state) == 0) {
bigBrother.child_died_normal(k_pid);
! } else
bigBrother.child_died_abnormal(k_pid);
! } else {
bigBrother.child_died_abnormal(k_pid);
! }
output.information(F_("child no. %d died!")
% k_pid, DEBUG_OUTPUT);
}
errno = alt_errno; /* reset errno */
! } //else if(intno == SIGPIPE) {}
else {
output.warning(F_("unknown SIGNAL %d") % intno, 0);
--- 35,56 ----
break;
else
! output.warning(F_("waitpid error\n"), errno);
}
if (k_pid == 0)
break;
+ /* check if child terminated corectly */
if(WIFEXITED(state)) {
! if(WEXITSTATUS(state) == 0)
bigBrother.child_died_normal(k_pid);
! else
bigBrother.child_died_abnormal(k_pid);
! } else
bigBrother.child_died_abnormal(k_pid);
!
output.information(F_("child no. %d died!")
% k_pid, DEBUG_OUTPUT);
}
errno = alt_errno; /* reset errno */
! }
else {
output.warning(F_("unknown SIGNAL %d") % intno, 0);
***************
*** 59,64 ****
exit(EXIT_FAILURE);
}
! output.information("Interrupt done", DEBUG_OUTPUT);
!
}
void setIntHandler()
--- 61,65 ----
exit(EXIT_FAILURE);
}
! output.information("Signal done", DEBUG_OUTPUT);
}
void setIntHandler()
***************
*** 71,92 ****
/* set signal handler */
! if (sigaction(SIGQUIT, &new_handler, NULL) < 0) {
! perror("could not install signal handler for sigquit");
! exit(EXIT_FAILURE);
! }
!
! if (sigaction(SIGPIPE, &new_handler, NULL) < 0) {
! perror("could not install signal handler for sigpipe");
! exit(EXIT_FAILURE);
! }
! if (sigaction(SIGINT, &new_handler, NULL) < 0) {
! perror("could not install signal handler for sigint");
! exit(EXIT_FAILURE);
! }
! if (sigaction(SIGCHLD, &new_handler, NULL) < 0) {
! perror("could not install signal handler for sigchld");
! exit(EXIT_FAILURE);
}
- }
}
--- 72,84 ----
/* set signal handler */
! if (sigaction(SIGQUIT, &new_handler, NULL) < 0)
! output.critical(F_("could not install signal handler for sigquit"), errno);
! if (sigaction(SIGPIPE, &new_handler, NULL) < 0)
! output.critical(F_("could not install signal handler for sigpipe"), errno);
! if (sigaction(SIGINT, &new_handler, NULL) < 0)
! output.critical(F_("could not install signal handler for sigint"), errno);
! if (sigaction(SIGCHLD, &new_handler, NULL) < 0)
! output.critical(F_("could not install signal handler for sigchild"), errno);
}
}
Index: types.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/types.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** types.hpp 22 Sep 2005 15:44:52 -0000 1.4
--- types.hpp 4 Nov 2005 18:27:58 -0000 1.5
***************
*** 25,28 ****
--- 25,29 ----
};
+ /* with begin and end */
struct TimeStamp2
{
***************
*** 120,123 ****
--- 121,125 ----
include
}mode;
+
std::string expression; //! for output only
boost::regex rule;
***************
*** 128,133 ****
};
-
}
-
#endif
--- 130,133 ----
Index: system_calls.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/system_calls.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** system_calls.cpp 10 Jul 2005 16:33:23 -0000 1.13
--- system_calls.cpp 4 Nov 2005 18:27:58 -0000 1.14
***************
*** 56,75 ****
{
int ret;
-
- //assert( S_ISLNK(st->st_mode) );
-
- /*
- * read link
- */
- //linkname = network->readData();
-
output.information(F_("link %s %s") % name % link_dest, DEBUG_OUTPUT);
- /*
- * create link
- */
-
-
make_path(name);
-
ret = link( link_dest.c_str(), name.c_str() );
if( ret < 0 )
--- 56,61 ----
***************
*** 78,86 ****
return;
}
-
- //delete [] linkname;
-
setPermissions( name, st, SET_ALL);
-
}
--- 64,68 ----
***************
*** 96,106 ****
int ret;
make_path(name);
-
-
- //assert( S_ISDIR(st->st_mode) );
-
- /*
- * generate new directory
- */
ret = mkdir( name.c_str(), 0000 );
if( ret < 0 && errno!=EEXIST ) {
--- 78,81 ----
***************
*** 108,112 ****
return;
}
-
setPermissions( name , st, SET_ALL );
}
--- 83,86 ----
***************
*** 114,128 ****
void getChr(string name, struct stat &st)
{
-
int ret;
-
make_path(name);
-
-
- //assert( S_ISCHR(st->st_mode) );
-
- /*
- * create node
- */
ret = mknod( name.c_str(), S_IFCHR, st.st_rdev );
if( ret < 0 ) {
--- 88,93 ----
***************
*** 133,149 ****
}
-
-
void getBlk(string name, struct stat &st)
{
int ret;
-
- //assert( S_ISBLK(st->st_mode) );
-
make_path(name);
-
- /*
- * create node
- */
ret = mknod( name.c_str(), S_IFBLK, st.st_rdev );
if( ret < 0 ) {
--- 98,105 ----
***************
*** 151,155 ****
return;
}
-
setPermissions( name, st, SET_ALL );
}
--- 107,110 ----
***************
*** 159,176 ****
}
-
-
void getSlnk(string name, string link_dest, struct stat &st)
{
-
output.information(F_("getting symlink: %s") % name, DEBUG_OUTPUT);
output.information(F_("symlink dest: %s") % link_dest, DEBUG_OUTPUT);
int ret;
-
- //assert( S_ISLNK(st->st_mode) );
make_path(name);
- /*
- * create link
- */
ret = symlink( link_dest.c_str(), name.c_str() );
if( ret < 0 ) {
--- 114,123 ----
***************
*** 178,186 ****
return;
}
-
-
-
setPermissions( name, st, SET_OWNER | SET_LINK_OWNER);
-
}
void getSock(string name, struct stat &st)
--- 125,129 ----
***************
*** 197,203 ****
struct utimbuf u;
int ret;
-
mode = st.st_mode & 07777;
-
if( flags & SET_TIME )
{
--- 140,144 ----
***************
*** 272,276 ****
temp = p;
-
//ignore leading slash!!
*d++ = *p++;
--- 213,216 ----
***************
*** 318,328 ****
if (fd_pair(pipe1) < 0 ||
fd_pair(pipe2) < 0)
! perror("pipe-Fehler");
if ( (pid = fork()) < 0)
! perror("fork-Fehler");
!
else
! if (pid > 0) { /*------------ Elternprozess -------------*/
output.information(F_("child created - pid: %d")
% int2string(pid), DEBUG_OUTPUT);
--- 258,267 ----
if (fd_pair(pipe1) < 0 ||
fd_pair(pipe2) < 0)
! output.critical(F_("error pairing pipes"), errno);
if ( (pid = fork()) < 0)
! output.critical(F_("error forking"), errno);
else
! if (pid > 0) { /* parrent */
output.information(F_("child created - pid: %d")
% int2string(pid), DEBUG_OUTPUT);
***************
*** 335,360 ****
char remote_protocol_ver = 0;
if(read(f_in, &remote_protocol_ver, 1) < 1)
! output.critical("error connecting!", errno);
if (remote_protocol_ver != PROTOCOL_VERSION)
! output.critical("Protocol error - wrong Handshake", 0);
! output.information("Protocol Handshake successful", DEBUG_OUTPUT);
//set_nonblocking(f_in);
//set_nonblocking(f_out);
}
! else { /*------------ Kindprozess ---------------*/
close(pipe1[1]);
close(pipe2[0]);
if (pipe1[0] != STDIN_FILENO) {
if (dup2(pipe1[0], STDIN_FILENO) != STDIN_FILENO)
! perror("dup2-Fehler (bei stdin)");
close(pipe1[0]);
}
if (pipe2[1] != STDOUT_FILENO) {
if (dup2(pipe2[1], STDOUT_FILENO) != STDOUT_FILENO)
! perror("dup2-Fehler (bei stdout)");
close(pipe2[1]);
}
!
ssh(destination_host, username, cmd);
}
--- 274,299 ----
char remote_protocol_ver = 0;
if(read(f_in, &remote_protocol_ver, 1) < 1)
! output.critical(F_("error connecting!"), errno);
if (remote_protocol_ver != PROTOCOL_VERSION)
! output.critical(F_("protocol error - wrong handshake"), 0);
! output.information(F_("protocol handshake successful"), DEBUG_OUTPUT);
//set_nonblocking(f_in);
//set_nonblocking(f_out);
}
! else { /* child */
close(pipe1[1]);
close(pipe2[0]);
if (pipe1[0] != STDIN_FILENO) {
if (dup2(pipe1[0], STDIN_FILENO) != STDIN_FILENO)
! output.critical(F_("error duplicating STDIN_FILENO"), errno);
close(pipe1[0]);
}
if (pipe2[1] != STDOUT_FILENO) {
if (dup2(pipe2[1], STDOUT_FILENO) != STDOUT_FILENO)
! output.critical(F_("error duplicating STDOUT_FILENO"), errno);
close(pipe2[1]);
}
! /* initiating ssh connection */
ssh(destination_host, username, cmd);
}
***************
*** 370,379 ****
if (fd_pair(to_child_pipe) < 0 ||
fd_pair(from_child_pipe) < 0) {
! output.critical("unable to create pipe", errno);
}
pid = fork();
if (pid == -1) {
! output.critical("unable to fork", errno);
}
--- 309,318 ----
if (fd_pair(to_child_pipe) < 0 ||
fd_pair(from_child_pipe) < 0) {
! output.critical(F_("unable to create pipe"), errno);
}
pid = fork();
if (pid == -1) {
! output.critical(F_("unable to fork"), errno);
}
***************
*** 383,387 ****
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
! output.critical("Failed to dup/close", errno);
}
if (to_child_pipe[0] != STDIN_FILENO)
--- 322,326 ----
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
! output.critical(F_("Failed to dup/close"), errno);
}
if (to_child_pipe[0] != STDIN_FILENO)
***************
*** 392,399 ****
}
-
if (close(from_child_pipe[1]) < 0 ||
close(to_child_pipe[0]) < 0) {
! output.critical("Failed to close", errno);
}
--- 331,337 ----
}
if (close(from_child_pipe[1]) < 0 ||
close(to_child_pipe[0]) < 0) {
! output.critical(F_("Failed to close pipe"), errno);
}
***************
*** 424,428 ****
//set_nonblocking(fd[1]);
}
-
return ret;
}
--- 362,365 ----
***************
*** 431,435 ****
{
int val;
-
if ((val = fcntl(fd, F_GETFL, 0)) == -1)
return;
--- 368,371 ----
***************
*** 443,447 ****
{
int val;
-
if ((val = fcntl(fd, F_GETFL, 0)) == -1)
return;
--- 379,382 ----
***************
*** 452,456 ****
}
-
void ssh(string destination_host, string username, string cmd)
{
--- 387,390 ----
***************
*** 470,474 ****
}
-
string dir_getlast(string directory, struct TimeStamp &lastBackupTime)
{
--- 404,407 ----
***************
*** 557,569 ****
}
- //std::cerr << "seltsames jahr hier: " << time.tm_year << " " <<time.tm_mon << " " <<time.tm_mday << " " <<time.tm_wday << " " <<time.tm_hour << " " <<time.tm_min << " " <<time.tm_sec << "\n";
if((lastt = mktime(&time)) == -1)
{
! output.warning("error calculating time of last backup: ", errno);
}
!
! //time = *localtime(&lastt);
!
! //std::cerr << "seltsames jahr hier: " <<time.tm_year << "\n";
lastBackupTime.year = time.tm_year+1900;
lastBackupTime.month =time.tm_mon+1;
--- 490,498 ----
}
if((lastt = mktime(&time)) == -1)
{
! output.critical("error calculating time of last backup: ", errno);
}
!
lastBackupTime.year = time.tm_year+1900;
lastBackupTime.month =time.tm_mon+1;
***************
*** 572,582 ****
lastBackupTime.minute = time.tm_min;
lastBackupTime.weekday = time.tm_wday;
! //std::cerr << "seltsamer tag hier: " << lastBackupTime.weekday << std::endl;
path.append("/");
return path;
-
}
-
std::list<string> dir_getlast2(string directory)
{
--- 501,509 ----
lastBackupTime.minute = time.tm_min;
lastBackupTime.weekday = time.tm_wday;
!
path.append("/");
return path;
}
std::list<string> dir_getlast2(string directory)
{
***************
*** 665,674 ****
}
- /*ret = chdir("..");
- if( ret<0 )
- {
- output.non_critical(string("chdir(\"..\"): "), errno);
- return( ret );
- }*/
snprintf( newdir, MAXDATE, "%04d-%02d-%02d@%02d:%02d:%02d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
--- 592,595 ----
***************
*** 711,724 ****
}
-
-
-
void removeFile(string fileName)
{
int state = 0;
! output.information(F_("delete File: %s") % fileName, NORMAL_OUTPUT);
state = remove(fileName.c_str());
if (state != 0)
! output.warning(F_("Could not remove file %s")
% fileName , errno);
}
--- 632,642 ----
}
void removeFile(string fileName)
{
int state = 0;
! output.information(F_("delete file: %s") % fileName, NORMAL_OUTPUT);
state = remove(fileName.c_str());
if (state != 0)
! output.warning(F_("could not remove file %s")
% fileName , errno);
}
***************
*** 727,731 ****
void mmap_copy(string source, string destination)
{
-
int fd_source, fd_dest;
struct stat st;
--- 645,648 ----
***************
*** 774,778 ****
void normal_copy(string source, string destination)
{
-
int fd_source, fd_dest;
char puffer[BUFFER_SIZE];
--- 691,694 ----
Index: common.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/common.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** common.hpp 8 Jun 2005 19:29:04 -0000 1.2
--- common.hpp 4 Nov 2005 18:27:58 -0000 1.3
***************
*** 8,22 ****
extern MessageHandling output;
! /** g++ libs does not provide methods to convert 64bit ints into network byte
! order. This function do that.
! \param source is a pointer to the 64bit or 32 bit Integer. The original data
! would not be modified.
! \param length is the size of the value in bytes (e.g. 8 for 64 bit).
! The functions returns a pointer to an array with the length of the
! original data. The array contains the data in network byte order. The
! caller have to delete the new allocted memory **/
! //char *hostToNetByte(void *source, int length);
!
! /** g++ libs does not provide methods to convert 64bit ints into network byte
order. This function do that.
\param value is a Integer in host byte order
--- 8,12 ----
extern MessageHandling output;
! /** glibc does not provide methods to convert 64bit ints into network byte
order. This function do that.
\param value is a Integer in host byte order
***************
*** 27,40 ****
/** g++ libs does not provide methods to convert 64bit ints into host byte
order. This function do that.
- \param source is a pointer to the 64bit or 32 bit Integer. The original data
- would not be modified.
- \param length is the size of the value in bytes (e.g. 8 for 64 bit).
- The functions returns a pointer to an array with the length of the
- original data. The array contains the data in host byte order. The
- caller have to delete the new allocted memory **/
- //char *netToHostByte(void *source, int length);
-
- /** g++ libs does not provide methods to convert 64bit ints into host byte
- order. This function do that.
\param value is a Integer in net byte order
\param length is the size of the value in bytes (e.g. 8 for 64 bit).
--- 17,20 ----
Index: common.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/common.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** common.cpp 14 Jun 2005 20:23:33 -0000 1.5
--- common.cpp 4 Nov 2005 18:27:58 -0000 1.6
***************
*** 10,19 ****
******************************************************************************/
#include "support.h"
-
#include "common/common.hpp"
#include <netinet/in.h>
-
namespace faubackup
{
--- 10,17 ----
***************
*** 23,27 ****
uint64_t ret = 0;
#ifdef WORDS_BIGENDIAN
-
ret = value;
#else
--- 21,24 ----
***************
*** 58,65 ****
#ifdef WORDS_BIGENDIAN
-
ret = value;
#else
-
if (length == 8) { //64 bit value
/* Split the 8 bytes into two 4 byte integers.
--- 55,60 ----
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php