Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/tests/sys/sendfile_test.c
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | verify_source_and_dest(const char* dest_filename, int src_fd, off_t offset, | ||||
/* | /* | ||||
* Per sendfile(2), "send the whole file" (paraphrased). This means | * Per sendfile(2), "send the whole file" (paraphrased). This means | ||||
* that we need to grab the file size, as passing in length = 0 with | * that we need to grab the file size, as passing in length = 0 with | ||||
* mmap(2) will result in a failure with EINVAL (length = 0 is invalid). | * mmap(2) will result in a failure with EINVAL (length = 0 is invalid). | ||||
*/ | */ | ||||
length = (nbytes == 0) ? (size_t)(src_file_size - offset) : nbytes; | length = (nbytes == 0) ? (size_t)(src_file_size - offset) : nbytes; | ||||
ATF_REQUIRE_EQ_MSG(dest_file_size, length, | ATF_REQUIRE_EQ_MSG(dest_file_size, length, | ||||
"number of bytes written out to %s (%ju) doesn't match the " | "number of bytes written out to %s (%zu) doesn't match the " | ||||
"expected number of bytes (%ju)", dest_filename, dest_file_size, | "expected number of bytes (%zu)", dest_filename, dest_file_size, | ||||
length); | length); | ||||
ATF_REQUIRE_EQ_MSG(0, lseek(src_fd, offset, SEEK_SET), | ATF_REQUIRE_EQ_MSG(0, lseek(src_fd, offset, SEEK_SET), | ||||
"lseek failed: %s", strerror(errno)); | "lseek failed: %s", strerror(errno)); | ||||
dest_pointer = mmap(NULL, length, PROT_READ, MAP_PRIVATE, dest_fd, 0); | dest_pointer = mmap(NULL, length, PROT_READ, MAP_PRIVATE, dest_fd, 0); | ||||
ATF_REQUIRE_MSG(dest_pointer != MAP_FAILED, "mmap failed: %s", | ATF_REQUIRE_MSG(dest_pointer != MAP_FAILED, "mmap failed: %s", | ||||
strerror(errno)); | strerror(errno)); | ||||
▲ Show 20 Lines • Show All 845 Lines • Show Last 20 Lines |