mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
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>
This commit is contained in:
committed by
Pavel Emelyanov
parent
954ba48d1d
commit
eb02c8c1fd
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user