Commit 74a3920a by Andrey Mazo Committed by Serge Hallyn

Mark functions as static and arguments/arrays as const where possible

Mark most of functions that are used within only one file as static. After 95ee490b it's easy to prove they are not in public API. Several arrays and structs are also marked static. This prevents them from being exported from liblxc.so List of removed previously exported symbols: bdevs btrfs_ops check_autodev create_partial dir_ops dump_stacktrace get_mapped_rootid get_next_index lock_mutex loop_ops lvm_ops lxc_abort lxcapi_clone lxc_attach_drop_privs lxc_attach_get_init_uidgi lxc_attach_getpwshell lxc_attach_remount_sys_pr lxc_attach_set_environmen lxc_attach_to_ns lxc_clear_saved_nics lxc_config_readline lxc_devs lxc_free_idmap lxc_global_config_value lxc_poll lxc_proc_get_context_info lxc_set_state lxc_spawn mk_devtmpfs mount_check_fs ongoing_create overlayfs_destroy overlayfs_ops prepend_lxc_header remove_partial save_phys_nics setup_pivot_root signames static_mutex thread_mutex unlock_mutex unpriv_assign_nic zfs_ops Signed-off-by: 's avatarAndrey Mazo <mazo@telum.ru> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 64b1be29
......@@ -62,7 +62,7 @@
lxc_log_define(lxc_attach, lxc);
struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
static struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
{
struct lxc_proc_context_info *info = calloc(1, sizeof(*info));
FILE *proc_file;
......@@ -137,7 +137,7 @@ static void lxc_proc_put_context_info(struct lxc_proc_context_info *ctx)
free(ctx);
}
int lxc_attach_to_ns(pid_t pid, int which)
static int lxc_attach_to_ns(pid_t pid, int which)
{
char path[MAXPATHLEN];
/* according to <http://article.gmane.org/gmane.linux.kernel.containers.lxc.devel/1429>,
......@@ -204,7 +204,7 @@ int lxc_attach_to_ns(pid_t pid, int which)
return 0;
}
int lxc_attach_remount_sys_proc()
static int lxc_attach_remount_sys_proc(void)
{
int ret;
......@@ -247,7 +247,7 @@ int lxc_attach_remount_sys_proc()
return 0;
}
int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
static int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
{
int last_cap = lxc_caps_last_cap();
int cap;
......@@ -265,7 +265,7 @@ int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
return 0;
}
int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep)
static int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep)
{
if (policy == LXC_ATTACH_CLEAR_ENV) {
char **extra_keep_store = NULL;
......@@ -373,7 +373,7 @@ int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra
return 0;
}
char *lxc_attach_getpwshell(uid_t uid)
static char *lxc_attach_getpwshell(uid_t uid)
{
/* local variables */
pid_t pid;
......@@ -528,7 +528,7 @@ char *lxc_attach_getpwshell(uid_t uid)
}
}
void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid)
static void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid)
{
FILE *proc_file;
char proc_fn[MAXPATHLEN];
......@@ -857,7 +857,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
rexit(0);
}
int attach_child_main(void* data)
static int attach_child_main(void* data)
{
struct attach_clone_payload* payload = (struct attach_clone_payload*)data;
int ipc_socket = payload->ipc_socket;
......
......@@ -33,17 +33,6 @@ struct lxc_proc_context_info {
unsigned long long capability_mask;
};
extern struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid);
extern int lxc_attach_to_ns(pid_t other_pid, int which);
extern int lxc_attach_remount_sys_proc();
extern int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx);
extern int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep);
extern char *lxc_attach_getpwshell(uid_t uid);
extern void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid);
extern int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_function, void* exec_payload, lxc_attach_options_t* options, pid_t* attached_process);
#endif
......@@ -324,8 +324,8 @@ static int detect_fs(struct bdev *bdev, char *type, int len)
}
struct bdev_type {
char *name;
struct bdev_ops *ops;
const char *name;
const struct bdev_ops *ops;
};
static int is_dir(const char *path)
......@@ -469,7 +469,7 @@ static int dir_create(struct bdev *bdev, const char *dest, const char *n,
return 0;
}
struct bdev_ops dir_ops = {
static const struct bdev_ops dir_ops = {
.detect = &dir_detect,
.mount = &dir_mount,
.umount = &dir_umount,
......@@ -726,7 +726,7 @@ static int zfs_create(struct bdev *bdev, const char *dest, const char *n,
exit(1);
}
struct bdev_ops zfs_ops = {
static const struct bdev_ops zfs_ops = {
.detect = &zfs_detect,
.mount = &zfs_mount,
.umount = &zfs_umount,
......@@ -1125,7 +1125,7 @@ static int lvm_create(struct bdev *bdev, const char *dest, const char *n,
return 0;
}
struct bdev_ops lvm_ops = {
static const struct bdev_ops lvm_ops = {
.detect = &lvm_detect,
.mount = &lvm_mount,
.umount = &lvm_umount,
......@@ -1422,7 +1422,7 @@ static int btrfs_create(struct bdev *bdev, const char *dest, const char *n,
return btrfs_subvolume_create(bdev->dest);
}
struct bdev_ops btrfs_ops = {
static const struct bdev_ops btrfs_ops = {
.detect = &btrfs_detect,
.mount = &btrfs_mount,
.umount = &btrfs_umount,
......@@ -1692,7 +1692,7 @@ static int loop_destroy(struct bdev *orig)
return unlink(orig->src + 5);
}
struct bdev_ops loop_ops = {
static const struct bdev_ops loop_ops = {
.detect = &loop_detect,
.mount = &loop_mount,
.umount = &loop_umount,
......@@ -1864,7 +1864,7 @@ static int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char
return 0;
}
int overlayfs_destroy(struct bdev *orig)
static int overlayfs_destroy(struct bdev *orig)
{
char *upper;
......@@ -1925,7 +1925,7 @@ static int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
return 0;
}
struct bdev_ops overlayfs_ops = {
static const struct bdev_ops overlayfs_ops = {
.detect = &overlayfs_detect,
.mount = &overlayfs_mount,
.umount = &overlayfs_umount,
......@@ -1934,7 +1934,7 @@ struct bdev_ops overlayfs_ops = {
.create = &overlayfs_create,
};
struct bdev_type bdevs[] = {
static const struct bdev_type bdevs[] = {
{.name = "zfs", .ops = &zfs_ops,},
{.name = "lvm", .ops = &lvm_ops,},
{.name = "btrfs", .ops = &btrfs_ops,},
......
......@@ -72,8 +72,8 @@ struct bdev_ops {
* data is so far unused.
*/
struct bdev {
struct bdev_ops *ops;
char *type;
const struct bdev_ops *ops;
const char *type;
char *src;
char *dest;
char *data;
......
......@@ -97,7 +97,7 @@ static int fill_sock_name(char *path, int len, const char *name,
static const char *lxc_cmd_str(lxc_cmd_t cmd)
{
static const char *cmdname[LXC_CMD_MAX] = {
static const char * const cmdname[LXC_CMD_MAX] = {
[LXC_CMD_CONSOLE] = "console",
[LXC_CMD_STOP] = "stop",
[LXC_CMD_GET_STATE] = "get_state",
......
......@@ -1111,7 +1111,7 @@ static uint64_t fnv_64a_buf(void *buf, size_t len, uint64_t hval)
#define LINELEN 4096
#define MAX_FSTYPE_LEN 128
int mount_check_fs( const char *dir, char *fstype )
static int mount_check_fs( const char *dir, char *fstype )
{
char buf[LINELEN], *p;
struct stat s;
......@@ -1175,7 +1175,7 @@ int mount_check_fs( const char *dir, char *fstype )
* the devtmpfs subdirectory.
*/
char *mk_devtmpfs(const char *name, char *path, const char *lxcpath)
static char *mk_devtmpfs(const char *name, char *path, const char *lxcpath)
{
int ret;
struct stat s;
......@@ -1353,13 +1353,13 @@ static int mount_autodev(const char *name, char *root, const char *lxcpath)
}
struct lxc_devs {
char *name;
const char *name;
mode_t mode;
int maj;
int min;
};
struct lxc_devs lxc_devs[] = {
static const struct lxc_devs lxc_devs[] = {
{ "null", S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 3 },
{ "zero", S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 5 },
{ "full", S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 7 },
......@@ -1369,10 +1369,9 @@ struct lxc_devs lxc_devs[] = {
{ "console", S_IFCHR | S_IRUSR | S_IWUSR, 5, 1 },
};
static int setup_autodev(char *root)
static int setup_autodev(const char *root)
{
int ret;
struct lxc_devs *d;
char path[MAXPATHLEN];
int i;
mode_t cmask;
......@@ -1388,7 +1387,7 @@ static int setup_autodev(char *root)
INFO("Populating /dev under %s\n", root);
cmask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
for (i = 0; i < sizeof(lxc_devs) / sizeof(lxc_devs[0]); i++) {
d = &lxc_devs[i];
const struct lxc_devs *d = &lxc_devs[i];
ret = snprintf(path, MAXPATHLEN, "%s/dev/%s", root, d->name);
if (ret < 0 || ret >= MAXPATHLEN)
return -1;
......@@ -1550,7 +1549,7 @@ static int setup_rootfs(struct lxc_conf *conf)
return 0;
}
int setup_pivot_root(const struct lxc_rootfs *rootfs)
static int setup_pivot_root(const struct lxc_rootfs *rootfs)
{
if (!rootfs->path)
return 0;
......@@ -2980,7 +2979,7 @@ void lxc_delete_network(struct lxc_handler *handler)
}
}
int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
{
pid_t child;
......@@ -3132,7 +3131,7 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
* return the host uid to which the container root is mapped, or -1 on
* error
*/
uid_t get_mapped_rootid(struct lxc_conf *conf)
static uid_t get_mapped_rootid(struct lxc_conf *conf)
{
struct lxc_list *it;
struct id_map *map;
......@@ -3398,7 +3397,7 @@ struct start_args {
#define MAX_SYMLINK_DEPTH 32
int check_autodev( const char *rootfs, void *data )
static int check_autodev( const char *rootfs, void *data )
{
struct start_args *arg = data;
int ret;
......@@ -3772,7 +3771,7 @@ int lxc_clear_config_caps(struct lxc_conf *c)
return 0;
}
int lxc_free_idmap(struct lxc_list *id_map) {
static int lxc_free_idmap(struct lxc_list *id_map) {
struct lxc_list *it, *next;
lxc_list_for_each_safe(it, id_map, next) {
......@@ -3874,7 +3873,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
return 0;
}
void lxc_clear_saved_nics(struct lxc_conf *conf)
static void lxc_clear_saved_nics(struct lxc_conf *conf)
{
int i;
......
......@@ -164,8 +164,6 @@ struct id_map {
unsigned long hostid, nsid, range;
};
extern int lxc_free_idmap(struct lxc_list *idmap);
/*
* Defines a structure containing a pty information for
* virtualizing a tty
......@@ -374,7 +372,6 @@ extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf,
extern void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf);
extern uid_t get_mapped_rootid(struct lxc_conf *conf);
extern int find_unmapped_nsuid(struct lxc_conf *conf);
extern int mapped_hostid(int id, struct lxc_conf *conf);
extern int chown_mapped_root(char *path, struct lxc_conf *conf);
......
......@@ -151,10 +151,10 @@ static struct lxc_config_t config[] = {
struct signame {
int num;
char *name;
const char *name;
};
struct signame signames[] = {
static const struct signame signames[] = {
{ SIGHUP, "HUP" },
{ SIGINT, "INT" },
{ SIGQUIT, "QUIT" },
......@@ -1586,7 +1586,7 @@ out:
return ret;
}
int lxc_config_readline(char *buffer, struct lxc_conf *conf)
static int lxc_config_readline(char *buffer, struct lxc_conf *conf)
{
return parse_line(buffer, conf);
}
......
......@@ -40,7 +40,6 @@ extern struct lxc_config_t *lxc_getconfig(const char *key);
extern int lxc_list_nicconfigs(struct lxc_conf *c, const char *key, char *retv, int inlen);
extern int lxc_listconfigs(char *retv, int inlen);
extern int lxc_config_read(const char *file, struct lxc_conf *conf);
extern int lxc_config_readline(char *buffer, struct lxc_conf *conf);
extern int lxc_config_define_add(struct lxc_list *defines, char* arg);
extern int lxc_config_define_load(struct lxc_list *defines,
......
......@@ -233,8 +233,6 @@ static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo, \
/*
* top categories
*/
extern struct lxc_log_category lxc_log_category_lxc;
#define TRACE(format, ...) do { \
struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT; \
LXC_TRACE(&locinfo, format, ##__VA_ARGS__); \
......
......@@ -97,7 +97,7 @@ int lists_contain_common_entry(struct lxc_list *p1, struct lxc_list *p2) {
return 0;
}
struct lxc_list *get_list(char *input, char *delimiter) {
static struct lxc_list *get_list(char *input, char *delimiter) {
char *workstr = NULL;
char *workptr = NULL;
char *sptr = NULL;
......@@ -138,7 +138,7 @@ struct lxc_list *get_list(char *input, char *delimiter) {
return workstr_list;
}
struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
static struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
int len = 0;
char* value = NULL;
struct lxc_list *config_list = NULL;
......@@ -167,7 +167,7 @@ struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
return config_list;
}
int get_config_integer(struct lxc_container *c, char *key) {
static int get_config_integer(struct lxc_container *c, char *key) {
int len = 0;
int ret = 0;
char* value = NULL;
......
......@@ -58,7 +58,7 @@ static unsigned long get_fssize(char *s)
return ret;
}
void usage(const char *me)
static void usage(const char *me)
{
printf("Usage: %s [-s] [-B backingstore] [-L size] [-K] [-M] [-H]\n", me);
printf(" [-p lxcpath] [-P newlxcpath] orig new\n");
......
......@@ -30,7 +30,7 @@ struct lxc_config_items {
const char *(*fn)(void);
};
struct lxc_config_items items[] =
static struct lxc_config_items items[] =
{
{ .name = "lxcpath", .fn = &lxc_get_default_config_path, },
{ .name = "lvm_vg", .fn = &lxc_get_default_lvm_vg, },
......@@ -39,14 +39,14 @@ struct lxc_config_items items[] =
{ .name = NULL, },
};
void usage(char *me)
static void usage(char *me)
{
printf("Usage: %s -l: list all available configuration items\n", me);
printf(" %s item: print configuration item\n", me);
exit(1);
}
void list_config_items(void)
static void list_config_items(void)
{
struct lxc_config_items *i;
......
......@@ -145,7 +145,7 @@ Options :\n\
.checker = NULL,
};
bool validate_bdev_args(struct lxc_arguments *a)
static bool validate_bdev_args(struct lxc_arguments *a)
{
if (strcmp(a->bdevtype, "best") != 0) {
if (a->fstype || a->fssize) {
......
......@@ -244,7 +244,7 @@ static void print_stats(struct lxc_container *c)
}
}
void print_info_msg_int(const char *key, int value)
static void print_info_msg_int(const char *key, int value)
{
if (humanize)
printf("%-15s %d\n", key, value);
......@@ -256,7 +256,7 @@ void print_info_msg_int(const char *key, int value)
}
}
void print_info_msg_str(const char *key, const char *value)
static void print_info_msg_str(const char *key, const char *value)
{
if (humanize)
printf("%-15s %s\n", key, value);
......
......@@ -42,7 +42,7 @@ lxc_log_define(lxc_init, lxc);
static int quiet;
static struct option options[] = {
static const struct option options[] = {
{ "name", required_argument, NULL, 'n' },
{ "logpriority", required_argument, NULL, 'l' },
{ "quiet", no_argument, NULL, 'q' },
......
......@@ -34,18 +34,18 @@
lxc_log_define(lxc_snapshot, lxc);
char *newname;
char *snapshot;
static char *newname;
static char *snapshot;
#define DO_SNAP 0
#define DO_LIST 1
#define DO_RESTORE 2
#define DO_DESTROY 3
int action;
int print_comments;
char *commentfile;
static int action;
static int print_comments;
static char *commentfile;
int do_snapshot(struct lxc_container *c)
static int do_snapshot(struct lxc_container *c)
{
int ret;
......@@ -59,7 +59,7 @@ int do_snapshot(struct lxc_container *c)
return 0;
}
void print_file(char *path)
static void print_file(char *path)
{
if (!path)
return;
......@@ -76,7 +76,7 @@ void print_file(char *path)
fclose(f);
}
int do_list_snapshots(struct lxc_container *c)
static int do_list_snapshots(struct lxc_container *c)
{
struct lxc_snapshot *s;
int i, n;
......@@ -100,7 +100,7 @@ int do_list_snapshots(struct lxc_container *c)
return 0;
}
int do_restore_snapshots(struct lxc_container *c)
static int do_restore_snapshots(struct lxc_container *c)
{
if (c->snapshot_restore(c, snapshot, newname))
return 0;
......@@ -109,7 +109,7 @@ int do_restore_snapshots(struct lxc_container *c)
return -1;
}
int do_destroy_snapshots(struct lxc_container *c)
static int do_destroy_snapshots(struct lxc_container *c)
{
if (c->snapshot_destroy(c, snapshot))
return 0;
......
......@@ -80,7 +80,7 @@ Options :\n\
};
/* returns -1 on failure, 0 on success */
int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c)
static int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c)
{
int ret;
pid_t pid;
......
......@@ -42,7 +42,7 @@
lxc_log_define(lxc_unshare_ui, lxc);
void usage(char *cmd)
static void usage(char *cmd)
{
fprintf(stderr, "%s <options> command [command_arguments]\n", basename(cmd));
fprintf(stderr, "Options are:\n");
......
......@@ -50,7 +50,7 @@
#include "utils.h"
#include "network.h"
void usage(char *me, bool fail)
static void usage(char *me, bool fail)
{
fprintf(stderr, "Usage: %s pid type bridge nicname\n", me);
fprintf(stderr, " nicname is the name to use inside the container\n");
......
......@@ -127,7 +127,7 @@ struct id_map {
struct id_map *next;
};
struct id_map default_map = {
static struct id_map default_map = {
.which = 'b',
.host_id = 100000,
.ns_id = 0,
......
......@@ -99,7 +99,7 @@ static bool config_file_exists(const char *lxcpath, const char *cname)
* we remove that file. When we load or try to start a container, if
* we find that file, without a flock, we remove the container.
*/
int ongoing_create(struct lxc_container *c)
static int ongoing_create(struct lxc_container *c)
{
int len = strlen(c->config_path) + strlen(c->name) + 10;
char *path = alloca(len);
......@@ -135,7 +135,7 @@ int ongoing_create(struct lxc_container *c)
return 2;
}
int create_partial(struct lxc_container *c)
static int create_partial(struct lxc_container *c)
{
// $lxcpath + '/' + $name + '/partial' + \0
int len = strlen(c->config_path) + strlen(c->name) + 10;
......@@ -165,7 +165,7 @@ int create_partial(struct lxc_container *c)
return fd;
}
void remove_partial(struct lxc_container *c, int fd)
static void remove_partial(struct lxc_container *c, int fd)
{
// $lxcpath + '/' + $name + '/partial' + \0
int len = strlen(c->config_path) + strlen(c->name) + 10;
......@@ -1037,7 +1037,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet
return true;
}
bool prepend_lxc_header(char *path, const char *t, char *const argv[])
static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
{
long flen;
char *contents;
......@@ -2414,7 +2414,7 @@ static int create_file_dirname(char *path)
return ret;
}
struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname,
static struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname,
const char *lxcpath, int flags,
const char *bdevtype, const char *bdevdata, unsigned long newsize,
char **hookargs)
......@@ -2587,7 +2587,7 @@ static int lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options_t
return lxc_wait_for_pid_status(pid);
}
int get_next_index(const char *lxcpath, char *cname)
static int get_next_index(const char *lxcpath, char *cname)
{
char *fname;
struct stat sb;
......
......@@ -45,10 +45,10 @@
lxc_log_define(lxc_lock, lxc);
#ifdef MUTEX_DEBUGGING
pthread_mutex_t thread_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
pthread_mutex_t static_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
static pthread_mutex_t thread_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
static pthread_mutex_t static_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
inline void dump_stacktrace(void)
static inline void dump_stacktrace(void)
{
void *array[MAX_STACKDEPTH];
size_t size;
......@@ -67,13 +67,13 @@ inline void dump_stacktrace(void)
free (strings);
}
#else
pthread_mutex_t thread_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t thread_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
inline void dump_stacktrace(void) {;}
static inline void dump_stacktrace(void) {;}
#endif
void lock_mutex(pthread_mutex_t *l)
static void lock_mutex(pthread_mutex_t *l)
{
int ret;
......@@ -84,7 +84,7 @@ void lock_mutex(pthread_mutex_t *l)
}
}
void unlock_mutex(pthread_mutex_t *l)
static void unlock_mutex(pthread_mutex_t *l)
{
int ret;
......
......@@ -69,11 +69,11 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
return ret;
}
static char *namespaces_list[] = {
static const char * const namespaces_list[] = {
"MOUNT", "PID", "UTSNAME", "IPC",
"USER", "NETWORK"
};
static int cloneflags_list[] = {
static const int cloneflags_list[] = {
CLONE_NEWNS, CLONE_NEWPID, CLONE_NEWUTS, CLONE_NEWIPC,
CLONE_NEWUSER, CLONE_NEWNET
};
......
......@@ -1092,7 +1092,7 @@ int lxc_bridge_attach(const char *bridge, const char *ifname)
return err;
}
static char* lxc_network_types[LXC_NET_MAXCONFTYPE + 1] = {
static const char* const lxc_network_types[LXC_NET_MAXCONFTYPE + 1] = {
[LXC_NET_VETH] = "veth",
[LXC_NET_MACVLAN] = "macvlan",
[LXC_NET_VLAN] = "vlan",
......@@ -1107,7 +1107,7 @@ const char *lxc_net_type_to_str(int type)
return lxc_network_types[type];
}
static char padchar[] =
static const char padchar[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *lxc_mkifname(char *template)
......
......@@ -65,7 +65,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
return err;
}
int lxc_char_left_gc(char *buffer, size_t len)
int lxc_char_left_gc(const char *buffer, size_t len)
{
int i;
for (i = 0; i < len; i++) {
......@@ -77,7 +77,7 @@ int lxc_char_left_gc(char *buffer, size_t len)
return 0;
}
int lxc_char_right_gc(char *buffer, size_t len)
int lxc_char_right_gc(const char *buffer, size_t len)
{
int i;
for (i = len - 1; i >= 0; i--) {
......@@ -91,7 +91,7 @@ int lxc_char_right_gc(char *buffer, size_t len)
return 0;
}
int lxc_is_line_empty(char *line)
int lxc_is_line_empty(const char *line)
{
int i;
size_t len = strlen(line);
......
......@@ -31,10 +31,10 @@ typedef int (*lxc_file_cb)(char *buffer, void *data);
extern int lxc_file_for_each_line(const char *file, lxc_file_cb callback,
void* data);
extern int lxc_char_left_gc(char *buffer, size_t len);
extern int lxc_char_left_gc(const char *buffer, size_t len);
extern int lxc_char_right_gc(char *buffer, size_t len);
extern int lxc_char_right_gc(const char *buffer, size_t len);
extern int lxc_is_line_empty(char *line);
extern int lxc_is_line_empty(const char *line);
#endif
......@@ -277,14 +277,14 @@ static int signal_handler(int fd, uint32_t events, void *data,
return 1;
}
int lxc_set_state(const char *name, struct lxc_handler *handler, lxc_state_t state)
static int lxc_set_state(const char *name, struct lxc_handler *handler, lxc_state_t state)
{
handler->state = state;
lxc_monitor_send_state(name, state, handler->lxcpath);
return 0;
}
int lxc_poll(const char *name, struct lxc_handler *handler)
static int lxc_poll(const char *name, struct lxc_handler *handler)
{
int sigfd = handler->sigfd;
int pid = handler->pid;
......@@ -464,7 +464,7 @@ static void lxc_fini(const char *name, struct lxc_handler *handler)
free(handler);
}
void lxc_abort(const char *name, struct lxc_handler *handler)
static void lxc_abort(const char *name, struct lxc_handler *handler)
{
int ret, status;
......@@ -656,7 +656,7 @@ out_warn_father:
return -1;
}
int save_phys_nics(struct lxc_conf *conf)
static int save_phys_nics(struct lxc_conf *conf)
{
struct lxc_list *iterator;
......@@ -686,7 +686,7 @@ int save_phys_nics(struct lxc_conf *conf)
return 0;
}
int lxc_spawn(struct lxc_handler *handler)
static int lxc_spawn(struct lxc_handler *handler)
{
int failed_before_rename = 0;
const char *name = handler->name;
......
......@@ -55,7 +55,7 @@ struct ns_info {
int clone_flag;
};
const struct ns_info ns_info[LXC_NS_MAX];
extern const struct ns_info ns_info[LXC_NS_MAX];
struct lxc_handler {
pid_t pid;
......@@ -74,11 +74,7 @@ struct lxc_handler {
};
extern struct lxc_handler *lxc_init(const char *name, struct lxc_conf *, const char *);
extern int lxc_spawn(struct lxc_handler *);
extern int lxc_poll(const char *name, struct lxc_handler *handler);
extern void lxc_abort(const char *name, struct lxc_handler *handler);
extern int lxc_set_state(const char *, struct lxc_handler *, lxc_state_t);
extern int lxc_check_inherited(struct lxc_conf *conf, int fd_to_ignore);
int __lxc_start(const char *, struct lxc_conf *, struct lxc_operations *,
void *, const char *);
......
......@@ -42,7 +42,7 @@
lxc_log_define(lxc_state, lxc);
static char *strstate[] = {
static const char * const strstate[] = {
"STOPPED", "STARTING", "RUNNING", "STOPPING",
"ABORTING", "FREEZING", "FROZEN", "THAWED",
};
......
......@@ -238,9 +238,9 @@ static char *copy_global_config_value(char *p)
#define DEFAULT_THIN_POOL "lxc"
#define DEFAULT_ZFSROOT "lxc"
const char *lxc_global_config_value(const char *option_name)
static const char *lxc_global_config_value(const char *option_name)
{
static const char *options[][2] = {
static const char * const options[][2] = {
{ "lvm_vg", DEFAULT_VG },
{ "lvm_thin_pool", DEFAULT_THIN_POOL },
{ "zfsroot", DEFAULT_ZFSROOT },
......@@ -272,7 +272,7 @@ const char *lxc_global_config_value(const char *option_name)
user_lxc_path = strdup(LXCPATH);
}
const char *(*ptr)[2];
const char * const (*ptr)[2];
const char *value;
size_t i;
char buf[1024], *p, *p2;
......
......@@ -45,7 +45,6 @@ extern const char *get_rundir(void);
* Return a buffer containing the default container path.
* Caller must NOT free this buffer, since it may be static.
*/
extern const char *lxc_global_config_value(const char *option_name);
extern const char *default_lxc_path(void);
extern const char *default_zfs_root(void);
extern const char *default_lvm_vg(void);
......@@ -267,5 +266,4 @@ extern size_t lxc_array_len(void **array);
extern void **lxc_append_null_to_array(void **array, size_t count);
extern void dump_stacktrace(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment