On Wed, Nov 16, 2011 at 10:24:23AM +0600, Roman Mamedov wrote:
> Hello,
>
> I have just tried the version from Squeeze (1.41.12-4stable1), and it does
> work properly
Yes, that's not surprising. The 1.41 version doesn't try to use the
new-style resize2fs ioctl. The fundamental issue is what error code
should be returned when an ioctl doesn't exist. Note:
% file /tmp/bad-ioctl-32 /tmp/bad-ioctl-64
/tmp/bad-ioctl-32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26, not stripped
/tmp/bad-ioctl-64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
% /tmp/bad-ioctl-64 file
ENOTTY is 25
EINVAL is 22
ioctl 0xDEAD1FFFF returns 25 (Inappropriate ioctl for device)
% /tmp/bad-ioctl-32 file
ENOTTY is 25
EINVAL is 22
ioctl 0xDEAD1FFFF returns 22 (Invalid argument)
The issue is the kernel is returning a different error code when you
are using a 32-bit binary with a 64-bit kernel, which you are doing on
your MIPS system. So this is a mips-specific bug, and arguably its a
kernel-level problem. We can work around it by checking for EINVAL,
but that's unfortunate since EINVAL can mean other things ---
including its canonical "Invalid argument".
- Ted
/*
* bad-ioctl.c - try calling a non-existent ioctl, and see what happens
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
int fd;
fd = open(argv[1], O_RDONLY, 0);
if (fd < 0) {
perror("open");
exit(1);
}
printf("ENOTTY is %d\n", ENOTTY);
printf("EINVAL is %d\n", EINVAL);
if (ioctl(fd, (unsigned) 0xDEAD1FFFF, 0) < 0) {
int err = errno;
fprintf(stderr, "ioctl 0xDEAD1FFFF returns %d (%s)\n",
err, strerror(err));
exit(1);
}
return 0;
}
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]