X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Fcalcsize.c;h=f14fd17743bb819b0e9211582448cd5ff5b5dfc7;hb=bd1ae9014cb0c6d1e012ddb8a15d243458cf649c;hp=7d8ad04f0fa276b1ebf9ffd16c57a714f99453b5;hpb=d3b2175e084f88c8736ad7073eacbf4670147aec;p=debian%2Famanda diff --git a/client-src/calcsize.c b/client-src/calcsize.c index 7d8ad04..f14fd17 100644 --- a/client-src/calcsize.c +++ b/client-src/calcsize.c @@ -32,8 +32,9 @@ * argv[1] is the config name or NOCONFIG */ #include "amanda.h" -#include "statfs.h" -#include "version.h" +#include "match.h" +#include "conffile.h" +#include "fsusage.h" #include "sl.h" #include "util.h" @@ -128,39 +129,47 @@ main( char *d; int l, w; + /* + * 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); set_pname("calcsize"); dbopen(NULL); + config_init(CONFIG_INIT_CLIENT, NULL); /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); if (argc < 2) { - fprintf(stderr,"Usage: %s file[s]\n",argv[0]); + g_fprintf(stderr,_("Usage: %s file[s]\n"),argv[0]); return 1; } for(i=1; id_name); if(lstat(newname, &finfo) == -1) { - fprintf(stderr, "%s/%s: %s\n", + g_fprintf(stderr, "%s/%s: %s\n", dirname, f->d_name, strerror(errno)); continue; } @@ -479,6 +490,10 @@ traverse_dirs( perror(dirname); #endif } + + /* drop root privs -- we're done with the permission-sensitive calls */ + set_root_privs(0); + amfree(newbase); amfree(newname); amfree(aparent); @@ -555,20 +570,20 @@ final_size_dump( int level, char * topdir) { - generic_fs_stats_t stats; + struct fs_usage fsusage; off_t mapsize; char *s; /* calculate the map sizes */ s = stralloc2(topdir, "/."); - if(get_fs_stats(s, &stats) == -1) { + if(get_fs_usage(s, NULL, &fsusage) == -1) { error("statfs %s: %s", s, strerror(errno)); /*NOTREACHED*/ } amfree(s); - mapsize = (stats.files + (off_t)7) / (off_t)8; /* in bytes */ + mapsize = (fsusage.fsu_files + (off_t)7) / (off_t)8; /* in bytes */ mapsize = (mapsize + (off_t)1023) / (off_t)1024; /* in kbytes */ /* the dump contains three maps plus the files */