2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

fsnotify: fanotify -- Group objects in image

As Pavel proposed we can refine fanotify image objects
squeezing common part in separate entry. Finally the objects
are grouped as

enum mark_type {
	INODE	= 1;
	MOUNT	= 2;
}

message fanotify_inode_mark_entry {
	required uint64		i_ino		= 1;
	required fh_entry	f_handle	= 2;
}

message fanotify_mount_mark_entry {
	required uint32		mnt_id		= 1;
}

message fanotify_mark_entry {
	required uint32		id		= 1;
	required mark_type	type		= 2;

	required uint32		mflags		= 3;
	required uint32		mask		= 4;
	required uint32		ignored_mask	= 5;
	required uint32		s_dev		= 6;

	optional fanotify_inode_mark_entry ie	= 7;
	optional fanotify_mount_mark_entry me	= 8;
}

This required some tuning in fdinfo parsing and
fsnotify code itself, but result looks good to me.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov
2013-01-15 23:17:57 +04:00
committed by Pavel Emelyanov
parent fd72e27d90
commit eb8f8c12cd
3 changed files with 46 additions and 23 deletions

View File

@@ -937,6 +937,7 @@ int parse_fdinfo(int fd, int type,
continue;
}
if (fdinfo_field(str, "fanotify ino")) {
FanotifyInodeMarkEntry ie = FANOTIFY_INODE_MARK_ENTRY__INIT;
FhEntry f_handle = FH_ENTRY__INIT;
int hoff;
@@ -944,14 +945,15 @@ int parse_fdinfo(int fd, int type,
goto parse_err;
fanotify_mark_entry__init(&entry.ffy);
entry.ffy.f_handle = &f_handle;
ie.f_handle = &f_handle;
entry.ffy.ie = &ie;
ret = sscanf(str,
"fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x "
"fhandle-bytes:%x fhandle-type:%x f_handle: %n",
&entry.ffy.i_ino, &entry.ffy.s_dev,
&ie.i_ino, &entry.ffy.s_dev,
&entry.ffy.mflags, &entry.ffy.mask, &entry.ffy.ignored_mask,
&entry.ffy.f_handle->bytes, &entry.ffy.f_handle->type,
&f_handle.bytes, &f_handle.type,
&hoff);
if (ret != 7)
goto parse_err;
@@ -961,9 +963,8 @@ int parse_fdinfo(int fd, int type,
if (!f_handle.handle)
return -1;
parse_fhandle_encoded(str + hoff, entry.ffy.f_handle);
parse_fhandle_encoded(str + hoff, &f_handle);
entry.ffy.has_mnt_id = false;
entry.ffy.type = MARK_TYPE__INODE;
ret = cb(&entry, arg);
@@ -976,19 +977,21 @@ int parse_fdinfo(int fd, int type,
continue;
}
if (fdinfo_field(str, "fanotify mnt_id")) {
FanotifyMountMarkEntry me = FANOTIFY_MOUNT_MARK_ENTRY__INIT;
if (type != FD_TYPES__FANOTIFY)
goto parse_err;
fanotify_mark_entry__init(&entry.ffy);
entry.ffy.me = &me;
ret = sscanf(str,
"fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x",
&entry.ffy.mnt_id, &entry.ffy.mflags,
&me.mnt_id, &entry.ffy.mflags,
&entry.ffy.mask, &entry.ffy.ignored_mask);
if (ret != 4)
goto parse_err;
entry.ffy.has_mnt_id = true;
entry.ffy.type = MARK_TYPE__MOUNT;
ret = cb(&entry, arg);
if (ret)