Changeset 1109 in MondoRescue
- Timestamp:
- Feb 8, 2007, 12:37:50 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-fifo.c
r1107 r1109 11 11 #include <unistd.h> 12 12 #include <stdio.h> 13 #ifndef S_SPLINT_S 13 14 #include <signal.h> 15 #endif 14 16 #include <fcntl.h> 15 #include <stdio.h>16 17 17 18 #include <errno.h> … … 22 23 #include <sys/sem.h> 23 24 #include <sys/wait.h> 25 #ifndef S_SPLINT_S 24 26 #include <pthread.h> 27 #endif 25 28 26 29 #include "my-stuff.h" 27 30 #include "mondostructures.h" 28 31 #include "libmondo.h" 32 #include "mr_mem.h" 29 33 30 34 /** … … 41 45 */ 42 46 pid_t g_mastermind_pid = 0; 43 44 45 47 46 48 /** … … 73 75 long internal_tape_block_size) 74 76 { 75 char sz_dir[32];77 char *sz_dir; 76 78 char keych; 77 79 char *tmp; 78 char *command;79 80 FILE *fres; 80 81 int bufsize; // in megabytes … … 83 84 int wise_lower_limit; 84 85 85 malloc_string(tmp);86 malloc_string(command);87 86 assert_string_is_neither_NULL_nor_zerolength(device); 88 87 assert(direction == 'w' || direction == 'r'); 89 sprintf(sz_dir, "%c", direction);88 mr_asprintf(&sz_dir, "%c", direction); 90 89 wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32); 91 90 wise_lower_limit = 1; // wise_upper_limit/2 + 1; 92 paranoid_system("sync");91 sync(); 93 92 for (bufsize = wise_upper_limit, res = -1; 94 93 res != 0 && bufsize >= wise_lower_limit; bufsize--) { 95 sprintf(tmp,96 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",97 internal_tape_block_size, bufsize, 'm');94 mr_asprintf(&tmp, 95 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", 96 internal_tape_block_size, bufsize, 'm'); 98 97 res = run_program_and_log_output(tmp, 2); 98 mr_free(tmp); 99 99 } 100 100 if (!res) { 101 101 bufsize++; 102 sprintf(tmp, "Negotiated max buffer of %d MB ", bufsize);102 mr_asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize); 103 103 log_to_screen(tmp); 104 mr_free(tmp); 104 105 } else { 105 106 bufsize = 0; 106 107 res = 0; 107 108 log_to_screen 108 ( "Cannot negotiate a buffer of ANY size. Using dd instead.");109 (_("Cannot negotiate a buffer of ANY size. Using dd instead.")); 109 110 } 110 111 if (direction == 'r') { … … 124 125 mr_msg(2, "Calling buffer --- command = '%s'", g_sz_call_to_buffer); 125 126 fres = popen(g_sz_call_to_buffer, sz_dir); 127 mr_free(sz_dir); 126 128 if (fres) { 127 129 mr_msg(2, "Successfully opened ('%c') tape device %s", direction, … … 132 134 } 133 135 sleep(2); 134 sprintf(tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);136 mr_asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer); 135 137 if (run_program_and_log_output(tmp, 2)) { 136 138 mr_msg(2, "Warning - I think I failed to open tape, actually."); 137 139 } 140 mr_free(tmp); 138 141 g_tape_buffer_size_MB = bufsize; 139 tmp[30] = '\0'; 140 sprintf(command, "ps %s | grep buffer | grep -v grep", ps_options); 141 if (run_program_and_log_output(command, 1)) { 142 mr_asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options); 143 if (run_program_and_log_output(tmp, 1)) { 142 144 fres = NULL; 143 log_to_screen("Failed to open tape streamer. Buffer error."); 144 } else { 145 log_to_screen("Buffer successfully started."); 146 } 147 148 mr_free(command); 145 log_to_screen(_("Failed to open tape streamer. Buffer error.")); 146 } else { 147 log_to_screen(_("Buffer successfully started.")); 148 } 149 149 mr_free(tmp); 150 150 return (fres); … … 161 161 char *command; 162 162 163 malloc_string(tmp); 164 sync(); 163 165 if (g_sz_call_to_buffer == NULL) { 164 166 return; … … 167 169 return; 168 170 } 169 malloc_string(tmp); 170 malloc_string(command); 171 paranoid_system("sync"); 172 sprintf(command, 171 mr_asprintf(&command, 173 172 "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $2;}' | grep -v PID | head -1", ps_options, g_sz_call_to_buffer); 174 173 mr_msg(2, "kill_buffer() --- command = %s", command); 175 174 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 176 sprintf(command, "kill %s", tmp); 175 mr_free(command); 176 177 mr_asprintf(&command, "kill %s", tmp); 177 178 mr_msg(2, "kill_buffer() --- command = %s", command); 178 179 if (strlen(tmp) > 0) { … … 182 183 mr_free(command); 183 184 } 184 185 186 187 185 188 186 … … 198 196 /* @} - end of fifoGroup */ 199 197 200 int 201 extract_config_file_from_ramdisk(struct s_bkpinfo *bkpinfo, 202 char *ramdisk_fname, 203 char *output_cfg_file, 204 char *output_mountlist_file); 198 /* BERLIOS: useless ? 199 int 200 extract_config_file_from_ramdisk( struct s_bkpinfo *bkpinfo, 201 char *ramdisk_fname, 202 char *output_cfg_file, 203 char *output_mountlist_file); 204 */
Note:
See TracChangeset
for help on using the changeset viewer.