Changeset 2421 in MondoRescue
- Timestamp:
- Sep 24, 2009, 3:50:38 PM (15 years ago)
- Location:
- branches/2.2.10
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2420 r2421 993 993 if (!does_file_exist(archiving_filelist_fname)) { 994 994 log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no); 995 mr_free(archiving_afioball_fname); 995 996 break; 996 997 } … … 1291 1292 malloc_string(result_str); 1292 1293 transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1293 memset((void *) transfer_block, 0, 1294 sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1294 memset((void *) transfer_block, 0, sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1295 1295 p_last_set_archived = (int *) transfer_block; 1296 1296 p_archival_threads_running = (int *) (transfer_block + 4); 1297 1297 p_next_set_to_archive = (int *) (transfer_block + 8); 1298 1298 p_list_of_fileset_flags = (char *) (transfer_block + 12); 1299 memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), 1300 (void *) bkpinfo, sizeof(struct s_bkpinfo)); 1299 memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo)); 1301 1300 pvp = &vp; 1302 1301 vp = (void *) result_str; … … 1310 1309 "Please wait. This may take a couple of hours.", 1311 1310 "Working...", 1312 get_last_filelist_number() + 1);1311 (long)get_last_filelist_number() + 1L); 1313 1312 1314 1313 log_msg(5, "We're gonna party like it's your birthday."); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2405 r2421 2257 2257 char *where_is_root_mounted() { 2258 2258 /*@ buffers **************** */ 2259 char *output ;2259 char *output = NULL; 2260 2260 2261 2261 -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2420 r2421 8 8 #include "my-stuff.h" 9 9 #include "mr_mem.h" 10 #include "mr_str.h" 10 11 #include "mondostructures.h" 11 12 #include "libmondo-fork.h" … … 39 40 char *result = NULL; 40 41 char *tmpf = NULL; 42 char *newcall = NULL; 43 char *tmp = NULL; 41 44 42 45 /*@ pointers **************************************************** */ 43 FILE *fin ;46 FILE *fin = NULL; 44 47 45 48 /*@******************************************************************** */ … … 47 50 assert_string_is_neither_NULL_nor_zerolength(call); 48 51 49 mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo-> scratchdir);50 mr_ strcat(call, " > %s", tmpf);51 log_msg(4, "Calling command: %s", call);52 mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo->tmpdir); 53 mr_asprintf(newcall, "%s > %s", call, tmpf); 54 log_msg(4, "Calling command: %s", newcall); 52 55 /* By default return an empty string in any case */ 53 56 mr_asprintf(result, ""); 54 57 55 system(call); 56 if ((fin = fopen(ftmp, "r"))) { 58 system(newcall); 59 mr_free(newcall); 60 61 if ((fin = fopen(tmpf, "r"))) { 57 62 while (!feof(fin)) { 58 mr_getline(result, fin); 59 log_msg(9, "Loop result: %s", result); 60 } 61 log_msg(4, "Final Result: %s", result); 63 mr_getline(tmp, fin); 64 mr_chomp(tmp); 65 /* In case of extreme debug ;-) 66 log_msg(9, "Loop result: ***%s***", tmp); 67 */ 68 /* There is empty contant at the end of the file that needs to be skiped */ 69 if (strlen(tmp) > 0) { 70 mr_free(result); 71 mr_asprintf(result, "%s", tmp); 72 } 73 mr_free(tmp); 74 } 75 log_msg(4, "Result: %s", result); 62 76 mr_strip_spaces(result); 63 77 paranoid_pclose(fin); 64 78 } else { 65 log_OS_error("Unable to popen call"); 66 } 67 mr_free(ftmp) 68 log_msg(4, "Returns: %s", result); 79 log_OS_error("Unable to open resulting file"); 80 } 81 mr_free(tmpf); 69 82 return(result); 70 83 } -
branches/2.2.10/mondo/src/common/libmondo-tools-EXT.h
r2325 r2421 3 3 extern void clean_up_KDE_desktop_if_necessary(void); 4 4 extern long get_time(); 5 extern char *mr_date(void);6 5 extern void (*log_debug_msg) (int debug_level, const char *szFile, 7 6 const char *szFunction, int nLine, -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2406 r2421 803 803 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo)); 804 804 805 /* We need tmpdir as early as possible for further function calls */ 806 bkpinfo->tmpdir = NULL; // Really setup after 807 setup_tmpdir(NULL); 808 805 809 /* Initialized in same order as in the structure declaration to detect errors more easily */ 806 810 bkpinfo->media_device = NULL; … … 822 826 bkpinfo->use_star = FALSE; 823 827 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 824 bkpinfo->disaster_recovery = (am_I_in_disaster_recovery_mode()? TRUE : FALSE);828 bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode(); 825 829 if (bkpinfo->disaster_recovery) { 826 830 mr_asprintf(bkpinfo->isodir, "%s", "/"); … … 829 833 } 830 834 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 835 /* bkpinfo->tmpdir is here in the struct */ 831 836 bkpinfo->scratchdir = NULL; // Really setup after 832 bkpinfo->tmpdir = NULL; // Really setup after833 837 bkpinfo->optimal_set_size = 0; 834 838 bkpinfo->backup_media_type = none; … … 857 861 bkpinfo->restore_mode = interactive; 858 862 859 setup_tmpdir(NULL);860 863 sensibly_set_scratchdir(); 861 864 } … … 1364 1367 va_end(args); 1365 1368 1366 // do not slow down the progran if standard debug level1367 // must be enabled: if no flush, the log won't be up-to-date if there1368 // is a segfault1369 //if (g_dwDebugLevel != 1)1370 1371 1369 fprintf(fout, "\n"); 1372 1370 paranoid_fclose(fout); -
branches/2.2.10/mondo/src/common/libmondo-tools.h
r2325 r2421 6 6 7 7 long get_time(); 8 char *mr_date(void);9 8 extern void (*log_debug_msg) (int debug_level, const char *szFile, 10 9 const char *szFunction, int nLine, -
branches/2.2.10/mondo/src/common/newt-specific.c
r2414 r2421 96 96 extern int g_current_media_number; 97 97 pid_t g_main_pid = 0; ///< The PID of the main Mondo process. 98 long g_maximum_progress = 999 ; ///< The maximum amount of progress (100%) for the currently opened progress form.98 long g_maximum_progress = 999L; ///< The maximum amount of progress (100%) for the currently opened progress form. 99 99 long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form. 100 100 long g_start_time = 0L; ///< The time (in seconds since the epoch) that the progress form was opened. … … 644 644 g_blurb3 = newtLabel(2, 4, blurb2); 645 645 newtCenteredWindow(60, 11, title); 646 g_scale = newtScale(3, 6, 54, g_maximum_progress);646 g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress); 647 647 g_progressForm = newtForm(NULL, NULL, 0); 648 648 g_percentline = newtLabel(10, 9, "This is the percentline"); -
branches/2.2.10/mondo/src/include/mr_str.h
r2208 r2421 17 17 extern char *mr_strtok(char *instr, const char *delims, int *lastpos); 18 18 extern char *mr_stresc(char *instr, char *toesc, const char escchr); 19 extern inlinechar *mr_date(void);19 extern char *mr_date(void); 20 20 extern void mr_strip_spaces(char *in_out); 21 extern void mr_strip_char(char *in_out, char *caracs); 22 extern void mr_chomp(char *in_out); 21 23 22 24 #endif /* MR_STR_H */ -
branches/2.2.10/mondo/src/lib/mr_mem.c
r2341 r2421 53 53 } 54 54 55 /* encapsulation function for getline */56 void mr_getline_int(char **lineptr, FILE *fd, int line, const char *file) {57 58 ssize_t ret;59 size_t n = 0;60 61 ret = getline(lineptr,&n,fd);62 if ((ret == -1) && (! feof(fd))) {63 mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting...");64 mr_exit(-1,"Unable to alloc memory in mr_getline");65 }66 }67 68 55 /* encapsulation function for asprintf */ 69 56 void mr_asprintf_int(char **strp, int line, const char *file, const char *fmt, ...) { … … 79 66 } 80 67 va_end(args); 68 } 69 70 /* encapsulation function for getline */ 71 void mr_getline_int(char **lineptr, FILE *fd, int line, const char *file) { 72 73 ssize_t ret; 74 size_t n = 0; 75 76 ret = getline(lineptr,&n,fd); 77 if ((ret == -1) && (! feof(fd))) { 78 mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting..."); 79 mr_exit(-1,"Unable to alloc memory in mr_getline"); 80 } 81 /* We reached end of file, allocating empty string */ 82 if (ret == -1) { 83 mr_asprintf_int(lineptr, line, file, ""); 84 } 81 85 } 82 86 -
branches/2.2.10/mondo/src/lib/mr_str.c
r1924 r2421 104 104 } 105 105 106 /* Return a string containing the date */107 char *mr_date(void) {108 109 time_t tcurr;110 111 tcurr = time(NULL);112 return(ctime(&tcurr));113 }114 115 116 106 /** 117 * Remove all characters whose ASCII value is less than or equal to 32 118 * (spaces and control characters) from both sides of @p in_out. 119 * @param in_out The string to strip spaces/control characters from (modified). 107 * Remove all characters in caracs from begining and end of string @p in_out 108 * @param in_out The string to strip char characters from (modified). 120 109 */ 121 void mr_strip_ spaces(char *in_out) {110 void mr_strip_char(char *in_out, char *caracs) { 122 111 int i = 0; 123 112 int j = 0; 124 size_t length;113 int length = 0; 125 114 115 if (caracs == NULL) { 116 return; 117 } 126 118 if (in_out == NULL) { 127 119 return; 128 120 } 129 length = strlen(in_out);121 length = (int)strlen(in_out); 130 122 131 /* Skip initial spaces and special chars */ 132 for (i = 0; in_out[i] <= ' ' && i < (int)length ; i++); 123 /* Skip initial caracs */ 124 for (i = 0; index(caracs, in_out[i]) != NULL && i < length ; i++); 125 133 126 /* Shift the string to the begining if needed */ 134 127 if (i != 0) { 135 for (j = 0; i < (int)length ; i++, j++) {128 for (j = 0; i < length ; i++, j++) { 136 129 in_out[j] = in_out[i]; 137 130 } … … 142 135 143 136 /* Skip final spaces and special chars */ 144 for (i = (int)strlen(in_out) - 1; i >= 0 && in _out[i] <= ' '; i--);137 for (i = (int)strlen(in_out) - 1; i >= 0 && index(caracs, in_out[i]) != NULL; i--); 145 138 146 139 /* The string now ends after that char */ … … 148 141 in_out[i] = '\0'; 149 142 } 143 144 /** 145 * Remove all characters whose ASCII value is less than or equal to 32 146 * (spaces and control characters) from both sides of @p in_out. 147 * @param in_out The string to strip spaces/control characters from (modified). 148 */ 149 void mr_strip_spaces(char *in_out) { 150 151 int i; 152 char *tmp = NULL; 153 154 mr_asprintf(tmp, ""); 155 156 /* Build the string of char to avoid: ctrl char up to space*/ 157 for (i = 0; i <= ' '; i++) { 158 mr_strcat(tmp, "%c", i); 159 } 160 161 mr_strip_char(in_out, tmp); 162 mr_free(tmp); 163 } 164 165 /* 166 * Remove '\n' char from both sides of @p in_out. 167 * @param in_out The string to strip characters from (modified). 168 */ 169 void mr_chomp(char *in_out) { 170 171 mr_strip_char(in_out, "\n"); 172 } 173 174 /* Return an allocated string containing the date */ 175 char *mr_date(void) { 176 177 time_t tcurr; 178 char *tmp = NULL; 179 180 tcurr = time(NULL); 181 mr_asprintf(tmp, "%s", ctime(&tcurr)); 182 mr_chomp(tmp); 183 return(tmp); 184 } 185 186 -
branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c
r2413 r2421 10 10 #include "my-stuff.h" 11 11 #include "mr_mem.h" 12 #include "mr_str.h" 12 13 #include "../common/mondostructures.h" 13 14 #include "../common/libmondo.h" … … 161 162 printf("Initializing...\n"); 162 163 163 init_bkpinfo();164 165 164 /* initialize log file with time stamp */ 166 165 unlink(MONDO_LOGFILE); 167 log_msg(0, "Time started: %s", mr_date()); 166 tmp = mr_date(); 167 log_msg(0, "Time started: %s", tmp); 168 mr_free(tmp); 169 170 init_bkpinfo(); 168 171 169 172 /* Memory allocation is done in those functions */ … … 416 419 417 420 /* finalize log file with time stamp */ 418 log_msg(0, "Time finished: %s", mr_date()); 421 tmp = mr_date(); 422 log_msg(0, "Time finished: %s", tmp); 423 mr_free(tmp); 419 424 420 425 chdir("/tmp"); -
branches/2.2.10/mondo/test/test-mountlist.c
r2395 r2421 46 46 void (*mr_cleanup)(int) = NULL; 47 47 48 voidmain() {48 int main() { 49 49 50 50 struct mountlist_itself *mountlist = NULL; -
branches/2.2.10/mondo/test/test-msg.c
r2310 r2421 24 24 int l = 0; 25 25 char *str = NULL; 26 size_t n = (size_t)0;27 26 FILE *fd = NULL; 28 27 … … 53 52 54 53 if ((fd = fopen(s,"r")) != NULL) { 55 (void)getline(&str, &n, fd);54 mr_getline(str, fd); 56 55 fprintf(stdout, "%s", str); 57 56 mr_free(str); -
branches/2.2.10/mondo/test/test-truncname.c
r2323 r2421 47 47 } 48 48 49 voidmain() {49 int main() { 50 50 51 51 char *part = NULL; -
branches/2.2.10/tools/myval
r2351 r2421 2 2 3 3 # Call valgrind to test mondo 4 PTH=$HOME/ 4 5 5 sudo valgrind --log-file=/tmp/val.log --show-reachable=yes --track-origins=yes --leak-check=full /home/bruno/local/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -I "/etc /var/lib/rpm" -d /home 6 sudo valgrind --log-file=/tmp/valg.log --show-reachable=yes --track-origins=yes --leak-check=full /home/bruno/local/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -G -I "/etc /var/lib/rpm" -E /etc/init.d -d /home 7 sudo valgrind --log-file=/tmp/valm.log --tool=massif --heap=yes --stacks=yes --alloc-fn=mr_malloc --massif-out-file=/tmp/valm.out /home/bruno/local/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -G -I "/etc /var/lib/rpm" -E /etc/init.d -d /home 8 sudo valgrind --log-file=/tmp/valc.log --tool=callgrind --callgrind-out-file=/tmp/valc.out /home/bruno/local/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -Y -I "/etc /var/lib/rpm" -T /tmp -S /var/spool/mondo -E /etc/init.d -d /home 6 sudo valgrind $PTH/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -v 7 sudo valgrind --log-file=/tmp/val.log --show-reachable=yes --track-origins=yes --leak-check=full $PTH/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -I "/etc /var/lib/rpm" -d /home 8 sudo valgrind --log-file=/tmp/valg.log --show-reachable=yes --track-origins=yes --leak-check=full $PTH/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -G -I "/etc /var/lib/rpm" -E /etc/init.d -d /home 9 sudo valgrind --log-file=/tmp/valm.log --tool=massif --heap=yes --stacks=yes --alloc-fn=mr_malloc --massif-out-file=/tmp/valm.out $PTH/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -G -I "/etc /var/lib/rpm" -E /etc/init.d -d /home 10 sudo valgrind --log-file=/tmp/valc.log --tool=callgrind --callgrind-out-file=/tmp/valc.out $PTH/pb/projects/mondorescue/build/BUILD/mondo-2.2.10/src/mondoarchive/mondoarchive -K 99 -Oi -g -Y -I "/etc /var/lib/rpm" -T /tmp -S /var/spool/mondo -E /etc/init.d -d /home
Note:
See TracChangeset
for help on using the changeset viewer.