amcleanupdisk.c

来自「开源备份软件源码 AMANDA, the Advanced Marylan」· C语言 代码 · 共 148 行

C
148
字号
/* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of U.M. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission.  U.M. makes no representations about the * suitability of this software for any purpose.  It is provided "as is" * without express or implied warranty. * * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Authors: the Amanda Development Team.  Its members are listed in a * file named AUTHORS, in the root directory of this distribution. *//* * $Id: amcleanupdisk.c 7238 2007-07-06 20:03:37Z dustin $ */#include "amanda.h"#include "conffile.h"#include "diskfile.h"#include "clock.h"#include "version.h"#include "holding.h"#include "infofile.h"#include "server_util.h"/* Utility funcitons *//* Call open_diskfile() with the diskfile from the configuration */static voidinit_diskfile(void){    char *conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));    disklist_t diskq; /* never used, but required by read_diskfile */    if (read_diskfile(conf_diskfile, &diskq) < 0) {	error(_("could not load disklist %s"), conf_diskfile);	/*NOTREACHED*/    }    amfree(conf_diskfile);}/* Call open_infofile() with the infofile from the configuration */static voidinit_infofile(void){    char *conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));    if (open_infofile(conf_infofile) < 0) {	error(_("could not open info db \"%s\""), conf_infofile);	/*NOTREACHED*/    }    amfree(conf_infofile);}/* A callback for holding_cleanup to mark corrupt DLEs with force_no_bump * for their next run. * * @param hostname: hostname of DLE * @param disk: disk of DLE */static voidcorrupt_dle(    char *hostname,    char *disk){    info_t info;    dbprintf(_("Corrupted dump of DLE %s:%s found; setting force-no-bump.\n"),	hostname, disk);    get_info(hostname, disk, &info);    info.command &= ~FORCE_BUMP;    info.command |= FORCE_NO_BUMP;    if(put_info(hostname, disk, &info)) {	dbprintf(_("could not put info record for %s:%s: %s"),	      hostname, disk, strerror(errno));    }}intmain(    int		argc,    char **	argv){    FILE *verbose_output = NULL;    char *cfg_opt = NULL;    /*     * Configure program for internationalization:     *   1) Only set the message locale for now.     *   2) Set textdomain for all amanda related programs to "amanda"     *      We don't want to be forced to support dozens of message catalogs.     */      setlocale(LC_MESSAGES, "C");    textdomain("amanda");     safe_fd(-1, 0);    safe_cd();    set_pname("amcleanupdisk");    dbopen(DBG_SUBDIR_SERVER);    if(argc < 2) {	error(_("Usage: amcleanupdisk%s <config>"), versionsuffix());	/*NOTREACHED*/    }    /* parse options */    if (argc >= 2 && strcmp(argv[1], "-v") == 0) {	verbose_output = stderr;	cfg_opt = argv[2];    } else {	cfg_opt = argv[1];    }    config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_FATAL,		cfg_opt);    check_running_as(RUNNING_AS_DUMPUSER);    dbrename(config_name, DBG_SUBDIR_SERVER);    init_diskfile();    init_infofile();    /* actually perform the cleanup */    holding_cleanup(corrupt_dle, verbose_output);    close_infofile();    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?