btrfs-progs: introduce global config

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-11-21 13:52:01 +01:00
parent 96485c34ac
commit 95f515f2d1
3 changed files with 18 additions and 0 deletions

View File

@ -212,6 +212,8 @@ int main(int argc, char **argv)
const char *bname; const char *bname;
int ret; int ret;
btrfs_config_init();
if ((bname = strrchr(argv[0], '/')) != NULL) if ((bname = strrchr(argv[0], '/')) != NULL)
bname++; bname++;
else else

View File

@ -63,6 +63,8 @@ static char argv0_buf[ARGV0_BUF_SIZE] = "btrfs";
static int rand_seed_initlized = 0; static int rand_seed_initlized = 0;
static unsigned short rand_seed[3]; static unsigned short rand_seed[3];
struct btrfs_config bconf;
const char *get_argv0_buf(void) const char *get_argv0_buf(void)
{ {
return argv0_buf; return argv0_buf;
@ -4287,3 +4289,7 @@ unsigned int rand_range(unsigned int upper)
*/ */
return (unsigned int)(jrand48(rand_seed) % upper); return (unsigned int)(jrand48(rand_seed) % upper);
} }
void btrfs_config_init(void)
{
}

10
utils.h
View File

@ -368,6 +368,16 @@ int string_is_numerical(const char *str);
__warning_on((cond), (fmt), ##__VA_ARGS__); \ __warning_on((cond), (fmt), ##__VA_ARGS__); \
} while (0) } while (0)
/*
* Global program state, configurable by command line and available to
* functions without extra context passing.
*/
struct btrfs_config {
};
extern struct btrfs_config bconf;
void btrfs_config_init(void);
__attribute__ ((format (printf, 1, 2))) __attribute__ ((format (printf, 1, 2)))
static inline void __warning(const char *fmt, ...) static inline void __warning(const char *fmt, ...)
{ {