Re: compat ioctl32 for /dev/snapshot?

Michael Tokarev
2009-05-04T22:26:40Z

Arnd Bergmann wrote:
> On Monday 04 May 2009, Michael Tokarev wrote:
>> Is the following patch ok? I just pulled all the SNAPSHOT_* stuff from
>> include/linux/suspend_ioctls.h and added them into fs/compat_ioctl.c.
[]

> You are however missing support for deprecated ioctls in your
> code: SNAPSHOT_SET_SWAP_FILE and SNAPSHOT_PMOPS are trivial
> (COMPATIBLE_IOCTL), but you also need to add support for
> these

Well, as comments in that file (kernel/power/user.c) states, those
ioctls are obsolete and will be removed and are only preserved for
compatibility etc. Since no one complained so far (well, no one
complained about whole /dev/snapshot thing at all ;), maybe there's
no need to define those and the following ones too?

> #define SNAPSHOT_ATOMIC_SNAPSHOT32 _IOW(SNAPSHOT_IOC_MAGIC, 3, compat_uptr_t)
> #define SNAPSHOT_SET_IMAGE_SIZE32 _IOW(SNAPSHOT_IOC_MAGIC, 6, compat_ulong)
> #define SNAPSHOT_AVAIL_SWAP32 _IOR(SNAPSHOT_IOC_MAGIC, 7, compat_uptr_t)
> #define SNAPSHOT_GET_SWAP_PAGE32 _IOR(SNAPSHOT_IOC_MAGIC, 8, compat_uptr_t)
>
>> I can't test it so far, because uswsusp tools are broken in mixed
>> 32/64bit case in other places. But at least it compiles fine and
>> does not complain anymore.
>
> I try to reduce the size of compat_ioctl.c. A better implementation
> would be to add a ->compat_ioctl() operation to the file_operations
> and list the compatible ioctl numbers as well.

Well, your way is definitely a lot cleaner. But I didn't know about
either of them anyway :)

> Please try this patch instead:

Ok. Your patch was garbled by your MUA (inserting =3D =20 and breaking
lines), but that's ok. After de-garbling it now complains about
undefined compat_uptr_t. For that, I've added

#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif

at the end of the file. Also there was a typo (duplicated above),
compat_ulong should be compat_ulong_t. After all that it finally
compiles. As of "works" -- the above my comment still applies,
uswsusp for one is badly broken on 32/64 bits. I'm trying to
create a simpler test-case, as time permits.

Thanks!

/mjt