Changeset 2303 in MondoRescue
- Timestamp:
- Jul 24, 2009, 9:19:38 PM (15 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2301 r2303 1213 1213 mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1214 1214 1215 mr_ sprintf(&g_serial_string, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));1215 mr_asprintf(&g_serial_string, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1")); 1216 1216 strip_spaces(g_serial_string); 1217 1217 mr_strcat(g_serial_string, "...word."); -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2296 r2303 896 896 if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) { 897 897 log_it("Hmm! No tape drive specified. Let's see what we can do."); 898 if (find_tape_device_and_size(flag_val['d'], tmp)) {899 fatal_error900 898 p = mr_find_tape_device(); 899 if (!p) { 900 fatal_error("Tape device not specified. I couldn't find it either."); 901 901 } 902 902 flag_set['d'] = TRUE; 903 strcpy(flag_val['d'], p); 904 mr_free(p); 903 905 mr_asprintf(&tmp1, "You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']); 904 906 log_to_screen(tmp1); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2296 r2303 1636 1636 case tape: 1637 1637 1638 if ((!bkpinfo->restore_mode) && ( find_tape_device_and_size(bkpinfo->media_device, sz_size))) {1638 if ((!bkpinfo->restore_mode) && (!mr_find_tape_device())) { 1639 1639 log_msg(3, "Ok, using vanilla scsi tape."); 1640 1640 strcpy(bkpinfo->media_device, VANILLA_SCSI_TAPE); -
branches/2.2.10/mondo/src/common/libmondo-stream-EXT.h
r1954 r2303 5 5 extern int closein_tape(); 6 6 extern int closeout_tape(); 7 extern int find_tape_device_and_size(char *dev, char *siz);7 extern char *mr_find_tape_device(void); 8 8 extern void insist_on_this_tape_number(int tapeno); 9 9 extern void log_tape_pos(void); -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2296 r2303 250 250 251 251 /** 252 * Determine the name and sizeof the tape device. Tries the SCSI tape for252 * Determine the name of the tape device. Tries the SCSI tape for 253 253 * this platform, then the IDE tape, then "/dev/st0", then "/dev/osst0". 254 * @param dev Where to put the found tape device. 255 * @param siz Where to put the tape size (a string like "4GB") 256 * @return 0 if success, nonzero if failure (in which @p dev and @p siz are undefined). 257 */ 258 int find_tape_device_and_size(char *dev, char *siz) 259 { 260 char tmp[MAX_STR_LEN]; 254 * @return the allocated tape string if success, NULL if failure 255 */ 256 char *mr_find_tape_device(void) 257 { 258 char *tmp = NULL; 261 259 char *command = NULL; 262 char cdr_exe[MAX_STR_LEN]; 260 char *cdr_exe = NULL; 261 char *dev = NULL; 263 262 int res; 264 263 265 264 log_to_screen("I am looking for your tape streamer. Please wait."); 266 dev[0] = '\0';267 if (siz != NULL) {268 siz[0] = '\0';269 }270 265 if (find_home_of_exe("cdrecord")) { 271 strcpy(cdr_exe, "cdrecord");272 } else { 273 strcpy(cdr_exe, "dvdrecord");266 mr_asprintf(&cdr_exe, "cdrecord"); 267 } else { 268 mr_asprintf(&cdr_exe, "dvdrecord"); 274 269 } 275 270 mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe); 276 strcpy(tmp, call_program_and_get_last_line_of_output(command));271 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 277 272 mr_free(command); 278 273 279 274 if (atoi(tmp) != 1) { 280 log_it 281 ("Either too few or too many tape streamers for me to detect..."); 282 strcpy(dev, VANILLA_SCSI_TAPE); 283 return 1; 284 } 275 log_it("Either too few or too many tape streamers for me to detect..."); 276 mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE); 277 mr_free(tmp); 278 return(dev); 279 } 280 mr_free(tmp); 281 285 282 mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe); 286 strcpy(tmp, call_program_and_get_last_line_of_output(command));283 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 287 284 mr_free(command); 288 285 289 286 if (strlen(tmp) < 2) { 290 287 log_it("Could not find tape device"); 291 return 1; 292 } 288 mr_free(tmp); 289 return(dev); 290 } 291 mr_free(tmp); 293 292 mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe); 294 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 293 mr_free(cdr_exe); 294 295 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 295 296 mr_free(command); 296 297 297 strcpy(dev, VANILLA_SCSI_TAPE);298 mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE); 298 299 dev[strlen(dev) - 1] = '\0'; 299 strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 300 mr_strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 301 mr_free(tmp); 302 300 303 res = 0; 301 304 if (!mt_says_tape_exists(dev)) { 302 strcpy(dev, ALT_TAPE); 305 mr_free(dev); 306 mr_asprintf(&dev, "%s", ALT_TAPE); 303 307 if (!mt_says_tape_exists(dev)) { 304 308 log_it("Cannot openin %s", dev); 305 strcpy(dev, "/dev/st0"); 309 mr_free(dev); 310 mr_asprintf(&dev, "/dev/st0"); 306 311 if (!mt_says_tape_exists(dev)) { 307 312 log_it("Cannot openin %s", dev); 308 strcpy(dev, "/dev/osst0"); 313 mr_free(dev); 314 mr_asprintf(&dev, "/dev/osst0"); 309 315 if (!mt_says_tape_exists(dev)) { 310 316 res++; … … 318 324 log_it("At this point, dev = %s and res = %d", dev, res); 319 325 320 strcpy(tmp, call_program_and_get_last_line_of_output("\ 321 cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | \ 322 grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | \ 323 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'")); 326 mr_asprintf(&tmp, call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'")); 324 327 325 328 if (mt_says_tape_exists(dev)) { … … 327 330 } else { 328 331 log_it("Turning %s", dev); 329 strcpy(tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 330 sprintf(dev, "/dev/os%s", tmp); 332 mr_free(tmp); 333 mr_asprintf(&tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 334 mr_free(dev); 335 mr_asprintf(&dev, "/dev/os%s", tmp); 331 336 log_it("...into %s", dev); 332 337 if (mt_says_tape_exists(dev)) { … … 340 345 341 346 if (res) { 342 return (res); 347 mr_free(tmp); 348 return (dev); 343 349 } 344 350 345 351 if (strlen(tmp) < 2) { 346 352 log_it("Warning - size of tape unknown"); 347 return (0); 348 } else { 349 if (siz != NULL) { 350 strcpy(siz, tmp); 351 } 352 return (0); 353 } 354 } 355 356 357 358 353 } 354 mr_free(tmp); 355 return (NULL); 356 } 359 357 360 358 -
branches/2.2.10/mondo/src/common/libmondo-stream.h
r1954 r2303 7 7 int closein_tape(); 8 8 int closeout_tape(); 9 int find_tape_device_and_size(char *dev, char *siz);9 char *mr_find_tape_device(void); 10 10 void insist_on_this_tape_number(int tapeno); 11 11 void log_tape_pos(void);
Note:
See TracChangeset
for help on using the changeset viewer.