From nobody Wed Apr 03 09:59:34 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V8gFz16CCz5GT1c; Wed, 3 Apr 2024 09:59:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V8gFy6CgFz45Yt; Wed, 3 Apr 2024 09:59:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712138374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cTlvFaABIJq0ArGLJ491jTu+YRSiWk7iLKiaSXlqgYI=; b=Asrr6LdFFhupoCAIsDoacX1TfjYAG8EfhdZFdpuipp/aKi9PJ0aPhPiqIsmfPFFhJYoz+v wGLWP99Ko4MaPVpOY7uvZQuONo0BXvoJgaYspjbYJxjygqhrG+H11w1J5HkPh9Dyu84k/M 06s7ENs1/nlzhukLjPPnyNyGM6WA7hWAo0ApveU/FCXUiLkEBg/phqVF/NXjqvG9pFyVK+ aMY9gxxj2ylYoTJfk4l/vCx8iLjHq+/FINZxRdEXWj30Q5oDJNQ6j9L3H+1eklwCM3WQqR PkoepZTs/vYnsOqTFg0WC9BhujRrWi1xJUpxvjTFLTVqoAamsEc1hD1x8jjFtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712138374; a=rsa-sha256; cv=none; b=Yu2m1Dlq99vshaUa1PzZHQwGOAy0Pcx8sQzLnOTo2UX/U53hn/5LSjnHIOHx9jg9hxW/TH Zg8WdrLNlF5q9591XMUoKm9Svexn9FxEd+LlRc3MI3ol8JxcForilYA+SQ1mCPXXLPjHrk eaoFFbpLMCqb59qzFPYVSwdJ6W0k2d3s/DiVpJfJ+xcuz+8II+r/V8olRaRsgc3zlKHgZk NftZGQEPCYDw1Ruf+iKQuD5ol0KCFggbW6JQgmJ8hStBzf3dllvp1rChlMOJVxWqSt89G7 Gr703EDV7VXnNPlmZB1fjMxOpQSckd0niDcDQXLpXh5E2xmT8LUHKlM/Wwy77g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712138374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cTlvFaABIJq0ArGLJ491jTu+YRSiWk7iLKiaSXlqgYI=; b=uFPQOT+u5D1+MXqboVV3STcshM43Ou8DWdJF7i9FcdNCrGVpiWfR0CM1jpMjf+0mOnIdqN xSuXjS5RbVCfSaOAU9vB7PMakRm96RvG1olPtqPbig1WKGhBKdNnHxUAC8zxddqjrYvjpt J+Z0oVjgZ0OolEo88lQm+ps7An8q3OX43768b+iz5323qGP9jHLdeX0vdkdhA4lGNfP1hm pwkG55p0xr5l8n2b4pQkRl8Ueozcmk1XvkITAg5Sz28/4S2gCP1mi+oUskq3RiJs3iyHwl ZJOmsTYkTpwlcqJx6iEnQHi8YVp54I80h5f5R42oprWy8BfUNaXXJ8J86wLYIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4V8gFy5qhqzSmx; Wed, 3 Apr 2024 09:59:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4339xYpv052997; Wed, 3 Apr 2024 09:59:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4339xYcM052994; Wed, 3 Apr 2024 09:59:34 GMT (envelope-from git) Date: Wed, 3 Apr 2024 09:59:34 GMT Message-Id: <202404030959.4339xYcM052994@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 584e1c355ae3 - main - tarfs: Ignore global extended headers. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 584e1c355ae3c994331005b7196cc87a714e5317 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=584e1c355ae3c994331005b7196cc87a714e5317 commit 584e1c355ae3c994331005b7196cc87a714e5317 Author: Dag-Erling Smørgrav AuthorDate: 2024-04-03 09:55:06 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-03 09:55:06 +0000 tarfs: Ignore global extended headers. Previously, we would error out if we encountered a global extended header, because we don't know what it means. This doesn't really matter though, and traditionally, tar implementations have either ignored them or treated them as plain files, so just ignore them. This allows tarfs to mount tar files created by `git archive`. MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44600 --- sys/fs/tarfs/tarfs_vfsops.c | 13 +++++++------ tests/sys/fs/tarfs/tarfs_test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/sys/fs/tarfs/tarfs_vfsops.c b/sys/fs/tarfs/tarfs_vfsops.c index df657fb13414..cbc3d88eaad8 100644 --- a/sys/fs/tarfs/tarfs_vfsops.c +++ b/sys/fs/tarfs/tarfs_vfsops.c @@ -553,13 +553,14 @@ again: TARFS_DPF(ALLOC, "%s: [%c] %zu @%jd %o %d:%d\n", __func__, hdrp->typeflag[0], sz, (intmax_t)mtime, mode, uid, gid); - /* extended header? */ + /* global extended header? */ if (hdrp->typeflag[0] == TAR_TYPE_GLOBAL_EXTHDR) { - printf("%s: unsupported global extended header at %zu\n", - __func__, (size_t)(TARFS_BLOCKSIZE * (blknum - 1))); - error = EFTYPE; - goto bad; + TARFS_DPF(ALLOC, "%s: %zu-byte global extended header at %zu\n", + __func__, sz, TARFS_BLOCKSIZE * (blknum - 1)); + goto skip; } + + /* extended header? */ if (hdrp->typeflag[0] == TAR_TYPE_EXTHDR) { if (exthdr != NULL) { TARFS_DPF(IO, "%s: multiple extended headers at %zu\n", @@ -568,7 +569,7 @@ again: goto bad; } /* read the contents of the exthdr */ - TARFS_DPF(ALLOC, "%s: %zu-byte extended header at %zd\n", + TARFS_DPF(ALLOC, "%s: %zu-byte extended header at %zu\n", __func__, sz, TARFS_BLOCKSIZE * (blknum - 1)); exthdr = malloc(sz, M_TEMP, M_WAITOK); res = tarfs_io_read_buf(tmp, false, exthdr, diff --git a/tests/sys/fs/tarfs/tarfs_test.sh b/tests/sys/fs/tarfs/tarfs_test.sh index 5d3fbca2f4ee..f1322033fbad 100644 --- a/tests/sys/fs/tarfs/tarfs_test.sh +++ b/tests/sys/fs/tarfs/tarfs_test.sh @@ -357,6 +357,29 @@ tarfs_long_paths_cleanup() { tarfs_cleanup } +atf_test_case tarfs_git_archive cleanup +tarfs_git_archive_head() { + atf_set "descr" "Verify that tarfs supports archives created by git" + atf_set "require.user" "root" + atf_set "require.progs" "git" +} +tarfs_git_archive_body() { + tarfs_setup + mkdir foo + echo "Hello, world!" >foo/bar + git -C foo init --initial-branch=tarfs + git -C foo config user.name "File System" + git -C foo config user.email fs@freebsd.org + git -C foo add bar + git -C foo commit -m bar + git -C foo archive --output=../tarfs_git_archive.tar HEAD + atf_check mount -rt tarfs tarfs_git_archive.tar "${mnt}" + atf_check -o file:foo/bar cat "${mnt}"/bar +} +tarfs_git_archive_cleanup() { + tarfs_cleanup +} + atf_init_test_cases() { atf_add_test_case tarfs_basic atf_add_test_case tarfs_basic_gnu @@ -374,4 +397,5 @@ atf_init_test_cases() { atf_add_test_case tarfs_checksum atf_add_test_case tarfs_long_names atf_add_test_case tarfs_long_paths + atf_add_test_case tarfs_git_archive }