All pastes #1940354 Raw Edit

erwan

public text v1 · immutable
#1940354 ·published 2010-09-14 08:37 UTC
rendered paste body
diff --git a/metadataCreator/lib/Makefile b/metadataCreator/lib/Makefileindex d6795c1..9df066d 100644--- a/metadataCreator/lib/Makefile+++ b/metadataCreator/lib/Makefile@@ -11,8 +11,9 @@ OBJS      = situpdateMetadataCreator.o situpdateSHA1.o # # C compiler and flags #+INCLUDE   = -I ../../ CC        = gcc-CFLAGS    = -fPIC -g -Wall ${INCLUDE} -m32+CFLAGS    = -fPIC -g -Wall ${INCLUDE} -m32 -Werror LDFLAGS   = -shared -fPIC  SYSLIBS   = -lpthreaddiff --git a/metadataCreator/lib/situpdateMetadataCreator.c b/metadataCreator/lib/situpdateMetadataCreator.cindex b0efa4e..a912f50 100644--- a/metadataCreator/lib/situpdateMetadataCreator.c+++ b/metadataCreator/lib/situpdateMetadataCreator.c@@ -21,10 +21,10 @@ #include <unistd.h> #include <string.h> #include <fcntl.h>+#include "common/situpdate.h" #include "situpdateSHA1.h"  #define LINE_SIZE 80-#define BLOCK_SIZE 1048576 //1Mb #define progress_file "/tmp/export_progress" static void progress_count(unsigned long i,unsigned long max_count) {@@ -45,7 +45,7 @@ int createMetadataForPartition(const char * device, unsigned char **result, 	unsigned long long *size,unsigned long *count) { 	unsigned char * res = NULL;-	unsigned char  block[BLOCK_SIZE] = {0};+	unsigned char  block[DATA_BLOCK_SIZE_B] = {0};  	int    fd = -1; 	unsigned long    i=0;@@ -65,7 +65,7 @@ int createMetadataForPartition(const char * device, unsigned char **result, 	*size = lseek64(fd,0,SEEK_END); 	lseek64(fd,0,SEEK_SET); -	*count = *size/BLOCK_SIZE + 1;+	*count = *size/DATA_BLOCK_SIZE_B + 1;  	res = malloc(*count * LINE_SIZE); @@ -79,12 +79,12 @@ int createMetadataForPartition(const char * device, unsigned char **result, 	for (i=0;i< *count;i++) 	{ 		int end_flag = 0;-		n1=read(fd,block,BLOCK_SIZE);+		n1=read(fd,block,DATA_BLOCK_SIZE_B); 		if (n1 < 0) 			break; 		if (n1 == 0) 			break;-		if (n1 < BLOCK_SIZE) /* end of file */+		if (n1 < DATA_BLOCK_SIZE_B) /* end of file */ 			end_flag=1; 		n2 = sprintf((char *)res,"%07lu:%010d:%40s\n",i,n1,sha1_to_ascii( sha1(block,n1))); 		res += n2;diff --git a/metadataCreator/lib/situpdateMetadataCreator.h b/metadataCreator/lib/situpdateMetadataCreator.hindex 2e96fdf..fb3ad04 100644--- a/metadataCreator/lib/situpdateMetadataCreator.h+++ b/metadataCreator/lib/situpdateMetadataCreator.h@@ -24,7 +24,4 @@ int createMetadataForPartition(const char * device, unsigned char **result, /** Free the memory previously allocated by createMetadataForPartition()  */ void freeMetadata(unsigned char *data);--#define BLOCK_SIZE 1048576 //1Mb- #endifdiff --git a/metadataCreator/src/Makefile b/metadataCreator/src/Makefileindex 6756ffe..aab10d1 100644--- a/metadataCreator/src/Makefile+++ b/metadataCreator/src/Makefile@@ -1,5 +1,6 @@ DESTDIR=/usr-CFLAGS=-Wall -g -I ../lib -m32+INCLUDE=-I ../lib -I ../../+CFLAGS=-Wall -g $(INCLUDE) -m32 -Werror LDFLAGS=-lpthread ../lib/libsitupdateMetadataCreator.a TARGET=situpdateMetadataCreator all: $(TARGET)diff --git a/metadataCreator/src/situpdateMetadataCreator.c b/metadataCreator/src/situpdateMetadataCreator.cindex d2a3255..3ccc28b 100644--- a/metadataCreator/src/situpdateMetadataCreator.c+++ b/metadataCreator/src/situpdateMetadataCreator.c@@ -9,6 +9,7 @@  *  ****************************************************************************/ #include <stdio.h>+#include "common/situpdate.h" #include "situpdateMetadataCreator.h" #include "situpdateSHA1.h" @@ -27,7 +28,7 @@ int main(int argc, char **argv) 	} 	printf("#CONTENT:%-16s\n",argv[2]); 	printf("#MEDIAVERSION:%-14s\n",argv[3]);-	printf("#CHUNCKSIZE:%08d\n",BLOCK_SIZE);+	printf("#CHUNCKSIZE:%08d\n",DATA_BLOCK_SIZE_B); 	printf("#SIZE:%016llu\n",size); 	printf("#BLOCKCOUNT:%08lu\n",count); 	printf("%s",result);diff --git a/updateServer/lib/Makefile b/updateServer/lib/Makefileindex 0d9379c..305e401 100644--- a/updateServer/lib/Makefile+++ b/updateServer/lib/Makefile@@ -10,8 +10,9 @@ OBJS      = situpdateServer.o situpdateIPlist.o # # C compiler and flags #+INCLUDE   = -I ../../ CC        = gcc-CFLAGS    = -fPIC -g -Wall ${INCLUDE} -m32+CFLAGS    = -fPIC -g -Wall $(INCLUDE) -m32 -Werror LDFLAGS   = -shared -fPIC  SYSLIBS   = -lpthreaddiff --git a/updateServer/lib/situpdateIPlist.c b/updateServer/lib/situpdateIPlist.cindex df0dcdc..30d8462 100644--- a/updateServer/lib/situpdateIPlist.c+++ b/updateServer/lib/situpdateIPlist.c@@ -12,6 +12,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h>+#include "situpdateFilter.h" #include "situpdateServer.h"  void elect_sdu(struct update_participants_t * participants,unsigned int participant_count,unsigned long chunck_count)diff --git a/updateServer/lib/situpdateServer.c b/updateServer/lib/situpdateServer.cindex 0a598e3..e3eee23 100644--- a/updateServer/lib/situpdateServer.c+++ b/updateServer/lib/situpdateServer.c@@ -25,6 +25,7 @@ #include <net/if.h> #include <arpa/inet.h> #include <fcntl.h>+#include "situpdateFilter.h" #include "situpdateServer.h"  #define CHUNKSLIST_TMP_FILE "/tmp/situpdate_all_chunkslist"diff --git a/updateServer/lib/situpdateServer.h b/updateServer/lib/situpdateServer.hindex fd9ec4a..ced1b99 100644--- a/updateServer/lib/situpdateServer.h+++ b/updateServer/lib/situpdateServer.h@@ -71,7 +71,7 @@ struct update_participants_t { 	unsigned int result; 	unsigned int do_participate; 	unsigned int spbno;-	       char *chunks;+	char *chunks; }; /* File header constants */ #define HDR_SZ_CONTENT    26@@ -91,10 +91,6 @@ struct update_participants_t { #define META_OFF_DATA        (HDR_OFF_BLOCKCOUNT + HDR_SZ_BLOCKCOUNT) #define META_OFF_LINE_SHA1   19 -#define  MAX_PART_SIZE_GB  245-#define  MAX_CHUNKS_COUNT  (MAX_PART_SIZE_GB * 1024)-- #define  UPDATE_MAX_SDU 1024  /* Defines udpcast's maximum bandwidth */diff --git a/updateServer/src/Makefile b/updateServer/src/Makefileindex 43efcba..1e74e60 100644--- a/updateServer/src/Makefile+++ b/updateServer/src/Makefile@@ -1,5 +1,6 @@ DESTDIR=/usr-CFLAGS=-Wall -g -I ../lib -m32+INCLUDE=-I ../lib -I ../../+CFLAGS=-Wall -g $(INCLUDE) -m32 -D_GNU_SOURCE -Werror LDFLAGS=-lpthread ../lib/libsitupdateServer.a TARGET=situpdateServer IN_FILTER=situpdateInputFilter@@ -11,9 +12,9 @@ $(TARGET): $(TARGET).c 	gcc $(CFLAGS) $(LDFLAGS) -o $@ $(TARGET).c ../lib/libsitupdateServer.a  $(IN_FILTER):$(IN_FILTER).c $(SHA1).c-	gcc -m32 -Wall -g -D_GNU_SOURCE -I ../lib -I ../../metadataCreator/lib/ -o $@ $^+	gcc $(CFLAGS) -I ../../metadataCreator/lib/ -o $@ $^ $(OUT_FILTER):$(OUT_FILTER).c $(SHA1).c-	gcc -m32 -Wall -g -D_GNU_SOURCE -I ../lib -I ../../metadataCreator/lib/ -o $@ $^+	gcc $(CFLAGS) -I ../../metadataCreator/lib/ -o $@ $^  clean: 	rm -f *.o *~diff --git a/updateServer/src/situpdateInputFilter.c b/updateServer/src/situpdateInputFilter.cindex b2e8212..59689d2 100644--- a/updateServer/src/situpdateInputFilter.c+++ b/updateServer/src/situpdateInputFilter.c@@ -17,19 +17,9 @@ #include <errno.h> #include <string.h> #include <stdint.h>+#include "situpdateFilter.h" #include "situpdateServer.h" -#define  CHUNK_SZ (1024*1024)-#define  MAX_PART_SIZE_GB  245-#define  MAX_CHUNKS_COUNT  (MAX_PART_SIZE_GB * 1024)--struct data_chunck_t {-	uint8_t data[CHUNK_SZ];-	uint32_t chunck_tag;-	uint64_t chunck_nb;-	uint32_t chunck_sz;-} __attribute__ ((aligned (4096),packed));;- int main(int argc,char **argv) { 	int r=0;@@ -41,7 +31,7 @@ int main(int argc,char **argv) 	off64_t seekpos=0,lastseekpos=0; 	if (argc != 3) 		return -1;-	data_chunk.chunck_tag = 0xfeedfeed;+	data_chunk.chunck_tag = SIGNATURE;  /* Get chunklist */ 	fchunks=open(argv[2],O_RDONLY);diff --git a/updateServer/src/situpdateOutputFilter.c b/updateServer/src/situpdateOutputFilter.cindex a03765d..1ed3543 100644--- a/updateServer/src/situpdateOutputFilter.c+++ b/updateServer/src/situpdateOutputFilter.c@@ -17,23 +17,9 @@ #include <errno.h> #include <string.h> #include <stdint.h>+#include "situpdateFilter.h" #include "situpdateSHA1.h" -#define  CHUNK_SZ (1024*1024)-#define  MAX_PART_SIZE_GB  245-#define  MAX_CHUNKS_COUNT  (MAX_PART_SIZE_GB * 1024)--#define  METADATA_HEADER_SZ 0x78-#define  METADATA_LINE_SZ   0x3C--#define SHA1_SZ 42-struct data_chunck_t {-	uint8_t  data[CHUNK_SZ];-	uint32_t chunck_tag;-	uint64_t chunck_nb;-	uint32_t chunck_sz;-} __attribute__ ((aligned (4096),packed));- int write_meta(int fd_metadata,uint8_t *data,uint32_t sz,uint32_t pos) { 	static uint32_t lastpos=0;@@ -42,14 +28,14 @@ int write_meta(int fd_metadata,uint8_t *data,uint32_t sz,uint32_t pos) 	int      		r=0; 	newpos=METADATA_HEADER_SZ + pos*METADATA_LINE_SZ; 	if (newpos != lastpos) {-		if ( lseek(fd_metadata, newpos,SEEK_SET) < 0) {+		if ( lseek(fd_metadata, newpos, SEEK_SET) < 0) { 			return -1; 		} 		lastpos=newpos; 	} 	snprintf(line,METADATA_LINE_SZ+1,"%07u:%010d:%40s\n",pos,sz,sha1_to_ascii( sha1(data,sz))); 	r=write(fd_metadata,line,METADATA_LINE_SZ);-	if (r==METADATA_LINE_SZ)+	if (r == METADATA_LINE_SZ) 		lastpos+=METADATA_LINE_SZ; 	return r; }@@ -76,8 +62,8 @@ int main(int argc,char **argv) 	} 	do { 		r=fread_unlocked(&data_chunk,1,sizeof(data_chunk),stdin);-		if (r>0) {-			if (data_chunk.chunck_tag != 0xfeedfeed) {+		if (r > 0 ) {+			if (data_chunk.chunck_tag != SIGNATURE) { 				fprintf(stderr,"Ouch ! Data coming from udpcast is invalid at i=%d!\n",i); 				ret=4; 				continue;@@ -105,14 +91,14 @@ int main(int argc,char **argv) 				continue; 			} 			i++;-		} else if (r<0) {+		} else if (r < 0) { 			fprintf(stderr,"<fread> error for i=%d: ret=%d, err=%s\n",i,r,strerror(errno)); 			ret=8; 		} else { 			fprintf(stderr,"End of data at i=%d, success !\n",i); 			ret=0; 		}-	} while (r>0);+	} while (r > 0); 	close(fd_partition); 	close(fd_metadata); 	return ret;