Commit ca49321f authored by Andries E. Brouwer's avatar Andries E. Brouwer Committed by Linus Torvalds

[PATCH] struct loop_info64 with __u64

(i) Replace in struct loop_info the dev_t field by __kernel_old_dev_t,
where this type is defined in <asm/posix_types.h>, so that problems
with a differently sized dev_t in userspace are avoided.

(ii) Introduce a new loop_info64, with __u64 device, inode and offset
fields.
parent 24ebdc14
This diff is collapsed.
...@@ -40,6 +40,8 @@ typedef __kernel_gid_t __kernel_old_gid_t; ...@@ -40,6 +40,8 @@ typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_uid_t __kernel_uid32_t; typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t; typedef __kernel_gid_t __kernel_gid32_t;
typedef unsigned int __kernel_old_dev_t;
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifndef __GNUC__ #ifndef __GNUC__
......
...@@ -45,6 +45,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -45,6 +45,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -38,6 +38,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -38,6 +38,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -43,6 +43,8 @@ typedef __kernel_gid_t __kernel_old_gid_t; ...@@ -43,6 +43,8 @@ typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_uid_t __kernel_uid32_t; typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t; typedef __kernel_gid_t __kernel_gid32_t;
typedef unsigned int __kernel_old_dev_t;
# ifdef __KERNEL__ # ifdef __KERNEL__
# ifndef __GNUC__ # ifndef __GNUC__
......
...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -39,6 +39,7 @@ typedef int __kernel_uid32_t; ...@@ -39,6 +39,7 @@ typedef int __kernel_uid32_t;
typedef int __kernel_gid32_t; typedef int __kernel_gid32_t;
typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_uid_t __kernel_old_uid_t;
typedef __kernel_gid_t __kernel_old_gid_t; typedef __kernel_gid_t __kernel_old_gid_t;
typedef unsigned int __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -39,6 +39,7 @@ typedef int __kernel_uid32_t; ...@@ -39,6 +39,7 @@ typedef int __kernel_uid32_t;
typedef int __kernel_gid32_t; typedef int __kernel_gid32_t;
typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_uid_t __kernel_old_uid_t;
typedef __kernel_gid_t __kernel_old_gid_t; typedef __kernel_gid_t __kernel_old_gid_t;
typedef unsigned int __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -45,6 +45,8 @@ typedef long long __kernel_off64_t; ...@@ -45,6 +45,8 @@ typedef long long __kernel_off64_t;
typedef unsigned long long __kernel_ino64_t; typedef unsigned long long __kernel_ino64_t;
#endif #endif
typedef unsigned int __kernel_old_dev_t;
typedef struct { typedef struct {
#if defined(__KERNEL__) || defined(__USE_ALL) #if defined(__KERNEL__) || defined(__USE_ALL)
int val[2]; int val[2];
......
...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -33,6 +33,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned int __kernel_old_uid_t; typedef unsigned int __kernel_old_uid_t;
typedef unsigned int __kernel_old_gid_t; typedef unsigned int __kernel_old_gid_t;
typedef unsigned int __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -39,6 +39,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -39,6 +39,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned int __kernel_old_uid_t; typedef unsigned int __kernel_old_uid_t;
typedef unsigned int __kernel_old_gid_t; typedef unsigned int __kernel_old_gid_t;
typedef unsigned long __kernel_old_dev_t;
typedef struct { typedef struct {
int val[2]; int val[2];
......
...@@ -47,6 +47,7 @@ typedef unsigned int __kernel_uid32_t; ...@@ -47,6 +47,7 @@ typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t; typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#else /* __s390x__ */ #else /* __s390x__ */
......
...@@ -31,6 +31,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -31,6 +31,7 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long __kernel_loff_t; typedef long long __kernel_loff_t;
......
...@@ -31,6 +31,7 @@ typedef unsigned int __kernel_uid32_t; ...@@ -31,6 +31,7 @@ typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t; typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t; typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
typedef int __kernel_clockid_t; typedef int __kernel_clockid_t;
typedef int __kernel_timer_t; typedef int __kernel_timer_t;
......
...@@ -34,6 +34,8 @@ typedef __kernel_gid_t __kernel_old_gid_t; ...@@ -34,6 +34,8 @@ typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_uid_t __kernel_uid32_t; typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t; typedef __kernel_gid_t __kernel_gid32_t;
typedef unsigned int __kernel_old_dev_t;
/* Note this piece of asymmetry from the v9 ABI. */ /* Note this piece of asymmetry from the v9 ABI. */
typedef int __kernel_suseconds_t; typedef int __kernel_suseconds_t;
......
...@@ -42,7 +42,7 @@ typedef unsigned int __kernel_gid32_t; ...@@ -42,7 +42,7 @@ typedef unsigned int __kernel_gid32_t;
/* Some bogus code depends on this; we don't care. */ /* Some bogus code depends on this; we don't care. */
typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_uid_t __kernel_old_uid_t;
typedef unsigned int __kernel_old_dev_t;
typedef struct { typedef struct {
#if defined(__KERNEL__) || defined(__USE_ALL) #if defined(__KERNEL__) || defined(__USE_ALL)
......
...@@ -22,8 +22,8 @@ typedef long __kernel_ptrdiff_t; ...@@ -22,8 +22,8 @@ typedef long __kernel_ptrdiff_t;
typedef long __kernel_time_t; typedef long __kernel_time_t;
typedef long __kernel_suseconds_t; typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t; typedef long __kernel_clock_t;
typedef int __kernel_timer_t; typedef int __kernel_timer_t;
typedef int __kernel_clockid_t; typedef int __kernel_clockid_t;
typedef int __kernel_daddr_t; typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t; typedef char * __kernel_caddr_t;
typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_uid16_t;
...@@ -42,6 +42,8 @@ typedef __kernel_gid_t __kernel_old_gid_t; ...@@ -42,6 +42,8 @@ typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_uid_t __kernel_uid32_t; typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t; typedef __kernel_gid_t __kernel_gid32_t;
typedef unsigned long __kernel_old_dev_t;
#ifdef __KERNEL__ #ifdef __KERNEL__
#undef __FD_SET #undef __FD_SET
......
#ifndef _LINUX_LOOP_H #ifndef _LINUX_LOOP_H
#define _LINUX_LOOP_H #define _LINUX_LOOP_H
#include <linux/kdev_t.h>
/* /*
* include/linux/loop.h * include/linux/loop.h
* *
...@@ -74,34 +72,37 @@ typedef int (* transfer_proc_t)(struct loop_device *, int cmd, ...@@ -74,34 +72,37 @@ typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
#define LO_FLAGS_READ_ONLY 2 #define LO_FLAGS_READ_ONLY 2
#define LO_FLAGS_BH_REMAP 4 #define LO_FLAGS_BH_REMAP 4
/* #include <asm/posix_types.h> /* for __kernel_old_dev_t */
* Note that this structure gets the wrong offsets when directly used #include <asm/types.h> /* for __u64 */
* from a glibc program, because glibc has a 32bit dev_t.
* Prevent people from shooting in their own foot.
*/
#if __GLIBC__ >= 2 && !defined(dev_t)
#error "Wrong dev_t in loop.h"
#endif
/*
* This uses kdev_t because glibc currently has no appropiate
* conversion version for the loop ioctls.
* The situation is very unpleasant
*/
/* Backwards compatibility version */
struct loop_info { struct loop_info {
int lo_number; /* ioctl r/o */ int lo_number; /* ioctl r/o */
dev_t lo_device; /* ioctl r/o */ __kernel_old_dev_t lo_device; /* ioctl r/o */
unsigned long lo_inode; /* ioctl r/o */ unsigned long lo_inode; /* ioctl r/o */
dev_t lo_rdevice; /* ioctl r/o */ __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
int lo_offset; int lo_offset;
int lo_encrypt_type; int lo_encrypt_type;
int lo_encrypt_key_size; /* ioctl w/o */ int lo_encrypt_key_size; /* ioctl w/o */
int lo_flags; /* ioctl r/o */ int lo_flags; /* ioctl r/o */
char lo_name[LO_NAME_SIZE]; char lo_name[LO_NAME_SIZE];
unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
unsigned long lo_init[2]; unsigned long lo_init[2];
char reserved[4]; char reserved[4];
};
struct loop_info64 {
__u64 lo_device; /* ioctl r/o */
__u64 lo_inode; /* ioctl r/o */
__u64 lo_rdevice; /* ioctl r/o */
__u64 lo_offset;
__u32 lo_number; /* ioctl r/o */
__u32 lo_encrypt_type;
__u32 lo_encrypt_key_size; /* ioctl w/o */
__u32 lo_flags; /* ioctl r/o */
__u8 lo_name[LO_NAME_SIZE];
__u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
__u64 lo_init[2];
}; };
/* /*
...@@ -125,7 +126,7 @@ struct loop_func_table { ...@@ -125,7 +126,7 @@ struct loop_func_table {
int number; /* filter type */ int number; /* filter type */
int (*transfer)(struct loop_device *lo, int cmd, char *raw_buf, int (*transfer)(struct loop_device *lo, int cmd, char *raw_buf,
char *loop_buf, int size, sector_t real_block); char *loop_buf, int size, sector_t real_block);
int (*init)(struct loop_device *, struct loop_info *); int (*init)(struct loop_device *, const struct loop_info64 *);
/* release is called from loop_unregister_transfer or clr_fd */ /* release is called from loop_unregister_transfer or clr_fd */
int (*release)(struct loop_device *); int (*release)(struct loop_device *);
int (*ioctl)(struct loop_device *, int cmd, unsigned long arg); int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
...@@ -134,7 +135,7 @@ struct loop_func_table { ...@@ -134,7 +135,7 @@ struct loop_func_table {
void (*unlock)(struct loop_device *); void (*unlock)(struct loop_device *);
}; };
int loop_register_transfer(struct loop_func_table *funcs); int loop_register_transfer(struct loop_func_table *funcs);
int loop_unregister_transfer(int number); int loop_unregister_transfer(int number);
#endif #endif
...@@ -142,9 +143,11 @@ int loop_unregister_transfer(int number); ...@@ -142,9 +143,11 @@ int loop_unregister_transfer(int number);
* IOCTL commands --- we will commandeer 0x4C ('L') * IOCTL commands --- we will commandeer 0x4C ('L')
*/ */
#define LOOP_SET_FD 0x4C00 #define LOOP_SET_FD 0x4C00
#define LOOP_CLR_FD 0x4C01 #define LOOP_CLR_FD 0x4C01
#define LOOP_SET_STATUS 0x4C02 #define LOOP_SET_STATUS 0x4C02
#define LOOP_GET_STATUS 0x4C03 #define LOOP_GET_STATUS 0x4C03
#define LOOP_SET_STATUS64 0x4C04
#define LOOP_GET_STATUS64 0x4C05
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment