2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 21:07:43 +00:00

zdtm/memfd00: test memfd file mode

Signed-off-by: Michał Mirosław <emmir@google.com>
This commit is contained in:
Michał Mirosław 2023-07-27 21:30:26 +02:00 committed by Andrei Vagin
parent dfa5410951
commit 3628589b51

View File

@ -30,8 +30,10 @@ int main(int argc, char *argv[])
{
int fd, fl_flags1, fl_flags2, fd_flags1, fd_flags2;
struct statfs statfs1, statfs2;
struct stat stat;
off_t pos1, pos2;
char buf[5];
int fmode1, fmode2;
test_init(argc, argv);
@ -58,6 +60,13 @@ int main(int argc, char *argv[])
if (lseek(fd, pos1, SEEK_SET) < 0)
err(1, "seek error");
if (fchmod(fd, 0642))
err(1, "Can't set permission bits");
if (fstat(fd, &stat) < 0)
err(1, "fstat() issue");
fmode1 = stat.st_mode;
test_daemon();
test_waitsig();
@ -85,6 +94,15 @@ int main(int argc, char *argv[])
return 1;
}
if (fstat(fd, &stat) < 0)
err(1, "fstat() issue");
fmode2 = stat.st_mode;
if (fmode1 != fmode2) {
fail("stat.st_mode = %#o != %#o", fmode2, fmode1);
return 1;
}
pos2 = lseek(fd, 0, SEEK_CUR);
if (pos1 != pos2) {
fail("position differs");