mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
files-reg: Add a few helpers to access ghost files remaps from inotify
The remap_put will be needed to defer unlinking of ghost files if they are referred from inotify system. The lookup_remap is needed to figure out if the watch target the inotify has present in ghost files list. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
746ac3fee5
commit
7bd34c699e
27
files-reg.c
27
files-reg.c
@@ -244,6 +244,33 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void remap_put(struct file_remap *remap)
|
||||||
|
{
|
||||||
|
mutex_lock(ghost_file_mutex);
|
||||||
|
if (--remap->users == 0) {
|
||||||
|
pr_info("Unlink the ghost %s\n", remap->path);
|
||||||
|
unlink(remap->path);
|
||||||
|
}
|
||||||
|
mutex_unlock(ghost_file_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct file_remap *lookup_ghost_remap(u32 dev, u32 ino)
|
||||||
|
{
|
||||||
|
struct ghost_file *gf;
|
||||||
|
|
||||||
|
mutex_lock(ghost_file_mutex);
|
||||||
|
list_for_each_entry(gf, &ghost_files, list) {
|
||||||
|
if (gf->dev == dev && gf->ino == ino) {
|
||||||
|
gf->remap.users++;
|
||||||
|
mutex_unlock(ghost_file_mutex);
|
||||||
|
return &gf->remap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mutex_unlock(ghost_file_mutex);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int dump_ghost_remap(char *path, const struct stat *st, int lfd, u32 id)
|
static int dump_ghost_remap(char *path, const struct stat *st, int lfd, u32 id)
|
||||||
{
|
{
|
||||||
struct ghost_file *gf;
|
struct ghost_file *gf;
|
||||||
|
@@ -33,4 +33,7 @@ extern int prepare_shared_reg_files(void);
|
|||||||
extern int dump_reg_file(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset);
|
extern int dump_reg_file(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset);
|
||||||
extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
|
extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
|
||||||
|
|
||||||
|
extern struct file_remap *lookup_ghost_remap(u32 dev, u32 ino);
|
||||||
|
extern void remap_put(struct file_remap *remap);
|
||||||
|
|
||||||
#endif /* FILES_REG_H__ */
|
#endif /* FILES_REG_H__ */
|
||||||
|
Reference in New Issue
Block a user