2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: amcleanupdisk.c 7238 2007-07-06 20:03:37Z dustin $
36 #include "server_util.h"
38 /* Utility funcitons */
40 /* Call open_infofile() with the infofile from the configuration
45 char *conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));
46 if (open_infofile(conf_infofile) < 0) {
47 error(_("could not open info db \"%s\""), conf_infofile);
50 amfree(conf_infofile);
53 /* A callback for holding_cleanup to mark corrupt DLEs with force_no_bump
56 * @param hostname: hostname of DLE
57 * @param disk: disk of DLE
66 dbprintf(_("Corrupted dump of DLE %s:%s found; setting force-no-bump.\n"),
69 get_info(hostname, disk, &info);
70 info.command &= ~FORCE_BUMP;
71 info.command |= FORCE_NO_BUMP;
72 if(put_info(hostname, disk, &info)) {
73 dbprintf(_("could not put info record for %s:%s: %s"),
74 hostname, disk, strerror(errno));
83 FILE *verbose_output = NULL;
89 * Configure program for internationalization:
90 * 1) Only set the message locale for now.
91 * 2) Set textdomain for all amanda related programs to "amanda"
92 * We don't want to be forced to support dozens of message catalogs.
94 setlocale(LC_MESSAGES, "C");
100 set_pname("amcleanupdisk");
102 dbopen(DBG_SUBDIR_SERVER);
105 error(_("Usage: amcleanupdisk <config>"));
110 if (argc >= 2 && strcmp(argv[1], "-v") == 0) {
111 verbose_output = stderr;
117 config_init(CONFIG_INIT_EXPLICIT_NAME,
120 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
121 read_diskfile(conf_diskfile, &diskq);
122 /* diskq also ends up in a global, used by holding_cleanup */
123 amfree(conf_diskfile);
125 if (config_errors(NULL) >= CFGERR_WARNINGS) {
126 config_print_errors();
127 if (config_errors(NULL) >= CFGERR_ERRORS) {
128 g_critical(_("errors processing config file"));
132 check_running_as(RUNNING_AS_DUMPUSER);
134 dbrename(get_config_name(), DBG_SUBDIR_SERVER);
138 /* actually perform the cleanup */
139 holding_cleanup(corrupt_dle, verbose_output);