Bug 204157 - lib/libarchive/functional_test:test_write_disk_times failed on a UFS1 filesystem (btime isn't implemented until UFS2)
Summary: lib/libarchive/functional_test:test_write_disk_times failed on a UFS1 filesys...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Martin Matuska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-30 17:28 UTC by Ed Maste
Modified: 2016-07-08 22:11 UTC (History)
4 users (show)

See Also:


Attachments
Fix for the test on UFS1 (956 bytes, patch)
2015-10-31 15:06 UTC, Andrew Turner
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2015-10-30 17:28:00 UTC
Test case: lib/libarchive/functional_test:test_write_disk_times

    Test program: /usr/tests/lib/libarchive/functional_test
    Result: failed: atf-check failed; see the output of the test for details
    Duration: 3.159s
    Execution context

Metadata

    allowed_architectures =
    allowed_platforms =
    description =
    has_cleanup = false
    required_configs =
    required_disk_space = 0
    required_files =
    required_memory = 0
    required_programs =
    required_user =
    timeout = 300

Standard output

Executing command [ /usr/tests/lib/libarchive/libarchive_test -d -r /usr/tests/lib/libarchive -v test_write_disk_times ]

Standard error

Fail: program did not exit cleanly
stdout:

If tests fail or crash, details will be in:
   /tmp/kyua.atf-tester.khnV1Y/libarchive_test.2015-10-29T07.30.01-000

Reference files will be read from: /usr/tests/lib/libarchive
Exercising: libarchive 3.1.2
245: test_write_disk_times
/usr/src/contrib/libarchive/libarchive/test/test_write_disk_times.c:130: File file11 has btime -1.000000000, expected 3456789.000012000

stderr:
 *** forcing core dump so failure can be debugged ***
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 20:14:57 UTC
Based on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204155 , I'm questioning whether or not birthtime is working on the file system/architecture -- what do you have mounted for /tmp ?
Comment 2 Ed Maste freebsd_committer freebsd_triage 2015-10-30 20:19:26 UTC
Yes, it looks like birthtime is indeed not working (although birthtime in PR204155 was a bug).

There's just a single UFS / mount on this system:

cavium% mount
/dev/ufs/freebsd_root on / (ufs, local, noatime)
devfs on /dev (devfs, local, multilabel)
cavium%
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 20:28:38 UTC
(In reply to Ed Maste from comment #2)

Agreed. The ls -l issue in the other bug was a legitimate mistake on my part :). It worked by accident because mtime and btime for a newly created file is the same (which reminds me that I need to change the btime in the other testcases that check the birth time).

Hmmm... I wonder if it's -o noatime. Here's what I'm using right now on my VM:

$ mount -p
/dev/da0p2              /                       ufs     rw              1 1
devfs                   /dev                    devfs   rw,multilabel   0 0
172.16.45.1:/Users/ngie/.ssh /home/ngie/.ssh            nfs     rw              0 0
172.16.45.1:/Users/ngie/nfs /home/ngie/nfs              nfs     rw              0 0
Comment 4 Ed Maste freebsd_committer freebsd_triage 2015-10-30 20:33:02 UTC
I just tried on a local noatime UFS mount here and still see birthtime set:

feynman% stat a.file
286 4 -rw-r--r-- 1 root wheel 0 0 "Oct 30 16:31:52 2015" "Oct 30 16:31:52 2015" "Oct 30 16:31:52 2015" "Oct 30 16:31:52 2015" 32768 0 0 a.file
Comment 5 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 20:37:05 UTC
(In reply to Ed Maste from comment #4)

Huh.

- Is there a bad type width in one of the machine/ headers?
- Is there a bug in libarchive or some conditional logic that happens to work on amd64, just because and doesn't work on arm64...?
Comment 6 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 20:41:04 UTC
(In reply to NGie Cooper from comment #5)

Or is utimes(2) working? Have you run pjdfstest on the platform yet (cd /usr/tests/sys/pjdfstest; sudo kyua test)?

 873 void
 874 archive_entry_set_birthtime(struct archive_entry *entry, time_t t, long ns)
 875 {
 876         FIX_NS(t, ns);
 877         entry->stat_valid = 0;
 878         entry->ae_set |= AE_SET_BIRTHTIME;
 879         entry->ae_stat.aest_birthtime = t;
 880         entry->ae_stat.aest_birthtime_nsec = ns;
 881 }
 882 
 883 void
 884 archive_entry_unset_birthtime(struct archive_entry *entry)
 885 {
 886         archive_entry_set_birthtime(entry, 0, 0);
 887         entry->ae_set &= ~AE_SET_BIRTHTIME;
 888 }
Comment 7 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 20:44:08 UTC
Adding kientzle for input on libarchive.
Comment 8 Ed Maste freebsd_committer freebsd_triage 2015-10-30 20:58:41 UTC
I saw the same thing on my Edgerouter Lite (mips64):

root@erl:~ # touch /tmp/a.file
root@erl:~ # stat -f %B /tmp/a.file
-1

Aha, it's because the Cavium has a UFS1 /

root@cavium:~ # dumpfs / | head -n1
magic   11954 (UFS1)    time    Thu Oct 29 11:52:42 2015
Comment 9 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 21:00:54 UTC
*blinks* UFS1 didn't have btime support?
Comment 10 Ed Maste freebsd_committer freebsd_triage 2015-10-30 21:05:06 UTC
Wikipedia says Kirk added it in UFS2.
Comment 11 Enji Cooper freebsd_committer freebsd_triage 2015-10-30 22:05:56 UTC
Well, that's unfortunate. Not sure how to move forward with this though -- maybe just document sometime to the effect of `Don't use UFS1!` and move on?

Then again, this will hit us at $work because we use UFS1 on our boot media... crap.
Comment 12 Andrew Turner freebsd_committer freebsd_triage 2015-10-31 15:06:30 UTC
Created attachment 162642 [details]
Fix for the test on UFS1

I've attached the fix I'm using on the Cavium.
Comment 13 Enji Cooper freebsd_committer freebsd_triage 2015-10-31 22:16:46 UTC
(In reply to Andrew Turner from comment #12)

That'll do for this case. It might be a good idea to note that not all filesystems support btime instead of just UFS1 (example: msdosfs probably..). If st_btime = -1 the definitive "file system doesn't support btime" check?
Comment 14 commit-hook freebsd_committer freebsd_triage 2016-06-29 07:01:16 UTC
A commit references this bug:

Author: mm
Date: Wed Jun 29 07:00:16 UTC 2016
New revision: 302264
URL: https://svnweb.freebsd.org/changeset/base/302264

Log:
  Update vendor/libarchive to git 084ef320b8fc62e3fd3acb762fe6175d48d7829c

  Vendor issues fixed:
  #686: Correctly grow buffer in archive_string_append_from_wcs_in_codepage()
  FreeBSD PR #204157: Fix test on filesystems without birthtime support

  PR:	204157

Changes:
  vendor/libarchive/dist/CMakeLists.txt
  vendor/libarchive/dist/build/cmake/CheckStructMember.cmake
  vendor/libarchive/dist/configure.ac
  vendor/libarchive/dist/libarchive/archive_read_disk_posix.c
  vendor/libarchive/dist/libarchive/archive_string.c
  vendor/libarchive/dist/libarchive/archive_write_disk_posix.c
  vendor/libarchive/dist/libarchive/test/main.c
  vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c
  vendor/libarchive/dist/libarchive_fe/passphrase.c
Comment 15 commit-hook freebsd_committer freebsd_triage 2016-06-30 08:52:29 UTC
A commit references this bug:

Author: mm
Date: Thu Jun 30 08:51:51 UTC 2016
New revision: 302294
URL: https://svnweb.freebsd.org/changeset/base/302294

Log:
  MFV r302264:

  Sync libarchive with vendor, bugfixes for tests:
  - fix tests on filesystems without birthtime support, e.g. UFS1 (1)
  - vendor issue #729: avoid use of C99 for-scope declarations in
    test_write_format_gnutar_filenames.c

  MFC after:	1 week
  PR:		204157 (1)
  Approved by:	re (hrs)

Changes:
_U  head/contrib/libarchive/
_U  head/contrib/libarchive/libarchive/
  head/contrib/libarchive/libarchive/archive_read_disk_posix.c
  head/contrib/libarchive/libarchive/archive_string.c
  head/contrib/libarchive/libarchive/archive_write_disk_posix.c
  head/contrib/libarchive/libarchive/test/main.c
  head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
_U  head/contrib/libarchive/libarchive_fe/
  head/contrib/libarchive/libarchive_fe/passphrase.c
Comment 16 commit-hook freebsd_committer freebsd_triage 2016-07-08 10:06:18 UTC
A commit references this bug:

Author: mm
Date: Fri Jul  8 10:06:03 UTC 2016
New revision: 302425
URL: https://svnweb.freebsd.org/changeset/base/302425

Log:
  MFC r302294:

  Sync libarchive with vendor, bugfixes for tests:
  - fix tests on filesystems without birthtime support, e.g. UFS1 (1)
  - vendor issue #729: avoid use of C99 for-scope declarations in
    test_write_format_gnutar_filenames.c

  PR:	204157 (1)

Changes:
_U  stable/10/
  stable/10/contrib/libarchive/libarchive/archive_read_disk_posix.c
  stable/10/contrib/libarchive/libarchive/archive_string.c
  stable/10/contrib/libarchive/libarchive/archive_write_disk_posix.c
  stable/10/contrib/libarchive/libarchive/test/main.c
  stable/10/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
  stable/10/contrib/libarchive/libarchive_fe/passphrase.c
Comment 17 Martin Matuska freebsd_committer freebsd_triage 2016-07-08 22:11:47 UTC
Fixed in HEAD and stable/10