Re: [PATCH v2 1/7] gen_init_cpio: write to fd instead of stdout stream

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

 



On Thu, Aug 14, 2025 at 03:17:59PM +1000, David Disseldorp wrote:
> In preparation for more efficient archiving using copy_file_range(),
> switch from writing archive data to stdout to using STDOUT_FILENO and
> I/O via write(), dprintf(), etc.
> Basic I/O error handling is added to cover cases such as ENOSPC. Partial
> writes are treated as errors.
> 
> Signed-off-by: David Disseldorp <ddiss@xxxxxxx>
> ---
>  usr/gen_init_cpio.c | 139 ++++++++++++++++++++++++++------------------
>  1 file changed, 81 insertions(+), 58 deletions(-)
> 
> diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
> index edcdb8abfa31c..d8779fe4b8f1f 100644
> --- a/usr/gen_init_cpio.c
> +++ b/usr/gen_init_cpio.c
[...]
> @@ -96,23 +103,24 @@ static void cpio_trailer(void)
>  		0,			/* rminor */
>  		(unsigned)strlen(name)+1, /* namesize */
>  		0);			/* chksum */
> -	push_hdr(s);
> -	push_rest(name);
> +	offset += len;
>  
> -	while (offset % 512) {
> -		putchar(0);
> -		offset++;
> -	}
> +	if (len != CPIO_HDR_LEN
> +	 || push_rest(name) < 0
> +	 || push_pad(padlen(offset, 512)) < 0)


Thanks, patch looks good to me.

Just a minor coding style bike shedding: Starting continuation lines
with '||' seems to be rather unusual in Linux code:

    $ git grep -Ee '^\s*(\|\||&&)' **/*.c | wc -l
    64
    $ git grep -Ee '(\|\||&&)$' **/*.c | wc -l
    2553

Kind regards,
Nicolas




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux