mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
tests: do not try to read more than packet in AutoFS test
The intention was to make sure, that only one packet is sent at a time.
And thus read has to return exactly the size of one packet.
But it doesnt' work as expected, because size of autofs_v5_packet_union
differs on 32 bit and 64 bit architectures.
This is a bug, but it's hidden so deeply, that no one really cares by the
following 2 aspects:
1) Autofs pipe has O_DIRECT flag, which means excess bytes will be discarded
upon read.
2) No one tries to read more than one packet size at a time.
So let's fix the test instead and do not try to read more bytes, than
expected.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
7148e16b31
commit
a58330a26b
1 changed files with 5 additions and 8 deletions
|
|
@ -460,7 +460,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
|
|||
{
|
||||
union autofs_v5_packet_union *packet;
|
||||
ssize_t bytes;
|
||||
size_t psize = sizeof(*packet) + 1;
|
||||
size_t psize = sizeof(*packet);
|
||||
int err = 0;
|
||||
|
||||
packet = malloc(psize);
|
||||
|
|
@ -473,7 +473,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
|
|||
siginterrupt(SIGUSR2, 1);
|
||||
|
||||
while (!stop && !err) {
|
||||
memset(packet, 0, sizeof(*packet));
|
||||
memset(packet, 0, psize);
|
||||
|
||||
bytes = read(pipe, packet, psize);
|
||||
if (bytes < 0) {
|
||||
|
|
@ -483,12 +483,9 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if (bytes == psize) {
|
||||
pr_err("read more that expected\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (bytes != sizeof(*packet)) {
|
||||
pr_err("read less than expected: %zd\n", bytes);
|
||||
if (bytes != psize) {
|
||||
pr_err("read less than expected: %zd < %zd\n",
|
||||
bytes, psize);
|
||||
return -EINVAL;
|
||||
}
|
||||
err = automountd_serve(mountpoint, param, packet);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue