]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/dbcheck-B.patch
ebl Update about STAP
[bacula/bacula] / bacula / patches / testing / dbcheck-B.patch
1 Index: src/dird/dird_conf.c
2 ===================================================================
3 --- src/dird/dird_conf.c        (révision 7525)
4 +++ src/dird/dird_conf.c        (copie de travail)
5 @@ -509,6 +509,16 @@
6     {NULL,               0}
7  };
8  
9 +char *CAT::display(POOLMEM *dst) {
10 +   Mmsg(dst,"catalog=%s\ndb_name=%s\ndb_driver=%s\ndb_user=%s\n"
11 +        "db_password=%s\ndb_address=%s\ndb_port=%i\n"
12 +        "db_socket=%s\n",
13 +        name(), NPRTB(db_name),
14 +        NPRTB(db_driver), NPRTB(db_user), NPRTB(db_password),
15 +        NPRTB(db_address), db_port, NPRTB(db_socket));
16 +   return dst;
17 +}
18 +
19  const char *level_to_str(int level)
20  {
21     int i;
22 Index: src/dird/dird_conf.h
23 ===================================================================
24 --- src/dird/dird_conf.h        (révision 7525)
25 +++ src/dird/dird_conf.h        (copie de travail)
26 @@ -236,6 +236,7 @@
27  
28     /* Methods */
29     char *name() const;
30 +   char *display(POOLMEM *dst);       /* Get catalog information */
31  };
32  
33  inline char *CAT::name() const { return hdr.name; }
34 Index: src/baconfig.h
35 ===================================================================
36 --- src/baconfig.h      (révision 7525)
37 +++ src/baconfig.h      (copie de travail)
38 @@ -79,7 +79,8 @@
39  
40  /* Allow printing of NULL pointers */
41  #define NPRT(x) (x)?(x):_("*None*")
42
43 +#define NPRTB(x) (x)?(x):""
44 +
45  #if defined(HAVE_WIN32)
46  
47  #define WIN32_REPARSE_POINT 1
48 Index: src/tools/dbcheck.c
49 ===================================================================
50 --- src/tools/dbcheck.c (révision 7525)
51 +++ src/tools/dbcheck.c (copie de travail)
52 @@ -100,14 +100,14 @@
53  static void do_interactive_mode();
54  static bool yes_no(const char *prompt);
55  
56 -
57  static void usage()
58  {
59     fprintf(stderr,
60 -"Usage: dbcheck [-c config] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]\n"
61 +"Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]\n"
62  "       -b              batch mode\n"
63  "       -C              catalog name in the director conf file\n"
64  "       -c              Director conf filename\n"
65 +"       -B              print catalog configuration and exit\n"
66  "       -d <nn>         set debug level to <nn>\n"
67  "       -dt             print timestamp in debug output\n"
68  "       -f              fix inconsistencies\n"
69 @@ -121,6 +121,7 @@
70     int ch;
71     const char *user, *password, *db_name, *dbhost;
72     int dbport = 0;
73 +   bool print_catalog=false;
74     char *configfile = NULL;
75     char *catalogname = NULL;
76     char *endptr;
77 @@ -136,8 +137,12 @@
78     memset(&name_list, 0, sizeof(name_list));
79  
80  
81 -   while ((ch = getopt(argc, argv, "bc:C:d:fv?")) != -1) {
82 +   while ((ch = getopt(argc, argv, "bc:C:d:fvB?")) != -1) {
83        switch (ch) {
84 +      case 'B':
85 +         print_catalog = true;     /* get catalog information from config */
86 +         break;
87 +
88        case 'b':                    /* batch */
89           batch = true;
90           break;
91 @@ -215,6 +220,16 @@
92              exit(1);
93           }
94           set_working_directory(director->working_directory);
95 +
96 +         /* Print catalog information and exit (-B) */
97 +         if (print_catalog) {
98 +            POOLMEM *buf = get_pool_memory(PM_MESSAGE);
99 +            printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(buf),
100 +                   db_get_type(), working_directory);
101 +            free_pool_memory(buf);
102 +            exit(0);
103 +         }
104 +
105           db_name = catalog->db_name;
106           user = catalog->db_user;
107           password = catalog->db_password;