Changeset 2321 in MondoRescue for branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c
- Timestamp:
- Aug 18, 2009, 2:37:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c
r2320 r2321 170 170 char *say_at_end = NULL; 171 171 172 /* Make sure I'm root; abort if not */173 if (getuid() != 0) {174 fprintf(stderr, "Please run as root.\r\n");175 exit(127);176 }177 178 /* If -V, -v or --version then echo version no. and quit */179 if (argc == 2180 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")181 || !strcmp(argv[argc - 1], "--version"))) {182 printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);183 exit(0);184 }185 186 172 /* Initialize variables */ 187 188 printf("Initializing...\n");189 if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {190 fatal_error("Cannot malloc bkpinfo");191 }192 reset_bkpinfo();193 173 194 174 res = 0; 195 175 retval = 0; 196 176 diffs = 0; 197 malloc_libmondo_global_strings(); 177 178 printf("Initializing...\n"); 179 180 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo)); 181 init_bkpinfo(); 198 182 199 183 /* initialize log file with time stamp */ … … 201 185 log_msg(0, "Time started: %s", mr_date()); 202 186 187 /* Memory allocation is done in those functions */ 188 malloc_libmondo_global_strings(); 189 if (argc == 1) { 190 g_text_mode = FALSE; 191 } else { 192 g_text_mode = TRUE; 193 } 194 setup_newt_stuff(); 195 196 /* Make sure I'm root; abort if not */ 197 if (getuid() != 0) { 198 fatal_error("Please run as root.\n"); 199 } 200 201 /* If -V, -v or --version then echo version no. and quit */ 202 if (argc == 2 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V") || !strcmp(argv[argc - 1], "--version"))) { 203 printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION); 204 finish(0); 205 } 206 207 203 208 /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */ 204 209 mr_asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH")); 205 210 setenv("PATH", tmp1, 1); 206 paranoid_free(tmp1);211 mr_free(tmp1); 207 212 208 213 /* Add the ARCH environment variable for ia64 purposes */ 209 214 mr_asprintf(&tmp1,"%s",get_architecture()); 210 215 setenv("ARCH", tmp1, 1); 211 paranoid_free(tmp1);216 mr_free(tmp1); 212 217 213 218 /* Add MONDO_SHARE environment variable for mindi */ … … 231 236 g_loglevel = 10; 232 237 g_text_mode = TRUE; 233 setup_newt_stuff();234 238 if (!strstr(argv[2], "filelist")) { 235 239 printf("Sorry - filelist goes first\n"); … … 242 246 if (argc == 4 && !strcmp(argv[1], "setfattr")) { 243 247 g_loglevel = 10; 244 g_text_mode = TRUE;245 setup_newt_stuff();246 248 finish(set_fattr_list(argv[2], argv[3])); 247 249 } … … 249 251 if (argc == 3 && !strcmp(argv[1], "wildcards")) { 250 252 g_loglevel = 10; 251 g_text_mode = TRUE;252 setup_newt_stuff();253 253 malloc_string(tmp); 254 254 turn_wildcard_chars_into_literal_chars(tmp, argv[2]); … … 260 260 if (argc == 4 && !strcmp(argv[1], "getfacl")) { 261 261 g_loglevel = 10; 262 g_text_mode = TRUE;263 setup_newt_stuff();264 262 if (!strstr(argv[2], "filelist")) { 265 263 printf("Sorry - filelist goes first\n"); … … 272 270 if (argc == 4 && !strcmp(argv[1], "setfacl")) { 273 271 g_loglevel = 10; 274 g_text_mode = TRUE;275 setup_newt_stuff();276 272 finish(set_acl_list(argv[2], argv[3])); 277 273 } … … 279 275 if (argc > 2 && !strcmp(argv[1], "find-cd")) { 280 276 g_loglevel = 10; 281 g_text_mode = TRUE;282 setup_newt_stuff();283 277 malloc_string(tmp); 284 278 if (find_cdrw_device(tmp)) { … … 299 293 if (argc > 2 && !strcmp(argv[1], "find-dvd")) { 300 294 g_loglevel = 10; 301 g_text_mode = TRUE;302 setup_newt_stuff();303 295 malloc_string(tmp); 304 296 if (find_dvd_device(tmp, atoi(argv[2]))) { … … 331 323 /* Process command line, if there is one. If not, ask user for info. */ 332 324 if (argc == 1) { 333 g_text_mode = FALSE;334 setup_newt_stuff();335 325 res = interactively_obtain_media_parameters_from_user(TRUE); /* yes, archiving */ 336 326 if (res) { … … 347 337 finish(1); 348 338 } 349 setup_newt_stuff();350 339 } 351 340 352 341 /* Finish configuring global structures */ 353 342 if (post_param_configuration()) { 354 fatal_error 355 ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting..."); 356 } 357 358 log_to_screen 359 ("BusyBox's sources are available from http://www.busybox.net"); 343 fatal_error("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting..."); 344 } 345 346 log_to_screen("BusyBox's sources are available from http://www.busybox.net"); 360 347 361 348 /* If we're meant to backup then backup */ … … 412 399 if (say_at_end != NULL) { 413 400 log_to_screen(say_at_end); 414 paranoid_free(say_at_end);401 mr_free(say_at_end); 415 402 } 416 403 mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
Note:
See TracChangeset
for help on using the changeset viewer.