android_kernel_oneplus_msm8998/include/linux/usb/f_mtp.h
Hemant Kumar ff1259b38e USB: gadget: Implement COMPAT_IOCTL for ioctls
32-bit userspace calling into 64-bit kernel
cause different ioctl codes to get generated.
The different ioctl code gets generated
because sizeof is used on mtp and accessory
structures which is different for 32/64
compilation. Because of this, 64-bit kernel
can never execute the right ioctl command.

Implement compat_ioctl to handle such
execution environment.

Change-Id: I26cc10986e28a28eab6f3c65f28f4d2b808112d9
Signed-off-by: Sujeet Kumar <ksujeet@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2016-06-10 15:14:01 -07:00

53 lines
1.4 KiB
C

/*
* Gadget Function Driver for MTP
*
* Copyright (C) 2010 Google, Inc.
* Author: Mike Lockwood <lockwood@android.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __LINUX_USB_F_MTP_H
#define __LINUX_USB_F_MTP_H
#include <uapi/linux/usb/f_mtp.h>
#include <linux/ioctl.h>
#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif
#ifdef __KERNEL__
#ifdef CONFIG_COMPAT
struct __compat_mtp_file_range {
compat_int_t fd;
compat_loff_t offset;
int64_t length;
uint16_t command;
uint32_t transaction_id;
};
struct __compat_mtp_event {
compat_size_t length;
compat_caddr_t data;
};
#define COMPAT_MTP_SEND_FILE _IOW('M', 0, \
struct __compat_mtp_file_range)
#define COMPAT_MTP_RECEIVE_FILE _IOW('M', 1, \
struct __compat_mtp_file_range)
#define COMPAT_MTP_SEND_EVENT _IOW('M', 3, \
struct __compat_mtp_event)
#define COMPAT_MTP_SEND_FILE_WITH_HEADER _IOW('M', 4, \
struct __compat_mtp_file_range)
#endif
#endif
#endif /* __LINUX_USB_F_MTP_H */