From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v5 1/2] splice02: Generate input in C
Date: Tue, 20 Apr 2021 11:21:01 +0200 [thread overview]
Message-ID: <YH6c/cm9uY0QRrbu@yuki> (raw)
In-Reply-To: <20210420084410.16179-1-pvorel@suse.cz>
Hi!
> SAFE_CLOSE(fd);
> + fd = SAFE_OPEN(TEST_FILENAME, O_RDONLY);
> + to_check = st.st_size;
> +
> + psize = sysconf(_SC_PAGESIZE);
> +
> + tst_res(TINFO, "checking file content");
> + do {
> + i = 0;
> + size = to_check > psize ? psize : to_check;
> +
> + map = SAFE_MMAP(NULL, size, PROT_READ, MAP_PRIVATE, fd,
> + st.st_size - to_check);
Huh, why do we loop backward over the file?
Maybe we can just do simple loop here that would be easier to
understand:
blocks = LTP_ALIGN(st.st_size, page_size) / page_size;
for (block = 0; block < blocks; block++) {
map = SAFE_MMAP(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, block * pagesize);
to_check = (block+1) * page_size < st.st_size ? page_size : st.st_size % page_size;
for (i = 0; i < to_check; i++) {
if (map[i] != get_letter(block * page_size + i))
fail++;
}
SAFE_MUNMAP(map, size);
}
[Beware I haven't tested the code :-)]
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-04-20 9:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 8:44 [LTP] [PATCH v5 1/2] splice02: Generate input in C Petr Vorel
2021-04-20 8:44 ` [LTP] [PATCH v5 2/2] commands: Add shell pipe test Petr Vorel
2021-04-20 9:21 ` Cyril Hrubis [this message]
2021-04-20 16:57 ` [LTP] [PATCH v5 1/2] splice02: Generate input in C Petr Vorel
2021-04-21 9:40 ` Cyril Hrubis
2021-04-21 10:04 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YH6c/cm9uY0QRrbu@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox