linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] struct loop_info
@ 2003-04-17 23:34 Andries.Brouwer
  2003-04-18  0:22 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andries.Brouwer @ 2003-04-17 23:34 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-kernel

Until now as the source already says, we had a very unpleasant
situation with struct loop_info:

-/* 
- * Note that this structure gets the wrong offsets when directly used
- * 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        
- */

In the patch below I remove the definition for this struct from
<linux/loop.h> and put it in <asm/loopinfo.h>.
In this struct the occurrences of dev_t have been replaced by their
actual values (short int / int / long int).

This part of the patch ends the unpleasant situation: userspace
can use this definition without gymnastics like

#include <linux/posix_types.h>
#undef dev_t
#define dev_t __kernel_dev_t
#include <linux/loop.h>
#undef dev_t


The second part of this patch adds a new struct loop_info2
in <linux/loop.h> identical to the old struct but with
unsigned long long instead of dev_t.
Now kernel and userspace use the same struct, simplifying life.

Unfortunately for compatibility some translation between
loop_info and loop_info2 is required.

Andries

---------------------------------------------------------------
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/block/loop.c b/drivers/block/loop.c
--- a/drivers/block/loop.c	Tue Mar 25 04:54:31 2003
+++ b/drivers/block/loop.c	Fri Apr 18 00:57:31 2003
@@ -120,13 +120,13 @@
 	return 0;
 }
 
-static int none_status(struct loop_device *lo, struct loop_info *info)
+static int none_status(struct loop_device *lo, const struct loop_info2 *info)
 {
 	lo->lo_flags |= LO_FLAGS_BH_REMAP;
 	return 0;
 }
 
-static int xor_status(struct loop_device *lo, struct loop_info *info)
+static int xor_status(struct loop_device *lo, const struct loop_info2 *info)
 {
 	if (info->lo_encrypt_key_size <= 0)
 		return -EINVAL;
@@ -215,7 +215,8 @@
 			 * The transfer failed, but we still write the data to
 			 * keep prepare/commit calls balanced.
 			 */
-			printk(KERN_ERR "loop: transfer error block %llu\n", (unsigned long long)index);
+			printk(KERN_ERR "loop: transfer error block %llu\n",
+			       (unsigned long long)index);
 			memset(kaddr + offset, 0, size);
 		}
 		flush_dcache_page(page);
@@ -270,7 +271,9 @@
 	int bsize;
 };
 
-static int lo_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size)
+static int
+lo_read_actor(read_descriptor_t *desc, struct page *page,
+	      unsigned long offset, unsigned long size)
 {
 	char *kaddr;
 	unsigned long count = desc->count;
@@ -284,7 +287,8 @@
 	kaddr = kmap(page);
 	if (lo_do_transfer(lo, READ, kaddr + offset, p->data, size, IV)) {
 		size = 0;
-		printk(KERN_ERR "loop: transfer error block %ld\n",page->index);
+		printk(KERN_ERR "loop: transfer error block %ld\n",
+		       page->index);
 		desc->error = -EINVAL;
 	}
 	kunmap(page);
@@ -297,7 +301,7 @@
 
 static int
 do_lo_receive(struct loop_device *lo,
-		struct bio_vec *bvec, int bsize, loff_t pos)
+	      struct bio_vec *bvec, int bsize, loff_t pos)
 {
 	struct lo_read_data cookie;
 	struct file *file;
@@ -330,8 +334,8 @@
 	return ret;
 }
 
-static inline unsigned long loop_get_iv(struct loop_device *lo,
-					unsigned long sector)
+static inline unsigned long
+loop_get_iv(struct loop_device *lo, unsigned long sector)
 {
 	int bs = lo->lo_blocksize;
 	unsigned long offset, IV;
@@ -358,6 +362,7 @@
 }
 
 static int loop_end_io_transfer(struct bio *, unsigned int, int);
+
 static void loop_put_buffer(struct bio *bio)
 {
 	/*
@@ -764,7 +769,8 @@
 	return err;
 }
 
-static int loop_init_xfer(struct loop_device *lo, int type,struct loop_info *i)
+static int
+loop_init_xfer(struct loop_device *lo, int type, const struct loop_info2 *i)
 {
 	int err = 0; 
 	if (type) {
@@ -822,9 +828,9 @@
 	return 0;
 }
 
-static int loop_set_status(struct loop_device *lo, struct loop_info *arg)
+static int
+loop_set_status(struct loop_device *lo, const struct loop_info2 *info)
 {
-	struct loop_info info; 
 	int err;
 	unsigned int type;
 	loff_t offset;
@@ -834,23 +840,21 @@
 		return -EPERM;
 	if (lo->lo_state != Lo_bound)
 		return -ENXIO;
-	if (copy_from_user(&info, arg, sizeof (struct loop_info)))
-		return -EFAULT; 
-	if ((unsigned int) info.lo_encrypt_key_size > LO_KEY_SIZE)
+	if ((unsigned int) info->lo_encrypt_key_size > LO_KEY_SIZE)
 		return -EINVAL;
-	type = info.lo_encrypt_type; 
+	type = info->lo_encrypt_type; 
 	if (type >= MAX_LO_CRYPT || xfer_funcs[type] == NULL)
 		return -EINVAL;
-	if (type == LO_CRYPT_XOR && info.lo_encrypt_key_size == 0)
+	if (type == LO_CRYPT_XOR && info->lo_encrypt_key_size == 0)
 		return -EINVAL;
 
 	err = loop_release_xfer(lo);
 	if (!err) 
-		err = loop_init_xfer(lo, type, &info);
+		err = loop_init_xfer(lo, type, info);
 
 	offset = lo->lo_offset;
-	if (offset != info.lo_offset) {
-		lo->lo_offset = info.lo_offset;
+	if (offset != info->lo_offset) {
+		lo->lo_offset = info->lo_offset;
 		if (figure_loop_size(lo)){
 			err = -EFBIG;
 			lo->lo_offset = offset;
@@ -860,51 +864,126 @@
 	if (err)
 		return err;	
 
-	strncpy(lo->lo_name, info.lo_name, LO_NAME_SIZE);
+	strncpy(lo->lo_name, info->lo_name, LO_NAME_SIZE);
 
 	lo->transfer = xfer_funcs[type]->transfer;
 	lo->ioctl = xfer_funcs[type]->ioctl;
-	lo->lo_encrypt_key_size = info.lo_encrypt_key_size;
-	lo->lo_init[0] = info.lo_init[0];
-	lo->lo_init[1] = info.lo_init[1];
-	if (info.lo_encrypt_key_size) {
-		memcpy(lo->lo_encrypt_key, info.lo_encrypt_key, 
-		       info.lo_encrypt_key_size);
+	lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
+	lo->lo_init[0] = info->lo_init[0];
+	lo->lo_init[1] = info->lo_init[1];
+	if (info->lo_encrypt_key_size) {
+		memcpy(lo->lo_encrypt_key, info->lo_encrypt_key, 
+		       info->lo_encrypt_key_size);
 		lo->lo_key_owner = current->uid; 
 	}	
 
 	return 0;
 }
 
-static int loop_get_status(struct loop_device *lo, struct loop_info *arg)
+static int
+loop_set_status1(struct loop_device *lo, const struct loop_info *arg)
 {
-	struct file *file = lo->lo_backing_file;
 	struct loop_info info;
+	struct loop_info2 info2;
+
+	if (copy_from_user(&info, arg, sizeof (struct loop_info)))
+		return -EFAULT;
+	info2.lo_number = info.lo_number;
+	info2.lo_device = info.lo_device;
+	info2.lo_inode = info.lo_inode;
+	info2.lo_rdevice = info.lo_rdevice;
+	info2.lo_offset = info.lo_offset;
+	info2.lo_encrypt_type = info.lo_encrypt_type;
+	info2.lo_encrypt_key_size = info.lo_encrypt_key_size;
+	info2.lo_flags = info.lo_flags;
+	info2.lo_init[0] = info.lo_init[0];
+	info2.lo_init[1] = info.lo_init[1];
+	memcpy(info2.lo_name, info.lo_name, LO_NAME_SIZE);
+	memcpy(info2.lo_encrypt_key, info.lo_encrypt_key, LO_KEY_SIZE);
+	return loop_set_status(lo, &info2);
+}
+
+static int
+loop_set_status2(struct loop_device *lo, const struct loop_info2 *arg)
+{
+	struct loop_info2 info2;
+
+	if (copy_from_user(&info2, arg, sizeof (struct loop_info2)))
+		return -EFAULT;
+	return loop_set_status(lo, &info2);
+}
+
+static int
+loop_get_status(struct loop_device *lo, struct loop_info2 *info)
+{
+	struct file *file = lo->lo_backing_file;
 	struct kstat stat;
 	int error;
 
 	if (lo->lo_state != Lo_bound)
 		return -ENXIO;
-	if (!arg)
-		return -EINVAL;
 	error = vfs_getattr(file->f_vfsmnt, file->f_dentry, &stat);
 	if (error)
 		return error;
-	memset(&info, 0, sizeof(info));
-	info.lo_number = lo->lo_number;
-	info.lo_device = stat.dev;
-	info.lo_inode = stat.ino;
-	info.lo_rdevice = lo->lo_device ? stat.rdev : stat.dev;
-	info.lo_offset = lo->lo_offset;
-	info.lo_flags = lo->lo_flags;
-	strncpy(info.lo_name, lo->lo_name, LO_NAME_SIZE);
-	info.lo_encrypt_type = lo->lo_encrypt_type;
+	memset(info, 0, sizeof(*info));
+	info->lo_number = lo->lo_number;
+	info->lo_device = stat.dev;
+	info->lo_inode = stat.ino;
+	info->lo_rdevice = lo->lo_device ? stat.rdev : stat.dev;
+	info->lo_offset = lo->lo_offset;
+	info->lo_flags = lo->lo_flags;
+	strncpy(info->lo_name, lo->lo_name, LO_NAME_SIZE);
+	info->lo_encrypt_type = lo->lo_encrypt_type;
 	if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
-		info.lo_encrypt_key_size = lo->lo_encrypt_key_size;
-		memcpy(info.lo_encrypt_key, lo->lo_encrypt_key,
+		info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
+		memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
 		       lo->lo_encrypt_key_size);
 	}
-	return copy_to_user(arg, &info, sizeof(info)) ? -EFAULT : 0;
+	return 0;
+}
+
+static int
+loop_get_status1(struct loop_device *lo, struct loop_info *arg) {
+	struct loop_info info;
+	struct loop_info2 info2;
+	int err;
+
+	err = loop_get_status(lo, &info2);
+	if (!err) {
+		info.lo_number = info2.lo_number;
+		info.lo_device = info2.lo_device;
+		info.lo_inode = info2.lo_inode;
+		info.lo_rdevice = info2.lo_rdevice;
+		info.lo_offset = info2.lo_offset;
+		info.lo_encrypt_type = info2.lo_encrypt_type;
+		info.lo_encrypt_key_size = info2.lo_encrypt_key_size;
+		info.lo_flags = info2.lo_flags;
+		info.lo_init[0] = info2.lo_init[0];
+		info.lo_init[1] = info2.lo_init[1];
+		memcpy(info.lo_name, info2.lo_name, LO_NAME_SIZE);
+		memcpy(info.lo_encrypt_key, info2.lo_encrypt_key, LO_KEY_SIZE);
+
+		if (info.lo_device != info2.lo_device ||
+		    info.lo_rdevice != info2.lo_rdevice)
+			err = -EOVERFLOW;
+	}
+
+	if (!err)
+		err = (!arg ? -EINVAL :
+		       copy_to_user(arg, &info, sizeof(info)) ? -EFAULT : 0);
+	return err;
+}
+
+static int
+loop_get_status2(struct loop_device *lo, struct loop_info2 *arg) {
+	struct loop_info2 info2;
+	int err;
+
+	err = loop_get_status(lo, &info2);
+	if (!err)
+		err = (!arg ? -EINVAL :
+		       copy_to_user(arg, &info2, sizeof(info2)) ? -EFAULT : 0);
+	return err;
 }
 
 static int lo_ioctl(struct inode * inode, struct file * file,
@@ -922,10 +1001,16 @@
 		err = loop_clr_fd(lo, inode->i_bdev);
 		break;
 	case LOOP_SET_STATUS:
-		err = loop_set_status(lo, (struct loop_info *) arg);
+		err = loop_set_status1(lo, (struct loop_info *) arg);
 		break;
 	case LOOP_GET_STATUS:
-		err = loop_get_status(lo, (struct loop_info *) arg);
+		err = loop_get_status1(lo, (struct loop_info *) arg);
+		break;
+	case LOOP_SET_STATUS2:
+		err = loop_set_status2(lo, (struct loop_info2 *) arg);
+		break;
+	case LOOP_GET_STATUS2:
+		err = loop_get_status2(lo, (struct loop_info2 *) arg);
 		break;
 	default:
 		err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-alpha/loopinfo.h b/include/asm-alpha/loopinfo.h
--- a/include/asm-alpha/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-alpha/loopinfo.h	Thu Apr 17 23:48:34 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_ALPHA_LOOP_H
+#define _ASM_ALPHA_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-arm/loopinfo.h b/include/asm-arm/loopinfo.h
--- a/include/asm-arm/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-arm/loopinfo.h	Thu Apr 17 23:48:54 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_ARM_LOOP_H
+#define _ASM_ARM_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-cris/loopinfo.h b/include/asm-cris/loopinfo.h
--- a/include/asm-cris/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-cris/loopinfo.h	Thu Apr 17 23:49:07 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_CRIS_LOOP_H
+#define _ASM_CRIS_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-i386/loopinfo.h b/include/asm-i386/loopinfo.h
--- a/include/asm-i386/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-i386/loopinfo.h	Thu Apr 17 23:06:15 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_I386_LOOP_H
+#define _ASM_I386_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-ia64/loopinfo.h b/include/asm-ia64/loopinfo.h
--- a/include/asm-ia64/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-ia64/loopinfo.h	Thu Apr 17 23:49:39 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_IA64_LOOP_H
+#define _ASM_IA64_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-m68k/loopinfo.h b/include/asm-m68k/loopinfo.h
--- a/include/asm-m68k/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-m68k/loopinfo.h	Thu Apr 17 23:07:18 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_M68K_LOOP_H
+#define _ASM_M68K_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-m68knommu/loopinfo.h b/include/asm-m68knommu/loopinfo.h
--- a/include/asm-m68knommu/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-m68knommu/loopinfo.h	Thu Apr 17 23:56:34 2003
@@ -0,0 +1 @@
+#include <asm-m68k/loopinfo.h>
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-mips/loopinfo.h b/include/asm-mips/loopinfo.h
--- a/include/asm-mips/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-mips/loopinfo.h	Thu Apr 17 23:09:44 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_MIPS_LOOP_H
+#define _ASM_MIPS_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-mips64/loopinfo.h b/include/asm-mips64/loopinfo.h
--- a/include/asm-mips64/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-mips64/loopinfo.h	Thu Apr 17 23:10:17 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_MIPS64_LOOP_H
+#define _ASM_MIPS64_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-parisc/loopinfo.h b/include/asm-parisc/loopinfo.h
--- a/include/asm-parisc/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-parisc/loopinfo.h	Thu Apr 17 23:10:36 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_PARISC_LOOP_H
+#define _ASM_PARISC_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-ppc/loopinfo.h b/include/asm-ppc/loopinfo.h
--- a/include/asm-ppc/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-ppc/loopinfo.h	Thu Apr 17 23:11:14 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_PPC_LOOP_H
+#define _ASM_PPC_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-ppc64/loopinfo.h b/include/asm-ppc64/loopinfo.h
--- a/include/asm-ppc64/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-ppc64/loopinfo.h	Thu Apr 17 23:12:15 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_PPC64_LOOP_H
+#define _ASM_PPC64_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned long	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned long	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-s390/loopinfo.h b/include/asm-s390/loopinfo.h
--- a/include/asm-s390/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-s390/loopinfo.h	Thu Apr 17 23:12:58 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_S390_LOOP_H
+#define _ASM_S390_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-s390x/loopinfo.h b/include/asm-s390x/loopinfo.h
--- a/include/asm-s390x/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-s390x/loopinfo.h	Thu Apr 17 23:13:21 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_S390X_LOOP_H
+#define _ASM_S390X_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-sh/loopinfo.h b/include/asm-sh/loopinfo.h
--- a/include/asm-sh/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-sh/loopinfo.h	Thu Apr 17 23:14:14 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_SH_LOOP_H
+#define _ASM_SH_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-sparc/loopinfo.h b/include/asm-sparc/loopinfo.h
--- a/include/asm-sparc/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-sparc/loopinfo.h	Thu Apr 17 23:52:04 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_SPARC_LOOP_H
+#define _ASM_SPARC_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned short	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned short	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-sparc64/loopinfo.h b/include/asm-sparc64/loopinfo.h
--- a/include/asm-sparc64/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-sparc64/loopinfo.h	Thu Apr 17 23:15:03 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_SPARC64_LOOP_H
+#define _ASM_SPARC64_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-um/loopinfo.h b/include/asm-um/loopinfo.h
--- a/include/asm-um/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-um/loopinfo.h	Thu Apr 17 23:46:33 2003
@@ -0,0 +1,6 @@
+#ifndef _UM_LOOP_H
+#define _UM_LOOP_H
+
+#include "asm/arch/loopinfo.h"
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-v850/loopinfo.h b/include/asm-v850/loopinfo.h
--- a/include/asm-v850/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-v850/loopinfo.h	Thu Apr 17 23:47:11 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_V850_LOOP_H
+#define _ASM_V850_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned int	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned int	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/asm-x86_64/loopinfo.h b/include/asm-x86_64/loopinfo.h
--- a/include/asm-x86_64/loopinfo.h	Thu Jan  1 01:00:00 1970
+++ b/include/asm-x86_64/loopinfo.h	Thu Apr 17 23:47:49 2003
@@ -0,0 +1,22 @@
+#ifndef _ASM_X86_64_LOOP_H
+#define _ASM_X86_64_LOOP_H
+
+#define LO_NAME_SIZE	64
+#define LO_KEY_SIZE	32
+
+struct loop_info {
+	int		lo_number;	/* ioctl r/o */
+	unsigned long	lo_device; 	/* ioctl r/o */
+	unsigned long	lo_inode; 	/* ioctl r/o */
+	unsigned long	lo_rdevice; 	/* ioctl r/o */
+	int		lo_offset;
+	int		lo_encrypt_type;
+	int		lo_encrypt_key_size; 	/* ioctl w/o */
+	int		lo_flags;		/* ioctl r/o */
+	char		lo_name[LO_NAME_SIZE];
+	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	lo_init[2];
+	char		reserved[4];
+};
+
+#endif
diff -u --recursive --new-file -X /linux/dontdiff a/include/linux/loop.h b/include/linux/loop.h
--- a/include/linux/loop.h	Fri Nov 22 22:41:13 2002
+++ b/include/linux/loop.h	Fri Apr 18 00:32:53 2003
@@ -1,8 +1,6 @@
 #ifndef _LINUX_LOOP_H
 #define _LINUX_LOOP_H
 
-#include <linux/kdev_t.h>
-
 /*
  * include/linux/loop.h
  *
@@ -74,34 +72,21 @@
 #define LO_FLAGS_READ_ONLY	2
 #define LO_FLAGS_BH_REMAP	4
 
-/* 
- * Note that this structure gets the wrong offsets when directly used
- * 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	
- */
+#include <asm/loopinfo.h>	/* for struct loop_info */
 
-struct loop_info {
-	int		lo_number;	/* ioctl r/o */
-	dev_t		lo_device; 	/* ioctl r/o */
-	unsigned long	lo_inode; 	/* ioctl r/o */
-	dev_t		lo_rdevice; 	/* ioctl r/o */
-	int		lo_offset;
-	int		lo_encrypt_type;
-	int		lo_encrypt_key_size; 	/* ioctl w/o */
-	int		lo_flags;	/* ioctl r/o */
-	char		lo_name[LO_NAME_SIZE];
-	unsigned char	lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
-	unsigned long	lo_init[2];
-	char		reserved[4];
+struct loop_info2 {
+	int		   lo_number;		/* ioctl r/o */
+	unsigned long long lo_device; 		/* ioctl r/o */
+	unsigned long	   lo_inode; 		/* ioctl r/o */
+	unsigned long long lo_rdevice; 		/* ioctl r/o */
+	int		   lo_offset;
+	int		   lo_encrypt_type;
+	int		   lo_encrypt_key_size; 	/* ioctl w/o */
+	int		   lo_flags;			/* ioctl r/o */
+	char		   lo_name[LO_NAME_SIZE];
+	unsigned char	   lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+	unsigned long	   lo_init[2];
+	char		   reserved[4];
 };
 
 /*
@@ -125,7 +110,7 @@
 	int number; 	/* filter type */ 
 	int (*transfer)(struct loop_device *lo, int cmd, char *raw_buf,
 			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_info2 *); 
 	/* release is called from loop_unregister_transfer or clr_fd */
 	int (*release)(struct loop_device *); 
 	int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
@@ -134,7 +119,7 @@
 	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); 
 
 #endif
@@ -142,9 +127,11 @@
  * IOCTL commands --- we will commandeer 0x4C ('L')
  */
 
-#define LOOP_SET_FD	0x4C00
-#define LOOP_CLR_FD	0x4C01
-#define LOOP_SET_STATUS	0x4C02
-#define LOOP_GET_STATUS	0x4C03
+#define LOOP_SET_FD		0x4C00
+#define LOOP_CLR_FD		0x4C01
+#define LOOP_SET_STATUS		0x4C02
+#define LOOP_GET_STATUS		0x4C03
+#define LOOP_SET_STATUS2	0x4C04
+#define LOOP_GET_STATUS2	0x4C05
 
 #endif

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
  2003-04-17 23:34 [PATCH] struct loop_info Andries.Brouwer
@ 2003-04-18  0:22 ` Andrew Morton
  2003-04-18  5:05 ` Andreas Dilger
  2003-04-18 13:24 ` Jari Ruusu
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2003-04-18  0:22 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: torvalds, linux-kernel

Andries.Brouwer@cwi.nl wrote:
>
> Until now as the source already says, we had a very unpleasant
> situation with struct loop_info:

This patch makes me pull faces, sorry.

a) The name "loop_info2" is meaningless.  Something like loop_info64 would
   communicate something to the reader.

b) It is impossible for the reader to tell _why_ loop_info and loop_info2
   exist.  

   It will be especially mysterious in 2.8, where there is no loop_info,
   only a loop_info2.

   Hence covering commentary is compulsory.

c) Could we not save a lot of noise by putting:

	typedef unsigned short legacy_dev_t;	/* <= linux-2.4.x */

   into asm/posix_types.h and then keep all this stuff just in
   <linux/loop.h>?

d) Would it be possible to just add a u64 to the _end_ of the existing
   loop_info and, in the legacy ioctl(), simply massage it?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
  2003-04-17 23:34 [PATCH] struct loop_info Andries.Brouwer
  2003-04-18  0:22 ` Andrew Morton
@ 2003-04-18  5:05 ` Andreas Dilger
  2003-04-18 13:24 ` Jari Ruusu
  2 siblings, 0 replies; 8+ messages in thread
From: Andreas Dilger @ 2003-04-18  5:05 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: akpm, torvalds, linux-kernel

On Apr 18, 2003  01:34 +0200, Andries.Brouwer@cwi.nl wrote:
> Until now as the source already says, we had a very unpleasant
> situation with struct loop_info:
> 
> -/* 
> - * Note that this structure gets the wrong offsets when directly used
> - * 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        
> - */
> 
> In the patch below I remove the definition for this struct from
> <linux/loop.h> and put it in <asm/loopinfo.h>.

Great.  Now we have 20 copies of asm-foo/loopinfo.h.  Couldn't you
just have asm-generic/loopinfo.h and each of the arch-specific
pieces just include that?

> In this struct the occurrences of dev_t have been replaced by their
> actual values (short int / int / long int).

Even better, have specific sized types (__u16, __u32, __u64) for the
fields, so there is no ambiguity (e.g. sparc64, or 32-bit code running
on x86-64).

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
  2003-04-17 23:34 [PATCH] struct loop_info Andries.Brouwer
  2003-04-18  0:22 ` Andrew Morton
  2003-04-18  5:05 ` Andreas Dilger
@ 2003-04-18 13:24 ` Jari Ruusu
  2 siblings, 0 replies; 8+ messages in thread
From: Jari Ruusu @ 2003-04-18 13:24 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: akpm, torvalds, linux-kernel

Andries.Brouwer@cwi.nl wrote:
> The second part of this patch adds a new struct loop_info2
> in <linux/loop.h> identical to the old struct but with
> unsigned long long instead of dev_t.
> Now kernel and userspace use the same struct, simplifying life.
> 
> Unfortunately for compatibility some translation between
> loop_info and loop_info2 is required.

Andries, if you are going to define new struct loop_info2, please change
lo_offset to 64 bits, and add new 64 bit lo_size element. Specifying offset
without size is little bit silly.

Regards,
Jari Ruusu <jari.ruusu@pp.inet.fi>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
@ 2003-04-18  9:36 Andries.Brouwer
  0 siblings, 0 replies; 8+ messages in thread
From: Andries.Brouwer @ 2003-04-18  9:36 UTC (permalink / raw)
  To: Andries.Brouwer, hch; +Cc: akpm, linux-kernel, torvalds

> Can we name it old_dev_t or dev16_t ?

Not 16 - the size varies among architectures.
Yes, nothing wrong with __old_dev_t.

Andries

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
  2003-04-18  9:06 Andries.Brouwer
@ 2003-04-18  9:12 ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2003-04-18  9:12 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: akpm, linux-kernel, torvalds

On Fri, Apr 18, 2003 at 11:06:24AM +0200, Andries.Brouwer@cwi.nl wrote:
> Ask, and I'll add legacy_dev_t. I slightly prefer the present version.

Can we name it old_dev_t or dev16_t ?  We already have old_uid_t/old_gid_t
and uid16_t/hid16_t.  A bit consistency can't hurt...


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
@ 2003-04-18  9:06 Andries.Brouwer
  2003-04-18  9:12 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Andries.Brouwer @ 2003-04-18  9:06 UTC (permalink / raw)
  To: Andries.Brouwer, akpm; +Cc: linux-kernel, torvalds

    From: Andrew Morton <akpm@digeo.com>

    Andries.Brouwer@cwi.nl wrote:
    >
    > Until now as the source already says, we had a very unpleasant
    > situation with struct loop_info:

    This patch makes me pull faces, sorry.

    a) The name "loop_info2" is meaningless.  Something like loop_info64
       would communicate something to the reader.

The 2 communicates that this is a second version of the same struct.
For userspace that is very true, since literally the same definition
can be used.

    b) It is impossible for the reader to tell _why_ loop_info and loop_info2
       exist.  

       It will be especially mysterious in 2.8, where there is no loop_info,
       only a loop_info2.

       Hence covering commentary is compulsory.

OK.

    c) Could we not save a lot of noise by putting:

        typedef unsigned short legacy_dev_t;    /* <= linux-2.4.x */

       into asm/posix_types.h and then keep all this stuff just in
       <linux/loop.h>?

Yes. I considered that and preferred the completely explicit version.
But if you prefer the compact version, and shift a little bit more
work to user space, that also is a possibility.

    d) Would it be possible to just add a u64 to the _end_ of the existing
       loop_info and, in the legacy ioctl(), simply massage it?

Everything is possible, but a smaller change in the kernel corresponds
to a larger change in userspace (and I happen to maintain mount and
losetup and family :-), and there is a largish body of crypto code).
The version as given allows one to keep the user space code unchanged,
except that obscure gymnastics with the dev_t definition may be replaced by

#define LOOP_SET_STATUS    0x4C04
#define LOOP_GET_STATUS    0x4C05

(note that the kernel has loop_info2, but user space can just continue
to call it loop_info; the kernel has LOOP_SET_STATUS2, but user space
can just continue to call it LOOP_SET_STATUS, should it desire to do so).

So what I am saying is that the picture seen from kernel perspective only
differs a bit from the picture seen from both kernel and userspace.
I prefer the kernel changes that lead to minimal textual changes
in user space code.

Andries


[Conclusion:
Ask, and I'll add legacy_dev_t. I slightly prefer the present version.
Ask, and I'll do s/2/64/. No strong opinion.
If I send a second version it'll contain one more line of comment.]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] struct loop_info
@ 2003-04-18  8:38 Andries.Brouwer
  0 siblings, 0 replies; 8+ messages in thread
From: Andries.Brouwer @ 2003-04-18  8:38 UTC (permalink / raw)
  To: Andries.Brouwer, adilger; +Cc: akpm, linux-kernel, torvalds

    From: Andreas Dilger <adilger@clusterfs.com>

    > In this struct the occurrences of dev_t have been replaced by their
    > actual values (short int / int / long int).

    Even better, have specific sized types (__u16, __u32, __u64) for the
    fields, so there is no ambiguity (e.g. sparc64, or 32-bit code running
    on x86-64).

I replaced the dev_t's by the actual thing they were typedef'd to.
That is guaranteed to preserve correctness.

    > In the patch below I remove the definition for this struct from
    > <linux/loop.h> and put it in <asm/loopinfo.h>.

    Great.  Now we have 20 copies of asm-foo/loopinfo.h.  Couldn't you
    just have asm-generic/loopinfo.h and each of the arch-specific
    pieces just include that?

Yes, a bit ugly. I could have saved kernel source (20 small files)
by using __legacy_dev_t in loop.h, with a typedef of __legacy_dev_t
in <asm/posix_types.h>.

Maybe I should have done that. The reason I did what I did is
that all these defined types give lots of complications in
user space code. Maintainability of the union of kernel and
user space source is increased by just saying explicitly
what these types are.

Andries

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-04-18 13:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-17 23:34 [PATCH] struct loop_info Andries.Brouwer
2003-04-18  0:22 ` Andrew Morton
2003-04-18  5:05 ` Andreas Dilger
2003-04-18 13:24 ` Jari Ruusu
2003-04-18  8:38 Andries.Brouwer
2003-04-18  9:06 Andries.Brouwer
2003-04-18  9:12 ` Christoph Hellwig
2003-04-18  9:36 Andries.Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).