Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1609773rdg; Sat, 12 Aug 2023 08:18:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBGGnSpQOCBmnTpcMJKlrxJlZTC/jEO/1SR75T3GWuJkjkdBAaBelWvkaDtzHZnA6t3pky X-Received: by 2002:a17:906:4c1:b0:99b:d549:834f with SMTP id g1-20020a17090604c100b0099bd549834fmr4009149eja.68.1691853535068; Sat, 12 Aug 2023 08:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691853535; cv=none; d=google.com; s=arc-20160816; b=qc2BhENzeV3dguWJTxnGCLP8w+JH943P1QnQm3stYl7RhPltvuJyQKBwbosNqeFYFk 03S5NNk6opxZ+YF6FO2UMZQeZYQ5BDLs3pMkRUOCbsPCrSJaRw+2BTEBF7lDE1Wb0s65 ea/ngSxDvM9ajOG2U8oHadH4O6aVwwhx0YunKLUavrntl0L7y7+hOoaVkjVuiXOCDd15 Vs3LyGyyrtjs4wc2XB05DqBILQPICP3kWSachb2V+7OTbHMIYVTxbmeC+ntySqOFyhtT +krKAvlGDJSJsOstu/x6hfCRND3S2iOUjbvNB+6ywqgnWU/EIsXd7znf9ASAL8nTaMmj AtuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YQdPcn7J6OHzBvzj2jlS+T3Fc3clUUIvDfYpoQjzdl4=; fh=bjNX5l8F3Ar+NbShNLqRulW4/Iw0bb0bjPTOqnWkw38=; b=SGdwu7080N1BJ80O6dXHu7DMd18344mUqsapNEP6hehMA6bJxSDrl89l4kL03zqiIh xykkluxov1ihALlYbT8gM5rOoxlKFIC0s7MTbSpDwpjlX/vbnejQMsdlnfe+klJAsLJL jxBhLXA0xdHitIjDFYJE1Hwu84Ql/d2Rm1tzsRgB1sxyzdPTAPArzX2AV2TbqXoBF349 o+MXYxxR6X11RqIq1n1vjvggamXPViHzwVJs2KuqhaL5AOPOvpZNqUJZ83Gf4pNYrjdJ mcjpOwd5reu02DZ5YcFEq/Y29U8pev8/awjFh5PUubGNPIx7ha1opAsMVXExyHMgC6Vz 345A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@mister-muffin.de header.s=mail header.b=Mo46DmnI; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r15-20020a1709067fcf00b00992fef5cff9si5196114ejs.497.2023.08.12.08.18.31; Sat, 12 Aug 2023 08:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@mister-muffin.de header.s=mail header.b=Mo46DmnI; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbjHLPDz (ORCPT + 99 others); Sat, 12 Aug 2023 11:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjHLPDy (ORCPT ); Sat, 12 Aug 2023 11:03:54 -0400 Received: from fulda116.server4you.de (mister-muffin.de [144.76.155.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5DB510FB for ; Sat, 12 Aug 2023 08:03:53 -0700 (PDT) Received: from localhost (unknown [37.4.231.34]) by mister-muffin.de (Postfix) with ESMTPSA id AD9FD360; Sat, 12 Aug 2023 17:03:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mister-muffin.de; s=mail; t=1691852631; bh=3SzlG3W8vAQIDsr2VGMXcD2ThRqWNoQkipHCdzBmIms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mo46DmnI5ovvlT5jlbyzZqlhPOvlu7wxVqVNLh0Os4kxweyJBE4zOwY0f+ff9ITMd uH5y07Q3XjJzvmsG4SNOVZ3S8sLBGszxgIVRS/xwjM/JFasgMMYHXDUyxwcPTvZ/2R yGEswj2Mv3YCcJnaVoiBxyHmbly0GkWWAdROLDEU= From: Johannes Schauer Marin Rodrigues To: linux-ext4@vger.kernel.org Cc: Johannes Schauer Marin Rodrigues , adilger@dilger.ca, djwong@kernel.org Subject: [PATCH v2 0/1] mke2fs: the -d option can now handle tarball input Date: Sat, 12 Aug 2023 17:02:04 +0200 Message-Id: <20230812150204.462962-1-josch@mister-muffin.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: 605DCBDE-A388-4B98-BF5A-38773F15E3F4@dilger.ca References: <605DCBDE-A388-4B98-BF5A-38773F15E3F4@dilger.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi Andreas, thank you for your input! > Having just looked through the patch, I think it could use some cleanup. > Basic code style issues: > - wrapping lines at 80-columns > - avoid use of C++ comments in the code > - consistent indentation for continued lines > - consistent one blank line between functions > - consistent one blank line after variable declarations I've used clang-format with the `.clang-format` from the linux git to format the code. I also ran `scripts/checkpatch.pl` from linux to fix some more issues. > - split large highly-indented code blocks into helper functions There was particularly one highly indented switch() which I now put into its own function. > In terms of code structure, refactoring it to put libarchive handling > in a separate file (e.g. mke2fs-archive.c or similar) would also make > the maintenance easier, since it can be added/removed from the build > more easily, and (if necessary) removed from the tree if it is no longer > working. I've moved most of the libarchive functions into misc/create_inode_libarchive.c and hope this improves the situation. I've had to modify a couple of Makefile.in, make some functions of misc/create_inode.c non-extern and add them to create_inode.h so that misc/create_inode_libarchive.c can make use of them. Is this what you had in mind? > Then have only a couple of small function calls in the main mke2fs.c > code that are accessing the libarchive functionality if it is built-in, > or being no-ops (or just printing the error message) if libarchive is > unavailable. All the libarchive-specific functionality is behind __populate_fs_from_tar() which is the only function exposed in misc/create_inode_libarchive.h. If e2fsprogs was compiled without libarchive, an error message will be shown if the user tries to pass a regular file instead of a directory. If e2fsprogs was compiled with libarchive but the user does not have the shared library installed, another error about this will be displayed. There are probably still many things about my patch that can be improved. Thanks a lot for considering this and having a look at it! cheers, josch P.S. (more like a record for future-me) I tested that my changes allow libarchive to be compiled with and without libarchive headers installed and with and without libarchive shared library installed by running: mmdebstrap --variant=apt --include=git,ca-certificates,build-essential,autoconf,automake,autoconf-archive,pkg-config,gettext,texinfo,libblkid-dev,uuid-dev,m4,libarchive-dev \ --chrooted-customize-hook='git clone https://github.com/josch/e2fsprogs.git && cd e2fsprogs && git checkout libarchive-linux-ext4 && autoreconf -fi && ./configure && make -j4 && make check || cat tests/m_rootgnutar.failed tests/m_rootgnutar.log && apt remove --yes libarchive13 && tar -C include -c . | ./misc/mke2fs -q -F -o Linux -T ext4 -O metadata_csum,64bit -E lazy_itable_init=1 -b 1024 -d - image.ext4 16384' \ unstable /dev/null Johannes Schauer Marin Rodrigues (1): mke2fs: the -d option can now handle tarball input MCONFIG.in | 1 + configure | 134 ++++--- configure.ac | 9 + debugfs/Makefile.in | 25 +- lib/config.h.in | 3 + lib/ext2fs/Makefile.in | 25 +- misc/Makefile.in | 17 +- misc/create_inode.c | 61 ++- misc/create_inode.h | 10 + misc/create_inode_libarchive.c | 677 +++++++++++++++++++++++++++++++++ misc/create_inode_libarchive.h | 10 + misc/mke2fs.8.in | 10 +- misc/mke2fs.c | 12 +- tests/m_rootgnutar/expect | 141 +++++++ tests/m_rootgnutar/output.sed | 5 + tests/m_rootgnutar/script | 123 ++++++ tests/m_rootpaxtar/expect | 87 +++++ tests/m_rootpaxtar/mkpaxtar.pl | 69 ++++ tests/m_rootpaxtar/output.sed | 5 + tests/m_rootpaxtar/script | 44 +++ tests/m_roottar/expect | 208 ++++++++++ tests/m_roottar/mktar.pl | 62 +++ tests/m_roottar/output.sed | 5 + tests/m_roottar/script | 57 +++ 24 files changed, 1714 insertions(+), 86 deletions(-) create mode 100644 misc/create_inode_libarchive.c create mode 100644 misc/create_inode_libarchive.h create mode 100644 tests/m_rootgnutar/expect create mode 100644 tests/m_rootgnutar/output.sed create mode 100644 tests/m_rootgnutar/script create mode 100644 tests/m_rootpaxtar/expect create mode 100644 tests/m_rootpaxtar/mkpaxtar.pl create mode 100644 tests/m_rootpaxtar/output.sed create mode 100644 tests/m_rootpaxtar/script create mode 100644 tests/m_roottar/expect create mode 100644 tests/m_roottar/mktar.pl create mode 100644 tests/m_roottar/output.sed create mode 100644 tests/m_roottar/script -- 2.40.0