|
Lines 72-77
void expect_setlk(uint64_t ino, pid_t pid, uint64_t start, uint64_t end,
Link Here
|
| 72 |
return (in.header.opcode == FUSE_SETLK && |
72 |
return (in.header.opcode == FUSE_SETLK && |
| 73 |
in.header.nodeid == ino && |
73 |
in.header.nodeid == ino && |
| 74 |
in.body.setlk.fh == FH && |
74 |
in.body.setlk.fh == FH && |
|
|
75 |
in.body.setlk.owner == (uint32_t)pid && |
| 76 |
in.body.setlk.lk.start == start && |
| 77 |
in.body.setlk.lk.end == end && |
| 78 |
in.body.setlk.lk.type == type && |
| 79 |
in.body.setlk.lk.pid == (uint64_t)pid); |
| 80 |
}, Eq(true)), |
| 81 |
_) |
| 82 |
).WillOnce(Invoke(ReturnErrno(err))); |
| 83 |
} |
| 84 |
void expect_setlkw(uint64_t ino, pid_t pid, uint64_t start, uint64_t end, |
| 85 |
uint32_t type, int err) |
| 86 |
{ |
| 87 |
EXPECT_CALL(*m_mock, process( |
| 88 |
ResultOf([=](auto in) { |
| 89 |
return (in.header.opcode == FUSE_SETLKW && |
| 90 |
in.header.nodeid == ino && |
| 91 |
in.body.setlkw.fh == FH && |
| 75 |
in.body.setlkw.owner == (uint32_t)pid && |
92 |
in.body.setlkw.owner == (uint32_t)pid && |
| 76 |
in.body.setlkw.lk.start == start && |
93 |
in.body.setlkw.lk.start == start && |
| 77 |
in.body.setlkw.lk.end == end && |
94 |
in.body.setlkw.lk.end == end && |
|
Lines 343-348
TEST_F(SetlkFallback, local)
Link Here
|
| 343 |
leak(fd); |
360 |
leak(fd); |
| 344 |
} |
361 |
} |
| 345 |
|
362 |
|
|
|
363 |
/* Clear a lock with FUSE_SETLK */ |
| 364 |
TEST_F(Setlk, clear) |
| 365 |
{ |
| 366 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
| 367 |
const char RELPATH[] = "some_file.txt"; |
| 368 |
uint64_t ino = 42; |
| 369 |
struct flock fl; |
| 370 |
int fd; |
| 371 |
pid_t pid = 1234; |
| 372 |
|
| 373 |
expect_lookup(RELPATH, ino); |
| 374 |
expect_open(ino, 0, 1); |
| 375 |
expect_setlk(ino, pid, 10, 1009, F_UNLCK, 0); |
| 376 |
|
| 377 |
fd = open(FULLPATH, O_RDWR); |
| 378 |
ASSERT_LE(0, fd) << strerror(errno); |
| 379 |
fl.l_start = 10; |
| 380 |
fl.l_len = 1000; |
| 381 |
fl.l_pid = pid; |
| 382 |
fl.l_type = F_UNLCK; |
| 383 |
fl.l_whence = SEEK_SET; |
| 384 |
fl.l_sysid = 0; |
| 385 |
ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); |
| 386 |
leak(fd); |
| 387 |
} |
| 388 |
|
| 346 |
/* Set a new lock with FUSE_SETLK */ |
389 |
/* Set a new lock with FUSE_SETLK */ |
| 347 |
TEST_F(Setlk, set) |
390 |
TEST_F(Setlk, set) |
| 348 |
{ |
391 |
{ |
|
Lines 465-471
TEST_F(Setlkw, set)
Link Here
|
| 465 |
|
508 |
|
| 466 |
expect_lookup(RELPATH, ino); |
509 |
expect_lookup(RELPATH, ino); |
| 467 |
expect_open(ino, 0, 1); |
510 |
expect_open(ino, 0, 1); |
| 468 |
expect_setlk(ino, pid, 10, 1009, F_RDLCK, 0); |
511 |
expect_setlkw(ino, pid, 10, 1009, F_RDLCK, 0); |
| 469 |
|
512 |
|
| 470 |
fd = open(FULLPATH, O_RDWR); |
513 |
fd = open(FULLPATH, O_RDWR); |
| 471 |
ASSERT_LE(0, fd) << strerror(errno); |
514 |
ASSERT_LE(0, fd) << strerror(errno); |