lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Nov 2022 07:34:01 -0600
From:   Andreas Dilger <adilger@...ger.ca>
To:     "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Cc:     Theodore Ts'o <tytso@....edu>, linux-ext4@...r.kernel.org,
        Harshad Shirwadkar <harshadshirwadkar@...il.com>,
        Wang Shilong <wshilong@....com>,
        Andreas Dilger <adilger.kernel@...ger.ca>, Li Xi <lixi@....com>
Subject: Re: [RFCv1 06/72] dblist: add dblist merge logic

On Nov 7, 2022, at 06:22, Ritesh Harjani (IBM) <ritesh.list@...il.com> wrote:
> 
> From: Li Xi <lixi@....com>
> 
> This adds dblist merge logic.
> 
> TODO: Add a unit test for core operations of dblist. Currently there is
> no such test for this.
> 
> Signed-off-by: Li Xi <lixi@....com>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>

Reviewed-by: Andreas Dilger <adilger@...ger.ca>

> ---
> lib/ext2fs/dblist.c | 36 ++++++++++++++++++++++++++++++++++++
> lib/ext2fs/ext2fs.h |  1 +
> 2 files changed, 37 insertions(+)
> 
> diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
> index bbdb221d..5568b8ec 100644
> --- a/lib/ext2fs/dblist.c
> +++ b/lib/ext2fs/dblist.c
> @@ -119,6 +119,42 @@ errcode_t ext2fs_copy_dblist(ext2_dblist src, ext2_dblist *dest)
>    return 0;
> }
> 
> +/*
> + * Merge a directory block list @src to @dest
> + */
> +errcode_t ext2fs_merge_dblist(ext2_dblist src, ext2_dblist dest)
> +{
> +   unsigned long long src_count = src->count;
> +   unsigned long long dest_count = dest->count;
> +   unsigned long long size = src_count + dest_count;
> +   size_t size_entry = sizeof(struct ext2_db_entry2);
> +   struct ext2_db_entry2 *array, *array2;
> +   errcode_t retval;
> +
> +   if (src_count == 0)
> +       return 0;
> +
> +   if (src->sorted || (dest->sorted && dest_count != 0))
> +       return EINVAL;
> +
> +   retval = ext2fs_get_array(size, size_entry, &array);
> +   if (retval)
> +       return retval;
> +
> +   array2 = array;
> +   memcpy(array, src->list, src_count * size_entry);
> +   array += src_count;
> +   memcpy(array, dest->list, dest_count * size_entry);
> +   ext2fs_free_mem(&dest->list);
> +
> +   dest->list = array2;
> +   dest->count = src_count + dest_count;
> +   dest->size = size;
> +   dest->sorted = 0;
> +
> +   return 0;
> +}
> +
> /*
>  * Close a directory block list
>  *
> diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> index 18dddc2c..443f93d2 100644
> --- a/lib/ext2fs/ext2fs.h
> +++ b/lib/ext2fs/ext2fs.h
> @@ -1143,6 +1143,7 @@ extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
>                      blk_t blk, int blockcnt);
> extern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
>                       blk64_t blk, e2_blkcnt_t blockcnt);
> +extern errcode_t ext2fs_merge_dblist(ext2_dblist src, ext2_dblist dest);
> extern void ext2fs_dblist_sort(ext2_dblist dblist,
>                   EXT2_QSORT_TYPE (*sortfunc)(const void *,
>                               const void *));
> -- 
> 2.37.3
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ