Re: [PATCH rfc v3] New ioctl BTRFS_IOC_GET_CHUNK_INFO.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/19/20 9:59 PM, Josef Bacik wrote:
On 3/19/20 4:39 PM, Goffredo Baroncelli wrote:
From: Goffredo Baroncelli <kreijack@xxxxxxxxx>

Add a new ioctl to get info about chunk without requiring the root
privileges. This allow to a non root user to know how the space of the
filesystem is allocated.

Signed-off-by: Goffredo Baroncelli <kreijack@xxxxxxxxx>
---
  fs/btrfs/ioctl.c           | 211 +++++++++++++++++++++++++++++++++++++
  include/uapi/linux/btrfs.h |  38 +++++++
  2 files changed, 249 insertions(+)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 40b729dce91c..b3296a479bf6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2234,6 +2234,215 @@ static noinline int btrfs_ioctl_tree_search_v2(struct file *file,
      return ret;
  }
+/*
+ * Return:
+ *    1        -> copied all data, possible further data
+ *    0        -> copied all data, no further data
+ *    -EAGAIN        -> not enough space, restart it
+ *    -EFAULT        -> the user passed an invalid address/size pair
+ */
+static noinline int copy_chunk_info(struct btrfs_path *path,
+                   char __user *ubuf,
+                   size_t buf_size,
+                   u64 *used_buf,
+                   int *num_found,
+                   u64 *offset)
+{
+    struct extent_buffer *leaf;
[...]
+
+static noinline int btrfs_ioctl_get_chunk_info(struct file *file,
+                           void __user *argp)
+{
+    struct btrfs_ioctl_chunk_info arg;
+    struct inode *inode;
+    int ret;
+    size_t buf_size;
+    u64 data_offset;
+    const size_t buf_limit = SZ_16M;
+
+
+    data_offset = sizeof(struct btrfs_ioctl_chunk_info);

I think I'm missing something, but since we have a single btrfs_chunk_info_stripe at the end, this will point to the next slot, so we're just copying in starting at slot 1, not slot 0, because you pass in argp + data_offset below.  This looks wonky to me, thanks,

I think that you are confunsing  "struct btrfs_ioctl_chunk_info" with "struct btrfs_chunk_info". Only the second one has the single "struct btrfs_chunk_info_stripe" at the end. May be ?




Josef


--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux