Changeset 1142 in MondoRescue for branches/stable/mondo/src/common
- Timestamp:
- Feb 12, 2007, 3:02:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-archive.c
r1139 r1142 2039 2039 2040 2040 /*@ pointers ******************************************* */ 2041 FILE *fin ;2042 char *p ;2041 FILE *fin = NULL; 2042 char *p = NULL; 2043 2043 2044 2044 /*@ buffers ******************************************** */ 2045 char *tmp ;2045 char *tmp = NULL; 2046 2046 char *bigfile_fname = NULL; 2047 char *sz_devfile ;2047 char *sz_devfile = NULL; 2048 2048 char *ntfsprog_fifo = NULL; 2049 2049 /*@ long *********************************************** */ … … 2065 2065 assert_string_is_neither_NULL_nor_zerolength(biggielist_fname); 2066 2066 2067 malloc_string(tmp);2068 malloc_string(bigfile_fname);2069 malloc_string(sz_devfile);2070 2067 estimated_total_noof_slices = 2071 2068 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; … … 2081 2078 return (0); 2082 2079 } 2083 sprintf(tmp, "I am now backing up all large files.");2080 mr_asprintf(&tmp, "I am now backing up all large files."); 2084 2081 log_to_screen(tmp); 2085 2082 noof_biggie_files = count_lines_in_file(biggielist_fname); … … 2087 2084 "Please wait. This may take some time.", "", 2088 2085 estimated_total_noof_slices); 2086 mr_free(tmp); 2087 2089 2088 if (!(fin = fopen(biggielist_fname, "r"))) { 2090 2089 log_OS_error("Unable to openin biggielist"); 2091 2090 return (1); 2092 2091 } 2093 for ( fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin);2094 fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) {2092 for (mr_getline(&bigfile_fname, &n, fin); !feof(fin); 2093 mr_getline(&bigfile_fname, &n, fin), biggie_file_number++) { 2095 2094 use_ntfsprog = FALSE; 2096 2095 if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) { … … 2103 2102 ftmp = fopen(bigfile_fname, "w"); 2104 2103 paranoid_fclose(ftmp); 2105 sprintf(tmp, "bigfile %s was deleted - creating a dummy",2106 bigfile_fname);2107 2104 delete_when_done = TRUE; 2108 2105 } else { … … 2117 2114 "Calling ntfsclone in background because %s is an NTFS partition", 2118 2115 bigfile_fname); 2119 sprintf(sz_devfile, "%s/%d.%d.000",2116 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 2120 2117 bkpinfo->tmpdir, 2121 2118 (int) (random() % 32768), … … 2131 2128 bigfile_fname, sz_devfile); 2132 2129 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2130 mr_free(sz_devfile); 2133 2131 exit(res); 2134 2132 break; … … 2137 2135 "feed_into_ntfsprog() called in background --- pid=%ld", 2138 2136 (long int) (pid)); 2137 mr_free(sz_devfile); 2138 break; 2139 2139 } 2140 2140 } 2141 // Otherwise, use good old 'dd' and 'bzip2'2141 // Otherwise, use good old 'dd' and 'bzip2' 2142 2142 else { 2143 sz_devfile[0] = '\0';2144 2143 ntfsprog_fifo = NULL; 2145 2144 } 2146 2145 2147 // Whether partition or biggiefile, just do your thang :-)2148 sprintf(tmp, "Bigfile #%ld is '%s' (%ld KB)",2146 // Whether partition or biggiefile, just do your thang :-) 2147 mr_msg(5, "Bigfile #%ld is '%s' (%ld KB)", 2149 2148 biggie_file_number + 1, bigfile_fname, 2150 2149 (long) biggie_fsize >> 10); … … 2172 2171 p = bigfile_fname; 2173 2172 } 2174 sprintf(tmp, "Archiving %s ... ", bigfile_fname);2175 2173 if (res) { 2176 strcat(tmp, "Failed!");2174 mr_asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname); 2177 2175 } else { 2178 strcat(tmp, "OK"); 2179 } 2176 mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname); 2177 } 2178 mr_msg(4,tmp); 2179 mr_free(tmp); 2180 2180 if (delete_when_done) { 2181 2181 unlink(bigfile_fname); … … 2183 2183 } 2184 2184 } 2185 #ifndef _XWIN2186 2185 if (!g_text_mode) { 2187 2186 newtDrawRootText(0, g_noof_rows - 2, tmp); 2188 2187 newtRefresh(); 2189 2188 } 2190 #endif 2191 } 2189 } 2190 mr_free(bigfile_fname); 2191 paranoid_fclose(fin); 2192 2192 2193 mr_msg(1, "Finished backing up bigfiles"); 2193 2194 mr_msg(1, "estimated slices = %ld; actual slices = %ld", 2194 2195 estimated_total_noof_slices, g_current_progress); 2195 2196 close_progress_form(); 2196 paranoid_fclose(fin);2197 mr_free(tmp);2198 mr_free(bigfile_fname);2199 mr_free(sz_devfile);2200 2197 return (retval); 2201 2198 } 2202 2203 2204 2199 2205 2200 … … 2217 2212 2218 2213 /*@ buffers ********************************************** */ 2219 char *curr_filelist_fname; 2220 char *curr_afioball_fname; 2221 char *curr_xattr_list_fname; 2222 char *curr_acl_list_fname; 2223 char *tmp; 2224 char *media_usage_comment; 2225 2226 malloc_string(curr_afioball_fname); 2214 char *curr_filelist_fname = NULL; 2215 char *curr_afioball_fname = NULL; 2216 char *curr_xattr_list_fname = NULL; 2217 char *curr_acl_list_fname = NULL; 2218 char *media_usage_comment = NULL; 2219 char *tmp= mr_malloc(MAX_STR_LEN * 2); 2220 2221 /* BERLIOS: Useless ? 2222 mr_asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir); 2223 */ 2227 2224 malloc_string(media_usage_comment); 2228 malloc_string(curr_filelist_fname);2229 malloc_string(curr_xattr_list_fname);2230 malloc_string(curr_acl_list_fname);2231 2232 tmp = mr_malloc(MAX_STR_LEN * 2);2233 2234 sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);2235 2236 2225 log_to_screen("Archiving regular files"); 2237 2226 2238 open_progress_form( "Backing up filesystem",2239 "I am backing up your live filesystem now.",2240 "Please wait. This may take a couple of hours.",2241 "Working...",2227 open_progress_form(_("Backing up filesystem"), 2228 _("I am backing up your live filesystem now."), 2229 _("Please wait. This may take a couple of hours."), 2230 _("Working..."), 2242 2231 get_last_filelist_number(bkpinfo) + 1); 2243 2232 2244 sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 2245 0L); 2246 2247 for (curr_set_no = 0; does_file_exist(curr_filelist_fname); 2248 sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ, 2249 bkpinfo->tmpdir, ++curr_set_no)) { 2233 mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 2234 0L); 2235 2236 curr_set_no = 0; 2237 while (does_file_exist(curr_filelist_fname)) { 2250 2238 /* backup this set of files */ 2251 sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ, 2252 bkpinfo->tmpdir, curr_set_no); 2253 sprintf(curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 2254 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix); 2239 mr_asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 2240 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix); 2255 2241 2256 2242 mr_msg(1, "EXAT'g set %ld", curr_set_no); 2257 2243 if (g_getfattr) { 2258 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,2244 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 2259 2245 bkpinfo->tmpdir, curr_set_no); 2260 2246 get_fattr_list(curr_filelist_fname, curr_xattr_list_fname); 2261 2247 } 2262 2248 if (g_getfacl) { 2263 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,2249 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 2264 2250 bkpinfo->tmpdir, curr_set_no); 2265 2251 get_acl_list(curr_filelist_fname, curr_acl_list_fname); … … 2267 2253 2268 2254 mr_msg(1, "Archiving set %ld", curr_set_no); 2269 res = 2270 archive_this_fileset(bkpinfo, curr_filelist_fname, 2255 res = archive_this_fileset(bkpinfo, curr_filelist_fname, 2271 2256 curr_afioball_fname, curr_set_no); 2272 2257 retval += res; 2273 2258 if (res) { 2274 sprintf(tmp,2275 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",2276 curr_set_no);2259 mr_asprintf(&tmp, 2260 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", 2261 curr_set_no); 2277 2262 log_to_screen(tmp); 2263 mr_free(tmp); 2278 2264 } 2279 2265 … … 2287 2273 curr_afioball_fname); 2288 2274 iamhere("Writing EXAT files"); 2289 res += 2290 write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname, 2291 curr_acl_list_fname); 2292 // archives themselves 2275 res += write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname, 2276 curr_acl_list_fname); 2277 // archives themselves 2293 2278 res = move_files_to_stream(bkpinfo, curr_afioball_fname, NULL); 2294 2279 } else { … … 2320 2305 2321 2306 if (res) { 2322 sprintf(tmp, "Failed to add archive %ld's files to CD dir\n",2323 curr_set_no);2307 mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", 2308 curr_set_no); 2324 2309 log_to_screen(tmp); 2310 mr_free(tmp); 2325 2311 fatal_error 2326 2312 ("Is your hard disk is full? If not, please send the author the logfile."); 2327 2313 } 2328 } 2314 mr_free(curr_filelist_fname); 2315 mr_free(curr_afioball_fname); 2316 mr_free(curr_xattr_list_fname); 2317 mr_free(curr_acl_list_fname); 2318 mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, 2319 bkpinfo->tmpdir, ++curr_set_no); 2320 } 2321 mr_free(curr_filelist_fname); 2329 2322 close_progress_form(); 2330 sprintf(tmp, "Your regular files have been archived ");2331 2323 if (retval) { 2332 strcat(tmp, "(with errors)."); 2333 } else { 2334 strcat(tmp, "successfully."); 2335 } 2336 log_to_screen(tmp); 2337 mr_free(tmp); 2338 mr_free(curr_filelist_fname); 2339 mr_free(curr_afioball_fname); 2324 log_to_screen 2325 ("Your regular files have been archived (with errors)."); 2326 } else { 2327 log_to_screen 2328 ("Your regular files have been archived successfully."); 2329 } 2340 2330 mr_free(media_usage_comment); 2341 mr_free(curr_xattr_list_fname);2342 mr_free(curr_acl_list_fname);2343 2331 return (retval); 2344 2332 }
Note:
See TracChangeset
for help on using the changeset viewer.