faubackup2/src/common fileinfo.cpp,1.7,1.8 fileinfo.hpp,1.4,1.5

Erik Merkel <[email protected]> Sun, 03 Jul 2005 18:37:17 +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-serv7948/src/common

Modified Files:
	fileinfo.cpp fileinfo.hpp 
Log Message:
fixed hardlink bug: if a new created hardlink is transfered before the 
existing (unchanged) file is transfered, the hardlink is treated as a new
file and the existing (unchanged) file is created as a link to this new
file. These files need space on the disc. They should be both linked to an 
old backupset if the existing file is unchanged.

hardlink checking moved from InformationSender to FileSender

hardlinks are now transfered at the end of the backup process

directorys are now transferd after the sending of the hardlinks because
creating of hardlinks will change the modification time of directorys


Index: fileinfo.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/fileinfo.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** fileinfo.hpp	22 Jun 2005 23:56:21 -0000	1.4
--- fileinfo.hpp	3 Jul 2005 18:37:15 -0000	1.5
***************
*** 28,33 ****
  	BackupMode mode;
  	FileType type;
- 	string link_to_file;
  	off_t fileSize;
  public:
  	Fileinfo(string filename, string full_qualified_name);
--- 28,36 ----
  	BackupMode mode;
  	FileType type;
  	off_t fileSize;
+ 	uint64_t deviceNo;
+ 	uint64_t inodeNo;
+ 	bool fileExist;
+ 
  public:
  	Fileinfo(string filename, string full_qualified_name);
***************
*** 38,47 ****
  	BackupMode getBackupMode();
  	string getFilename();
- 	string getNameForLink();
  	time_t getChangeTime();
  	off_t getFileSize();
! 
  	void setBackupMode(BackupMode mode_for_backup);
! 	void setNameForLink(string destination);
  
  	/** constructor for raw-data from Network */
--- 41,57 ----
  	BackupMode getBackupMode();
  	string getFilename();
  	time_t getChangeTime();
  	off_t getFileSize();
! 	dev_t getDeviceNo();
! 	ino_t getInodeNo();
  	void setBackupMode(BackupMode mode_for_backup);
! 	inline void setNoHardlink()
! 	{
! 		deviceNo = 0;
! 		inodeNo = 0;
! 	}
! 	inline void setExisting(bool exist){fileExist = exist;}
! 	inline bool getExisting(){return fileExist;}
! 
  
  	/** constructor for raw-data from Network */

Index: fileinfo.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/fileinfo.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fileinfo.cpp	22 Jun 2005 23:56:21 -0000	1.7
--- fileinfo.cpp	3 Jul 2005 18:37:15 -0000	1.8
***************
*** 19,23 ****
  Fileinfo::Fileinfo(char *rawdata, unsigned int lengthOfData)
  {
! 	uint32_t net_size, filename_size, link_size;
  	uint8_t  byte_type, byte_mode;
  	net_size = *((uint32_t *) rawdata);
--- 19,24 ----
  Fileinfo::Fileinfo(char *rawdata, unsigned int lengthOfData)
  {
! 	fileExist = false;
! 	uint32_t net_size, filename_size;
  	uint8_t  byte_type, byte_mode;
  	net_size = *((uint32_t *) rawdata);
***************
*** 33,36 ****
--- 34,41 ----
  	fileSize = netToHostByte(*(uint64_t *)(rawdata + offset), 8);
  	offset += 8;
+ 	inodeNo = netToHostByte(*(uint64_t *)(rawdata + offset), 8);
+ 	offset += 8;
+ 	deviceNo = netToHostByte(*(uint64_t *)(rawdata + offset), 8);
+ 	offset += 8;
  	stat_mtime = ntohl(*(uint32_t *)(rawdata + offset));
  	offset += 4;
***************
*** 40,48 ****
  	memcpy(filename_c , rawdata + offset, filename_size);
  	offset += filename_size;
- 	link_size = ntohl(*(uint32_t *)(rawdata + offset));
- 	offset += 4;
- 	char * linkname_c = new char[link_size];
- 	memcpy(linkname_c , rawdata + offset, link_size);
- 	offset += link_size;
  	if(offset != size)
  		output.critical(F_("internal error calculating Fileinfo from"
--- 45,48 ----
***************
*** 50,59 ****
  
  	fileName = filename_c;
- 	link_to_file = linkname_c;
  	mode = (BackupMode) byte_mode;
  	type = (FileType) byte_type;
  
  	delete [] rawdata;
- 	delete [] linkname_c;
  	delete [] filename_c;
  }
--- 50,57 ----
***************
*** 61,65 ****
  void *Fileinfo::getRawData()
  {
! 	uint32_t net_size, filename_size, link_size;
  	uint8_t byte_type, byte_mode;
  	uint32_t size = getRawDataSize();
--- 59,63 ----
  void *Fileinfo::getRawData()
  {
! 	uint32_t net_size, filename_size;
  	uint8_t byte_type, byte_mode;
  	uint32_t size = getRawDataSize();
***************
*** 69,76 ****
  	net_size = htonl(size);
  	filename_size = htonl(fileName.length() + 1);
- 	link_size = htonl(link_to_file.length() + 1);
  	byte_type = type;
  	byte_mode = mode;
  	uint64_t network_fileSize = hostToNetByte(fileSize, 8);
  	uint32_t network_time = hostToNetByte(stat_mtime, 4);
  
--- 67,76 ----
  	net_size = htonl(size);
  	filename_size = htonl(fileName.length() + 1);
  	byte_type = type;
  	byte_mode = mode;
  	uint64_t network_fileSize = hostToNetByte(fileSize, 8);
+ 	uint64_t network_inodeNo = hostToNetByte(inodeNo, 8);
+ 	uint64_t network_deviceNo = hostToNetByte(deviceNo, 8);
+ 
  	uint32_t network_time = hostToNetByte(stat_mtime, 4);
  
***************
*** 83,86 ****
--- 83,90 ----
  	memcpy(return_pointer + offset , &network_fileSize , 8);
  	offset += 8;
+ 	memcpy(return_pointer + offset , &network_inodeNo , 8);
+ 	offset += 8;
+ 	memcpy(return_pointer + offset , &network_deviceNo , 8);
+ 	offset += 8;
  	memcpy(return_pointer + offset , &network_time , 4);
  	offset += 4;
***************
*** 90,98 ****
  	       fileName.length() + 1);
  	offset += fileName.length() + 1;
- 	memcpy(return_pointer + offset , &link_size , 4);
- 	offset += 4;
- 	memcpy(return_pointer + offset , link_to_file.c_str() ,
- 	       link_to_file.length() + 1);
- 	offset += link_to_file.length() + 1;
  	if(offset != size)
  		output.critical(F_("internal error calculating Fileinfo "
--- 94,97 ----
***************
*** 105,113 ****
  int Fileinfo::getRawDataSize()
  {
! 	int size = 4 * 4 //time, filename_size and link_size
  	           + 2 * 1 // mode and type
  	           + fileName.length() + 1 // +1 b.o. null termination of c strings
! 	           + link_to_file.length() + 1
! 	           + 8;
  	return size;
  }
--- 104,111 ----
  int Fileinfo::getRawDataSize()
  {
! 	int size = 4 * 3 //time, filename_size and link_size
  	           + 2 * 1 // mode and type
  	           + fileName.length() + 1 // +1 b.o. null termination of c strings
! 	           + 8 * 3;
  	return size;
  }
***************
*** 131,154 ****
  Fileinfo::Fileinfo(string filename, string full_qualified_name)
  		:
! 		fileName(filename), mode(NotSet), link_to_file("")
  {
  	struct stat st = getStat(full_qualified_name);
  	stat_mtime = st.st_mtime;
  	type = whatType(st);
  	fileSize = st.st_size;
  }
  
  Fileinfo::Fileinfo(string filename, struct stat st, BackupMode backup_mode)
  		:stat_mtime(st.st_mtime), fileName(filename), mode(backup_mode),
! 		type(whatType(st)),  link_to_file(""), fileSize(st.st_size)
! {}
  
  
  Fileinfo::Fileinfo()
  {
  	type = EXIT;
  	mode = NotSet;
  	fileName = "";
- 	link_to_file = "";
  	stat_mtime = 0;
  	fileSize =0;
--- 129,159 ----
  Fileinfo::Fileinfo(string filename, string full_qualified_name)
  		:
! 		fileName(filename), mode(NotSet)
  {
+ 	fileExist = false;
  	struct stat st = getStat(full_qualified_name);
  	stat_mtime = st.st_mtime;
  	type = whatType(st);
  	fileSize = st.st_size;
+ 	inodeNo = st.st_ino;
+ 	deviceNo = st.st_dev;
  }
  
  Fileinfo::Fileinfo(string filename, struct stat st, BackupMode backup_mode)
  		:stat_mtime(st.st_mtime), fileName(filename), mode(backup_mode),
! 		type(whatType(st)),  fileSize(st.st_size)
! {
! 	inodeNo = st.st_ino;
! 	deviceNo = st.st_dev;
! 	fileExist = false;
! }
  
  
  Fileinfo::Fileinfo()
  {
+ 	fileExist = false;
  	type = EXIT;
  	mode = NotSet;
  	fileName = "";
  	stat_mtime = 0;
  	fileSize =0;
***************
*** 170,186 ****
  }
  
! string Fileinfo::getNameForLink()
  {
! 	return link_to_file;
  }
  
! void Fileinfo::setBackupMode(BackupMode mode_for_backup)
  {
! 	mode = mode_for_backup;
  }
  
! void Fileinfo::setNameForLink(string destination)
  {
! 	link_to_file = destination;
  }
  
--- 175,191 ----
  }
  
! ino_t Fileinfo::getInodeNo()
  {
! 	return inodeNo;
  }
  
! dev_t Fileinfo::getDeviceNo()
  {
! 	return deviceNo;
  }
  
! void Fileinfo::setBackupMode(BackupMode mode_for_backup)
  {
! 	mode = mode_for_backup;
  }
  



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click