Commit fe1cf260 authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Pavel Emelyanov

dump: add const qualifiers where possible

Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c1999ec5
...@@ -97,8 +97,8 @@ struct fd_parms { ...@@ -97,8 +97,8 @@ struct fd_parms {
pid_t pid; pid_t pid;
}; };
static int dump_one_reg_file(struct fd_parms *p, int lfd, static int dump_one_reg_file(const struct fd_parms *p, int lfd,
struct cr_fdset *cr_fdset, const struct cr_fdset *cr_fdset,
bool do_close_lfd) bool do_close_lfd)
{ {
struct fdinfo_entry e; struct fdinfo_entry e;
...@@ -157,7 +157,7 @@ err: ...@@ -157,7 +157,7 @@ err:
return ret; return ret;
} }
static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset) static int dump_task_special_files(pid_t pid, const struct cr_fdset *cr_fdset)
{ {
struct fd_parms params; struct fd_parms params;
int fd, ret; int fd, ret;
...@@ -192,7 +192,7 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset) ...@@ -192,7 +192,7 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
} }
static int dump_pipe_and_data(int lfd, struct pipe_entry *e, static int dump_pipe_and_data(int lfd, struct pipe_entry *e,
struct cr_fdset *cr_fdset) const struct cr_fdset *cr_fdset)
{ {
int fd_pipes; int fd_pipes;
int steal_pipe[2]; int steal_pipe[2];
...@@ -246,8 +246,8 @@ err: ...@@ -246,8 +246,8 @@ err:
return ret; return ret;
} }
static int dump_one_pipe(struct fd_parms *p, unsigned int id, int lfd, static int dump_one_pipe(const struct fd_parms *p, unsigned int id, int lfd,
struct cr_fdset *cr_fdset) const struct cr_fdset *cr_fdset)
{ {
struct pipe_entry e; struct pipe_entry e;
int ret = -1; int ret = -1;
...@@ -285,7 +285,7 @@ err: ...@@ -285,7 +285,7 @@ err:
return ret; return ret;
} }
static int read_fd_params(pid_t pid, char *fd, struct fd_parms *p) static int read_fd_params(pid_t pid, const char *fd, struct fd_parms *p)
{ {
FILE *file; FILE *file;
int ret; int ret;
...@@ -312,7 +312,8 @@ static int read_fd_params(pid_t pid, char *fd, struct fd_parms *p) ...@@ -312,7 +312,8 @@ static int read_fd_params(pid_t pid, char *fd, struct fd_parms *p)
return 0; return 0;
} }
static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset *cr_fdset, static int dump_one_fd(pid_t pid, int pid_fd_dir, const char *d_name,
const struct cr_fdset *cr_fdset,
struct sk_queue *sk_queue) struct sk_queue *sk_queue)
{ {
struct stat fd_stat; struct stat fd_stat;
...@@ -372,7 +373,7 @@ out_close: ...@@ -372,7 +373,7 @@ out_close:
return err; return err;
} }
static int dump_task_files(pid_t pid, struct cr_fdset *cr_fdset, static int dump_task_files(pid_t pid, const struct cr_fdset *cr_fdset,
struct sk_queue *sk_queue) struct sk_queue *sk_queue)
{ {
struct dirent *de; struct dirent *de;
...@@ -414,7 +415,8 @@ static int dump_task_files(pid_t pid, struct cr_fdset *cr_fdset, ...@@ -414,7 +415,8 @@ static int dump_task_files(pid_t pid, struct cr_fdset *cr_fdset,
return 0; return 0;
} }
static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct cr_fdset *cr_fdset) static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list,
const struct cr_fdset *cr_fdset)
{ {
struct vma_area *vma_area; struct vma_area *vma_area;
int ret = -1; int ret = -1;
...@@ -473,8 +475,8 @@ err: ...@@ -473,8 +475,8 @@ err:
return ret; return ret;
} }
static int dump_task_creds(pid_t pid, static int dump_task_creds(pid_t pid, const struct parasite_dump_misc *misc,
struct parasite_dump_misc *misc, struct cr_fdset *fds) const struct cr_fdset *fds)
{ {
int ret, i; int ret, i;
struct proc_status_creds cr; struct proc_status_creds cr;
...@@ -569,7 +571,7 @@ err: ...@@ -569,7 +571,7 @@ err:
return ret; return ret;
} }
static int get_task_regs(pid_t pid, struct core_entry *core, struct parasite_ctl *ctl) static int get_task_regs(pid_t pid, struct core_entry *core, const struct parasite_ctl *ctl)
{ {
user_fpregs_struct_t fpregs = {-1}; user_fpregs_struct_t fpregs = {-1};
user_regs_struct_t regs = {-1}; user_regs_struct_t regs = {-1};
...@@ -653,7 +655,7 @@ err: ...@@ -653,7 +655,7 @@ err:
return ret; return ret;
} }
static int dump_task_core(struct core_entry *core, struct cr_fdset *fdset) static int dump_task_core(struct core_entry *core, const struct cr_fdset *fdset)
{ {
int fd_core = fdset->fds[CR_FD_CORE]; int fd_core = fdset->fds[CR_FD_CORE];
int ret; int ret;
...@@ -672,9 +674,9 @@ static int dump_task_core(struct core_entry *core, struct cr_fdset *fdset) ...@@ -672,9 +674,9 @@ static int dump_task_core(struct core_entry *core, struct cr_fdset *fdset)
return ret; return ret;
} }
static int dump_task_core_all(pid_t pid, struct proc_pid_stat *stat, static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
struct parasite_dump_misc *misc, struct parasite_ctl *ctl, const struct parasite_dump_misc *misc, const struct parasite_ctl *ctl,
struct cr_fdset *cr_fdset) const struct cr_fdset *cr_fdset)
{ {
struct core_entry *core = xzalloc(sizeof(*core)); struct core_entry *core = xzalloc(sizeof(*core));
int ret = -1; int ret = -1;
...@@ -737,7 +739,7 @@ err: ...@@ -737,7 +739,7 @@ err:
return ret; return ret;
} }
static int parse_threads(struct pstree_item *item, u32 **_t, int *_n) static int parse_threads(const struct pstree_item *item, u32 **_t, int *_n)
{ {
struct dirent *de; struct dirent *de;
DIR *dir; DIR *dir;
...@@ -778,7 +780,7 @@ static int get_threads(struct pstree_item *item) ...@@ -778,7 +780,7 @@ static int get_threads(struct pstree_item *item)
return parse_threads(item, &item->threads, &item->nr_threads); return parse_threads(item, &item->threads, &item->nr_threads);
} }
static int check_threads(struct pstree_item *item) static int check_threads(const struct pstree_item *item)
{ {
u32 *t; u32 *t;
int nr, ret; int nr, ret;
...@@ -798,7 +800,7 @@ static int check_threads(struct pstree_item *item) ...@@ -798,7 +800,7 @@ static int check_threads(struct pstree_item *item)
return 0; return 0;
} }
static int parse_children(struct pstree_item *item, u32 **_c, int *_n) static int parse_children(const struct pstree_item *item, u32 **_c, int *_n)
{ {
FILE *file; FILE *file;
char *tok; char *tok;
...@@ -844,7 +846,7 @@ static int get_children(struct pstree_item *item) ...@@ -844,7 +846,7 @@ static int get_children(struct pstree_item *item)
return parse_children(item, &item->children, &item->nr_children); return parse_children(item, &item->children, &item->nr_children);
} }
static void unseize_task_and_threads(struct pstree_item *item, int st) static void unseize_task_and_threads(const struct pstree_item *item, int st)
{ {
int i; int i;
...@@ -852,7 +854,8 @@ static void unseize_task_and_threads(struct pstree_item *item, int st) ...@@ -852,7 +854,8 @@ static void unseize_task_and_threads(struct pstree_item *item, int st)
unseize_task(item->threads[i], st); /* item->pid will be here */ unseize_task(item->threads[i], st); /* item->pid will be here */
} }
static void pstree_switch_state(struct list_head *list, struct cr_options *opts) static void pstree_switch_state(const struct list_head *list,
const struct cr_options *opts)
{ {
struct pstree_item *item; struct pstree_item *item;
...@@ -863,7 +866,7 @@ static void pstree_switch_state(struct list_head *list, struct cr_options *opts) ...@@ -863,7 +866,7 @@ static void pstree_switch_state(struct list_head *list, struct cr_options *opts)
} }
} }
static int seize_threads(struct pstree_item *item) static int seize_threads(const struct pstree_item *item)
{ {
int i = 0, ret; int i = 0, ret;
...@@ -965,7 +968,7 @@ err: ...@@ -965,7 +968,7 @@ err:
return NULL; return NULL;
} }
static int check_subtree(struct pstree_item *item) static int check_subtree(const struct pstree_item *item)
{ {
u32 *ch; u32 *ch;
int nr, ret; int nr, ret;
...@@ -1010,7 +1013,7 @@ static int collect_subtree(pid_t pid, pid_t ppid, struct list_head *pstree_list, ...@@ -1010,7 +1013,7 @@ static int collect_subtree(pid_t pid, pid_t ppid, struct list_head *pstree_list,
} }
static int collect_pstree(pid_t pid, struct list_head *pstree_list, static int collect_pstree(pid_t pid, struct list_head *pstree_list,
struct cr_options *opts) const struct cr_options *opts)
{ {
int ret, attempts = 5; int ret, attempts = 5;
...@@ -1070,9 +1073,10 @@ try_again: ...@@ -1070,9 +1073,10 @@ try_again:
return ret; return ret;
} }
static int dump_pstree(pid_t pid, struct list_head *pstree_list, struct cr_fdset *cr_fdset) static int dump_pstree(pid_t pid, const struct list_head *pstree_list,
const struct cr_fdset *cr_fdset)
{ {
struct pstree_item *item; const struct pstree_item *item;
struct pstree_entry e; struct pstree_entry e;
unsigned long i; unsigned long i;
int ret = -1; int ret = -1;
...@@ -1118,7 +1122,8 @@ err: ...@@ -1118,7 +1122,8 @@ err:
return ret; return ret;
} }
static struct vma_area *find_vma_by_addr(struct list_head *vma_area_list, unsigned long addr) static struct vma_area *find_vma_by_addr(const struct list_head *vma_area_list,
unsigned long addr)
{ {
struct vma_area *vma_area; struct vma_area *vma_area;
...@@ -1131,7 +1136,8 @@ static struct vma_area *find_vma_by_addr(struct list_head *vma_area_list, unsign ...@@ -1131,7 +1136,8 @@ static struct vma_area *find_vma_by_addr(struct list_head *vma_area_list, unsign
} }
/* kernel expects a special format in core file */ /* kernel expects a special format in core file */
static int finalize_core(pid_t pid, struct list_head *vma_area_list, struct cr_fdset *cr_fdset) static int finalize_core(pid_t pid, const struct list_head *vma_area_list,
const struct cr_fdset *cr_fdset)
{ {
int fd_core; int fd_core;
unsigned long num; unsigned long num;
...@@ -1177,7 +1183,7 @@ err: ...@@ -1177,7 +1183,7 @@ err:
} }
static int dump_task_thread(struct parasite_ctl *parasite_ctl, static int dump_task_thread(struct parasite_ctl *parasite_ctl,
pid_t pid, struct cr_fdset *cr_fdset) pid_t pid, const struct cr_fdset *cr_fdset)
{ {
struct core_entry *core = xzalloc(sizeof(*core)); struct core_entry *core = xzalloc(sizeof(*core));
int ret = -1; int ret = -1;
...@@ -1219,8 +1225,9 @@ err: ...@@ -1219,8 +1225,9 @@ err:
return ret; return ret;
} }
static int dump_one_zombie(struct pstree_item *item, struct proc_pid_stat *pps, static int dump_one_zombie(const struct pstree_item *item,
struct cr_fdset *cr_fdset) const struct proc_pid_stat *pps,
struct cr_fdset *cr_fdset)
{ {
struct core_entry *core; struct core_entry *core;
...@@ -1241,7 +1248,7 @@ static int dump_one_zombie(struct pstree_item *item, struct proc_pid_stat *pps, ...@@ -1241,7 +1248,7 @@ static int dump_one_zombie(struct pstree_item *item, struct proc_pid_stat *pps,
static struct proc_pid_stat pps_buf; static struct proc_pid_stat pps_buf;
static int dump_task_threads(struct parasite_ctl *parasite_ctl, static int dump_task_threads(struct parasite_ctl *parasite_ctl,
struct pstree_item *item) const struct pstree_item *item)
{ {
int i; int i;
struct cr_fdset *cr_fdset_thread = NULL; struct cr_fdset *cr_fdset_thread = NULL;
...@@ -1272,7 +1279,7 @@ err: ...@@ -1272,7 +1279,7 @@ err:
return -1; return -1;
} }
static int dump_one_task(struct pstree_item *item, struct cr_fdset *cr_fdset) static int dump_one_task(const struct pstree_item *item, struct cr_fdset *cr_fdset)
{ {
pid_t pid = item->pid; pid_t pid = item->pid;
LIST_HEAD(vma_area_list); LIST_HEAD(vma_area_list);
...@@ -1395,7 +1402,7 @@ err_free: ...@@ -1395,7 +1402,7 @@ err_free:
return ret; return ret;
} }
int cr_dump_tasks(pid_t pid, struct cr_options *opts) int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
{ {
LIST_HEAD(pstree_list); LIST_HEAD(pstree_list);
struct cr_fdset *cr_fdset = NULL; struct cr_fdset *cr_fdset = NULL;
......
...@@ -121,7 +121,7 @@ struct cr_fdset { ...@@ -121,7 +121,7 @@ struct cr_fdset {
CR_FD_DESC_USE(CR_FD_IPCNS_SHM) ) CR_FD_DESC_USE(CR_FD_IPCNS_SHM) )
#define CR_FD_DESC_NONE (0) #define CR_FD_DESC_NONE (0)
int cr_dump_tasks(pid_t pid, struct cr_options *opts); int cr_dump_tasks(pid_t pid, const struct cr_options *opts);
int cr_restore_tasks(pid_t pid, struct cr_options *opts); int cr_restore_tasks(pid_t pid, struct cr_options *opts);
int cr_show(unsigned long pid, struct cr_options *opts); int cr_show(unsigned long pid, struct cr_options *opts);
int convert_to_elf(char *elf_path, int fd_core); int convert_to_elf(char *elf_path, int fd_core);
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
* 0 on success * 0 on success
* -1 on error (error message is printed) * -1 on error (error message is printed)
*/ */
static inline int write_img_buf(int fd, void *ptr, int size) static inline int write_img_buf(int fd, const void *ptr, int size)
{ {
int ret; int ret;
ret = write(fd, ptr, size); ret = write(fd, ptr, size);
...@@ -131,12 +131,12 @@ static inline int read_img_buf(int fd, void *ptr, int size) ...@@ -131,12 +131,12 @@ static inline int read_img_buf(int fd, void *ptr, int size)
#define memzero_p(p) memset(p, 0, sizeof(*p)) #define memzero_p(p) memset(p, 0, sizeof(*p))
#define memzero(p, size) memset(p, 0, size) #define memzero(p, size) memset(p, 0, size)
extern void pr_info_siginfo(siginfo_t *siginfo); extern void pr_info_siginfo(const siginfo_t *siginfo);
struct vma_area; struct vma_area;
struct list_head; struct list_head;
extern void pr_vma(unsigned int loglevel, struct vma_area *vma_area); extern void pr_vma(unsigned int loglevel, const struct vma_area *vma_area);
#define pr_info_vma(vma_area) pr_vma(LOG_INFO, vma_area) #define pr_info_vma(vma_area) pr_vma(LOG_INFO, vma_area)
#define pr_msg_vma(vma_area) pr_vma(LOG_MSG, vma_area) #define pr_msg_vma(vma_area) pr_vma(LOG_MSG, vma_area)
...@@ -171,7 +171,7 @@ extern int reopen_fd_as_safe(int new_fd, int old_fd, bool allow_reuse_fd); ...@@ -171,7 +171,7 @@ extern int reopen_fd_as_safe(int new_fd, int old_fd, bool allow_reuse_fd);
#define reopen_fd_as(new_fd, old_fd) reopen_fd_as_safe(new_fd, old_fd, false) #define reopen_fd_as(new_fd, old_fd) reopen_fd_as_safe(new_fd, old_fd, false)
#define reopen_fd_as_nocheck(new_fd, old_fd) reopen_fd_as_safe(new_fd, old_fd, true) #define reopen_fd_as_nocheck(new_fd, old_fd) reopen_fd_as_safe(new_fd, old_fd, true)
extern void hex_dump(void *addr, unsigned long len); extern void hex_dump(const void *addr, unsigned long len);
int open_pid_proc(pid_t pid); int open_pid_proc(pid_t pid);
int close_pid_proc(void); int close_pid_proc(void);
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
#include "crtools.h" #include "crtools.h"
void hex_dump(void *addr, unsigned long len) void hex_dump(const void *addr, unsigned long len)
{ {
unsigned char *p = addr; const unsigned char *p = addr;
unsigned long i; unsigned long i;
len = (len + 8) & ~7; len = (len + 8) & ~7;
...@@ -51,13 +51,13 @@ void hex_dump(void *addr, unsigned long len) ...@@ -51,13 +51,13 @@ void hex_dump(void *addr, unsigned long len)
} }
} }
void pr_info_siginfo(siginfo_t *siginfo) void pr_info_siginfo(const siginfo_t *siginfo)
{ {
pr_info("si_signo %d si_errno %d si_code %d\n", pr_info("si_signo %d si_errno %d si_code %d\n",
siginfo->si_signo, siginfo->si_errno, siginfo->si_code); siginfo->si_signo, siginfo->si_errno, siginfo->si_code);
} }
void pr_vma(unsigned int loglevel, struct vma_area *vma_area) void pr_vma(unsigned int loglevel, const struct vma_area *vma_area)
{ {
if (!vma_area) if (!vma_area)
return; return;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "namespaces.h" #include "namespaces.h"
#include "sysctl.h" #include "sysctl.h"
static int dump_uts_string(int fd, char *str) static int dump_uts_string(int fd, const char *str)
{ {
int ret; int ret;
u32 len; u32 len;
......
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