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;
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>,
return 0;
}
-int lxc_attach_remount_sys_proc()
+static int lxc_attach_remount_sys_proc(void)
{
int ret;
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;
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;
return 0;
}
-char *lxc_attach_getpwshell(uid_t uid)
+static char *lxc_attach_getpwshell(uid_t uid)
{
/* local variables */
pid_t pid;
}
}
-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];
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;
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
}
struct bdev_type {
- char *name;
- struct bdev_ops *ops;
+ const char *name;
+ const struct bdev_ops *ops;
};
static int is_dir(const char *path)
return 0;
}
-struct bdev_ops dir_ops = {
+static const struct bdev_ops dir_ops = {
.detect = &dir_detect,
.mount = &dir_mount,
.umount = &dir_umount,
exit(1);
}
-struct bdev_ops zfs_ops = {
+static const struct bdev_ops zfs_ops = {
.detect = &zfs_detect,
.mount = &zfs_mount,
.umount = &zfs_umount,
return 0;
}
-struct bdev_ops lvm_ops = {
+static const struct bdev_ops lvm_ops = {
.detect = &lvm_detect,
.mount = &lvm_mount,
.umount = &lvm_umount,
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,
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,
return 0;
}
-int overlayfs_destroy(struct bdev *orig)
+static int overlayfs_destroy(struct bdev *orig)
{
char *upper;
return 0;
}
-struct bdev_ops overlayfs_ops = {
+static const struct bdev_ops overlayfs_ops = {
.detect = &overlayfs_detect,
.mount = &overlayfs_mount,
.umount = &overlayfs_umount,
.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,},
* 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;
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",
#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;
* 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;
}
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 },
{ "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;
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;
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;
}
}
-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;
* 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;
#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;
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) {
return 0;
}
-void lxc_clear_saved_nics(struct lxc_conf *conf)
+static void lxc_clear_saved_nics(struct lxc_conf *conf)
{
int i;
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
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);
struct signame {
int num;
- char *name;
+ const char *name;
};
-struct signame signames[] = {
+static const struct signame signames[] = {
{ SIGHUP, "HUP" },
{ SIGINT, "INT" },
{ SIGQUIT, "QUIT" },
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);
}
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,
/*
* 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__); \
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;
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;
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;
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");
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, },
{ .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;
.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) {
}
}
-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);
}
}
-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);
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' },
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;
return 0;
}
-void print_file(char *path)
+static void print_file(char *path)
{
if (!path)
return;
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;
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;
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;
};
/* 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;
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");
#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");
struct id_map *next;
};
-struct id_map default_map = {
+static struct id_map default_map = {
.which = 'b',
.host_id = 100000,
.ns_id = 0,
* 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);
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;
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;
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;
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)
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;
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;
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;
}
}
-void unlock_mutex(pthread_mutex_t *l)
+static void unlock_mutex(pthread_mutex_t *l)
{
int ret;
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
};
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",
return lxc_network_types[type];
}
-static char padchar[] =
+static const char padchar[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *lxc_mkifname(char *template)
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++) {
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--) {
return 0;
}
-int lxc_is_line_empty(char *line)
+int lxc_is_line_empty(const char *line)
{
int i;
size_t len = strlen(line);
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
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;
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;
return -1;
}
-int save_phys_nics(struct lxc_conf *conf)
+static int save_phys_nics(struct lxc_conf *conf)
{
struct lxc_list *iterator;
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;
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;
};
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 *);
lxc_log_define(lxc_state, lxc);
-static char *strstate[] = {
+static const char * const strstate[] = {
"STOPPED", "STARTING", "RUNNING", "STOPPING",
"ABORTING", "FREEZING", "FROZEN", "THAWED",
};
#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 },
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;
* 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);
extern void **lxc_append_null_to_array(void **array, size_t count);
-extern void dump_stacktrace(void);
#endif