Whamcloud - gitweb
add loop_device_get_info.patch in snapfs series
[fs/lustre-release.git] / lustre / kernel_patches / patches / loop_device_get_info.patch
diff --git a/lustre/kernel_patches/patches/loop_device_get_info.patch b/lustre/kernel_patches/patches/loop_device_get_info.patch
new file mode 100644 (file)
index 0000000..d45d64b
--- /dev/null
@@ -0,0 +1,57 @@
+Index: linux-2.4.20-8/drivers/block/loop.c
+===================================================================
+--- linux-2.4.20-8.orig/drivers/block/loop.c   2002-11-29 07:53:12.000000000 +0800
++++ linux-2.4.20-8/drivers/block/loop.c        2004-01-10 00:02:33.000000000 +0800
+@@ -843,6 +843,31 @@
+       }
+       return copy_to_user(arg, &info, sizeof(info)) ? -EFAULT : 0;
+ }
++static int loop_get_info(struct loop_device *lo, struct loop_info *arg)
++{
++      struct loop_info        info;
++      struct file *file = lo->lo_backing_file;
++
++      if (lo->lo_state != Lo_bound)
++              return -ENXIO;
++      if (!arg)
++              return -EINVAL;
++      memset(&info, 0, sizeof(info));
++      info.lo_number = lo->lo_number;
++      info.lo_device = kdev_t_to_nr(file->f_dentry->d_inode->i_dev);
++      info.lo_inode = file->f_dentry->d_inode->i_ino;
++      info.lo_rdevice = kdev_t_to_nr(lo->lo_device);
++      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,
++                     lo->lo_encrypt_key_size);
++      }
++      return memcpy(arg, &info, sizeof(info)) ? -EFAULT : 0;
++}
+ static int lo_ioctl(struct inode * inode, struct file * file,
+       unsigned int cmd, unsigned long arg)
+@@ -875,6 +900,9 @@
+       case LOOP_GET_STATUS:
+               err = loop_get_status(lo, (struct loop_info *) arg);
+               break;
++      case LOOP_GET_INFO:
++              err = loop_get_info(lo, (struct loop_info *) arg);
++              break;
+       case BLKGETSIZE:
+               if (lo->lo_state != Lo_bound) {
+                       err = -ENXIO;
+Index: linux-2.4.20-8/include/linux/loop.h
+===================================================================
+--- linux-2.4.20-8.orig/include/linux/loop.h   2001-09-18 04:16:30.000000000 +0800
++++ linux-2.4.20-8/include/linux/loop.h        2004-01-09 23:50:17.000000000 +0800
+@@ -151,5 +151,6 @@
+ #define LOOP_CLR_FD   0x4C01
+ #define LOOP_SET_STATUS       0x4C02
+ #define LOOP_GET_STATUS       0x4C03
++#define LOOP_GET_INFO 0x4C04
+ #endif