Lines 565-577
Link Here
|
565 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
565 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
566 |
const char RELPATH[] = "some_file.txt"; |
566 |
const char RELPATH[] = "some_file.txt"; |
567 |
const uint64_t ino = 42; |
567 |
const uint64_t ino = 42; |
568 |
const timespec oldtimes[2] = { |
568 |
const timespec newtimes[2] = { |
569 |
{.tv_sec = 1, .tv_nsec = 2}, |
569 |
{.tv_sec = 1, .tv_nsec = 2}, |
570 |
{.tv_sec = 3, .tv_nsec = 4}, |
570 |
{.tv_sec = 3, .tv_nsec = 4}, |
571 |
}; |
571 |
}; |
572 |
const timespec newtimes[2] = { |
572 |
const timespec oldtimes[3] = { |
573 |
{.tv_sec = 5, .tv_nsec = 6}, |
573 |
{.tv_sec = 5, .tv_nsec = 6}, |
574 |
{.tv_sec = 7, .tv_nsec = 8}, |
574 |
{.tv_sec = 7, .tv_nsec = 8}, |
|
|
575 |
{.tv_sec = 9, .tv_nsec = 10}, |
575 |
}; |
576 |
}; |
576 |
|
577 |
|
577 |
EXPECT_LOOKUP(1, RELPATH) |
578 |
EXPECT_LOOKUP(1, RELPATH) |
Lines 584-595
Link Here
|
584 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
585 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
585 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
586 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
586 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
587 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
|
|
588 |
out.body.entry.attr.crtime = oldtimes[2].tv_sec; |
589 |
out.body.entry.attr.crtimensec = oldtimes[2].tv_nsec; |
587 |
}))); |
590 |
}))); |
588 |
|
591 |
|
589 |
EXPECT_CALL(*m_mock, process( |
592 |
EXPECT_CALL(*m_mock, process( |
590 |
ResultOf([=](auto in) { |
593 |
ResultOf([=](auto in) { |
591 |
/* In protocol 7.23, ctime will be changed too */ |
594 |
/* In protocol 7.23, ctime will be changed too */ |
592 |
uint32_t valid = FATTR_ATIME | FATTR_MTIME; |
595 |
uint32_t valid = FATTR_ATIME | FATTR_MTIME | |
|
|
596 |
FATTR_CRTIME; |
593 |
return (in.header.opcode == FUSE_SETATTR && |
597 |
return (in.header.opcode == FUSE_SETATTR && |
594 |
in.header.nodeid == ino && |
598 |
in.header.nodeid == ino && |
595 |
in.body.setattr.valid == valid && |
599 |
in.body.setattr.valid == valid && |
Lines 598-603
Link Here
|
598 |
newtimes[0].tv_nsec && |
602 |
newtimes[0].tv_nsec && |
599 |
in.body.setattr.mtime == newtimes[1].tv_sec && |
603 |
in.body.setattr.mtime == newtimes[1].tv_sec && |
600 |
in.body.setattr.mtimensec == |
604 |
in.body.setattr.mtimensec == |
|
|
605 |
newtimes[1].tv_nsec && |
606 |
/* |
607 |
* birthtime can't be set directly. Instead, |
608 |
* it's set to the older of the old birthtime |
609 |
* and the new mtime |
610 |
*/ |
611 |
in.body.setattr.crtime == newtimes[1].tv_sec && |
612 |
in.body.setattr.crtimensec == |
601 |
newtimes[1].tv_nsec); |
613 |
newtimes[1].tv_nsec); |
602 |
}, Eq(true)), |
614 |
}, Eq(true)), |
603 |
_) |
615 |
_) |
Lines 609-627
Link Here
|
609 |
out.body.attr.attr.atimensec = newtimes[0].tv_nsec; |
621 |
out.body.attr.attr.atimensec = newtimes[0].tv_nsec; |
610 |
out.body.attr.attr.mtime = newtimes[1].tv_sec; |
622 |
out.body.attr.attr.mtime = newtimes[1].tv_sec; |
611 |
out.body.attr.attr.mtimensec = newtimes[1].tv_nsec; |
623 |
out.body.attr.attr.mtimensec = newtimes[1].tv_nsec; |
|
|
624 |
out.body.attr.attr.crtime = newtimes[1].tv_sec; |
625 |
out.body.attr.attr.crtimensec = newtimes[1].tv_nsec; |
612 |
}))); |
626 |
}))); |
|
|
627 |
|
628 |
//struct stat sb; |
629 |
//EXPECT_EQ(0, stat(FULLPATH, &sb)); |
630 |
//printf("atime=%ld.%ld\t", sb.st_atim.tv_sec, sb.st_atim.tv_nsec); |
631 |
//printf("mtime=%ld.%ld\t", sb.st_mtim.tv_sec, sb.st_mtim.tv_nsec); |
632 |
//printf("birthtime=%ld.%ld\n", sb.st_birthtim.tv_sec, sb.st_birthtim.tv_nsec); |
613 |
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0)) |
633 |
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0)) |
614 |
<< strerror(errno); |
634 |
<< strerror(errno); |
615 |
} |
635 |
} |
616 |
|
636 |
|
617 |
/* Change a file mtime but not its atime */ |
637 |
/* Change a file's mtime but not its atime */ |
618 |
TEST_F(Setattr, utimensat_mtime_only) { |
638 |
TEST_F(Setattr, utimensat_mtime_only) { |
619 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
639 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
620 |
const char RELPATH[] = "some_file.txt"; |
640 |
const char RELPATH[] = "some_file.txt"; |
621 |
const uint64_t ino = 42; |
641 |
const uint64_t ino = 42; |
622 |
const timespec oldtimes[2] = { |
642 |
const timespec oldtimes[3] = { |
623 |
{.tv_sec = 1, .tv_nsec = 2}, |
643 |
{.tv_sec = 1, .tv_nsec = 2}, |
624 |
{.tv_sec = 3, .tv_nsec = 4}, |
644 |
{.tv_sec = 3, .tv_nsec = 4}, |
|
|
645 |
{.tv_sec = 1, .tv_nsec = 1}, |
625 |
}; |
646 |
}; |
626 |
const timespec newtimes[2] = { |
647 |
const timespec newtimes[2] = { |
627 |
{.tv_sec = 5, .tv_nsec = UTIME_OMIT}, |
648 |
{.tv_sec = 5, .tv_nsec = UTIME_OMIT}, |
Lines 638-643
Link Here
|
638 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
659 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
639 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
660 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
640 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
661 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
|
|
662 |
out.body.entry.attr.crtime = oldtimes[2].tv_sec; |
663 |
out.body.entry.attr.crtimensec = oldtimes[2].tv_nsec; |
641 |
}))); |
664 |
}))); |
642 |
|
665 |
|
643 |
EXPECT_CALL(*m_mock, process( |
666 |
EXPECT_CALL(*m_mock, process( |
Lines 675-683
Link Here
|
675 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
698 |
const char FULLPATH[] = "mountpoint/some_file.txt"; |
676 |
const char RELPATH[] = "some_file.txt"; |
699 |
const char RELPATH[] = "some_file.txt"; |
677 |
const uint64_t ino = 42; |
700 |
const uint64_t ino = 42; |
678 |
const timespec oldtimes[2] = { |
701 |
const timespec oldtimes[3] = { |
679 |
{.tv_sec = 1, .tv_nsec = 2}, |
702 |
{.tv_sec = 1, .tv_nsec = 2}, |
680 |
{.tv_sec = 3, .tv_nsec = 4}, |
703 |
{.tv_sec = 3, .tv_nsec = 4}, |
|
|
704 |
{.tv_sec = 5, .tv_nsec = 6}, |
681 |
}; |
705 |
}; |
682 |
const timespec newtimes[2] = { |
706 |
const timespec newtimes[2] = { |
683 |
{.tv_sec = 0, .tv_nsec = UTIME_NOW}, |
707 |
{.tv_sec = 0, .tv_nsec = UTIME_NOW}, |
Lines 701-706
Link Here
|
701 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
725 |
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec; |
702 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
726 |
out.body.entry.attr.mtime = oldtimes[1].tv_sec; |
703 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
727 |
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec; |
|
|
728 |
out.body.entry.attr.crtime = oldtimes[2].tv_sec; |
729 |
out.body.entry.attr.crtimensec = oldtimes[2].tv_nsec; |
704 |
}))); |
730 |
}))); |
705 |
|
731 |
|
706 |
EXPECT_CALL(*m_mock, process( |
732 |
EXPECT_CALL(*m_mock, process( |