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 $
37 #include "server_util.h"
39 /* Utility funcitons */
41 /* Call open_infofile() with the infofile from the configuration
46 char *conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));
47 if (open_infofile(conf_infofile) < 0) {
48 error(_("could not open info db \"%s\""), conf_infofile);
51 amfree(conf_infofile);
54 /* A callback for holding_cleanup to mark corrupt DLEs with force_no_bump
57 * @param hostname: hostname of DLE
58 * @param disk: disk of DLE
67 dbprintf(_("Corrupted dump of DLE %s:%s found; setting force-no-bump.\n"),
70 get_info(hostname, disk, &info);
71 info.command &= ~FORCE_BUMP;
72 info.command |= FORCE_NO_BUMP;
73 if(put_info(hostname, disk, &info)) {
74 dbprintf(_("could not put info record for %s:%s: %s"),
75 hostname, disk, strerror(errno));
84 FILE *verbose_output = NULL;
90 * Configure program for internationalization:
91 * 1) Only set the message locale for now.
92 * 2) Set textdomain for all amanda related programs to "amanda"
93 * We don't want to be forced to support dozens of message catalogs.
95 setlocale(LC_MESSAGES, "C");
101 set_pname("amcleanupdisk");
103 dbopen(DBG_SUBDIR_SERVER);
106 error(_("Usage: amcleanupdisk%s <config>"), versionsuffix());
111 if (argc >= 2 && strcmp(argv[1], "-v") == 0) {
112 verbose_output = stderr;
118 config_init(CONFIG_INIT_EXPLICIT_NAME,
121 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
122 read_diskfile(conf_diskfile, &diskq);
123 /* diskq also ends up in a global, used by holding_cleanup */
124 amfree(conf_diskfile);
126 if (config_errors(NULL) >= CFGERR_WARNINGS) {
127 config_print_errors();
128 if (config_errors(NULL) >= CFGERR_ERRORS) {
129 g_critical(_("errors processing config file"));
133 check_running_as(RUNNING_AS_DUMPUSER);
135 dbrename(get_config_name(), DBG_SUBDIR_SERVER);
139 /* actually perform the cleanup */
140 holding_cleanup(corrupt_dle, verbose_output);