Commit eb02c8c1 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

test: file_locks -- Use device from mountinfo for BTRFS

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 954ba48d
......@@ -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@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,6 +40,10 @@ static int open_all_files(int *fd_0, int *fd_1, int *fd_2)
fstat(*fd_0, &buf);
inodes[0] = buf.st_ino;
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);
......@@ -108,8 +114,13 @@ static int check_file_locks()
if (i_no != inodes[0] && i_no != inodes[1] && i_no != inodes[2])
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;
......
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