[CRIU] [PATCH 2/2] test: file_locks -- Use device from mountinfo for BTRFS
Cyrill Gorcunov
gorcunov at openvz.org
Fri Sep 4 06:43:49 PDT 2015
BTRFS uses own device numbering scheme so lets do a trick
close one to what we have in CRIU itself -- mangle
device to match mountinfo output.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
test/zdtm/live/static/file_locks01.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/test/zdtm/live/static/file_locks01.c b/test/zdtm/live/static/file_locks01.c
index fd74ffe559ad..6944a473cbd1 100644
--- a/test/zdtm/live/static/file_locks01.c
+++ b/test/zdtm/live/static/file_locks01.c
@@ -10,6 +10,7 @@
#include <linux/limits.h>
#include "zdtmtst.h"
+#include "fs.h"
const char *test_doc = "Check that flock locks are restored";
const char *test_author = "Qiang Huang <h.huangqiang at huawei.com>";
@@ -21,6 +22,7 @@ char file0[PATH_MAX];
char file1[PATH_MAX];
char file2[PATH_MAX];
unsigned int inodes[3];
+static mnt_info_t *m;
dev_t dev;
static int open_all_files(int *fd_0, int *fd_1, int *fd_2)
@@ -38,7 +40,11 @@ static int open_all_files(int *fd_0, int *fd_1, int *fd_2)
fstat(*fd_0, &buf);
inodes[0] = buf.st_ino;
- dev = buf.st_dev;
+
+ if (!strcmp(m->fsname, "btrfs"))
+ dev = m->s_dev;
+ else
+ dev = buf.st_dev;
*fd_1 = open(file1, O_RDWR | O_CREAT | O_EXCL, 0666);
if (*fd_1 < 0) {
@@ -108,8 +114,13 @@ static int check_file_locks()
if (i_no != inodes[0] && i_no != inodes[1] && i_no != inodes[2])
continue;
- if (makedev(maj, min) != dev)
- continue;
+ if (!strcmp(m->fsname, "btrfs")) {
+ if (MKKDEV(major(maj), minor(min)) != dev)
+ continue;
+ } else {
+ if (makedev(maj, min) != dev)
+ continue;
+ }
if (!strcmp(fl_flag, "FLOCK") && !strcmp(fl_type, "ADVISORY")) {
if (!strcmp(fl_option, "READ"))
@@ -143,6 +154,14 @@ int main(int argc, char **argv)
test_init(argc, argv);
+ m = get_cwd_mnt_info();
+ if (!m) {
+ err("Can't fetch mountinfo");
+ return -1;
+ }
+ if (!strcmp(m->fsname, "btrfs"))
+ m->s_dev = kdev_to_odev(m->s_dev);
+
if (open_all_files(&fd_0, &fd_1, &fd_2))
return -1;
--
2.4.3
More information about the CRIU
mailing list