Changeset 3857 in MondoRescue for branches/3.3/mondo/src/common/libmondo-stream.c
- Timestamp:
- Mar 6, 2024, 5:30:47 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-stream.c
r3646 r3857 251 251 * Determine the name and size of the tape device. Tries the SCSI tape for 252 252 * this platform, then the IDE tape, then "/dev/st0", then "/dev/osst0". 253 * @param dev Where to put the found tape device. 253 * @param dev Where to put the found tape device. Allocated dynamically by caller or reallocated here 254 254 * @param siz Where to put the tape size (a string like "4GB") 255 255 * @return 0 if success, nonzero if failure (in which @p dev and @p siz are undefined). 256 256 */ 257 int find_tape_device_and_size(char *dev, char *siz) 258 { 257 int find_tape_device(char *dev) { 259 258 char *tmp = NULL; 260 259 char *command = NULL; … … 263 262 264 263 log_to_screen("I am looking for your tape streamer. Please wait."); 265 dev[0] = siz[0] = '\0';264 mr_free(dev); 266 265 if (find_home_of_exe("cdrecord")) { 267 266 mr_asprintf(cdr_exe, "cdrecord"); … … 275 274 if (atoi(tmp) != 1) { 276 275 log_it("Either too few or too many tape streamers for me to detect..."); 277 strcpy(dev, VANILLA_SCSI_TAPE);276 mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE); 278 277 mr_free(tmp); 279 278 mr_free(cdr_exe); … … 298 297 mr_free(command); 299 298 300 strcpy(dev, VANILLA_SCSI_TAPE);299 mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE); 301 300 dev[strlen(dev) - 1] = '\0'; 302 strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN'301 mr_strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 303 302 mr_free(tmp); 304 303 305 304 res = 0; 306 305 if (!mt_says_tape_exists(dev)) { 307 strcpy(dev, ALT_TAPE);306 mr_asprintf(dev, "%s", ALT_TAPE); 308 307 if (!mt_says_tape_exists(dev)) { 309 308 log_it("Cannot openin %s", dev); 310 strcpy(dev, "/dev/st0");309 mr_asprintf(dev, "%s", "/dev/st0"); 311 310 if (!mt_says_tape_exists(dev)) { 312 311 log_it("Cannot openin %s", dev); 313 strcpy(dev, "/dev/osst0");312 mr_asprintf(dev, "%s", "/dev/osst0"); 314 313 if (!mt_says_tape_exists(dev)) { 315 314 res++; … … 324 323 log_it("At this point, dev = %s and res = %d", dev, res); 325 324 } else { 326 log_it("At this point, dev is NULL and res = %d", dev, res); 327 } 328 329 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;};};};'"); 325 log_it("At this point, dev is NULL and res = %d", res); 326 } 330 327 331 328 if (mt_says_tape_exists(dev)) { … … 335 332 mr_free(tmp); 336 333 mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 337 sprintf(dev, "/dev/os%s", tmp);334 mr_asprintf(dev, "/dev/os%s", tmp); 338 335 log_it("...into %s", dev); 339 336 if (mt_says_tape_exists(dev)) { … … 343 340 } 344 341 } 345 346 siz[0] = '\0';347 342 log_it("res=%d; dev=%s", res, dev); 348 349 if (res) { 350 return (res); 351 } 352 353 if (strlen(tmp) < 2) { 354 siz[0] = '\0'; 355 log_it("Warning - size of tape unknown"); 356 } else { 357 strcpy(siz, tmp); 358 } 359 mr_free(tmp); 360 return (0); 343 return (res); 361 344 } 362 345
Note:
See TracChangeset
for help on using the changeset viewer.