Changeset 688 in MondoRescue for trunk/mondo/mondo/common/libmondo-stream.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-stream.c
r687 r688 9 9 * Functions for writing data to/reading data from streams (tape, CD stream, etc.) 10 10 */ 11 12 #include <unistd.h> 11 13 12 14 #include "my-stuff.h" … … 23 25 #define EXTRA_TAPE_CHECKSUMS 24 26 25 /*@unused@*/26 //static char cvsid[] = "$Id$";27 27 extern bool g_sigpipe; 28 28 extern int g_tape_buffer_size_MB; … … 119 119 } 120 120 sleep(1); 121 paranoid_system("sync");121 sync(); 122 122 sleep(1); 123 123 paranoid_pclose(g_tape_stream); … … 152 152 153 153 sleep(1); 154 paranoid_system("sync");154 sync(); 155 155 sleep(1); 156 156 log_it("closeout_tape() -- entering"); … … 213 213 int find_tape_device_and_size(char *dev, char *siz) 214 214 { 215 char *tmp; 216 char *command; 217 char *cdr_exe; 218 int res; 215 char *tmp = NULL; 216 char *tmp1 = NULL; 217 char *command = NULL; 218 char *cdr_exe = NULL; 219 int res = 0; 219 220 220 221 log_to_screen("I am looking for your tape streamer. Please wait."); 221 dev [0] = '\0';222 dev = NULL; 222 223 siz = NULL; 223 224 if (find_home_of_exe("cdrecord")) { … … 228 229 asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 229 230 cdr_exe); 230 asprintf(&tmp, call_program_and_get_last_line_of_output(command));231 tmp = call_program_and_get_last_line_of_output(command); 231 232 paranoid_free(command); 232 233 … … 234 235 log_it 235 236 ("Either too few or too many tape streamers for me to detect..."); 236 strcpy(dev, VANILLA_SCSI_TAPE);237 asprintf(&dev, VANILLA_SCSI_TAPE"0"); 237 238 paranoid_free(tmp); 238 239 paranoid_free(cdr_exe); … … 244 245 "%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", 245 246 cdr_exe); 246 asprintf(&tmp, call_program_and_get_last_line_of_output(command));247 tmp = call_program_and_get_last_line_of_output(command); 247 248 paranoid_free(command); 248 249 if (strlen(tmp) < 2) { … … 259 260 paranoid_free(cdr_exe); 260 261 261 asprintf(&tmp, call_program_and_get_last_line_of_output(command));262 tmp = call_program_and_get_last_line_of_output(command); 262 263 paranoid_free(command); 263 strcpy(dev, VANILLA_SCSI_TAPE); 264 dev[strlen(dev) - 1] = '\0'; 265 strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 264 265 asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp); 266 266 paranoid_free(tmp); 267 267 268 res = 0;269 268 if (!mt_says_tape_exists(dev)) { 270 strcpy(dev, ALT_TAPE); 269 paranoid_free(dev); 270 271 asprintf(&dev, ALT_TAPE"%s", tmp); 271 272 if (!mt_says_tape_exists(dev)) { 272 273 log_it("Cannot openin %s", dev); 273 strcpy(dev, "/dev/st0"); 274 paranoid_free(dev); 275 276 asprintf(&dev, VANILLA_SCSI_TAPE"0"); 274 277 if (!mt_says_tape_exists(dev)) { 275 278 log_it("Cannot openin %s", dev); 276 strcpy(dev, "/dev/osst0"); 279 paranoid_free(dev); 280 281 asprintf(&dev, "/dev/osst0"); 277 282 if (!mt_says_tape_exists(dev)) { 278 283 res++; … … 286 291 log_it("At this point, dev = %s and res = %d", dev, res); 287 292 288 asprintf(&tmp,call_program_and_get_last_line_of_output("\293 tmp = call_program_and_get_last_line_of_output("\ 289 294 cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | \ 290 295 grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | \ 291 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'") );296 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"); 292 297 293 298 if (mt_says_tape_exists(dev)) { … … 296 301 log_it("Turning %s", dev); 297 302 paranoid_free(tmp); 298 asprintf(&tmp ,303 asprintf(&tmp1, 299 304 (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 300 sprintf(dev, "/dev/os%s", tmp); 305 paranoid_free(dev); 306 asprintf(&dev, "/dev/os%s", tmp1); 307 paranoid_free(tmp1); 308 301 309 log_it("...into %s", dev); 302 310 if (mt_says_tape_exists(dev)) { … … 1228 1236 1229 1237 paranoid_pclose(g_tape_stream); 1230 sy stem("sync");1231 sy stem("sync");1232 sy stem("sync");1238 sync(); 1239 sync(); 1240 sync(); 1233 1241 log_it("Next tape requested."); 1234 1242 insist_on_this_tape_number(g_current_media_number + 1); // will increment it, too … … 1269 1277 1270 1278 paranoid_pclose(g_tape_stream); 1271 sy stem("sync");1272 sy stem("sync");1273 sy stem("sync");1279 sync(); 1280 sync(); 1281 sync(); 1274 1282 log_it("New tape requested."); 1275 1283 insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too
Note:
See TracChangeset
for help on using the changeset viewer.