-+static int
-+ext3_ext_store_extent_cb(struct ext3_extents_tree *tree,
-+ struct ext3_ext_path *path,
-+ struct ext3_ext_cache *newex)
-+{
-+ struct ext3_extent_buf *buf = (struct ext3_extent_buf *) tree->private;
-+
-+ if (newex->ec_type != EXT3_EXT_CACHE_EXTENT)
-+ return EXT_CONTINUE;
-+
-+ if (buf->err < 0)
-+ return EXT_BREAK;
-+ if (buf->cur - buf->buffer + sizeof(*newex) > buf->buflen)
-+ return EXT_BREAK;
-+
-+ if (!copy_to_user(buf->cur, newex, sizeof(*newex))) {
-+ buf->err++;
-+ buf->cur += sizeof(*newex);
-+ } else {
-+ buf->err = -EFAULT;
-+ return EXT_BREAK;
-+ }
-+ return EXT_CONTINUE;
-+}
-+
-+static int
-+ext3_ext_collect_stats_cb(struct ext3_extents_tree *tree,
-+ struct ext3_ext_path *path,
-+ struct ext3_ext_cache *ex)
-+{
-+ struct ext3_extent_tree_stats *buf =
-+ (struct ext3_extent_tree_stats *) tree->private;
-+ int depth;
-+
-+ if (ex->ec_type != EXT3_EXT_CACHE_EXTENT)
-+ return EXT_CONTINUE;
-+
-+ depth = EXT_DEPTH(tree);
-+ buf->extents_num++;
-+ if (path[depth].p_ext == EXT_FIRST_EXTENT(path[depth].p_hdr))
-+ buf->leaf_num++;
-+ return EXT_CONTINUE;
-+}
-+
-+int ext3_ext_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-+ unsigned long arg)
-+{
-+ int err = 0;
-+
-+ if (!(EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL))
-+ return -EINVAL;
-+
-+ if (cmd == EXT3_IOC_GET_EXTENTS) {
-+ struct ext3_extent_buf buf;
-+ struct ext3_extents_tree tree;
-+
-+ if (copy_from_user(&buf, (void *) arg, sizeof(buf)))
-+ return -EFAULT;
-+
-+ ext3_init_tree_desc(&tree, inode);
-+ buf.cur = buf.buffer;
-+ buf.err = 0;
-+ tree.private = &buf;
-+ down(&EXT3_I(inode)->truncate_sem);
-+ err = ext3_ext_walk_space(&tree, buf.start, EXT_MAX_BLOCK,
-+ ext3_ext_store_extent_cb);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ if (err == 0)
-+ err = buf.err;
-+ } else if (cmd == EXT3_IOC_GET_TREE_STATS) {
-+ struct ext3_extent_tree_stats buf;
-+ struct ext3_extents_tree tree;
-+
-+ ext3_init_tree_desc(&tree, inode);
-+ down(&EXT3_I(inode)->truncate_sem);
-+ buf.depth = EXT_DEPTH(&tree);
-+ buf.extents_num = 0;
-+ buf.leaf_num = 0;
-+ tree.private = &buf;
-+ err = ext3_ext_walk_space(&tree, 0, EXT_MAX_BLOCK,
-+ ext3_ext_collect_stats_cb);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ if (!err)
-+ err = copy_to_user((void *) arg, &buf, sizeof(buf));
-+ } else if (cmd == EXT3_IOC_GET_TREE_DEPTH) {
-+ struct ext3_extents_tree tree;
-+ ext3_init_tree_desc(&tree, inode);
-+ down(&EXT3_I(inode)->truncate_sem);
-+ err = EXT_DEPTH(&tree);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ }
-+
-+ return err;
-+}
-+