diff options
author | Cyrill Gorcunov <gorcunov@openvz.org> | 2015-09-04 16:43:00 +0300 |
---|---|---|
committer | Pavel Emelyanov <xemul@parallels.com> | 2015-09-04 19:36:27 +0300 |
commit | eb02c8c1fda3c8927175bd632365b29adcc0bd41 (patch) | |
tree | b3365db9bede8e2c41d885574a7eb8dde0c5707e | |
parent | 954ba48d1d94dc65b2b6915f29bddb684d04ebf8 (diff) |
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: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rw-r--r-- | test/zdtm/live/static/file_locks01.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/zdtm/live/static/file_locks01.c b/test/zdtm/live/static/file_locks01.c index fd74ffe55..6944a473c 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@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; |