2012-01-10 18:03:00 +04:00
|
|
|
#ifndef FILES_H_
|
|
|
|
#define FILES_H_
|
|
|
|
|
2012-02-22 13:46:36 +04:00
|
|
|
#include "compiler.h"
|
|
|
|
#include "types.h"
|
2012-03-26 23:11:00 +04:00
|
|
|
#include "lock.h"
|
2012-02-22 13:46:36 +04:00
|
|
|
#include "list.h"
|
|
|
|
#include "image.h"
|
|
|
|
|
2012-03-29 16:40:10 +04:00
|
|
|
struct fd_parms {
|
2012-04-10 17:49:39 +04:00
|
|
|
int fd;
|
2012-03-29 16:40:10 +04:00
|
|
|
unsigned long pos;
|
|
|
|
unsigned int flags;
|
2012-04-10 18:36:59 +04:00
|
|
|
char fd_flags;
|
2012-03-29 16:40:10 +04:00
|
|
|
struct stat stat;
|
|
|
|
pid_t pid;
|
2012-04-11 15:53:00 +04:00
|
|
|
fown_t fown;
|
2012-03-29 16:40:10 +04:00
|
|
|
};
|
|
|
|
|
2012-02-22 13:46:36 +04:00
|
|
|
enum fdinfo_states {
|
|
|
|
FD_STATE_PREP, /* Create unix sockets */
|
|
|
|
FD_STATE_CREATE, /* Create and send fd */
|
|
|
|
FD_STATE_RECV, /* Receive fd */
|
|
|
|
|
|
|
|
FD_STATE_MAX
|
|
|
|
};
|
|
|
|
|
2012-06-03 22:56:02 +04:00
|
|
|
struct file_desc;
|
|
|
|
|
2012-02-22 13:46:36 +04:00
|
|
|
struct fdinfo_list_entry {
|
2012-04-18 15:46:04 +04:00
|
|
|
struct list_head desc_list;
|
2012-06-03 22:56:02 +04:00
|
|
|
struct file_desc *desc;
|
2012-04-18 16:24:08 +04:00
|
|
|
struct list_head ps_list;
|
2012-02-22 13:46:36 +04:00
|
|
|
int pid;
|
2012-03-26 23:11:00 +04:00
|
|
|
futex_t real_pid;
|
2012-04-18 16:03:14 +04:00
|
|
|
struct fdinfo_entry fe;
|
2012-02-22 13:46:36 +04:00
|
|
|
};
|
|
|
|
|
2012-04-06 20:39:48 +04:00
|
|
|
struct file_desc_ops {
|
2012-05-04 15:41:05 +04:00
|
|
|
int type;
|
2012-04-06 20:39:48 +04:00
|
|
|
int (*open)(struct file_desc *);
|
|
|
|
int (*want_transport)(struct fdinfo_entry *, struct file_desc *);
|
|
|
|
};
|
|
|
|
|
2012-04-06 20:03:31 +04:00
|
|
|
struct file_desc {
|
2012-04-06 20:30:48 +04:00
|
|
|
u32 id;
|
|
|
|
struct list_head hash;
|
2012-04-06 20:03:31 +04:00
|
|
|
struct list_head fd_info_head;
|
2012-04-06 20:39:48 +04:00
|
|
|
struct file_desc_ops *ops;
|
2012-04-06 20:03:31 +04:00
|
|
|
};
|
|
|
|
|
2012-05-04 15:34:55 +04:00
|
|
|
struct fdtype_ops {
|
|
|
|
unsigned int type;
|
|
|
|
u32 (*make_gen_id)(const struct fd_parms *p);
|
|
|
|
int (*dump)(int lfd, u32 id, const struct fd_parms *p);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern u32 make_gen_id(const struct fd_parms *p);
|
|
|
|
struct cr_fdset;
|
|
|
|
extern int do_dump_gen_file(struct fd_parms *p, int lfd,
|
|
|
|
const struct fdtype_ops *ops, const struct cr_fdset *cr_fdset);
|
|
|
|
|
2012-05-04 15:41:05 +04:00
|
|
|
extern void file_desc_add(struct file_desc *d, u32 id, struct file_desc_ops *ops);
|
2012-04-06 20:03:31 +04:00
|
|
|
extern struct fdinfo_list_entry *file_master(struct file_desc *d);
|
2012-04-06 20:30:48 +04:00
|
|
|
extern struct file_desc *find_file_desc_raw(int type, u32 id);
|
2012-04-06 21:20:28 +04:00
|
|
|
extern int send_fd_to_peer(int fd, struct fdinfo_list_entry *, int transport);
|
2012-04-10 22:54:00 +04:00
|
|
|
extern int restore_fown(int fd, fown_t *fown);
|
2012-04-26 14:03:49 +04:00
|
|
|
int rst_file_params(int fd, fown_t *fown, int flags);
|
2012-04-05 20:02:00 +04:00
|
|
|
|
2012-04-05 12:48:57 +04:00
|
|
|
void show_saved_files(void);
|
2012-04-03 00:50:50 +04:00
|
|
|
extern int collect_reg_files(void);
|
2012-04-18 16:27:46 +04:00
|
|
|
struct pstree_item;
|
|
|
|
extern int prepare_fds(struct pstree_item *);
|
2012-04-18 16:24:08 +04:00
|
|
|
struct rst_info;
|
|
|
|
extern int prepare_fd_pid(int pid, struct rst_info *);
|
2012-02-22 18:51:27 +04:00
|
|
|
extern int prepare_shared_fdinfo(void);
|
2012-03-21 19:38:00 +04:00
|
|
|
extern int get_filemap_fd(int pid, struct vma_entry *vma_entry);
|
2012-04-09 13:41:05 +04:00
|
|
|
extern int prepare_fs(int pid);
|
2012-04-09 15:52:00 +04:00
|
|
|
extern int open_reg_by_id(u32 id);
|
2012-04-11 13:20:03 +04:00
|
|
|
int set_fd_flags(int fd, int flags);
|
2012-01-10 18:03:00 +04:00
|
|
|
|
2012-03-24 13:22:37 +04:00
|
|
|
extern int self_exe_fd;
|
|
|
|
|
2012-04-13 17:54:36 +04:00
|
|
|
void clear_ghost_files(void);
|
|
|
|
|
2012-01-10 18:03:00 +04:00
|
|
|
#endif /* FILES_H_ */
|