├── VERSION ├── Documentation ├── INSTALL.rst ├── btrfsck.8 ├── requirements.txt ├── Scrub.rst ├── Convert.rst ├── Glossary.rst ├── Swapfile.rst ├── Compression.rst ├── Qgroups.rst ├── Subvolumes.rst ├── Zoned-mode.rst ├── Checksumming.rst ├── Seeding-device.rst ├── dev │ ├── Copy-Design-r.png │ └── Leaf-structure.png ├── Volume-management.rst ├── Hardware.rst ├── _templates │ └── layout.html ├── CHANGES.rst ├── Balance.rst ├── CodingConventions ├── ch-bootloaders.rst ├── man-index.rst ├── Resize.rst ├── _static │ └── style.css ├── Administration.rst ├── Auto-repair.rst ├── btrfs-map-logical.rst ├── btrfs-find-root.rst ├── html-preview.sh ├── ch-flexibility.rst ├── man-preview.sh └── Custom-ioctls.rst ├── libbtrfsutil ├── python │ ├── README.md │ ├── setup.cfg │ ├── MANIFEST.in │ ├── tests │ │ └── .pylintrc │ ├── .gitignore │ └── version.py.in ├── libbtrfsutil.pc.in └── stubs.h ├── ci ├── images │ ├── ci-musl-i386 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── Dockerfile │ │ └── test-build │ ├── ci-musl-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── Dockerfile │ │ └── test-build │ ├── ci-centos-8-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── ci-almalinux-10-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── ci-rockylinux-9-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── ci-openSUSE-Leap-15.3-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── ci-openSUSE-Leap-15.6-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── ci-openSUSE-tumbleweed-x86_64 │ │ ├── docker-run │ │ ├── docker-build │ │ ├── run-tests │ │ └── test-build │ ├── images-base-update │ ├── images-build-all │ ├── run-tests │ ├── images-push-all │ ├── docker-build │ ├── test-build │ └── docker-run ├── actions │ ├── keep-last-devel-runs │ ├── delete-all-failed-devel-runs │ ├── keep-last-codeql-tests │ ├── keep-last-ci-image-tests │ ├── keep-last-coverage │ ├── keep-last-static-binaries │ ├── keep-last-sanitizer-tests │ ├── delete-all-runs-of-branch │ └── update-artifacts ├── build-default ├── ci-build-almalinux10 ├── ci-build-rockylinux9 ├── ci-build-musl ├── ci-build-tumbleweed ├── ci-build-musl-i386 ├── ci-build-centos8 ├── ci-build-leap153 └── ci-build-leap156 ├── tests ├── fsck-tests │ ├── 004-no-dir-index │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 011-no-inode-item │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 014-no-extent-info │ │ ├── .lowmem_repairable │ │ ├── no_extent.raw.xz │ │ └── no_extent_bad_dev.img │ ├── 016-wrong-inode-nbytes │ │ ├── .lowmem_repairable │ │ └── default_case.img.xz │ ├── 039-bad-inode-mode │ │ ├── .lowmem_repairable │ │ ├── bad_free_space_cache_imode.raw.xz │ │ └── bad_imodes_in_subvolume_tree.img.xz │ ├── 047-dev-bytes-used │ │ ├── .lowmem_repairable │ │ └── default_case.img.xz │ ├── 068-orphan-dev-extent │ │ ├── .lowmem_repairable │ │ └── default.img.xz │ ├── 001-bad-file-extent-bytenr │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 009-no-dir-item-or-index │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 010-no-rootdir-inode-item │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 017-missing-all-file-extent │ │ ├── .lowmem_repairable │ │ └── default_case.img.xz │ ├── 038-missing-one-file-extent │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 041-invalid-root-generation │ │ ├── .lowmem_repairable │ │ └── default_case.img │ ├── 043-bad-inode-generation │ │ ├── .lowmem_repairable │ │ ├── bad_inode_transid.img.xz │ │ └── bad_inode_geneartion.img.xz │ ├── 050-invalid-block-group-used │ │ ├── .lowmem_repairable │ │ └── default.img.xz │ ├── 051-invalid-super-bytes-used │ │ ├── .lowmem_repairable │ │ └── default.img.xz │ ├── 066-missing-root-orphan-item │ │ ├── .lowmem_repairable │ │ └── default.img.xz │ ├── 065-valid-log-tree │ │ ├── hole.img.xz │ │ ├── compressed.img.xz │ │ ├── already-present.img.xz │ │ └── test.sh │ ├── 002-bad-transid │ │ └── default_case.img │ ├── 012-leaf-corruption │ │ └── good.img.xz │ ├── 049-dir-hard-link │ │ ├── default.img.xz │ │ └── test.sh │ ├── 067-dupe-filename │ │ ├── default.img.xz │ │ └── test.sh │ ├── 003-shift-offsets │ │ └── default_case.img │ ├── 054-orphan-directory │ │ ├── default.img.xz │ │ └── test.sh │ ├── 063-log-missing-csum │ │ ├── default.img.xz │ │ └── test.sh │ ├── 005-bad-item-offset │ │ └── default_case.img │ ├── 006-bad-root-items │ │ ├── default_case.tar.xz │ │ ├── skinny_case.tar.xz │ │ └── test.sh │ ├── 020-extent-ref-cases │ │ ├── no_inline_ref.img │ │ ├── no_skinny_ref.img │ │ ├── extent_data_ref.img │ │ ├── keyed_block_ref.img │ │ ├── keyed_data_ref.img │ │ ├── shared_data_ref.img │ │ ├── shared_block_ref.img │ │ ├── keyed_data_ref_only.img │ │ ├── shared_data_ref_only.img │ │ ├── inline_regular_coexist.img │ │ ├── shared_block_ref_only.raw.xz │ │ ├── tree_reloc_for_fs_tree.img.xz │ │ ├── tree_reloc_for_data_reloc.img.xz │ │ ├── keyed_data_ref_with_reloc_leaf.img │ │ ├── ref_count_mismatch_false_alert.img │ │ ├── block_group_item_false_alert.raw.xz │ │ ├── keyed_data_ref_with_shared_leaf.img │ │ └── test.sh │ ├── 034-bad-inode-flags │ │ ├── default_case.img │ │ └── test.sh │ ├── 042-half-dropped-inode │ │ └── default.raw.xz │ ├── 053-bad-metadata-level │ │ ├── default.img.xz │ │ └── test.sh │ ├── 008-bad-dir-index-name │ │ └── default_case.img │ ├── 007-bad-offset-snapshots │ │ └── default_case.img │ ├── 026-bad-dir-item-name │ │ └── default_case.img.xz │ ├── 029-valid-orphan-item │ │ ├── orphan_inode.img.xz │ │ └── test.sh │ ├── 032-corrupted-qgroup │ │ ├── qgroup_corrupted.img │ │ └── test.sh │ ├── 035-inline-bad-ram-bytes │ │ ├── offset_by_one.img │ │ └── test.sh │ ├── 055-super-num-devs-mismatch │ │ └── default.raw.xz │ ├── 018-leaf-crossing-stripes │ │ ├── default_case.raw.xz │ │ └── test.sh │ ├── 036-bad-dev-extents │ │ ├── over_dev_boundary.img.xz │ │ └── test.sh │ ├── 064-deprecated-inode-cache │ │ ├── 4k_nodesize.img.xz │ │ └── test.sh │ ├── 019-non-skinny-false-alert │ │ ├── default_case.img.xz │ │ └── test.sh │ ├── 036-rescan-not-kicked-in │ │ ├── no_rescan_kicked_in.img │ │ └── test.sh │ ├── 045-overlap-csum-item │ │ ├── overlap_csum_item.img.xz │ │ └── test.sh │ ├── 061-out-of-order-inline-backref │ │ ├── btrfs_image.img.xz │ │ └── test.sh │ ├── 022-qgroup-rescan-halfway │ │ ├── qgroup_rescan_halfway.raw.xz │ │ └── test.sh │ ├── 021-partially-dropped-snapshot-case │ │ ├── dropped-snapshot.img │ │ └── test.sh │ ├── 023-qgroup-stack-overflow │ │ ├── quota_balance_loop_backref.raw.xz │ │ └── test.sh │ ├── 058-bad-free-space-tree-entry │ │ ├── corrupt-free-space-tree.img.xz │ │ └── corrupt-free-space-tree2.img.xz │ ├── 040-compressed-nodatasum │ │ ├── compressed_extent_without_csum.raw.xz │ │ └── test.sh │ ├── 027-bad-extent-inline-ref-type │ │ └── bad-extent-inline-ref-type.raw.xz │ ├── 030-reflinked-prealloc-extents │ │ └── reflinked-prealloc-extents.img.xz │ ├── 028-unaligned-super-dev-sizes │ │ ├── dev_and_super_mismatch_unaligned.raw.xz │ │ └── test.sh │ ├── 044-invalid-extent-item-generation │ │ ├── bad_extent_item_gen_for_data.img.xz │ │ └── bad_extent_item_gen_for_tree_block.img.xz │ ├── 033-lowmem-collission-dir-items │ │ └── test.sh │ ├── 056-raid56-false-alerts │ │ └── test.sh │ ├── 059-shrunk-device │ │ └── test.sh │ ├── 031-metadatadump-check-data-csum │ │ └── test.sh │ └── 060-degraded-check │ │ └── test.sh ├── misc-tests │ ├── 049-btrfstune-transid-mismatch │ │ ├── default_case.img │ │ └── test.sh │ ├── 034-metadata-uuid │ │ ├── disk1.raw.xz │ │ ├── disk2.raw.xz │ │ ├── disk3.raw.xz │ │ ├── disk4.raw.xz │ │ ├── disk5.raw.xz │ │ ├── disk6.raw.xz │ │ ├── disk7.raw.xz │ │ └── disk8.raw.xz │ ├── 052-seed-dirty-log │ │ ├── dirty_log.img.xz │ │ └── test.sh │ ├── 025-zstd-compression │ │ └── compress.raw.xz │ ├── 032-bad-item-ptr │ │ ├── bad_item_ptr.raw.xz │ │ └── test.sh │ ├── 060-ino-cache-clean │ │ └── ino-cache-enabled.raw.xz │ ├── 069-btrfstune-resume-bgt │ │ ├── half-converted-bgt.raw.xz │ │ └── test.sh │ ├── 012-find-root-no-result │ │ ├── first_meta_chunk.btrfs-image │ │ └── test.sh │ ├── 016-send-clone-src │ │ └── multi-clone-src-v4.8.2.stream.xz │ ├── 051-warning-rw-subvol-received-uuid │ │ └── subvol-rw-recv.img │ ├── 037-fi-show-on-new-file │ │ └── test.sh │ ├── 005-convert-progress-thread-crash │ │ └── test.sh │ ├── 057-btrfstune-free-space-tree │ │ └── test.sh │ ├── 048-image-restore-mount │ │ └── test.sh │ ├── 027-subvol-list-deleted-toplevel │ │ └── test.sh │ ├── 036-receive-dump-invalid-stream │ │ └── test.sh │ ├── 056-subvolume-list-uuid │ │ └── test.sh │ ├── 017-recv-stream-malformatted │ │ └── test.sh │ ├── 059-qgroup-show-stale-qgroup-crash │ │ └── test.sh │ ├── 022-filesystem-du-on-empty-subvol │ │ └── test.sh │ ├── 008-leaf-crossing-stripes │ │ └── test.sh │ ├── 064-csum-conversion-basic │ │ └── test.sh │ ├── 010-convert-delete-ext2-subvol │ │ └── test.sh │ ├── 068-subvol-delete-recursive-show-child │ │ └── test.sh │ ├── 020-fix-superblock-corruption │ │ └── test.sh │ ├── 026-image-non-printable-chars │ │ └── test.sh │ ├── 015-dump-super-garbage │ │ └── test.sh │ └── 031-qgroup-parent-child-relation │ │ └── test.sh ├── fuzz-tests │ ├── images │ │ ├── bko-156731.raw.xz │ │ ├── bko-156741.raw.xz │ │ ├── bko-161811.raw.xz │ │ ├── bko-161821.raw.xz │ │ ├── bko-167551.raw.xz │ │ ├── bko-167781.raw.xz │ │ ├── bko-167921.raw.xz │ │ ├── bko-168301.raw.xz │ │ ├── bko-172811.raw.xz │ │ ├── bko-172861.raw.xz │ │ ├── bko-199839.raw.xz │ │ ├── bko-200403.raw.xz │ │ ├── bko-200409.raw.xz │ │ ├── bad-superblock-1.raw.xz │ │ ├── bad-superblock-2.raw.xz │ │ ├── bad-superblock-3.raw.xz │ │ ├── bko-96971-btrfs-image.raw.xz │ │ ├── bko-97171-btrfs-image.raw.xz │ │ ├── bko-97191-btrfs-image.raw.xz │ │ ├── bko-97271-btrfs-image.raw.xz │ │ ├── sys-chunk-type-bogus.raw.xz │ │ ├── bko-104131-fsck-oob-read.raw.xz │ │ ├── bko-155181-bad-backref.raw.xz │ │ ├── superblock-total-bytes-0.raw.xz │ │ ├── sys-array-num-stripes-0.raw.xz │ │ ├── bko-104141-fsck-exception.raw.xz │ │ ├── bko-166361-blocksize-zero.raw.xz │ │ ├── superblock-stripsize-bogus.raw.xz │ │ ├── sys-chunk-stripe-len-bogus.raw.xz │ │ ├── bko-154021-invalid-drop-level.raw.xz │ │ ├── bko-169301-1-blocksize-zero.raw.xz │ │ ├── bko-169301-2-blocksize-zero.raw.xz │ │ ├── bko-155551-unaligned-tree-block.raw.xz │ │ ├── bko-199833-reloc-recovery-crash.raw.xz │ │ ├── bko-155151-bad-block-group-offset.raw.xz │ │ ├── bko-155181-unaligned-extent-item.raw.xz │ │ ├── bko-155621-bad-block-group-offset.raw.xz │ │ ├── bko-97021-invalid-chunk-sectorsize.raw.xz │ │ ├── bko-154961-heap-overflow-chunk-items.raw.xz │ │ ├── bko-153641-unaligned-tree-block-bytenr.raw.xz │ │ ├── bko-156811-bad-parent-ref-qgroup-verify.raw.xz │ │ ├── bko-169311-blocksize-zero-qgroup-verify.raw.xz │ │ ├── bko-97031-invalid-stripe-len-sys-array.raw.xz │ │ ├── bko-97041-invalid-sub-stripes-zero-FPE.raw.xz │ │ ├── bko-155201-wrong-chunk-item-in-root-tree.raw.xz │ │ ├── bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz │ │ ├── bko-155151-bad-block-group-offset.raw.txt │ │ ├── bko-104141-fsck-exception.txt │ │ ├── bko-155181-unaligned-extent-item.raw.txt │ │ └── bad-superblock.txt │ ├── 004-simple-dump-tree │ │ └── test.sh │ ├── 006-simple-tree-stats │ │ └── test.sh │ ├── 001-simple-check-unmounted │ │ └── test.sh │ ├── 009-simple-zero-log │ │ └── test.sh │ ├── 005-simple-dump-super │ │ └── test.sh │ ├── 002-simple-image │ │ └── test.sh │ ├── 007-simple-super-recover │ │ └── test.sh │ ├── 008-simple-chunk-recover │ │ └── test.sh │ └── 003-multi-check-unmounted │ │ └── test.sh ├── convert-tests │ ├── 020-refuse-needs-recovery │ │ ├── ext4.raw.xz │ │ └── test.sh │ ├── 004-ext2-backup-superblock-ranges │ │ ├── drdhdhrh.e2image.raw.xz │ │ ├── hrhdhdrd.e2image.raw.xz │ │ ├── hrhdhrh.e2image.raw.xz │ │ └── drdhdhdrd.e2image.raw.xz │ ├── 023-64k-blocksize-migrated │ │ └── test.sh │ ├── 018-fs-size-overflow │ │ └── test.sh │ ├── 026-rollback-output │ │ └── test.sh │ ├── 001-ext2-basic │ │ └── test.sh │ ├── 003-ext4-basic │ │ └── test.sh │ ├── 028-block-group-tree │ │ └── test.sh │ ├── 024-ntfs-basic │ │ └── test.sh │ ├── 016-invalid-large-inline-extent │ │ └── test.sh │ ├── 010-reiserfs-basic │ │ └── test.sh │ ├── 008-readonly-image │ │ └── test.sh │ ├── 022-reiserfs-parent-ref │ │ └── test.sh │ ├── 006-large-hole-extent │ │ └── test.sh │ ├── 007-unsupported-block-sizes │ │ └── test.sh │ ├── 012-reiserfs-large-hole-extent │ │ └── test.sh │ ├── 017-fs-near-full │ │ └── test.sh │ └── 027-large-symbolic-link │ │ └── test.sh ├── mkfs-tests │ ├── 006-partitioned-loopdev │ │ ├── partition-1g-1g │ │ └── test.sh │ ├── 003-mixed-with-wrong-nodesize │ │ └── test.sh │ ├── 002-no-force-mixed-on-small-volume │ │ └── test.sh │ ├── 028-block-group-tree │ │ └── test.sh │ ├── 029-raid-stripe-tree │ │ └── test.sh │ ├── 011-rootdir-create-file │ │ └── test.sh │ ├── 023-free-space-tree │ │ └── test.sh │ ├── 031-zoned-bgt │ │ └── test.sh │ ├── 022-rootdir-size │ │ └── test.sh │ ├── 016-rootdir-bad-symbolic-link │ │ └── test.sh │ ├── 004-rootdir-keeps-size │ │ └── test.sh │ ├── 019-basic-checksums-mkfs │ │ └── test.sh │ ├── 030-zoned-rst │ │ └── test.sh │ ├── 024-fst-bitmaps │ │ └── test.sh │ ├── 012-rootdir-no-shrink │ │ └── test.sh │ ├── 026-extent-tree-to-bgt │ │ └── test.sh │ ├── 007-mix-nodesize-sectorsize │ │ └── test.sh │ ├── 034-rootdir-extra-hard-links │ │ └── test.sh │ ├── 020-basic-checksums-mount │ │ └── test.sh │ └── 018-multidevice-overflow │ │ └── test.sh ├── template │ ├── test.sh.check-all-images │ ├── test.sh.single-mkfs-mount │ └── test.sh.multi-mkfs-mount ├── testsuite-files ├── check-setup.sh ├── cli-tests │ ├── 015-defrag-compress │ │ └── test.sh │ ├── 002-balance-full-no-filters │ │ └── test.sh │ ├── 006-qgroup-show-sync │ │ └── test.sh │ ├── 007-check-force │ │ └── test.sh │ ├── 005-qgroup-show │ │ └── test.sh │ ├── 017-fi-show-missing │ │ └── test.sh │ └── 011-defrag-recursion │ │ └── test.sh ├── test-console.sh ├── hash-tests.sh ├── common.local └── scan-results.sh ├── image ├── Makefile └── common.h ├── mkfs └── Makefile ├── convert └── Makefile ├── .editorconfig ├── .readthedocs.yaml ├── libbtrfs ├── libbtrfs.sym ├── version.h.in └── crc32c.h ├── .codespellrc ├── kernel-lib └── list_sort.h ├── 64-btrfs-zoned.rules ├── 64-btrfs-dm.rules ├── kernel-shared └── locking.c ├── .github └── workflows │ ├── extended-build.yml │ ├── codespell.yml │ └── test.yml ├── common ├── defs.h ├── tree-search.h ├── extent-tree-utils.h ├── inject-error.h └── filesystem-utils.h ├── cmds ├── subvolume.h └── receive-dump.h └── crypto └── crc32c.h /VERSION: -------------------------------------------------------------------------------- 1 | v6.17.1 2 | -------------------------------------------------------------------------------- /Documentation/INSTALL.rst: -------------------------------------------------------------------------------- 1 | ../INSTALL -------------------------------------------------------------------------------- /libbtrfsutil/python/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /ci/images/ci-musl-i386/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-musl-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /Documentation/btrfsck.8: -------------------------------------------------------------------------------- 1 | .so man8/btrfs-check.8 2 | -------------------------------------------------------------------------------- /Documentation/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx_rtd_theme 2 | -------------------------------------------------------------------------------- /ci/images/ci-centos-8-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-musl-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /tests/fsck-tests/004-no-dir-index/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/011-no-inode-item/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ci/images/ci-almalinux-10-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-centos-8-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /ci/images/ci-rockylinux-9-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /tests/fsck-tests/014-no-extent-info/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/016-wrong-inode-nbytes/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/039-bad-inode-mode/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/047-dev-bytes-used/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/068-orphan-dev-extent/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ci/images/ci-almalinux-10-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.3-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.6-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-tumbleweed-x86_64/docker-run: -------------------------------------------------------------------------------- 1 | ../docker-run -------------------------------------------------------------------------------- /ci/images/ci-rockylinux-9-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /tests/fsck-tests/001-bad-file-extent-bytenr/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/009-no-dir-item-or-index/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/010-no-rootdir-inode-item/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/017-missing-all-file-extent/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/038-missing-one-file-extent/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/041-invalid-root-generation/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/043-bad-inode-generation/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.3-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.6-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-tumbleweed-x86_64/docker-build: -------------------------------------------------------------------------------- 1 | ../docker-build -------------------------------------------------------------------------------- /tests/fsck-tests/050-invalid-block-group-used/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/051-invalid-super-bytes-used/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fsck-tests/066-missing-root-orphan-item/.lowmem_repairable: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libbtrfsutil/python/setup.cfg: -------------------------------------------------------------------------------- 1 | [pycodestyle] 2 | max-line-length = 120 3 | -------------------------------------------------------------------------------- /libbtrfsutil/python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include btrfsutilpy.h 2 | include version.py 3 | -------------------------------------------------------------------------------- /Documentation/Scrub.rst: -------------------------------------------------------------------------------- 1 | Scrub 2 | ===== 3 | 4 | .. include:: ch-scrub-intro.rst 5 | -------------------------------------------------------------------------------- /Documentation/Convert.rst: -------------------------------------------------------------------------------- 1 | Convert 2 | ======= 3 | 4 | .. include:: ch-convert-intro.rst 5 | -------------------------------------------------------------------------------- /Documentation/Glossary.rst: -------------------------------------------------------------------------------- 1 | Glossary 2 | ======== 3 | 4 | .. include:: ch-glossary.rst 5 | -------------------------------------------------------------------------------- /Documentation/Swapfile.rst: -------------------------------------------------------------------------------- 1 | Swapfile 2 | ======== 3 | 4 | .. include:: ch-swapfile.rst 5 | -------------------------------------------------------------------------------- /Documentation/Compression.rst: -------------------------------------------------------------------------------- 1 | Compression 2 | =========== 3 | 4 | .. include:: ch-compression.rst 5 | -------------------------------------------------------------------------------- /Documentation/Qgroups.rst: -------------------------------------------------------------------------------- 1 | Quota groups 2 | ============ 3 | 4 | .. include:: ch-quota-intro.rst 5 | -------------------------------------------------------------------------------- /Documentation/Subvolumes.rst: -------------------------------------------------------------------------------- 1 | Subvolumes 2 | ========== 3 | 4 | .. include:: ch-subvolume-intro.rst 5 | -------------------------------------------------------------------------------- /Documentation/Zoned-mode.rst: -------------------------------------------------------------------------------- 1 | Zoned mode 2 | ========== 3 | 4 | .. include:: ch-zoned-intro.rst 5 | -------------------------------------------------------------------------------- /Documentation/Checksumming.rst: -------------------------------------------------------------------------------- 1 | Checksumming 2 | ============ 3 | 4 | .. include:: ch-checksumming.rst 5 | -------------------------------------------------------------------------------- /tests/misc-tests/049-btrfstune-transid-mismatch/default_case.img: -------------------------------------------------------------------------------- 1 | ../../fsck-tests/002-bad-transid/default_case.img -------------------------------------------------------------------------------- /Documentation/Seeding-device.rst: -------------------------------------------------------------------------------- 1 | Seeding device 2 | ============== 3 | 4 | .. include:: ch-seeding-device.rst 5 | -------------------------------------------------------------------------------- /Documentation/dev/Copy-Design-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/Documentation/dev/Copy-Design-r.png -------------------------------------------------------------------------------- /Documentation/dev/Leaf-structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/Documentation/dev/Leaf-structure.png -------------------------------------------------------------------------------- /Documentation/Volume-management.rst: -------------------------------------------------------------------------------- 1 | Volume management 2 | ================= 3 | 4 | .. include:: ch-volume-management-intro.rst 5 | -------------------------------------------------------------------------------- /image/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | all: 4 | $(MAKE) -C .. btrfs-image 5 | 6 | clean: 7 | -$(RM) -f -- *.o *.o.d 8 | -------------------------------------------------------------------------------- /libbtrfsutil/python/tests/.pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | extension-pkg-allow-list=btrfsutil 3 | 4 | [FORMAT] 5 | max-line-length=120 6 | -------------------------------------------------------------------------------- /mkfs/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | all: 4 | $(MAKE) -C .. mkfs.btrfs 5 | 6 | clean: 7 | -$(RM) -f -- *.o *.o.d 8 | -------------------------------------------------------------------------------- /Documentation/Hardware.rst: -------------------------------------------------------------------------------- 1 | Hardware considerations 2 | ======================= 3 | 4 | .. include:: ch-hardware-considerations.rst 5 | -------------------------------------------------------------------------------- /convert/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | all: 4 | $(MAKE) -C .. btrfs-convert 5 | 6 | clean: 7 | -$(RM) -f -- *.o *.o.d 8 | -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-156731.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-156731.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-156741.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-156741.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-161811.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-161811.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-161821.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-161821.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-167551.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-167551.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-167781.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-167781.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-167921.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-167921.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-168301.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-168301.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-172811.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-172811.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-172861.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-172861.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-199839.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-199839.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-200403.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-200403.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-200409.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-200409.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/065-valid-log-tree/hole.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/065-valid-log-tree/hole.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bad-superblock-1.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bad-superblock-1.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bad-superblock-2.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bad-superblock-2.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bad-superblock-3.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bad-superblock-3.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk1.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk1.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk2.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk2.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk3.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk3.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk4.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk4.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk5.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk5.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk6.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk6.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk7.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk7.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/034-metadata-uuid/disk8.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/034-metadata-uuid/disk8.raw.xz -------------------------------------------------------------------------------- /libbtrfsutil/python/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.pyc 3 | /btrfsutil.egg-info 4 | /btrfsutil*.so 5 | /build 6 | /constants.c 7 | /dist 8 | /version.py 9 | -------------------------------------------------------------------------------- /tests/fsck-tests/002-bad-transid/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/002-bad-transid/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/004-no-dir-index/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/004-no-dir-index/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/012-leaf-corruption/good.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/012-leaf-corruption/good.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/049-dir-hard-link/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/049-dir-hard-link/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/067-dupe-filename/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/067-dupe-filename/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/003-shift-offsets/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/003-shift-offsets/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/011-no-inode-item/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/011-no-inode-item/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/014-no-extent-info/no_extent.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/014-no-extent-info/no_extent.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/054-orphan-directory/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/054-orphan-directory/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/063-log-missing-csum/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/063-log-missing-csum/default.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-96971-btrfs-image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-96971-btrfs-image.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97171-btrfs-image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97171-btrfs-image.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97191-btrfs-image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97191-btrfs-image.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97271-btrfs-image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97271-btrfs-image.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/sys-chunk-type-bogus.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/sys-chunk-type-bogus.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/052-seed-dirty-log/dirty_log.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/052-seed-dirty-log/dirty_log.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/005-bad-item-offset/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/005-bad-item-offset/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/006-bad-root-items/default_case.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/006-bad-root-items/default_case.tar.xz -------------------------------------------------------------------------------- /tests/fsck-tests/006-bad-root-items/skinny_case.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/006-bad-root-items/skinny_case.tar.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/no_inline_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/no_inline_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/no_skinny_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/no_skinny_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/034-bad-inode-flags/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/034-bad-inode-flags/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/042-half-dropped-inode/default.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/042-half-dropped-inode/default.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/047-dev-bytes-used/default_case.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/047-dev-bytes-used/default_case.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/053-bad-metadata-level/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/053-bad-metadata-level/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/065-valid-log-tree/compressed.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/065-valid-log-tree/compressed.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/068-orphan-dev-extent/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/068-orphan-dev-extent/default.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-104131-fsck-oob-read.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-104131-fsck-oob-read.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155181-bad-backref.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155181-bad-backref.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/superblock-total-bytes-0.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/superblock-total-bytes-0.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/sys-array-num-stripes-0.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/sys-array-num-stripes-0.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/025-zstd-compression/compress.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/025-zstd-compression/compress.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/032-bad-item-ptr/bad_item_ptr.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/032-bad-item-ptr/bad_item_ptr.raw.xz -------------------------------------------------------------------------------- /tests/convert-tests/020-refuse-needs-recovery/ext4.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/convert-tests/020-refuse-needs-recovery/ext4.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/008-bad-dir-index-name/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/008-bad-dir-index-name/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/014-no-extent-info/no_extent_bad_dev.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/014-no-extent-info/no_extent_bad_dev.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/keyed_block_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/keyed_block_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/keyed_data_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/shared_data_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/shared_data_ref.img -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-104141-fsck-exception.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-104141-fsck-exception.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-166361-blocksize-zero.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-166361-blocksize-zero.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/superblock-stripsize-bogus.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/superblock-stripsize-bogus.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/sys-chunk-stripe-len-bogus.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/sys-chunk-stripe-len-bogus.raw.xz -------------------------------------------------------------------------------- /tests/mkfs-tests/006-partitioned-loopdev/partition-1g-1g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/mkfs-tests/006-partitioned-loopdev/partition-1g-1g -------------------------------------------------------------------------------- /tests/fsck-tests/001-bad-file-extent-bytenr/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/001-bad-file-extent-bytenr/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/007-bad-offset-snapshots/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/007-bad-offset-snapshots/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/009-no-dir-item-or-index/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/009-no-dir-item-or-index/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/010-no-rootdir-inode-item/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/010-no-rootdir-inode-item/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/016-wrong-inode-nbytes/default_case.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/016-wrong-inode-nbytes/default_case.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/shared_block_ref.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/shared_block_ref.img -------------------------------------------------------------------------------- /tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/026-bad-dir-item-name/default_case.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/032-corrupted-qgroup/qgroup_corrupted.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/032-corrupted-qgroup/qgroup_corrupted.img -------------------------------------------------------------------------------- /tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img -------------------------------------------------------------------------------- /tests/fsck-tests/050-invalid-block-group-used/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/050-invalid-block-group-used/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/051-invalid-super-bytes-used/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/051-invalid-super-bytes-used/default.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/055-super-num-devs-mismatch/default.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/055-super-num-devs-mismatch/default.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/065-valid-log-tree/already-present.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/065-valid-log-tree/already-present.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/066-missing-root-orphan-item/default.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/066-missing-root-orphan-item/default.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-154021-invalid-drop-level.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-154021-invalid-drop-level.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-169301-1-blocksize-zero.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-169301-1-blocksize-zero.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-169301-2-blocksize-zero.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-169301-2-blocksize-zero.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/018-leaf-crossing-stripes/default_case.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/018-leaf-crossing-stripes/default_case.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_only.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_only.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.img -------------------------------------------------------------------------------- /tests/fsck-tests/036-bad-dev-extents/over_dev_boundary.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/036-bad-dev-extents/over_dev_boundary.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/038-missing-one-file-extent/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/038-missing-one-file-extent/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/041-invalid-root-generation/default_case.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/041-invalid-root-generation/default_case.img -------------------------------------------------------------------------------- /tests/fsck-tests/064-deprecated-inode-cache/4k_nodesize.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/064-deprecated-inode-cache/4k_nodesize.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155551-unaligned-tree-block.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155551-unaligned-tree-block.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-199833-reloc-recovery-crash.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-199833-reloc-recovery-crash.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/060-ino-cache-clean/ino-cache-enabled.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/060-ino-cache-clean/ino-cache-enabled.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/017-missing-all-file-extent/default_case.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/017-missing-all-file-extent/default_case.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/019-non-skinny-false-alert/default_case.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/019-non-skinny-false-alert/default_case.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/inline_regular_coexist.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/inline_regular_coexist.img -------------------------------------------------------------------------------- /tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.img -------------------------------------------------------------------------------- /tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155181-unaligned-extent-item.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155181-unaligned-extent-item.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97021-invalid-chunk-sectorsize.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/shared_block_ref_only.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/shared_block_ref_only.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/tree_reloc_for_fs_tree.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/tree_reloc_for_fs_tree.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/043-bad-inode-generation/bad_inode_transid.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/043-bad-inode-generation/bad_inode_transid.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/061-out-of-order-inline-backref/btrfs_image.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/061-out-of-order-inline-backref/btrfs_image.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-154961-heap-overflow-chunk-items.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-154961-heap-overflow-chunk-items.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/069-btrfstune-resume-bgt/half-converted-bgt.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/069-btrfstune-resume-bgt/half-converted-bgt.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/tree_reloc_for_data_reloc.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/tree_reloc_for_data_reloc.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/039-bad-inode-mode/bad_free_space_cache_imode.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/039-bad-inode-mode/bad_free_space_cache_imode.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/043-bad-inode-generation/bad_inode_geneartion.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/043-bad-inode-generation/bad_inode_geneartion.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-153641-unaligned-tree-block-bytenr.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-153641-unaligned-tree-block-bytenr.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-156811-bad-parent-ref-qgroup-verify.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-156811-bad-parent-ref-qgroup-verify.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-169311-blocksize-zero-qgroup-verify.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-169311-blocksize-zero-qgroup-verify.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97031-invalid-stripe-len-sys-array.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97031-invalid-stripe-len-sys-array.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-97041-invalid-sub-stripes-zero-FPE.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-97041-invalid-sub-stripes-zero-FPE.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/012-find-root-no-result/first_meta_chunk.btrfs-image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/012-find-root-no-result/first_meta_chunk.btrfs-image -------------------------------------------------------------------------------- /tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/ref_count_mismatch_false_alert.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/ref_count_mismatch_false_alert.img -------------------------------------------------------------------------------- /tests/fsck-tests/022-qgroup-rescan-halfway/qgroup_rescan_halfway.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/022-qgroup-rescan-halfway/qgroup_rescan_halfway.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/039-bad-inode-mode/bad_imodes_in_subvolume_tree.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/039-bad-inode-mode/bad_imodes_in_subvolume_tree.img.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155201-wrong-chunk-item-in-root-tree.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-155201-wrong-chunk-item-in-root-tree.raw.xz -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz -------------------------------------------------------------------------------- /tests/misc-tests/051-warning-rw-subvol-received-uuid/subvol-rw-recv.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/misc-tests/051-warning-rw-subvol-received-uuid/subvol-rw-recv.img -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_shared_leaf.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_shared_leaf.img -------------------------------------------------------------------------------- /tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.img -------------------------------------------------------------------------------- /tests/convert-tests/004-ext2-backup-superblock-ranges/drdhdhrh.e2image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/convert-tests/004-ext2-backup-superblock-ranges/drdhdhrh.e2image.raw.xz -------------------------------------------------------------------------------- /tests/convert-tests/004-ext2-backup-superblock-ranges/hrhdhdrd.e2image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/convert-tests/004-ext2-backup-superblock-ranges/hrhdhdrd.e2image.raw.xz -------------------------------------------------------------------------------- /tests/convert-tests/004-ext2-backup-superblock-ranges/hrhdhrh.e2image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/convert-tests/004-ext2-backup-superblock-ranges/hrhdhrh.e2image.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/023-qgroup-stack-overflow/quota_balance_loop_backref.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/023-qgroup-stack-overflow/quota_balance_loop_backref.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/058-bad-free-space-tree-entry/corrupt-free-space-tree.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/058-bad-free-space-tree-entry/corrupt-free-space-tree.img.xz -------------------------------------------------------------------------------- /Documentation/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {% block extrahead %} 3 | 4 | {% endblock %} 5 | -------------------------------------------------------------------------------- /tests/convert-tests/004-ext2-backup-superblock-ranges/drdhdhdrd.e2image.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/convert-tests/004-ext2-backup-superblock-ranges/drdhdhdrd.e2image.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/040-compressed-nodatasum/compressed_extent_without_csum.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/040-compressed-nodatasum/compressed_extent_without_csum.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/058-bad-free-space-tree-entry/corrupt-free-space-tree2.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/058-bad-free-space-tree-entry/corrupt-free-space-tree2.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/027-bad-extent-inline-ref-type/bad-extent-inline-ref-type.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/027-bad-extent-inline-ref-type/bad-extent-inline-ref-type.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | end_of_line = lf 3 | insert_final_newline = true 4 | trim_trailing_whitespace = true 5 | charset = utf-8 6 | indent_style = tab 7 | indent_size = 8 8 | 9 | [*.py] 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /Documentation/CHANGES.rst: -------------------------------------------------------------------------------- 1 | Changes (btrfs-progs) 2 | ===================== 3 | 4 | Signed release tarballs can be found at https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/ 5 | 6 | .. include:: ../CHANGES 7 | -------------------------------------------------------------------------------- /tests/fsck-tests/028-unaligned-super-dev-sizes/dev_and_super_mismatch_unaligned.raw.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/028-unaligned-super-dev-sizes/dev_and_super_mismatch_unaligned.raw.xz -------------------------------------------------------------------------------- /tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen_for_data.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen_for_data.img.xz -------------------------------------------------------------------------------- /tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen_for_tree_block.img.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdave/btrfs-progs/HEAD/tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen_for_tree_block.img.xz -------------------------------------------------------------------------------- /tests/template/test.sh.check-all-images: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run check on all images 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_image() { 7 | run_check "$TOP/btrfs" check --readonly "$1" 8 | } 9 | 10 | check_all_images 11 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | build: 3 | os: ubuntu-22.04 4 | tools: 5 | python: "3.12" 6 | sphinx: 7 | configuration: Documentation/conf.py 8 | python: 9 | install: 10 | - requirements: Documentation/requirements.txt 11 | -------------------------------------------------------------------------------- /Documentation/Balance.rst: -------------------------------------------------------------------------------- 1 | Balance 2 | ======= 3 | 4 | .. include:: ch-balance-intro.rst 5 | 6 | Filters 7 | ------- 8 | 9 | .. include:: ch-balance-filters.rst 10 | 11 | Examples 12 | -------- 13 | 14 | .. include:: ch-balance-examples.rst 15 | -------------------------------------------------------------------------------- /ci/images/images-base-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Update all base images from Dockerfile 3 | # Run before: images-build-all 4 | 5 | for dir in ci-*; do 6 | echo "Update $dir" 7 | cd "$dir" 8 | docker pull `awk '/^FROM/ {print $2}' < Dockerfile` 9 | cd .. 10 | done 11 | -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.txt: -------------------------------------------------------------------------------- 1 | URL: https://bugzilla.kernel.org/show_bug.cgi?id=155151 2 | Lukas Lueg 2016-08-27 20:19:24 UTC 3 | 4 | More news from the fuzzer. The attached image causes btrfsck to enter what 5 | seems to be an endless loop; using btrfs-progs v4.7-42-g56e9586. 6 | -------------------------------------------------------------------------------- /tests/fsck-tests/065-valid-log-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check doesn't cause false alerts on various valid log trees 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | check_image() { 10 | run_check "$TOP/btrfs" check "$1" 11 | } 12 | 13 | check_all_images 14 | -------------------------------------------------------------------------------- /tests/mkfs-tests/003-mixed-with-wrong-nodesize/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Mixed mode needs equal sectorsize and nodesize 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | 9 | run_mayfail "$TOP/mkfs.btrfs" -b 512M -f -M -s 4096 -n 16384 "$TEST_DEV" && _fail 10 | 11 | exit 0 12 | -------------------------------------------------------------------------------- /libbtrfs/libbtrfs.sym: -------------------------------------------------------------------------------- 1 | LIBBTRFS_0.1 { 2 | global: 3 | /* common/send-stream.h */ 4 | btrfs_read_and_process_send_stream; /* used */ 5 | 6 | /* common/send-utils.h */ 7 | subvol_uuid_search; /* used */ 8 | subvol_uuid_search_init; /* used */ 9 | btrfs_subvolid_resolve; /* used */ 10 | local: 11 | *; 12 | }; 13 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | # Ref: https://github.com/codespell-project/codespell#using-a-config-file 3 | skip = .git*,*.svg,*.css,.codespellrc,fsck-tests 4 | check-hidden = true 5 | ignore-regex = \b(Yann Collet|TOI)\b 6 | # annote - used as a noun 7 | # iput - function name 8 | ignore-words-list = annote,annotes,iput,uptodate 9 | -------------------------------------------------------------------------------- /libbtrfsutil/libbtrfsutil.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libbtrfsutil 7 | Description: libbtrfsutil library 8 | Version: @BTRFS_VERSION_PLAIN@ 9 | URL: https://btrfs.readthedocs.io 10 | Cflags: -I${includedir} 11 | Libs: -L${libdir} -lbtrfsutil 12 | -------------------------------------------------------------------------------- /kernel-lib/list_sort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * taken from linux kernel include/list_sort.h 3 | */ 4 | #ifndef _LINUX_LIST_SORT_H 5 | #define _LINUX_LIST_SORT_H 6 | 7 | struct list_head; 8 | 9 | void list_sort(void *priv, struct list_head *head, 10 | int (*cmp)(void *priv, struct list_head *a, 11 | struct list_head *b)); 12 | #endif 13 | -------------------------------------------------------------------------------- /tests/fsck-tests/063-log-missing-csum/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect missing log csum items. 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | check_image() { 10 | run_mustfail "missing log csum items not detected" \ 11 | "$TOP/btrfs" check "$1" 12 | } 13 | 14 | check_all_images 15 | -------------------------------------------------------------------------------- /ci/images/images-build-all: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Rebuild all docker images 3 | # Run after: images-base-update 4 | 5 | for dir in ci-*; do 6 | echo "Build $dir" 7 | cd "$dir" 8 | # Do not build images with any stale branch snapshot, scripts ran 9 | # locally will update that as needed 10 | rm devel.tar.gz 11 | ./docker-build 12 | cd .. 13 | done 14 | -------------------------------------------------------------------------------- /tests/fsck-tests/067-dupe-filename/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can report duplicate filename as an error 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | check_image() { 10 | run_mustfail "duplicate filename not reported as error" \ 11 | "$TOP/btrfs" check "$1" 12 | } 13 | 14 | check_all_images 15 | -------------------------------------------------------------------------------- /ci/images/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /tests/fsck-tests/018-leaf-crossing-stripes/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | image=$(extract_image "./default_case.raw.xz") 8 | run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | 9 | grep -q "crossing stripe boundary" || 10 | _fail "no expected error message in the output" 11 | 12 | rm -f "$image" 13 | -------------------------------------------------------------------------------- /tests/fuzz-tests/004-simple-dump-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | run_mayfail "$TOP/btrfs" inspect-internal dump-tree "$1" 12 | } 13 | 14 | check_all_images "$TEST_TOP/fuzz-tests/images" 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /tests/fsck-tests/064-deprecated-inode-cache/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can report deprecated inode cache as an error 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | check_image() { 10 | run_mustfail "deprecated inode cache not reported as an error" \ 11 | "$TOP/btrfs" check "$1" 12 | } 13 | 14 | check_all_images 15 | -------------------------------------------------------------------------------- /tests/fuzz-tests/006-simple-tree-stats/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | run_mayfail "$TOP/btrfs" inspect-internal tree-stats "$1" 12 | } 13 | 14 | check_all_images "$TEST_TOP/fuzz-tests/images" 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /ci/images/ci-centos-8-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /ci/images/images-push-all: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # After pull and build push all images to the hub 3 | # Run after: images-build-all 4 | 5 | echo "WARNING: You are not supposed to run this" 6 | 7 | hubname=kdave 8 | tag=latest 9 | 10 | for dir in ci-*; do 11 | echo "Enter $dir" 12 | dir="${dir,,}" 13 | echo docker push "$hubname/$dir:$tag" 14 | docker push "$hubname/$dir:$tag" 15 | done 16 | -------------------------------------------------------------------------------- /tests/misc-tests/052-seed-dirty-log/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make sure btrfstune will not set seed flag when the fs has dirty log 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfstune 8 | 9 | image=$(extract_image "./dirty_log.img.xz") 10 | 11 | run_mustfail "btrfstune should reject fs with dirty log for seeding flag" \ 12 | "$TOP/btrfstune" -S1 "$image" 13 | -------------------------------------------------------------------------------- /ci/images/ci-almalinux-10-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /ci/images/ci-rockylinux-9-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /tests/template/test.sh.single-mkfs-mount: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Simple test to create a new filesystem and test that it can be mounted 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | prepare_test_dev 8 | 9 | run_check_mkfs_test_dev 10 | run_check_mount_test_dev 11 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 12 | run_check_umount_test_dev 13 | -------------------------------------------------------------------------------- /64-btrfs-zoned.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM!="block", GOTO="btrfs_end" 2 | ACTION!="add|change", GOTO="btrfs_end" 3 | ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_end" 4 | 5 | # Zoned btrfs needs an IO scheduler that supports zone write locking and 6 | # currently mq-deadline is the only scheduler capable of this. 7 | ATTR{queue/zoned}=="host-managed", ATTR{queue/scheduler}="mq-deadline" 8 | 9 | LABEL="btrfs_end" 10 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.3-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.6-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-tumbleweed-x86_64/run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | where="$1" 4 | 5 | cd "$where" || { echo "ERROR: $1 not found"; exit 1; } 6 | 7 | make TEST_LOG=dump test-cli 8 | make TEST_LOG=dump test-mkfs 9 | make TEST_LOG=dump test-check 10 | make TEST_LOG=dump test-check-lowmem 11 | make TEST_LOG=dump test-misc 12 | make TEST_LOG=dump test-convert 13 | make TEST_LOG=dump test-fuzz 14 | -------------------------------------------------------------------------------- /ci/images/docker-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run from the directory with Dockerfile, directory name should match the image 3 | # name 4 | 5 | prefix=kdave 6 | image=$(basename `pwd` | tr '[A-Z]' '[a-z]') 7 | 8 | # Make sure the file exists as it's required but can be empty. In that case 9 | # it's downloaded when ./test-build is executed 10 | touch devel.tar.gz 11 | docker build -t "$prefix/$image" . 12 | -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-104141-fsck-exception.txt: -------------------------------------------------------------------------------- 1 | URL: https://bugzilla.kernel.org/show_bug.cgi?id=104141 2 | Hanno Boeck 2015-09-07 07:27:58 UTC 3 | 4 | Created attachment 186951 [details] 5 | malformed filesystem causing floating point exception 6 | 7 | The attacked file will cause a floating point exception in btrfsck. 8 | 9 | This was found while fuzzing btrfs-progs with american fuzzy lop. 10 | -------------------------------------------------------------------------------- /tests/fsck-tests/035-inline-bad-ram-bytes/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Around 2014, btrfs kernel has a regression that create inline extent 3 | # with ram_bytes offset by one. 4 | # This old regression could be caught by tree-check code. 5 | # This test case will check if btrfs check could detect and repair it. 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | check_all_images 12 | -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bko-155181-unaligned-extent-item.raw.txt: -------------------------------------------------------------------------------- 1 | URL: https://bugzilla.kernel.org/show_bug.cgi?id=155181 2 | Lukas Lueg 2016-08-28 10:52:32 UTC 3 | 4 | Created attachment 230891 [details] 5 | BTRFS-image that reaches abort() in btrfsck 6 | 7 | More news from the fuzzer. The attached image causes btrfsck to reach abort() 8 | in in cmds-check.c:add_tree_backref(); using btrfs-progs v4.7-42-g56e9586. 9 | -------------------------------------------------------------------------------- /tests/misc-tests/037-fi-show-on-new-file/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # test for 'filesystem show' on fresh local file 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | 11 | _mktemp_local img 3g 12 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f img 13 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem show img 14 | 15 | rm -f img 16 | -------------------------------------------------------------------------------- /tests/fuzz-tests/001-simple-check-unmounted/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # iterate over all fuzzed images and run 'btrfs check' 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | 11 | # redefine the one provided by common 12 | check_image() { 13 | run_mayfail "$TOP/btrfs" check "$1" 14 | } 15 | 16 | check_all_images "$TEST_TOP/fuzz-tests/images" 17 | 18 | exit 0 19 | -------------------------------------------------------------------------------- /ci/images/ci-musl-i386/docker-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run from the directory with Dockerfile, directory name should match the image 3 | # name 4 | 5 | prefix=kdave 6 | image=$(basename `pwd` | tr '[A-Z]' '[a-z]') 7 | 8 | # Make sure the file exists as it's required but can be empty. In that case 9 | # it's downloaded when ./test-build is executed 10 | touch devel.tar.gz 11 | docker build --platform linux/386 -t "$prefix/$image" . 12 | -------------------------------------------------------------------------------- /64-btrfs-dm.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM!="block", GOTO="btrfs_end" 2 | KERNEL!="dm-[0-9]*", GOTO="btrfs_end" 3 | ACTION!="add|change", GOTO="btrfs_end" 4 | ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_end" 5 | 6 | # Once the device mapper symlink is created, tell btrfs about it 7 | # so we get the friendly name in /proc/mounts (and tools that read it) 8 | ENV{DM_NAME}=="?*", RUN{builtin}+="btrfs ready /dev/mapper/$env{DM_NAME}" 9 | 10 | LABEL="btrfs_end" 11 | -------------------------------------------------------------------------------- /tests/misc-tests/032-bad-item-ptr/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that btrfs inspect dump-tree won't segfault on heavily corrupted 4 | # tree leaf 5 | # Issue: #128 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | check_image() { 12 | run_check "$TOP/btrfs" inspect-internal dump-tree "$1" 13 | run_mustfail "btrfs check failed to detect such corruption" \ 14 | "$TOP/btrfs" check "$1" 15 | } 16 | 17 | check_all_images 18 | -------------------------------------------------------------------------------- /tests/misc-tests/005-convert-progress-thread-crash/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # test convert-thread-conflict 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq btrfs-convert 7 | 8 | mkfs.ext4 -V &>/dev/null || _not_run "mkfs.ext4 not found" 9 | prepare_test_dev 10 | 11 | for ((i = 0; i < 20; i++)); do 12 | _log "loop $i" 13 | mkfs.ext4 -F "$TEST_DEV" &>>"$RESULTS" || _not_run "mkfs.ext4 failed" 14 | run_check "$TOP/btrfs-convert" "$TEST_DEV" 15 | done 16 | -------------------------------------------------------------------------------- /tests/mkfs-tests/002-no-force-mixed-on-small-volume/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that we do not force mixed block groups on small volumes anymore 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | 9 | setup_root_helper 10 | 11 | mixed=$(run_check_stdout "$TOP/mkfs.btrfs" -b 512M -n 64k -f "$TEST_DEV" | grep -E 'Data|Metadata') 12 | echo "$mixed" | grep -q -v 'Data+Metadata:' || _fail "unexpected: created a mixed-bg filesystem" 13 | -------------------------------------------------------------------------------- /tests/fsck-tests/023-qgroup-stack-overflow/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Check whether btrfs check quota verify will cause stack overflow. 4 | # This is caused by lack of handling of tree reloc tree. 5 | # Fixed by patch: 6 | # btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree 7 | 8 | source "$TEST_TOP/common" || exit 9 | 10 | check_prereq btrfs 11 | 12 | check_image() 13 | { 14 | run_check "$TOP/btrfs" check "$1" 15 | } 16 | 17 | check_all_images 18 | -------------------------------------------------------------------------------- /ci/actions/keep-last-devel-runs: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | 3 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 4 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 5 | 6 | repo="kdave/btrfs-progs" 7 | 8 | from=11 9 | 10 | for id in $(gh run -R "$repo" list --limit 100 --workflow 'Devel build and tests' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do 11 | echo "Delete run $id" 12 | gh run -R "$repo" delete "$id" 13 | done 14 | -------------------------------------------------------------------------------- /tests/fuzz-tests/009-simple-zero-log/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | local image 12 | 13 | image="$1" 14 | run_check cp "$image" "$image".scratch 15 | run_mayfail "$TOP/btrfs" rescue zero-log "$image".scratch 16 | rm -- "$image".scratch 17 | } 18 | 19 | check_all_images "$TEST_TOP/fuzz-tests/images" 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/misc-tests/069-btrfstune-resume-bgt/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # To check if btrfstune can handle half converted fs. 3 | # 4 | # Due to a bug in the block group items loading code, old block groups items 5 | # in the old extent tree can be skipped, thus causing resume failure. 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | check_image() { 12 | run_check "$TOP/btrfstune" --convert-to-block-group-tree "$1" 13 | } 14 | 15 | check_all_images 16 | -------------------------------------------------------------------------------- /tests/fsck-tests/022-qgroup-rescan-halfway/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # check whether btrfsck can detect running qgroup rescan 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq btrfs 7 | 8 | check_image() { 9 | local image 10 | 11 | image=$1 12 | run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | \ 13 | grep -q "Counts for qgroup id" 14 | if [ $? -eq 0 ]; then 15 | _fail "Btrfs check doesn't detect rescan correctly" 16 | fi 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /tests/fuzz-tests/005-simple-dump-super/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | local image 12 | 13 | image="$1" 14 | run_mayfail "$TOP/btrfs" inspect-internal dump-super "$image" 15 | run_mayfail "$TOP/btrfs" inspect-internal dump-super -Ffa "$image" 16 | } 17 | 18 | check_all_images "$TEST_TOP/fuzz-tests/images" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/mkfs-tests/028-block-group-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Basic check if mkfs supports the block-group-tree 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | run_check_mkfs_test_dev -O block-group-tree 13 | 14 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \ 15 | grep -q BLOCK_GROUP_TREE || _fail "block group tree not created" 16 | -------------------------------------------------------------------------------- /ci/build-default: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [optional arguments to configure] 3 | 4 | if ! [ -f "./autogen.sh" ]; then 5 | echo "ERROR: cannot find autogen.sh, run from the top level directory" 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | jobs=`grep -c ^processor /proc/cpuinfo` 12 | 13 | ./autogen.sh 14 | ./configure "$@" 15 | echo "D=$D" 16 | make -j $jobs 17 | make -j $jobs btrfs.box 18 | make hash-speedtest hash-vectest ioctl-test json-formatter-test string-table-test 19 | -------------------------------------------------------------------------------- /tests/fuzz-tests/002-simple-image/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # iterate over all fuzzed images and run 'btrfs-image' 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs-image 8 | 9 | setup_root_helper 10 | 11 | # redefine the one provided by common 12 | check_image() { 13 | truncate -s0 target 14 | run_mayfail "$TOP/btrfs-image" "$1" target 15 | truncate -s0 target 16 | } 17 | 18 | check_all_images "$TEST_TOP/fuzz-tests/images" 19 | 20 | rm -- target 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/fuzz-tests/007-simple-super-recover/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | local image 12 | 13 | image=$1 14 | run_check cp "$image" "$image".scratch 15 | run_mayfail $TOP/btrfs rescue super-recover -y -v "$image".scratch 16 | rm -- "$image".scratch 17 | } 18 | 19 | check_all_images "$TEST_TOP/fuzz-tests/images" 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /libbtrfs/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __LIBBTRFS_VERSION_H__ 2 | #define __LIBBTRFS_VERSION_H__ 3 | 4 | #define BTRFS_LIB_MAJOR @LIBBTRFS_MAJOR@ 5 | #define BTRFS_LIB_MINOR @LIBBTRFS_MINOR@ 6 | #define BTRFS_LIB_PATCHLEVEL @LIBBTRFS_PATCHLEVEL@ 7 | 8 | #define BTRFS_LIB_VERSION ( BTRFS_LIB_MAJOR * 10000 + \ 9 | BTRFS_LIB_MINOR * 100 + \ 10 | BTRFS_LIB_PATCHLEVEL ) 11 | 12 | #define BTRFS_BUILD_VERSION "Btrfs @PACKAGE_VERSION@" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /tests/fuzz-tests/008-simple-chunk-recover/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | setup_root_helper 8 | 9 | # redefine the one provided by common 10 | check_image() { 11 | local image 12 | 13 | image="$1" 14 | run_check cp "$image" "$image".scratch 15 | run_mayfail "$TOP/btrfs" rescue chunk-recover -y -v "$image".scratch 16 | rm -- "$image".scratch 17 | } 18 | 19 | check_all_images "$TEST_TOP/fuzz-tests/images" 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/fsck-tests/029-valid-orphan-item/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # To check if btrfs check can handle valid orphan items. 3 | # Orphan item is a marker for deleted inodes that were open at the time of 4 | # deletion. # Orphan inode/root will is not referenced and will have an orphan 5 | # item, which should not be reported as error. 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | check_image() { 12 | run_check "$TOP/btrfs" check "$1" 13 | } 14 | 15 | check_all_images 16 | -------------------------------------------------------------------------------- /tests/fsck-tests/034-bad-inode-flags/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # In order to confirm that 'btrfs check' supports checking symlinks 3 | # with immutable/append attributes that are not possible to set by standard 4 | # syscall or ioctl so they're handled as corruption 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs 9 | 10 | check_image() { 11 | run_mustfail "check should report errors about inode flags" \ 12 | $SUDO_HELPER "$TOP/btrfs" check "$1" 13 | } 14 | 15 | check_all_images 16 | -------------------------------------------------------------------------------- /tests/fsck-tests/006-bad-root-items/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | 5 | check_prereq btrfs 6 | 7 | _log "extracting image default_case.tar.xz" 8 | tar --no-same-owner -xJf default_case.tar.xz || \ 9 | _fail "failed to extract default_case.tar.xz" 10 | check_image test.img 11 | 12 | _log "extracting image skinny_case.tar.xz" 13 | tar --no-same-owner -xJf skinny_case.tar.xz || \ 14 | _fail "failed to extract skinny_case.tar.xz" 15 | check_image test.img 16 | 17 | rm test.img 18 | -------------------------------------------------------------------------------- /tests/fsck-tests/045-overlap-csum-item/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect overlapped csum items 4 | # 5 | # There is one report of overlap csum items, causing tree-checker to reject 6 | # the csum tree. 7 | # 8 | # Make sure btrfs check can at least detect such error 9 | 10 | source "$TEST_TOP/common" || exit 11 | 12 | check_prereq btrfs 13 | 14 | check_image() { 15 | run_mustfail "overlapping csum item not detected" \ 16 | "$TOP/btrfs" check "$1" 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /tests/mkfs-tests/029-raid-stripe-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Basic check if mkfs supports the raid-stripe-tree 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_experimental_build 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev -O raid-stripe-tree 14 | 15 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \ 16 | grep -q RAID_STRIPE_TREE || _fail "raid stripe tree not created" 17 | -------------------------------------------------------------------------------- /tests/template/test.sh.multi-mkfs-mount: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a new multi-device filesystem and test that it can be mounted 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | setup_loopdevs 4 8 | prepare_loopdevs 9 | TEST_DEV=${loopdevs[1]} 10 | 11 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 "${loopdevs[@]}" 12 | run_check_mount_test_dev 13 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 14 | run_check_umount_test_dev 15 | 16 | cleanup_loopdevs 17 | -------------------------------------------------------------------------------- /Documentation/CodingConventions: -------------------------------------------------------------------------------- 1 | C style 2 | ------- 3 | 4 | The kernel CodingStyle where applicable 5 | 6 | https://www.kernel.org/doc/html/latest/process/coding-style.html 7 | 8 | Error messages 9 | -------------- 10 | 11 | * formatting: 12 | * use `error("string ...")` 13 | * no trailing newline 14 | * small letter starts the first word 15 | * no string splitting 16 | * move string to new line if it's too long, un-indent to the left if it 17 | exceeds 80 chars 18 | * contents: 19 | * be descriptive 20 | -------------------------------------------------------------------------------- /tests/misc-tests/049-btrfstune-transid-mismatch/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verify that btrfstune would reject fs with transid mismatch problems 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq btrfs-image 7 | check_prereq btrfs 8 | check_prereq btrfstune 9 | 10 | # Although we're not checking the image, here we just reuse the infrastructure 11 | check_image() { 12 | run_mustfail "btrfstune should fail when the image has transid error" \ 13 | "$TOP/btrfstune" -u "$1" 14 | } 15 | 16 | check_all_images 17 | -------------------------------------------------------------------------------- /ci/actions/delete-all-failed-devel-runs: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Delete all failed devel runs 4 | 5 | workflow='Devel build and tests' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --status failure --json databaseId | jq '.[].databaseId'); do 12 | echo "Delete run $id" 13 | gh run -R "$repo" delete "$id" 14 | done 15 | -------------------------------------------------------------------------------- /tests/fsck-tests/049-dir-hard-link/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect overlapped dir with 2 links 4 | # 5 | # There is a report that btrfs-check doesn't report dir with 2 links as 6 | # error, and only get caught by tree-checker. 7 | # 8 | # Make sure btrfs check can at least detect such error. 9 | 10 | source "$TEST_TOP/common" || exit 11 | 12 | check_prereq btrfs 13 | 14 | check_image() { 15 | run_mustfail "dir with 2 links not detected" \ 16 | "$TOP/btrfs" check "$1" 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /tests/convert-tests/023-64k-blocksize-migrated/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Make sure the migrated range doesn't cause csum errors 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | setup_root_helper 8 | prepare_test_dev 10G 9 | 10 | check_global_prereq mkfs.ext4 11 | check_prereq btrfs-convert 12 | check_prereq btrfs 13 | 14 | run_check mkfs.ext4 -b 64K -F "$TEST_DEV" 15 | run_check $SUDO_HELPER "$TOP/btrfs-convert" --nodesize 64K "$TEST_DEV" 16 | run_check $SUDO_HELPER "$TOP/btrfs" check --check-data-csum "$TEST_DEV" 17 | -------------------------------------------------------------------------------- /tests/fsck-tests/053-bad-metadata-level/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect invalid metadata backref level. 4 | # 5 | # There is a report that btrfs-check original mode doesn't report invalid 6 | # metadata backref level, and lowmem mode would just crash. 7 | # 8 | # Make sure btrfs check can at least detect such error. 9 | 10 | source "$TEST_TOP/common" || exit 11 | 12 | check_prereq btrfs 13 | 14 | check_image() { 15 | run_mustfail "invalid metadata backref level not detected" \ 16 | "$TOP/btrfs" check "$1" 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /tests/fsck-tests/036-rescan-not-kicked-in/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Under certain power loss case, btrfs quota tree can be initialized but 3 | # rescan not kicked in. Can be also reproduced by fstests/btrfs/166 but with 4 | # low probability. 5 | # 6 | # This test case verifies a special case when 'btrfs check' does not report 7 | # qgroup accounting difference as an error, thus no false alert for btrfs/166. 8 | 9 | source "$TEST_TOP/common" || exit 10 | 11 | check_prereq btrfs 12 | 13 | check_image() { 14 | run_check "$TOP/btrfs" check "$1" 15 | } 16 | 17 | check_all_images 18 | -------------------------------------------------------------------------------- /tests/testsuite-files: -------------------------------------------------------------------------------- 1 | F README.md 2 | G Documentation/ 3 | F testsuite-id 4 | F ../fssum 5 | F ../btrfs-corrupt-block 6 | F ../btrfs-find-root 7 | F ../btrfs-select-super 8 | F common 9 | F common.convert 10 | F common.local 11 | G tests/cli-tests/ 12 | F cli-tests.sh 13 | G tests/convert-tests/ 14 | F convert-tests.sh 15 | G tests/fsck-tests/ 16 | F fsck-tests.sh 17 | G tests/fuzz-tests/ 18 | F fuzz-tests.sh 19 | G tests/misc-tests/ 20 | F misc-tests.sh 21 | G tests/mkfs-tests/ 22 | F mkfs-tests.sh 23 | F scan-results.sh 24 | F test-console.sh 25 | F clean-tests.sh 26 | F Makefile 27 | -------------------------------------------------------------------------------- /tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # confirm whether 'btrfs check' supports check ing of a partially dropped 3 | # snapshot 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | check_image() 10 | { 11 | local image 12 | 13 | image=$1 14 | run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | 15 | grep -q "Errors found in extent allocation tree or chunk allocation" 16 | if [ $? -eq 0 ]; then 17 | rm -f "$image" 18 | _fail "unexpected error occurred when checking $img" 19 | fi 20 | } 21 | 22 | check_all_images 23 | -------------------------------------------------------------------------------- /ci/actions/keep-last-codeql-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Keep last runs of master for CodeQL workflow 4 | 5 | workflow='CodeQL (Advanced)' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for branch in master; do 12 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do 13 | echo "Delete run $id" 14 | gh run -R "$repo" delete "$id" 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /tests/fsck-tests/061-out-of-order-inline-backref/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect out-of-order inline backref items. 4 | # 5 | # There is a report that one ntfs2btrfs generated some out-of-order inline 6 | # backref items, while btrfs-check failed to detect it at all. 7 | # 8 | # Make sure btrfs check can at least detect such error. 9 | 10 | source "$TEST_TOP/common" || exit 11 | 12 | check_prereq btrfs 13 | 14 | check_image() { 15 | run_mustfail "out-of-order inline backref items not detected" \ 16 | "$TOP/btrfs" check "$1" 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /ci/actions/keep-last-ci-image-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Keep last runs of master and release-test 4 | 5 | workflow='CI image tests' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for branch in master release-test; do 12 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do 13 | echo "Delete run $id" 14 | gh run -R "$repo" delete "$id" 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /ci/actions/keep-last-coverage: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Keep last runs of master and coverage-test 4 | 5 | workflow='Code coverage tests' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for branch in master coverage-test; do 12 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do 13 | echo "Delete run $id" 14 | gh run -R "$repo" delete "$id" 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /ci/actions/keep-last-static-binaries: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Keep last runs of master and release-test 4 | 5 | workflow='Static binaries' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for branch in master release-test; do 12 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do 13 | echo "Delete run $id" 14 | gh run -R "$repo" delete "$id" 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /tests/mkfs-tests/011-rootdir-create-file/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Regression test for mkfs.btrfs --rootdir on non-existent file. 3 | # Expected behavior: it should create a new file if destination doesn't exist 4 | # Regression 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs") 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq mkfs.btrfs 9 | 10 | tmp=$(_mktemp_dir mkfs-rootdir) 11 | # we can't use TEST_DEV, a file is needed 12 | img=$(_mktemp mkfs-rootdir) 13 | run_check "$TOP/mkfs.btrfs" -f --rootdir "$INTERNAL_BIN/Documentation/" "$img" 14 | 15 | rm -rf -- "$img" 16 | -------------------------------------------------------------------------------- /ci/actions/keep-last-sanitizer-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Keep last runs of master and sanitize-test 4 | 5 | workflow='Sanitizer checks' 6 | repo="kdave/btrfs-progs" 7 | 8 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 9 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 10 | 11 | for branch in master sanitize-test; do 12 | for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do 13 | echo "Delete run $id" 14 | gh run -R "$repo" delete "$id" 15 | done 16 | done 17 | -------------------------------------------------------------------------------- /kernel-shared/locking.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #include "kerncompat.h" 4 | #include "kernel-shared/ctree.h" 5 | #include "kernel-shared/extent_io.h" 6 | 7 | struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root) 8 | { 9 | root->node->refs++; 10 | return root->node; 11 | } 12 | 13 | struct extent_buffer *btrfs_try_read_lock_root_node(struct btrfs_root *root) 14 | { 15 | root->node->refs++; 16 | return root->node; 17 | } 18 | 19 | struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root) 20 | { 21 | root->node->refs++; 22 | return root->node; 23 | } 24 | -------------------------------------------------------------------------------- /tests/fuzz-tests/images/bad-superblock.txt: -------------------------------------------------------------------------------- 1 | bad-superblock-*.txt 2 | 3 | Crafted images from Jiri Slaby, produced by some symbolic execution framework 4 | that finds unhandled cases at mount time. 5 | 6 | Relevant kernel patches to backport: 7 | 8 | e3540eab29e1b2260bc4b9b3979a49a00e3e3af8 9 | btrfs: add more checks to btrfs_read_sys_array 10 | 11 | ce7fca5f57ed0fcd7e7b3d7b1a3e1791f8e56fa3 12 | btrfs: add checks for sys_chunk_array sizes 13 | 14 | 75d6ad382bb91f363452119d34238e156589ca2d 15 | btrfs: more superblock checks, lower bounds on devices and sectorsize/nodesize 16 | 17 | (and more from fs/btrfs/super.c) 18 | -------------------------------------------------------------------------------- /Documentation/ch-bootloaders.rst: -------------------------------------------------------------------------------- 1 | GRUB2 (https://www.gnu.org/software/grub) has the most advanced support of 2 | booting from BTRFS with respect to features. 3 | 4 | U-Boot (https://www.denx.de/wiki/U-Boot/) has decent support for booting but 5 | not all BTRFS features are implemented, check the documentation. 6 | 7 | In general, the first 1MiB on each device is unused with the exception of 8 | primary superblock that is on the offset 64KiB and spans 4KiB. The rest can be 9 | freely used by bootloaders or for other system information. Note that booting 10 | from a filesystem on :doc:`zoned device` is not supported. 11 | -------------------------------------------------------------------------------- /tests/misc-tests/057-btrfstune-free-space-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test btrfstune --convert-to-free-space-tree option 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfstune 9 | check_prereq btrfs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | check_kernel_support_acl 14 | 15 | run_check_mkfs_test_dev -O ^free-space-tree 16 | run_check_mount_test_dev 17 | populate_fs 18 | run_check_umount_test_dev 19 | 20 | run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-free-space-tree "$TEST_DEV" 21 | 22 | run_check "$TOP/btrfs" check "$TEST_DEV" 23 | -------------------------------------------------------------------------------- /tests/check-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Check that the system setup and configuration are sufficient for all tests to run 4 | 5 | for dir in *-tests; do 6 | missing= 7 | echo "Checking prerequisites for: $dir" 8 | for prog in $(find "$dir" -name 'test.sh' -exec grep check_global_prereq '{}' \; | sort -u); do 9 | if [ "$prog" = check_global_prereq ]; then 10 | continue 11 | fi 12 | if type -p "$prog" &> /dev/null; then 13 | echo "Check $prog: OK" 14 | else 15 | echo "Check $prog: MISSING" 16 | missing+=" $prog" 17 | fi 18 | done 19 | 20 | if ! [ -z "$missing" ]; then 21 | echo "MISSING: $missing" 22 | fi 23 | done 24 | -------------------------------------------------------------------------------- /ci/images/ci-musl-i386/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | WORKDIR /tmp 4 | 5 | RUN apk update 6 | RUN apk add linux-headers musl-dev util-linux-dev bash 7 | RUN apk add attr-dev acl-dev e2fsprogs-dev zlib-dev lzo-dev zstd-dev 8 | RUN apk add autoconf automake make gcc tar gzip clang pahole 9 | RUN apk add python3 py3-setuptools python3-dev 10 | RUN apk add libgcrypt-dev libsodium-dev libkcapi-dev 11 | 12 | # For downloading fresh sources 13 | RUN apk add wget 14 | 15 | # Only build tests 16 | COPY ./test-build . 17 | COPY ./devel.tar.gz . 18 | 19 | CMD ["./test-build", "devel", "--disable-documentation", "--disable-backtrace", "--disable-libudev"] 20 | -------------------------------------------------------------------------------- /ci/images/ci-musl-x86_64/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | WORKDIR /tmp 4 | 5 | RUN apk update 6 | RUN apk add linux-headers musl-dev util-linux-dev bash 7 | RUN apk add attr-dev acl-dev e2fsprogs-dev zlib-dev lzo-dev zstd-dev 8 | RUN apk add autoconf automake make gcc tar gzip clang pahole 9 | RUN apk add python3 py3-setuptools python3-dev 10 | RUN apk add libgcrypt-dev libsodium-dev libkcapi-dev 11 | 12 | # For downloading fresh sources 13 | RUN apk add wget 14 | 15 | # Only build tests 16 | COPY ./test-build . 17 | COPY ./devel.tar.gz . 18 | 19 | CMD ["./test-build", "devel", "--disable-documentation", "--disable-backtrace", "--disable-libudev"] 20 | -------------------------------------------------------------------------------- /tests/convert-tests/018-fs-size-overflow/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if btrfs-convert can handle an ext4 fs whose size is 64G. 3 | # That fs size could trigger a multiply overflow and screw up free space 4 | # calculation 5 | 6 | source "$TEST_TOP/common" || exit 7 | source "$TEST_TOP/common.convert" || exit 8 | 9 | check_prereq btrfs-convert 10 | check_global_prereq mke2fs 11 | 12 | setup_root_helper 13 | prepare_test_dev 64g 14 | 15 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 16 | run_check_umount_test_dev 17 | 18 | # Unpatched btrfs-convert would fail half way due to corrupted free space 19 | # cache tree 20 | convert_test_do_convert 21 | -------------------------------------------------------------------------------- /tests/mkfs-tests/023-free-space-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Basic check if mkfs supports the runtime feature free-space-tree 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | run_check_mkfs_test_dev -O free-space-tree 13 | 14 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \ 15 | grep -q FREE_SPACE_TREE || _fail "free space tree not created" 16 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \ 17 | grep -q FREE_SPACE_TREE_VALID || _fail "free space tree not valid" 18 | -------------------------------------------------------------------------------- /ci/images/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /tests/convert-tests/026-rollback-output/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Make sure "btrfs-convert -r" is outputting the correct filename 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | setup_root_helper 8 | prepare_test_dev 9 | 10 | check_global_prereq mkfs.ext4 11 | check_prereq btrfs-convert 12 | check_prereq btrfs 13 | 14 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 15 | run_check_umount_test_dev 16 | convert_test_do_convert 17 | 18 | # Rollback and save the output. 19 | run_check_stdout "$TOP/btrfs-convert" --rollback "$TEST_DEV" | \ 20 | grep -q "ext2_saved/image" || _fail "rollback filename output is corruptedd" 21 | -------------------------------------------------------------------------------- /tests/misc-tests/048-image-restore-mount/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verify that the restored image of an empty btrfs filesystem can still be 3 | # mounted 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs-image 8 | check_prereq mkfs.btrfs 9 | check_prereq btrfs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | tmp=$(_mktemp_dir image) 15 | 16 | run_check_mkfs_test_dev 17 | run_check "$TOP/btrfs-image" "$TEST_DEV" "$tmp/dump" 18 | run_check "$TOP/btrfs-image" -r "$tmp/dump" "$tmp/restored" 19 | run_check $SUDO_HELPER mount -t btrfs -o loop "$tmp/restored" "$TEST_MNT" 20 | run_check $SUDO_HELPER umount "$TEST_MNT" 21 | 22 | rm -rf -- "$tmp" 23 | -------------------------------------------------------------------------------- /ci/images/ci-musl-i386/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /ci/images/ci-musl-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /tests/convert-tests/001-ext2-basic/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | source "$TEST_TOP/common.convert" || exit 5 | 6 | check_prereq btrfs-convert 7 | check_global_prereq mke2fs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | check_kernel_support_acl 12 | 13 | # Iterate over defaults and options that are not tied to hardware capabilities 14 | # or number of devices 15 | for feature in '' 'block-group-tree'; do 16 | convert_test ext2 "$feature" "ext2 4k nodesize" 4096 mke2fs -b 4096 17 | convert_test ext2 "$feature" "ext2 16k nodesize" 16384 mke2fs -b 4096 18 | convert_test ext2 "$feature" "ext2 64k nodesize" 65536 mke2fs -b 4096 19 | done 20 | -------------------------------------------------------------------------------- /tests/misc-tests/027-subvol-list-deleted-toplevel/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # check that the toplevel subvolume is not listed as regular or deleted 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | run_check_mkfs_test_dev 13 | run_check_mount_test_dev 14 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list "$TEST_MNT" | 15 | grep -i -q "id 5" && _fail "found toplevel among regular" 16 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -d "$TEST_MNT" | 17 | grep -i -q "id 5.*DELETED" && _fail "found toplevel among deleted" 18 | 19 | run_check_umount_test_dev 20 | -------------------------------------------------------------------------------- /ci/images/ci-centos-8-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /tests/fsck-tests/036-bad-dev-extents/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Due to DUP chunk allocator bugs, we could allocate DUP chunks while its dev 4 | # extents could exist beyond device boundary. 5 | # And since all related items (block group, chunk, device used bytes) are all 6 | # valid, btrfs check won't report any error. 7 | # 8 | # This test case contains hand crafted minimal image, to test if btrfs check 9 | # can detect and report such error. 10 | 11 | source "$TEST_TOP/common" || exit 12 | 13 | check_prereq btrfs 14 | 15 | check_image() { 16 | run_mustfail "btrfs check failed to detect invalid dev extents" \ 17 | "$TOP/btrfs" check "$1" 18 | } 19 | 20 | check_all_images 21 | -------------------------------------------------------------------------------- /ci/images/ci-almalinux-10-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /ci/images/ci-rockylinux-9-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /tests/cli-tests/015-defrag-compress/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test parsing of option 'defrag -c' 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | prepare_test_dev 8 | 9 | run_check_mkfs_test_dev 10 | run_check_mount_test_dev 11 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 12 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem defrag -v -c "$TEST_MNT/file" 13 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem defrag -v -clzo "$TEST_MNT/file" 14 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem defrag -v -czlib "$TEST_MNT/file" 15 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem defrag -v -czstd "$TEST_MNT/file" 16 | run_check_umount_test_dev 17 | -------------------------------------------------------------------------------- /tests/fsck-tests/054-orphan-directory/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # We could potentially have a directory and it's children with ORPHAN items left 3 | # for them without having been cleaned up. 4 | # 5 | # fsck shouldn't complain about this or attempt to do anything about it, the 6 | # orphan cleanup will do the correct thing. 7 | # 8 | # To create this image I simply modified the kernel to skip doing the 9 | # btrfs_truncate_inode_items() and removing the orphan item at evict time, and 10 | # then rm -rf'ed a directory. 11 | 12 | source "$TEST_TOP/common" || exit 13 | 14 | check_prereq btrfs 15 | 16 | check_image() { 17 | run_check "$TOP/btrfs" check "$1" 18 | } 19 | 20 | check_all_images 21 | -------------------------------------------------------------------------------- /tests/misc-tests/036-receive-dump-invalid-stream/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://bugzilla.kernel.org/show_bug.cgi?id=200085 3 | # 4 | # The --dump option should follow the --max-errors and not loop indefinetelly 5 | # by default 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | printf 'btrfs-stream\0\0\0\0\0' | run_mustfail "parsing invalid stream did not fail" \ 12 | "$TOP/btrfs" receive --dump 13 | printf 'btrfs-stream\0\0\0\0\0' | run_mustfail "parsing invalid stream did not fail" \ 14 | "$TOP/btrfs" receive --dump -E 1 15 | printf 'btrfs-stream\0\0\0\0\0' | run_mustfail "parsing invalid stream did not fail" \ 16 | "$TOP/btrfs" receive --dump -E 10 17 | -------------------------------------------------------------------------------- /.github/workflows/extended-build.yml: -------------------------------------------------------------------------------- 1 | # Build tests of various combinations of configure options 2 | # (pre-release tests) 3 | 4 | name: Extended build tests 5 | run-name: Extended build tests 6 | on: 7 | push: 8 | branches: 9 | - release-test 10 | jobs: 11 | build: 12 | runs-on: ubuntu-24.04 13 | steps: 14 | - uses: actions/checkout@v4 15 | - run: sudo apt-get update -qqq 16 | - run: sudo apt-get install -y pkg-config gcc liblzo2-dev libzstd-dev libblkid-dev uuid-dev zlib1g-dev libext2fs-dev e2fsprogs libudev-dev python3-sphinx libaio-dev liburing-dev attr ccache 17 | - name: Run tests/build-tests.sh 18 | run: ./tests/build-tests.sh --ccache 19 | -------------------------------------------------------------------------------- /Documentation/man-index.rst: -------------------------------------------------------------------------------- 1 | .. BTRFS manual pages index 2 | 3 | Manual pages 4 | ============ 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | btrfs 10 | btrfs-man5 11 | btrfs-balance 12 | btrfs-check 13 | btrfs-convert 14 | btrfs-device 15 | btrfs-filesystem 16 | btrfs-find-root 17 | btrfs-image 18 | btrfs-inspect-internal 19 | btrfs-ioctl 20 | btrfs-map-logical 21 | btrfs-property 22 | btrfs-qgroup 23 | btrfs-quota 24 | btrfs-receive 25 | btrfs-replace 26 | btrfs-rescue 27 | btrfs-restore 28 | btrfs-scrub 29 | btrfs-select-super 30 | btrfs-send 31 | btrfs-subvolume 32 | btrfstune 33 | fsck.btrfs 34 | mkfs.btrfs 35 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.3-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-Leap-15.6-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | echo "btrfs-progs build test of branch ${branch}" 13 | cd /tmp 14 | if [ -f "$fname" -a -s "$fname" ]; then 15 | echo "Found local file $fname, not downloading" 16 | else 17 | echo "Missing or empty tar, downloading branch $branch from git" 18 | rm -- "$fname" 19 | wget "$url" -O "$fname" 20 | fi 21 | tar xf "$fname" 22 | cd "btrfs-progs-$fnbase" 23 | ci/build-default "$@" 24 | -------------------------------------------------------------------------------- /tests/convert-tests/003-ext4-basic/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | source "$TEST_TOP/common.convert" || exit 5 | 6 | check_prereq btrfs-convert 7 | check_global_prereq mke2fs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | check_kernel_support_acl 12 | 13 | # Iterate over defaults and options that are not tied to hardware capabilities 14 | # or number of devices 15 | for feature in '' 'block-group-tree'; do 16 | convert_test ext4 "$feature" "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096 17 | convert_test ext4 "$feature" "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096 18 | convert_test ext4 "$feature" "ext4 64k nodesize" 65536 mke2fs -t ext4 -b 4096 19 | done 20 | -------------------------------------------------------------------------------- /tests/convert-tests/028-block-group-tree/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Make sure btrfs-convert can create a fs with bgt feature. 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | setup_root_helper 8 | prepare_test_dev 9 | 10 | check_global_prereq mkfs.ext4 11 | check_prereq btrfs-convert 12 | check_prereq btrfs 13 | 14 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 15 | run_check_umount_test_dev 16 | convert_test_do_convert bgt 16384 17 | 18 | # Manually check the super block to make sure it has BGT flag. 19 | run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" |\ 20 | grep -q "BLOCK_GROUP_TREE" || _fail "No block-group-tree feature enabled" 21 | -------------------------------------------------------------------------------- /tests/mkfs-tests/031-zoned-bgt/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verify mkfs for zoned devices support block-group-tree feature 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | # Create one 128M device with 4M zones, 32 of them 8 | setup_nullbdevs 1 128 4 9 | 10 | prepare_nullbdevs 11 | 12 | TEST_DEV="${nullb_devs[1]}" 13 | # Use single as it's supported on more kernels 14 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -m single -d single -O block-group-tree "$TEST_DEV" 15 | run_check_mount_test_dev 16 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 17 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" 18 | run_check_umount_test_dev 19 | 20 | cleanup_nullbdevs 21 | -------------------------------------------------------------------------------- /tests/convert-tests/024-ntfs-basic/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Really basic test of ntfs2btrfs conversion 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | if ! check_kernel_support_ntfs >/dev/null; then 8 | _not_run "no NTFS support" 9 | fi 10 | 11 | check_prereq btrfs-convert 12 | check_global_prereq mkfs.ntfs 13 | check_global_prereq ntfs2btrfs 14 | 15 | setup_root_helper 16 | prepare_test_dev 17 | 18 | # Iterate over defaults and options that are not tied to hardware capabilities 19 | # or number of devices. Test only 4K block size as minimum. 20 | for feature in '' 'block-group-tree'; do 21 | convert_test ntfs "$feature" "ntfs 4k nodesize" 4096 mkfs.ntfs -s 4096 22 | done 23 | -------------------------------------------------------------------------------- /tests/fsck-tests/032-corrupted-qgroup/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if btrfs check can handle valid orphan items. 3 | # Orphan item is a marker for deleted inodes that were open at the time of 4 | # deletion. Orphan inode/root is not referenced and will have an orphan 5 | # item, which should not be reported as error. 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | 11 | check_image() { 12 | run_mustfail "btrfs check failed to detect qgroup corruption" \ 13 | "$TOP/btrfs" check "$1" 14 | # Above command can fail due to other bugs, so add extra check to 15 | # ensure we can fix qgroup without problems. 16 | run_check "$TOP/btrfs" check --repair --force "$1" 17 | } 18 | 19 | check_all_images 20 | -------------------------------------------------------------------------------- /Documentation/Resize.rst: -------------------------------------------------------------------------------- 1 | Resize 2 | ====== 3 | 4 | A mounted filesystem can be resized after creation, grown or shrunk. On a 5 | multi-device filesystem the space occupied on each device can be resized 6 | independently. Data that reside in the area that would be out of the new size 7 | are relocated to the remaining space below the limit, so this constrains the 8 | minimum size to which a filesystem can be shrunk. 9 | 10 | Growing a filesystem is quick as it only needs to take note of the available 11 | space, while shrinking a filesystem needs to relocate potentially lots of data 12 | and this is IO intense. It is possible to shrink a filesystem in smaller steps. 13 | See :ref:`btrfs filesystem resize` for more. 14 | -------------------------------------------------------------------------------- /tests/test-console.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # a shell with test environment set up, logged commands and output 3 | 4 | LANG=C 5 | SCRIPT_DIR=$(dirname $(readlink -f "$0")) 6 | TOP=$(readlink -f "$SCRIPT_DIR/../") 7 | TEST_TOP="$TOP/tests" 8 | INTERNAL_BIN="$TOP" 9 | TEST_DEV=${TEST_DEV:-} 10 | RESULTS="$TOP/tests/test-console.txt" 11 | IMAGE="$TOP/tests/test.img" 12 | 13 | source common 14 | source common.convert 15 | 16 | setup_root_helper 17 | 18 | echo "Eval loop in test environment (log: $RESULTS)" 19 | echo -e " ---------------------\nStarting session, `date`" >> "$RESULTS" 20 | echo -n "`pwd`> " 21 | while read x; do 22 | echo "COMMAND: $x" >> "$RESULTS" 23 | { eval $x; } 2>&1 | tee -a "$RESULTS" 24 | echo -n "`pwd`> " 25 | done 26 | -------------------------------------------------------------------------------- /tests/fsck-tests/019-non-skinny-false-alert/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # $ btrfs check img 4 | # Checking filesystem on img 5 | # UUID: 17f2bf15-f4c2-4ebc-b1f7-39b7af26257a 6 | # checking extents 7 | # bad extent [29376512, 29392896), type mismatch with chunk 8 | # bad extent [29442048, 29458432), type mismatch with chunk 9 | # bad extent [29589504, 29605888), type mismatch with chunk 10 | # ... 11 | # 12 | # a buggy check leads to the above messages 13 | 14 | source "$TEST_TOP/common" || exit 15 | 16 | check_prereq btrfs 17 | 18 | image=$(extract_image "./default_case.img.xz") 19 | run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | 20 | grep -q "type mismatch with chunk" && 21 | _fail "unexpected error message in the output" 22 | 23 | rm -f "$image" 24 | -------------------------------------------------------------------------------- /Documentation/_static/style.css: -------------------------------------------------------------------------------- 1 | .wy-nav-content { 2 | max-width: 1200px !important; 3 | } 4 | 5 | .wy-table-responsive { 6 | white-space: normal !important; 7 | } 8 | 9 | .wy-table-responsive table td, .wy-table-responsive table th { 10 | white-space: normal !important; 11 | } 12 | 13 | .green { 14 | color: green; 15 | } 16 | 17 | .statusok { 18 | color: green; 19 | } 20 | 21 | .statusmok { 22 | /* color: orange; */ 23 | /* color: #ffae42; */ 24 | color: darkorange; 25 | } 26 | 27 | .statusunstable { 28 | color: red; 29 | } 30 | 31 | .statusunsupp { 32 | color: darkorange; 33 | } 34 | 35 | .statusincompat { 36 | color: goldenrod; 37 | }; 38 | 39 | table.main-table { 40 | border: 1px; 41 | width: 100%; 42 | } 43 | 44 | td.main-table-col { 45 | width: 33%; 46 | } 47 | -------------------------------------------------------------------------------- /tests/convert-tests/016-invalid-large-inline-extent/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if btrfs-convert refuses to rollback the filesystem, and leave the fs 3 | # and the convert image untouched 4 | 5 | source "$TEST_TOP/common" || exit 6 | source "$TEST_TOP/common.convert" || exit 7 | 8 | check_prereq btrfs-convert 9 | check_global_prereq mke2fs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 15 | 16 | # Create a 6K file, which should not be inlined 17 | run_check $SUDO_HELPER dd if=/dev/zero bs=2k count=3 of="$TEST_MNT/file1" 18 | 19 | run_check_umount_test_dev 20 | 21 | # convert_test_do_convert() will call btrfs check, which should expose any 22 | # invalid inline extent with too large size 23 | convert_test_do_convert 24 | -------------------------------------------------------------------------------- /Documentation/Administration.rst: -------------------------------------------------------------------------------- 1 | Administration 2 | ============== 3 | 4 | The main administration tool for BTRFS filesystems is :doc:`btrfs`. 5 | Please refer to the manual pages of the subcommands for further documentation. 6 | Other topics explaining features or concepts can be found in :doc:`btrfs-man5`. 7 | 8 | Mount options 9 | ------------- 10 | 11 | .. include:: ch-mount-options.rst 12 | 13 | Bootloaders 14 | ----------- 15 | 16 | .. include:: ch-bootloaders.rst 17 | 18 | .. _administration-limits: 19 | 20 | Filesystem limits 21 | ----------------- 22 | 23 | .. include:: ch-fs-limits.rst 24 | 25 | .. _administration-flexibility: 26 | 27 | Flexibility 28 | ----------- 29 | 30 | .. include:: ch-flexibility.rst 31 | 32 | Sysfs 33 | ----- 34 | 35 | .. include:: ch-sysfs.rst 36 | -------------------------------------------------------------------------------- /tests/convert-tests/020-refuse-needs-recovery/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Crafted image with needs_recovery incompat bit feature set, convert must 3 | # refuse to convert such image 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs-convert 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | # Override common function 14 | check_image() { 15 | local features 16 | 17 | TEST_DEV="$1" 18 | features=$(run_check_stdout dumpe2fs "$TEST_DEV" | grep 'Filesystem features') 19 | if ! echo "$features" | grep -q 'needs_recovery'; then 20 | _fail "image does not have the needs_recovery bit set" 21 | fi 22 | run_mustfail "convert worked on unclean image" \ 23 | "$TOP/btrfs-convert" "$TEST_DEV" 24 | rm -f "$TEST_DEV" 25 | } 26 | 27 | check_all_images 28 | -------------------------------------------------------------------------------- /tests/convert-tests/010-reiserfs-basic/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "$TEST_TOP/common" || exit 4 | source "$TEST_TOP/common.convert" || exit 5 | 6 | if ! check_kernel_support_reiserfs >/dev/null; then 7 | _not_run "no reiserfs support" 8 | fi 9 | 10 | check_prereq btrfs-convert 11 | check_global_prereq mkreiserfs 12 | 13 | setup_root_helper 14 | prepare_test_dev 15 | 16 | # Iterate over defaults and options that are not tied to hardware capabilities 17 | # or number of devices 18 | for feature in '' 'block-group-tree'; do 19 | convert_test reiserfs "$feature" "reiserfs 4k nodesize" 4096 mkreiserfs -b 4096 20 | convert_test reiserfs "$feature" "reiserfs 16k nodesize" 16384 mkreiserfs -b 4096 21 | convert_test reiserfs "$feature" "reiserfs 64k nodesize" 65536 mkreiserfs -b 4096 22 | done 23 | -------------------------------------------------------------------------------- /ci/images/docker-run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run the container 3 | # $0 [docker arguments] [-- command and arguments] 4 | 5 | prefix=kdave 6 | image=$(basename `pwd` | tr '[A-Z]' '[a-z]') 7 | 8 | declare -a ARGS 9 | while [ $# -gt 0 ]; do 10 | case "$1" in 11 | --) shift; break;; 12 | *) ARGS+=("$1"); shift;; 13 | esac 14 | done 15 | 16 | echo "ARGS: ${ARGS[@]}" 17 | echo "RUN : $@" 18 | 19 | # Running inside non-interactive terminal would fail 20 | tty= 21 | if [ -t 1 ]; then 22 | tty=-it 23 | fi 24 | 25 | # Device mapper devices are not visible inside the environment if the /dev mount 26 | # is the default one (tmpfs instead of devtmpfs) 27 | # Mounts and loop device manipulation is required 28 | docker run --mount type=bind,source=/dev,target=/dev $tty --privileged "${ARGS[@]}" "$prefix/$image" "$@" 29 | -------------------------------------------------------------------------------- /tests/fsck-tests/028-unaligned-super-dev-sizes/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # An image with mis-aligned superblock total_bytes, that will be found and 4 | # fixed by 'check' or fixed by 'rescue fix-device-size' 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs 9 | setup_root_helper 10 | 11 | check_all_images 12 | 13 | TEST_DEV=$(extract_image "./dev_and_super_mismatch_unaligned.raw.xz") 14 | 15 | # detect and fix 16 | run_check "$TOP/btrfs" rescue fix-device-size "$TEST_DEV" 17 | # no problem found 18 | run_check "$TOP/btrfs" rescue fix-device-size "$TEST_DEV" 19 | # check if fix-device-size worked 20 | run_check "$TOP/btrfs" check "$TEST_DEV" 21 | # mount test 22 | run_check_mount_test_dev 23 | run_check_umount_test_dev "$TEST_MNT" 24 | # remove restored image 25 | rm -- "$TEST_DEV" 26 | -------------------------------------------------------------------------------- /tests/mkfs-tests/022-rootdir-size/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Regression test for mkfs.btrfs --rootdir with DUP data profile and rootdir 3 | # size near the limit of the device. 4 | # 5 | # There is a bug that makes mkfs.btrfs always to create unnecessary SINGLE 6 | # chunks, which eats up a lot of space and leads to unexpected ENOSPC bugs. 7 | 8 | source "$TEST_TOP/common" || exit 9 | 10 | check_prereq mkfs.btrfs 11 | 12 | prepare_test_dev 13 | 14 | tmp=$(_mktemp_dir mkfs-rootdir) 15 | 16 | fallocate -l 128M $tmp/large_file 17 | 18 | # We should be able to create the fs with size limit to 2 * (128 + 32 + 8) 19 | # which is 336M. Here we round it up to 350M. 20 | run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" -d dup -b 350M "$TEST_DEV" 21 | run_check "$TOP/btrfs" check "$TEST_DEV" 22 | 23 | rm -rf -- "$tmp" 24 | -------------------------------------------------------------------------------- /tests/misc-tests/056-subvolume-list-uuid/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make sure "btrfs subvolume list -u" shows uuid correctly 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | check_global_prereq uuidparse 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | tmp=$(_mktemp_dir list_uuid) 15 | 16 | run_check_mkfs_test_dev 17 | run_check_mount_test_dev 18 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1" 19 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -u "$TEST_MNT" | \ 20 | cut -d\ -f9 > "$tmp/output" 21 | 22 | result=$(cat "$tmp/output" | uuidparse -o TYPE -n) 23 | rm -rf -- "$tmp" 24 | 25 | if [ "$result" == "invalid" ]; then 26 | _fail "subvolume list failed to report uuid" 27 | fi 28 | run_check_umount_test_dev 29 | -------------------------------------------------------------------------------- /tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Regression test for mkfs.btrfs --rootdir with dangling symlink (points to 3 | # non-existing location) 4 | # 5 | # Since mkfs.btrfs --rootdir will just create symbolic link rather than 6 | # follow it, we shouldn't hit any problem 7 | 8 | source "$TEST_TOP/common" || exit 9 | 10 | check_prereq mkfs.btrfs 11 | 12 | prepare_test_dev 13 | 14 | tmp=$(_mktemp_dir mkfs-rootdir) 15 | 16 | non_existing="/no/such/file$RANDOM$RANDOM" 17 | 18 | if [ -f "$non_existing" ]; then 19 | _not_run "Some one created $non_existing, which is not expect to exist" 20 | fi 21 | 22 | run_check ln -sf "$non_existing" "$tmp/foobar" 23 | 24 | run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" "$TEST_DEV" 25 | run_check "$TOP/btrfs" check "$TEST_DEV" 26 | 27 | rm -rf -- "$tmp" 28 | -------------------------------------------------------------------------------- /ci/images/ci-openSUSE-tumbleweed-x86_64/test-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # usage: $0 [branch name] [configure parameters] 3 | 4 | urlbase="https://github.com/kdave/btrfs-progs/archive" 5 | branch=${1:-devel} 6 | fnbase="${branch/\//-}" 7 | fname="${fnbase}.tar.gz" 8 | url="${urlbase}/${branch}.tar.gz" 9 | 10 | shift 11 | 12 | for i in gcc gcc-nm cc cpp gcc-ar gcc-ranlib lto-dump; do 13 | ln -sf /usr/bin/${i}-13 /usr/bin/${i} 14 | done 15 | gcc --version 16 | 17 | echo "btrfs-progs build test of branch ${branch}" 18 | cd /tmp 19 | if [ -f "$fname" -a -s "$fname" ]; then 20 | echo "Found local file $fname, not downloading" 21 | else 22 | echo "Missing or empty tar, downloading branch $branch from git" 23 | rm -- "$fname" 24 | wget "$url" -O "$fname" 25 | fi 26 | tar xf "$fname" 27 | cd "btrfs-progs-$fnbase" 28 | ci/build-default "$@" 29 | -------------------------------------------------------------------------------- /tests/misc-tests/017-recv-stream-malformatted/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # test receiving stream that's not valid, simple cases 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | 16 | echo -n '' | run_mayfail $SUDO_HELPER "$TOP/btrfs" receive "$TEST_MNT" && 17 | _fail "unexpected: received empty stream" 18 | 19 | echo -n '1' | run_mayfail $SUDO_HELPER "$TOP/btrfs" receive "$TEST_MNT" && 20 | _fail "unexpected: received stream with shrot and corrupted header" 21 | 22 | echo -n '12345678901234567' | run_mayfail $SUDO_HELPER "$TOP/btrfs" receive "$TEST_MNT" && 23 | _fail "unexpected: received stream with corrupted header" 24 | 25 | run_check_umount_test_dev 26 | -------------------------------------------------------------------------------- /tests/fsck-tests/033-lowmem-collission-dir-items/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Ensure that running btrfs check on a fs which has name collisions of files 3 | # doesn't result in false positives. This test is specifically targeted at 4 | # lowmem mode. 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs 9 | check_prereq mkfs.btrfs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | run_check_mkfs_test_dev 15 | run_check_mount_test_dev 16 | 17 | # Create 2 files whose names collide 18 | run_check $SUDO_HELPER touch "$TEST_MNT/5ab4e206~~~~~~~~XVT1U3ZF647YS2PD4AKAG826" 19 | run_check $SUDO_HELPER touch "$TEST_MNT/5ab4e26a~~~~~~~~AP1C3VQBE79IJOTVOEZIR9YU" 20 | 21 | run_check_umount_test_dev 22 | 23 | # The fs is clean so lowmem shouldn't produce any warnings 24 | run_check "$TOP/btrfs" check --readonly "$TEST_DEV" 25 | -------------------------------------------------------------------------------- /tests/misc-tests/059-qgroup-show-stale-qgroup-crash/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a stale qgroup and check that 'qgroup show' does not crash when trying 3 | # to print the path 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | setup_root_helper 8 | prepare_test_dev 9 | 10 | run_check_mkfs_test_dev 11 | run_check_mount_test_dev 12 | count=24 13 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 14 | run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT" 15 | for i in `seq $count`; do 16 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv$i" 17 | if [ "$(($i % 2))" = "0" ]; then 18 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/subv$i" 19 | fi 20 | done 21 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup show --sort path "$TEST_MNT" 22 | run_check_umount_test_dev 23 | -------------------------------------------------------------------------------- /tests/mkfs-tests/004-rootdir-keeps-size/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # make sure that mkfs.btrfs --rootsize does not change size of the image 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | 8 | prepare_test_dev 9 | 10 | test_mkfs_with_size() { 11 | local size 12 | local imgsize 13 | local tmp 14 | 15 | size="$1" 16 | run_check truncate -s"$size" "$TEST_DEV" 17 | imgsize=$(run_check_stdout stat --format=%s "$TEST_DEV") 18 | run_check_mkfs_test_dev --rootdir "$INTERNAL_BIN/Documentation" 19 | tmp=$(run_check_stdout stat --format=%s "$TEST_DEV") 20 | if ! [ "$imgsize" = "$tmp" ]; then 21 | _fail "image size changed from $imgsize to $tmp" 22 | fi 23 | } 24 | 25 | test_mkfs_with_size 128M 26 | test_mkfs_with_size 256M 27 | test_mkfs_with_size 512M 28 | test_mkfs_with_size 1G 29 | test_mkfs_with_size 2G 30 | -------------------------------------------------------------------------------- /tests/misc-tests/022-filesystem-du-on-empty-subvol/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # btrfs fi du should handle empty subvolumes (with ino == 2) 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | run_check_mkfs_test_dev 13 | run_check_mount_test_dev 14 | 15 | cd "$TEST_MNT" 16 | 17 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create test1 18 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create test1/test2 19 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot test1 test1-snap 20 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem du -s test1 21 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem du -s test1-snap | \ 22 | grep -q "ERROR:.*ioctl" && _fail "empty subvolume not handled" 23 | 24 | cd .. 25 | 26 | run_check_umount_test_dev 27 | -------------------------------------------------------------------------------- /Documentation/Auto-repair.rst: -------------------------------------------------------------------------------- 1 | Auto-repair on read 2 | =================== 3 | 4 | If data or metadata are found to be damaged at the time they’re read from a device, 5 | for example because the checksum does not match, they can be salvaged if the filesystem 6 | has another valid copy. This can be achieved by using a block group profile with redundancy 7 | like DUP, RAID1-like, or RAID5/6. 8 | 9 | The correct data is returned to the user application and the damaged copy is replaced by it. 10 | When this happens, a message is emitted to the system log. 11 | 12 | If there are multiple copies of data and one of them is damaged but not read by the user 13 | application, then this is not detected. 14 | 15 | To ensure the verification and automatic repair of all data and metadata copies, the 16 | :doc:`scrub` operation must be initiated manually. 17 | -------------------------------------------------------------------------------- /tests/misc-tests/008-leaf-crossing-stripes/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # test if btrfs-convert creates a filesystem without leaf crossing stripes 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq btrfs-convert 7 | check_prereq btrfs 8 | 9 | # In my test, it happened in 514M~560M, 737M~769M, 929M~917M, 10 | # and HAVE_ERROR=((size + 1) / 2) % 2 if size >= 970 11 | # 12 | SIZE_FROM=514 13 | SIZE_END=560 14 | A_PRIME_NUM=17 15 | for ((size = SIZE_FROM; size <= SIZE_END; size += A_PRIME_NUM)); do 16 | run_check truncate -s "$size"M "$IMAGE" 17 | run_check mkfs.ext4 -F "$IMAGE" 18 | run_check "$TOP/btrfs-convert" "$IMAGE" 19 | run_check_stdout "$TOP/btrfs" check "$IMAGE" 2>&1 | 20 | grep -q "crossing stripe boundary" && 21 | _fail "leaf crossing stripes after btrfs-convert" 22 | done 23 | 24 | # grep will expectedly fail 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/cli-tests/002-balance-full-no-filters/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # coverage of balance --full-balance 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | 16 | run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT" 17 | run_check $SUDO_HELPER "$TOP/btrfs" balance start "$TEST_MNT" 18 | 19 | # grep below can't use -q else this could lead to SIGPIPE 20 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" balance start --background "$TEST_MNT" | 21 | grep -F "Full balance without filters requested." >/dev/null || 22 | _fail "full balance warning not in the output" 23 | run_mayfail $SUDO_HELPER "$TOP/btrfs" balance cancel "$TEST_MNT" 24 | 25 | run_check_umount_test_dev 26 | -------------------------------------------------------------------------------- /common/defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef __BTRFS_COMMON_DEFS_H__ 18 | #define __BTRFS_COMMON_DEFS_H__ 19 | 20 | #define BTRFS_UUID_UNPARSED_SIZE 37 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/fsck-tests/056-raid56-false-alerts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make sure "btrfs check --check-data-csum" won't report false alerts on RAID56 4 | # data. 5 | # 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | check_prereq btrfs 10 | check_prereq mkfs.btrfs 11 | check_global_prereq losetup 12 | 13 | setup_root_helper 14 | 15 | setup_loopdevs 3 16 | prepare_loopdevs 17 | dev1=${loopdevs[1]} 18 | TEST_DEV=$dev1 19 | 20 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid1 -d raid5 "${loopdevs[@]}" 21 | run_check_mount_test_dev 22 | 23 | run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=16K count=1 \ 24 | status=noxfer > /dev/null 2>&1 25 | 26 | run_check_umount_test_dev 27 | 28 | # Check data csum should not report false alerts 29 | run_check $SUDO_HELPER "$TOP/btrfs" check --check-data-csum "$dev1" 30 | 31 | cleanup_loopdevs 32 | -------------------------------------------------------------------------------- /tests/fuzz-tests/003-multi-check-unmounted/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # iterate over all fuzzed images and run 'btrfs check', try various options to 4 | # get more code coverage 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | 12 | # redefine the one provided by common 13 | check_image() { 14 | local image 15 | 16 | image="$1" 17 | run_mayfail $TOP/btrfs check -s 1 "$image" 18 | run_mayfail $TOP/btrfs check --force --init-csum-tree "$image" 19 | run_mayfail $TOP/btrfs check --repair --force --init-extent-tree "$image" 20 | run_mayfail $TOP/btrfs check --repair --force --check-data-csum "$image" 21 | run_mayfail $TOP/btrfs check --subvol-extents "$image" 22 | run_mayfail $TOP/btrfs check --repair --force "$image" 23 | } 24 | 25 | check_all_images "$TEST_TOP/fuzz-tests/images" 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/misc-tests/012-find-root-no-result/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Regression test for case btrfs-find-root may print no result on a 3 | # recent fs or balanced fs, whose metadata chunk is the first chunk 4 | # and the only metadata chunk 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs-find-root 9 | check_prereq btrfs-image 10 | 11 | run_check "$TOP/btrfs-image" -r first_meta_chunk.btrfs-image test.img || \ 12 | _fail "failed to extract first_meta_chunk.btrfs-image" 13 | 14 | result=$(run_check_stdout "$INTERNAL_BIN/btrfs-find-root" test.img | sed '/^Superblock/d') 15 | 16 | if [ -z "$result" ]; then 17 | _fail "btrfs-find-root failed to find tree root" 18 | fi 19 | 20 | if ! echo "$result" | grep -q 'Found tree root at'; then 21 | _fail "btrfs-find-root failed to find tree root, unexpected output" 22 | fi 23 | 24 | rm test.img 25 | -------------------------------------------------------------------------------- /libbtrfsutil/python/version.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # This file is part of libbtrfsutil. 4 | # 5 | # libbtrfsutil is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation, either version 2.1 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # libbtrfsutil is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with libbtrfsutil. If not, see . 17 | 18 | btrfs_util_py_version = '@BTRFS_VERSION_PLAIN@' 19 | -------------------------------------------------------------------------------- /tests/mkfs-tests/006-partitioned-loopdev/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # recognize partitioned loop devices 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | if ! losetup --help | grep -q 'partscan'; then 7 | _not_run "losetup --partscan not available" 8 | exit 0 9 | fi 10 | 11 | check_prereq mkfs.btrfs 12 | 13 | setup_root_helper 14 | 15 | _mktemp_local img 16 | cp partition-1g-1g img 17 | run_check truncate -s2g img 18 | 19 | loopdev=$(run_check_stdout $SUDO_HELPER losetup --partscan --find --show img) 20 | base=$(basename "$loopdev") 21 | 22 | # expect partitions named like loop0p1 etc 23 | for looppart in $(ls /dev/"$base"?*); do 24 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$looppart" 25 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$looppart" 26 | done 27 | 28 | # cleanup 29 | run_check $SUDO_HELPER losetup -d "$loopdev" 30 | rm img 31 | -------------------------------------------------------------------------------- /tests/convert-tests/008-readonly-image/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if the converted ext2 image is readonly 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | check_prereq btrfs-convert 8 | check_global_prereq mke2fs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | default_mke2fs="mke2fs -t ext4 -b 4096" 14 | convert_test_preamble '' 'readonly image test' 16k "$default_mke2fs" 15 | convert_test_prep_fs ext4 $default_mke2fs 16 | run_check_umount_test_dev 17 | convert_test_do_convert 18 | run_check_mount_test_dev 19 | 20 | # It's expected to fail 21 | $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/ext2_saved/image" bs=1M count=1 \ 22 | &> /dev/null 23 | if [ $? -ne 1 ]; then 24 | echo "after convert ext2_saved/image is not read-only" 25 | exit 1 26 | fi 27 | run_check_umount_test_dev 28 | convert_test_post_rollback ext4 29 | -------------------------------------------------------------------------------- /tests/misc-tests/064-csum-conversion-basic/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verify the csum conversion works as expected. 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | check_experimental_build 8 | setup_root_helper 9 | prepare_test_dev 10 | 11 | convert_to_csum() 12 | { 13 | local new_csum="$1" 14 | 15 | run_check "$TOP/btrfstune" --csum "$new_csum" "$TEST_DEV" 16 | run_check "$TOP/btrfs" check --check-data-csum "$TEST_DEV" 17 | } 18 | 19 | run_check_mkfs_test_dev --csum crc32c 20 | 21 | # We only mount the filesystem once to populate its contents, later one we 22 | # would never mount the fs (to reduce the dependency on kernel features). 23 | run_check_mount_test_dev 24 | populate_fs 25 | run_check_umount_test_dev 26 | 27 | convert_to_csum xxhash 28 | convert_to_csum blake2 29 | convert_to_csum sha256 30 | convert_to_csum crc32c 31 | -------------------------------------------------------------------------------- /tests/convert-tests/022-reiserfs-parent-ref/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test that only toplevel directory self-reference is created 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | if ! check_kernel_support_reiserfs >/dev/null; then 8 | _not_run "no reiserfs support" 9 | fi 10 | 11 | check_prereq btrfs-convert 12 | check_global_prereq mkreiserfs 13 | 14 | setup_root_helper 15 | prepare_test_dev 16 | 17 | run_check $SUDO_HELPER mkreiserfs -q -f -b 4096 "$TEST_DEV" 18 | run_check_mount_test_dev -t reiserfs 19 | run_check $SUDO_HELPER mkdir "$TEST_MNT/a" 20 | run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/a/x" bs=1M count=64 21 | run_check $SUDO_HELPER mkdir "$TEST_MNT/a/y" 22 | run_check_umount_test_dev 23 | 24 | run_check $SUDO_HELPER "$TOP/btrfs-convert" "$TEST_DEV" 25 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 26 | -------------------------------------------------------------------------------- /tests/mkfs-tests/019-basic-checksums-mkfs/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test creating images with all supported checksums, mount checks are separate 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | if ! [ -f "/sys/fs/btrfs/features/supported_checksums" ]; then 14 | _not_run "kernel support for checksums missing" 15 | fi 16 | 17 | test_mkfs_checksum() 18 | { 19 | local csum 20 | 21 | csum="$1" 22 | run_check_stdout $SUDO_HELPER "$TOP/mkfs.btrfs" -f --csum "$csum" "$TEST_DEV" | grep -q "Checksum:.*$csum" 23 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 24 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 25 | } 26 | 27 | for csum in $(cat /sys/fs/btrfs/features/supported_checksums); do 28 | test_mkfs_checksum "$csum" 29 | done 30 | -------------------------------------------------------------------------------- /cmds/subvolume.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef __BTRFS_SUBVOLUME_H__ 18 | #define __BTRFS_SUBVOLUME_H__ 19 | 20 | struct rowspec; 21 | 22 | extern const struct rowspec btrfs_subvolume_rowspec[]; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /tests/convert-tests/006-large-hole-extent/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a base image with large hole extent, then convert to btrfs, 3 | # check the converted image. 4 | # Check if btrfs-convert can handle such large hole. 5 | # Fast pinpoint regression test. No options combination nor checksum 6 | # verification 7 | 8 | source "$TEST_TOP/common" || exit 9 | source "$TEST_TOP/common.convert" || exit 10 | 11 | check_prereq btrfs-convert 12 | check_global_prereq mke2fs 13 | 14 | setup_root_helper 15 | prepare_test_dev 16 | check_kernel_support_acl 17 | 18 | default_mke2fs="mke2fs -t ext4 -b 4096" 19 | convert_test_preamble '' 'large hole extent test' 16k "$default_mke2fs" 20 | convert_test_prep_fs ext4 $default_mke2fs 21 | 22 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=1M \ 23 | count=1 seek=1024 > /dev/null 2>&1 24 | 25 | run_check_umount_test_dev 26 | convert_test_do_convert 27 | -------------------------------------------------------------------------------- /tests/misc-tests/010-convert-delete-ext2-subvol/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # verify that convert rollback finds the ext2_subvolume intact and fails if it 4 | # was partially deleted 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs-convert 9 | check_prereq btrfs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | run_check truncate -s 2G "$TEST_DEV" 15 | run_check mkfs.ext4 -F "$TEST_DEV" 16 | run_check "$TOP/btrfs-convert" "$TEST_DEV" 17 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV" 18 | run_check_mount_test_dev 19 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete -c "$TEST_MNT/ext2_saved" 20 | run_check_umount_test_dev 21 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV" 22 | run_check_stdout "$TOP/btrfs-convert" --rollback "$TEST_DEV" | 23 | grep -q 'is it deleted' || _fail "unexpected rollback" 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /.github/workflows/codespell.yml: -------------------------------------------------------------------------------- 1 | # Check for typos on release and on-demand branches 2 | # 3 | # NOTE: this is not run on devel or pull requests 4 | # 5 | # - codespell configuration is within .codespellrc 6 | # - the workflow can be run separately from other workflows that trigger on 7 | # ci/* branches, use codespell/* as the prefix 8 | 9 | name: Codespell 10 | run-name: Codespell 11 | 12 | on: 13 | push: 14 | branches: 15 | - release-test 16 | - 'codespell/**' 17 | 18 | permissions: 19 | contents: read 20 | 21 | jobs: 22 | codespell: 23 | name: Check for spelling errors 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@v4 29 | - name: Annotate locations with typos 30 | uses: codespell-project/codespell-problem-matcher@v1 31 | - name: Codespell 32 | uses: codespell-project/actions-codespell@v2 33 | -------------------------------------------------------------------------------- /Documentation/btrfs-map-logical.rst: -------------------------------------------------------------------------------- 1 | btrfs-map-logical(8) 2 | ==================== 3 | 4 | SYNOPSIS 5 | -------- 6 | 7 | **btrfs-map-logical** 8 | 9 | DESCRIPTION 10 | ----------- 11 | 12 | **btrfs-map-logical** can be used to find out what the physical offsets are 13 | on the mirrors, the result is dumped to stdout by default. 14 | 15 | Mainly used for debug purpose. 16 | 17 | OPTIONS 18 | ------- 19 | 20 | -l|--logical 21 | Logical extent to map. 22 | -c|--copy 23 | Copy of the extent to read(usually 1 or 2). 24 | -o|--output 25 | Output file to hold the extent. 26 | -b|--bytes 27 | Number of bytes to read. 28 | 29 | EXIT STATUS 30 | ----------- 31 | 32 | **btrfs-map-logical** will return 0 if no error happened. 33 | If any problems happened, 1 will be returned. 34 | 35 | SEE ALSO 36 | -------- 37 | 38 | :doc:`mkfs.btrfs` 39 | -------------------------------------------------------------------------------- /tests/fsck-tests/040-compressed-nodatasum/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Verify that check can detect compressed extent without csum as an error 4 | # 5 | # There is report about nodatasum inode which has compressed extent, and when 6 | # its compressed data is corrupted, decompress screws up the whole kernel. 7 | # 8 | # While btrfs(5) shows that nodatasum will disable data CoW and compression, 9 | # there was bug in kernel that allowed this combination. And in above case, 10 | # lzo problem can lead to more serious kernel memory corruption since btrfs 11 | # completely depends its csum to prevent corruption. 12 | # 13 | # So btrfs check should report such compressed extent without csum as error. 14 | 15 | source "$TEST_TOP/common" || exit 16 | 17 | check_prereq btrfs 18 | 19 | check_image() { 20 | run_mustfail "compressed extent with csum not detected" \ 21 | "$TOP/btrfs" check "$1" 22 | } 23 | 24 | check_all_images 25 | -------------------------------------------------------------------------------- /tests/convert-tests/007-unsupported-block-sizes/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if block sizes smaller than 4k expectedly fail to convert 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | check_prereq btrfs-convert 8 | check_global_prereq mke2fs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | for bs in 1024 2048; do 14 | default_mke2fs="mke2fs -t ext4 -b $bs" 15 | convert_test_preamble '' "unsupported block size $bs" 16k "$default_mke2fs" 16 | convert_test_prep_fs ext4 $default_mke2fs 17 | 18 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=1M \ 19 | count=1 seek=1024 > /dev/null 2>&1 20 | 21 | run_check_umount_test_dev 22 | if _test_config "EXPERIMENTAL" && [ "$bs" == '2048' ]; then 23 | # Experimental support for mkfs.btrfs --sectorsize 2048 24 | continue 25 | fi 26 | run_mustfail "$bs block converted" "$TOP/btrfs-convert" "$TEST_DEV" 27 | done 28 | -------------------------------------------------------------------------------- /tests/fsck-tests/059-shrunk-device/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make sure "btrfs check" can detect device smaller than its total_bytes 4 | # in device item 5 | # 6 | 7 | source "$TEST_TOP/common" || exit 8 | 9 | setup_root_helper 10 | 11 | file="img" 12 | # Allocate an initial 1G file for testing. 13 | _mktemp_local "$file" 1g 14 | 15 | dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file") 16 | 17 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev" 18 | 19 | # The original device size from prepare_loopdevs is 2G. 20 | # Since the fs is empty, shrinking it to 996m will not cause any 21 | # lose of metadata. 22 | run_check $SUDO_HELPER losetup -d "$dev" 23 | truncate -s 996m "$file" 24 | dev=$(run_check_stdout $SUDO_HELPER losetup --find --show "$file") 25 | 26 | run_mustfail "btrfs check should detect errors in device size" \ 27 | "$TOP/btrfs" check "$dev" 28 | 29 | $SUDO_HELPER losetup -d "$dev" 30 | rm -- "$file" 31 | -------------------------------------------------------------------------------- /tests/misc-tests/068-subvol-delete-recursive-show-child/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Print all nested subvolume paths as they're getting deleted 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | prepare_test_dev 8 | 9 | run_check_mkfs_test_dev 10 | run_check_mount_test_dev 11 | for path in \ 12 | "subvol1" \ 13 | "subvol1/subvol2" \ 14 | "subvol1/subvol2/subvol3" \ 15 | "subvol1/subvol2/subvol3/subvol4" \ 16 | "subvol1/subvol2/subvol3/subvol4/subvol5"; do 17 | 18 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/$path" 19 | done 20 | 21 | run_mustfail "deleted non-empty subvolume" \ 22 | $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/subvol1" 23 | 24 | if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume delete --recursive "$TEST_MNT/subvol1" | 25 | grep -q 'subvol[2345]'; then 26 | _fail "nested subvolumes not printed" 27 | fi 28 | 29 | run_check_umount_test_dev 30 | -------------------------------------------------------------------------------- /tests/fsck-tests/020-extent-ref-cases/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # In order to confirm that 'btrfs check' supports checking a variety of refs, 3 | # add the following cases: 4 | # 5 | # * keyed_block_ref 6 | # * keyed_data_ref 7 | # * shared_block_ref 8 | # * shared_data_ref 9 | # * no_inline_ref (a extent item without inline ref) 10 | # * no_skinny_ref 11 | # 12 | # Special check for lowmem regression 13 | # * block_group_item_false_alert 14 | # Containing a block group and its first extent at 15 | # the beginning of leaf. 16 | # Which caused false alert for lowmem mode. 17 | # 18 | # Special cases with some rare backref types 19 | # * reloc tree 20 | # For both fs tree and data reloc tree. 21 | # Special for its backref pointing to itself and its short life span. 22 | 23 | source "$TEST_TOP/common" || exit 24 | 25 | check_prereq btrfs 26 | 27 | check_image() { 28 | run_check "$TOP/btrfs" check "$1" 29 | } 30 | 31 | check_all_images 32 | -------------------------------------------------------------------------------- /tests/mkfs-tests/030-zoned-rst/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verify mkfs for all currently supported profiles of zoned + raid-stripe-tree 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_experimental_build 7 | setup_root_helper 8 | setup_nullbdevs 4 128 4 9 | prepare_nullbdevs 10 | TEST_DEV=${nullb_devs[1]} 11 | 12 | profiles="single dup raid1 raid1c3 raid1c4 raid10" 13 | 14 | for dprofile in $profiles; do 15 | for mprofile in $profiles; do 16 | # It's sufficient to specify only 'zoned', the rst will be enabled 17 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -O zoned -d "$dprofile" -m "$mprofile" "${nullb_devs[@]}" 18 | done 19 | done 20 | 21 | run_mustfail "unsupported profile raid56 created" \ 22 | $SUDO_HELPER "$TOP/mkfs.btrfs" -f -O zoned -d raid5 -m raid5 "${nullb_devs[@]}" 23 | run_mustfail "unsupported profile raid56 created" \ 24 | $SUDO_HELPER "$TOP/mkfs.btrfs" -f -O zoned -d raid6 -m raid6 "${nullb_devs[@]}" 25 | 26 | cleanup_nullbdevs 27 | -------------------------------------------------------------------------------- /Documentation/btrfs-find-root.rst: -------------------------------------------------------------------------------- 1 | btrfs-find-root(8) 2 | ================== 3 | 4 | SYNOPSIS 5 | -------- 6 | 7 | **btrfs-find-root** [options] 8 | 9 | DESCRIPTION 10 | ----------- 11 | 12 | **btrfs-find-root** is used to find the satisfied root, you can filter by 13 | root tree's objectid, generation, level. 14 | 15 | OPTIONS 16 | ------- 17 | 18 | -a 19 | Search through all metadata extents, even the root has been already found. 20 | -g 21 | Filter root tree by it's original transaction id, tree root's generation in default. 22 | -o 23 | Filter root tree by it's objectid,tree root's objectid in default. 24 | -l 25 | Filter root tree by b-tree's level, level 0 in default. 26 | 27 | EXIT STATUS 28 | ----------- 29 | 30 | **btrfs-find-root** will return 0 if no error happened. 31 | If any problems happened, 1 will be returned. 32 | 33 | SEE ALSO 34 | -------- 35 | 36 | :doc:`mkfs.btrfs` 37 | -------------------------------------------------------------------------------- /tests/hash-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test all supported hash algorithms on all backends on the sample test vectors 3 | # This requires all crypto backends available for full coverage. 4 | 5 | make=make 6 | opts="-j16 $@" 7 | verdict= 8 | 9 | die() { 10 | echo "ERROR: $@" 11 | exit 1 12 | } 13 | 14 | buildme() { 15 | make clean-all 16 | 17 | echo "BUILD WITH: $1" 18 | ./autogen.sh && configure \ 19 | --disable-documentation --disable-convert --disable-python \ 20 | --with-crypto="$1" || die "configure not working with: $@" 21 | $make clean 22 | $make $opts hash-vectest 23 | if ./hash-vectest; then 24 | verdict="$verdict 25 | $1: OK" 26 | fi 27 | } 28 | 29 | # main() 30 | if ! [ -f configure.ac ]; then 31 | echo "Please run me from the top directory" 32 | exit 1 33 | fi 34 | 35 | buildme builtin 36 | buildme libgcrypt 37 | buildme libsodium 38 | buildme libkcapi 39 | buildme botan 40 | buildme openssl 41 | 42 | echo "VERDICT:" 43 | echo "$verdict" 44 | -------------------------------------------------------------------------------- /tests/mkfs-tests/024-fst-bitmaps/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check that free-space-tree does not create space bitmaps on an empty filesystem 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | setup_loopdevs 4 11 | prepare_loopdevs 12 | dev1=${loopdevs[1]} 13 | tmp=$(_mktemp fst-bitmap) 14 | 15 | test_do_mkfs() 16 | { 17 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" 18 | if run_check_stdout "$TOP/btrfs" check "$dev1" | grep -iq warning; then 19 | _fail "warnings found in check output" 20 | fi 21 | } 22 | 23 | test_do_mkfs -m raid1 -d raid0 ${loopdevs[@]} 24 | 25 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree \ 26 | -t free_space "$dev1" > "$tmp.dump-tree" 27 | cleanup_loopdevs 28 | 29 | if grep -q FREE_SPACE_BITMAP "$tmp.dump-tree"; then 30 | rm -f -- "$tmp*" 31 | _fail "free space bitmap should not be created for empty fs" 32 | fi 33 | rm -f -- "$tmp*" 34 | -------------------------------------------------------------------------------- /libbtrfsutil/stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libbtrfsutil. 3 | * 4 | * libbtrfsutil is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 2.1 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * libbtrfsutil is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with libbtrfsutil. If not, see . 16 | */ 17 | 18 | #ifndef _LIBBTRFSUTIL_STUBS_H_ 19 | #define _LIBBTRFSUTIL_STUBS_H_ 20 | 21 | #include 22 | 23 | void *reallocarray(void *ptr, size_t nmemb, size_t size); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tests/convert-tests/012-reiserfs-large-hole-extent/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a base image with large hole extent, then convert to btrfs, 3 | # check the converted image. 4 | # Check if btrfs-convert can handle such large hole. 5 | # Fast pinpoint regression test. No options combination nor checksum 6 | # verification 7 | 8 | source "$TEST_TOP/common" || exit 9 | source "$TEST_TOP/common.convert" || exit 10 | 11 | if ! check_kernel_support_reiserfs >/dev/null; then 12 | _not_run "no reiserfs support" 13 | fi 14 | 15 | check_prereq btrfs-convert 16 | check_global_prereq mkreiserfs 17 | 18 | setup_root_helper 19 | prepare_test_dev 20 | 21 | default_mkfs="mkreiserfs -b 4096" 22 | convert_test_preamble '' 'large hole extent test' 16k "$default_mkfs" 23 | convert_test_prep_fs reiserfs $default_mkfs 24 | 25 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=1M \ 26 | count=1 seek=1024 > /dev/null 2>&1 27 | 28 | run_check_umount_test_dev 29 | convert_test_do_convert 30 | -------------------------------------------------------------------------------- /tests/misc-tests/020-fix-superblock-corruption/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Corrupt primary superblock and restore it using backup superblock. 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs-select-super 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | FIRST_SUPERBLOCK_OFFSET=65536 14 | 15 | test_superblock_restore() 16 | { 17 | local seek 18 | 19 | run_check_mkfs_test_dev 20 | 21 | # Corrupt superblock checksum 22 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_DEV" \ 23 | seek="$FIRST_SUPERBLOCK_OFFSET" bs=1 count=4 conv=notrunc 24 | 25 | # Run btrfs check to detect corruption 26 | run_mayfail "$TOP/btrfs" check "$TEST_DEV" && \ 27 | _fail "btrfs check should detect corruption" 28 | 29 | # Copy backup superblock to primary 30 | run_check "$INTERNAL_BIN/btrfs-select-super" -s 1 "$TEST_DEV" 31 | 32 | # Perform btrfs check 33 | run_check "$TOP/btrfs" check "$TEST_DEV" 34 | } 35 | 36 | test_superblock_restore 37 | -------------------------------------------------------------------------------- /Documentation/html-preview.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate manual page preview as rendered by 'make html', removed some styling 3 | # so there can be visual artifacts, usable for CI summary 4 | 5 | if ! [ -f "$1" ]; then 6 | exit 0 7 | fi 8 | 9 | prefix=Documentation/ 10 | here=$(pwd) 11 | 12 | if [ "$(basename \"$here\")" = 'Documentation' ]; then 13 | prefix= 14 | fi 15 | 16 | fn="$1" 17 | bn=$(basename "$fn" .rst) 18 | html=$(find "${prefix}"_build/html -name "$bn".'html') 19 | 20 | if ! [ -f "$html" ]; then 21 | #echo "ERROR: cannot find html page '$html' from bn $bn fn $fn
" 22 | exit 0 23 | fi 24 | 25 | cat << EOF 26 |
27 | $fn 28 | 29 | EOF 30 | 31 | # Up to
, before that there's left bar navigation 32 | 33 | cat "$html" | sed -e 's/^\s\+//' | awk ' 34 | /^
/ { doit=1; next; } 35 | /^<\/body>/ { doit=0; next; } 36 | doit==1 { print; }' 37 | 38 | cat << EOF 39 | 40 |
41 | EOF 42 | -------------------------------------------------------------------------------- /tests/cli-tests/006-qgroup-show-sync/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # simple test of qgroup show --sync option 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 1g 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | 16 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/Sub" 17 | run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT/Sub" 18 | 19 | for opt in '' '--' '--sync'; do 20 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup limit 300M "$TEST_MNT/Sub" 21 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/Sub/file" bs=1M count=200 22 | 23 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup show -re $opt "$TEST_MNT/Sub" 24 | 25 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup limit none "$TEST_MNT/Sub" 26 | run_check $SUDO_HELPER rm -f "$TEST_MNT/Sub/file" 27 | run_check "$TOP/btrfs" filesystem sync "$TEST_MNT/Sub" 28 | done 29 | 30 | run_check_umount_test_dev 31 | -------------------------------------------------------------------------------- /tests/cli-tests/007-check-force/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # test 'btrfs check --force' on a mounted filesystem 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | 12 | # we need to use a real block device, because the check opens the device in 13 | # exclusive mode, that unfortunately behaves differently for direct file 14 | # access and for the real /dev/loop0 device 15 | setup_loopdevs 1 16 | prepare_loopdevs 17 | TEST_DEV=${loopdevs[1]} 18 | 19 | run_check_mkfs_test_dev 20 | run_check_mount_test_dev 21 | run_mustfail "checking mounted filesystem without --force" \ 22 | $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 23 | run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV" 24 | run_check $SUDO_HELPER "$TOP/btrfs" check --force --repair "$TEST_DEV" 25 | run_check_umount_test_dev 26 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 27 | run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV" 28 | 29 | cleanup_loopdevs 30 | -------------------------------------------------------------------------------- /tests/convert-tests/017-fs-near-full/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if btrfs-convert creates filesystem with device extents beyond the 3 | # device boundary 4 | 5 | source "$TEST_TOP/common" || exit 6 | source "$TEST_TOP/common.convert" || exit 7 | 8 | check_prereq btrfs-convert 9 | check_global_prereq mke2fs 10 | check_global_prereq fallocate 11 | 12 | setup_root_helper 13 | prepare_test_dev 1G 14 | 15 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 16 | 17 | # Use up 800MiB first 18 | for i in $(seq 1 4); do 19 | run_check $SUDO_HELPER fallocate -l 200M "$TEST_MNT/file$i" 20 | done 21 | 22 | # Then add 5MiB for above files. These 5 MiB will be allocated near the very 23 | # end of the fs, to confuse btrfs-convert 24 | for i in $(seq 1 4); do 25 | run_check $SUDO_HELPER fallocate -l 205M "$TEST_MNT/file$i" 26 | done 27 | 28 | run_check_umount_test_dev 29 | 30 | # convert_test_do_convert() will call btrfs check, which should expose any 31 | # invalid inline extent with too large size 32 | convert_test_do_convert 33 | -------------------------------------------------------------------------------- /ci/actions/delete-all-runs-of-branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 4 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 5 | 6 | repo="kdave/btrfs-progs" 7 | branch="$1" 8 | 9 | if [ -z "$branch" ]; then 10 | echo "ERROR: $0 branch" 11 | exit 1 12 | fi 13 | 14 | notthatone() { 15 | echo "ERROR: protected branch, will not remove: $1" 16 | exit 1 17 | } 18 | 19 | areyousure() { 20 | echo "WARNING: protected branch, make sure you want to remove it: $1" 21 | } 22 | 23 | case "$branch" in 24 | master) notthatone "$branch";; 25 | devel) areyousure "$branch";; 26 | esac 27 | 28 | echo "Delete all runs of branch $branch, are you sure? [y/N]" 29 | read -n 1 answer 30 | if ! [ "$answer" = 'y' ]; then 31 | echo "INFO: not deleting" 32 | exit 0 33 | fi 34 | echo 35 | 36 | for id in $(gh run -R "$repo" list --limit 100 --json databaseId --branch "$branch" | jq '.[].databaseId'); do 37 | echo "Delete run $id" 38 | gh run -R "$repo" delete "$id" 39 | done 40 | -------------------------------------------------------------------------------- /tests/misc-tests/026-image-non-printable-chars/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # check that sanitized names with matching crc do not contain unprintable 3 | # characters, namely 0x7f 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | run_check $SUDO_HELPER chmod a+rw "$TEST_MNT" 16 | 17 | # known to produce char 0x7f == 127 18 | touch "$TEST_MNT/|5gp!" 19 | 20 | run_check_umount_test_dev 21 | 22 | _mktemp_local img 23 | _mktemp_local img.restored 24 | _mktemp_local img.dump 25 | run_check $SUDO_HELPER "$TOP/btrfs-image" -ss "$TEST_DEV" img 26 | run_check $SUDO_HELPER "$TOP/btrfs-image" -r img img.restored 27 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree img.restored > img.dump 28 | 29 | ch7f=$(echo -en '\x7f') 30 | if grep -q "$ch7f" img.dump; then 31 | _fail "found char 0x7f in the sanitized names" 32 | fi 33 | 34 | rm -f -- img img.restored img.dump 35 | -------------------------------------------------------------------------------- /common/tree-search.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_TREE_SEARCH_H__ 2 | #define __COMMON_TREE_SEARCH_H__ 3 | 4 | #include "kerncompat.h" 5 | #include 6 | #include "kernel-shared/uapi/btrfs.h" 7 | 8 | #define BTRFS_TREE_SEARCH_V2_BUF_SIZE 65536 9 | 10 | struct btrfs_tree_search_args { 11 | bool use_v2; 12 | union { 13 | struct btrfs_ioctl_search_args args1; 14 | struct btrfs_ioctl_search_args_v2 args2; 15 | u8 filler[sizeof(struct btrfs_ioctl_search_args_v2) + 16 | BTRFS_TREE_SEARCH_V2_BUF_SIZE]; 17 | }; 18 | }; 19 | 20 | int btrfs_tree_search_ioctl(int fd, struct btrfs_tree_search_args *sa); 21 | 22 | static inline struct btrfs_ioctl_search_key *btrfs_tree_search_sk(struct btrfs_tree_search_args *sa) 23 | { 24 | /* Same offset for v1 and v2. */ 25 | return &sa->args1.key; 26 | } 27 | 28 | static inline void *btrfs_tree_search_data(struct btrfs_tree_search_args *sa, unsigned long offset) { 29 | if (sa->use_v2) 30 | return (void *)(sa->args2.buf + offset); 31 | return (void *)(sa->args1.buf + offset); 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ci/ci-build-almalinux10: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in AlmaLinux 10 CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-almalinux-10-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation "$@" 35 | -------------------------------------------------------------------------------- /ci/ci-build-rockylinux9: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in RockyLinux 9 CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-rockylinux-9-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation "$@" 35 | -------------------------------------------------------------------------------- /tests/fsck-tests/031-metadatadump-check-data-csum/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # To check if "btrfs check" can detect metadata dump (restored by btrfs-image) 3 | # and ignore --check-data-csum option 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | check_prereq mkfs.btrfs 9 | check_prereq btrfs-image 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | 16 | run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=4k count=16 17 | run_check_umount_test_dev 18 | 19 | _mktemp_local restored_image 20 | run_check $SUDO_HELPER "$TOP/btrfs-image" "$TEST_DEV" "restored_image" 21 | 22 | # use prepare_test_dev() to wipe all existing data on $TEST_DEV 23 | # so there is no way that restored image could have matching data csum 24 | prepare_test_dev 25 | 26 | run_check $SUDO_HELPER "$TOP/btrfs-image" -r "restored_image" "$TEST_DEV" 27 | 28 | # Should not report any error 29 | run_check "$TOP/btrfs" check --check-data-csum "$TEST_DEV" 30 | 31 | rm -rf -- "restored_image" 32 | -------------------------------------------------------------------------------- /tests/misc-tests/015-dump-super-garbage/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # let dump-super dump random data, must not crash 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq btrfs 8 | 9 | run_mustfail "attempt to print bad superblock without force" \ 10 | "$TOP/btrfs" inspect-internal dump-super /dev/urandom 11 | run_mustfail "attempt to print bad superblock without force" \ 12 | "$TOP/btrfs" inspect-internal dump-super -a /dev/urandom 13 | run_mustfail "attempt to print bad superblock without force" \ 14 | "$TOP/btrfs" inspect-internal dump-super -fa /dev/urandom 15 | 16 | # All forced, no failure 17 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 18 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 19 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 20 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 21 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 22 | run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom 23 | -------------------------------------------------------------------------------- /tests/misc-tests/031-qgroup-parent-child-relation/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test that btrfs 'qgroup show' outputs the correct parent-child qgroup relation 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | run_check_mkfs_test_dev 13 | run_check_mount_test_dev 14 | 15 | run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT" 16 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup create 1/0 "$TEST_MNT" 17 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup assign 0/5 1/0 "$TEST_MNT" 18 | run_check $SUDO_HELPER "$TOP/btrfs" quota rescan -w "$TEST_MNT" 19 | 20 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=-qgroupid \ 21 | -p "$TEST_MNT" | grep -q "1/0" \ 22 | || _fail "parent qgroup check failed, please check the log" 23 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=qgroupid \ 24 | -c "$TEST_MNT" | grep -q "0/5" \ 25 | || _fail "child qgroup check failed, please check the log" 26 | 27 | run_check_umount_test_dev "$TEST_MNT" 28 | -------------------------------------------------------------------------------- /tests/mkfs-tests/012-rootdir-no-shrink/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test if mkfs.btrfs --rootdir will skip shrinking correctly 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | 8 | setup_root_helper 9 | 10 | fs_size=$((512 * 1024 * 1024)) 11 | bs=$((1024 * 1024)) 12 | tmp=$(_mktemp_dir mkfs-rootdir) 13 | 14 | prepare_test_dev "$fs_size" 15 | 16 | # No shrink case 17 | 18 | run_check_mkfs_test_dev --rootdir "$tmp" 19 | run_check_mount_test_dev 20 | 21 | # We should be able to write at least half of the fs size data since the fs is 22 | # not shrunk 23 | run_check $SUDO_HELPER dd if=/dev/zero bs="$bs" count=$(($fs_size / $bs / 2)) \ 24 | of="$TEST_MNT/file" 25 | 26 | run_check_umount_test_dev 27 | 28 | # Shrink case 29 | 30 | run_check_mkfs_test_dev --rootdir "$tmp" --shrink 31 | run_check_mount_test_dev 32 | 33 | run_mustfail "mkfs.btrfs for shrink rootdir" \ 34 | $SUDO_HELPER dd if=/dev/zero bs="$bs" count=$(($fs_size / $bs / 2)) \ 35 | of="$TEST_MNT/file" 36 | 37 | run_check_umount_test_dev 38 | 39 | rm -rf -- "$tmp" 40 | -------------------------------------------------------------------------------- /ci/ci-build-musl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in musl CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-musl-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation --disable-backtrace --disable-libudev "$@" 35 | -------------------------------------------------------------------------------- /ci/ci-build-tumbleweed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in openSUSE Tumbleweed CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-openSUSE-tumbleweed-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation "$@" 35 | -------------------------------------------------------------------------------- /tests/common.local: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # additional arguments to various commands 4 | 5 | # already defined, eg. via make argument 6 | if [ -z "$TEST_ENABLE_OVERRIDE" ]; then 7 | # set to 'true' 8 | TEST_ENABLE_OVERRIDE=false 9 | 10 | TEST_ARGS_CHECK=--mode=lowmem 11 | fi 12 | 13 | 14 | # gets arguments of a current command and can decide if the argument insertion 15 | # should happen, eg. if some option combination does not make sense or would 16 | # break tests 17 | # 18 | # Return 0 if we need to skip option override 19 | # Return 1 if we don't need to skip option override 20 | _skip_spec() 21 | { 22 | local beacon 23 | 24 | beacon=.lowmem_repairable 25 | 26 | # For lowmem repair, only support fs tree repair for now 27 | # So we place lowmem repair beacon in the same dir of the test case 28 | if echo "$TEST_ARGS_CHECK" | grep -q 'mode=lowmem' && 29 | echo "$@" | grep -q -- '--repair'; then 30 | dir="$(dirname ${@: -1})" 31 | if [ -f ${dir}/${beacon} ]; then 32 | return 1; 33 | fi 34 | return 0; 35 | fi 36 | return 1 37 | } 38 | -------------------------------------------------------------------------------- /ci/actions/update-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ex 2 | # Usage: $0 tag 3 | # 4 | # Requires: gh extension 'release' installed (https://cli.github.com/manual/gh_release) 5 | 6 | if [ -z "$1" ]; then 7 | echo "ERROR: needs tag where to upload the static binaries" 8 | exit 1 9 | fi 10 | 11 | type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } 12 | type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } 13 | 14 | repo="kdave/btrfs-progs" 15 | 16 | tag="$1" 17 | # TODO: verify that tag exists 18 | 19 | # Read last workflow id for master branch 20 | id=$(gh run -R "$repo" list --limit 1 --workflow 'Static binaries' --branch 'master' --json databaseId | jq '.[].databaseId') 21 | 22 | for asset in btrfs.box.static btrfs.static; do 23 | gh run -R "$repo" download "$id" -n "$asset" 24 | chmod 755 "$asset" 25 | gh release -R "$repo" upload "$tag" "$asset" 26 | done 27 | 28 | for asset in btrfs.box.static.sha256 btrfs.static.sha256; do 29 | gh run -R "$repo" download "$id" -n "$asset" 30 | gh release -R "$repo" upload "$tag" "$asset" 31 | done 32 | -------------------------------------------------------------------------------- /ci/ci-build-musl-i386: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in musl CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-musl-i386 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation --disable-backtrace --disable-libudev "$@" 35 | -------------------------------------------------------------------------------- /ci/ci-build-centos8: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in Centos 8 CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-centos-8-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation --disable-libudev --disable-zoned "$@" 35 | -------------------------------------------------------------------------------- /ci/ci-build-leap153: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in openSUSE Leap 15.3 CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-openSUSE-Leap-15.3-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation --disable-zoned "$@" 35 | -------------------------------------------------------------------------------- /ci/ci-build-leap156: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Usage: $0 [branch] [configure options] 3 | # Create source tarball from HEAD or given branch and build it in openSUSE Leap 15.6 CI 4 | # environment. Configure options follow branch name that can be empty. 5 | 6 | HERE=`pwd` 7 | if [ -f "configure.ac" ]; then 8 | SOURCEDIR=`pwd` 9 | elif [ -f "../configure.ac" ]; then 10 | cd .. 11 | SOURCEDIR=`pwd` 12 | else 13 | echo "ERROR: cannot determine source directory from `pwd`" 14 | exit 1 15 | fi 16 | 17 | CIIMAGEDIR=ci/images/ci-openSUSE-Leap-15.6-x86_64 18 | BRANCH=${1:-HEAD} 19 | if [ "$#" -ge 1 ]; then 20 | shift 21 | fi 22 | HASH=$(git log -1 --format='%h %s' "$BRANCH") 23 | 24 | echo "CI: Generate archive from $BRANCH ($HASH)" 25 | git archive --prefix=btrfs-progs-devel/ -o devel.tar "$BRANCH" 26 | echo "$BRANCH $HASH" > GITCOMMIT 27 | tar uvf devel.tar GITCOMMIT 28 | #rm GITCOMMIT 29 | gzip --force --best devel.tar 30 | 31 | cd "$CIIMAGEDIR" 32 | cp "$SOURCEDIR/devel.tar.gz" . 33 | ./docker-build 34 | ./docker-run -- ./test-build devel --disable-documentation --disable-zoned "$@" 35 | -------------------------------------------------------------------------------- /tests/cli-tests/005-qgroup-show/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # qgroup show behaviour when quotas are not enabled 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | run_check_mkfs_test_dev 14 | run_check_mount_test_dev 15 | run_mayfail "$TOP/btrfs" qgroup show "$TEST_MNT" 16 | run_mayfail "$TOP/btrfs" --format json qgroup show "$TEST_MNT" 17 | run_mayfail $SUDO_HELPER "$TOP/btrfs" qgroup show "$TEST_MNT" 18 | run_mayfail $SUDO_HELPER "$TOP/btrfs" --format json qgroup show "$TEST_MNT" 19 | run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT" 20 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup limit 128m "$TEST_MNT" 21 | run_mayfail "$TOP/btrfs" qgroup show "$TEST_MNT" 22 | run_mayfail "$TOP/btrfs" --format json qgroup show "$TEST_MNT" 23 | run_check $SUDO_HELPER "$TOP/btrfs" qgroup show "$TEST_MNT" 24 | run_check $SUDO_HELPER "$TOP/btrfs" --format json qgroup show "$TEST_MNT" 25 | run_check $SUDO_HELPER "$TOP/btrfs" quota disable "$TEST_MNT" 26 | run_check_umount_test_dev 27 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # Testing workflow for CI developments, reacts to push of branch 'devel-ci' 2 | name: Testing CI build 3 | run-name: Testing CI 4 | on: 5 | push: 6 | branches: 7 | - devel-ci 8 | jobs: 9 | build: 10 | runs-on: ubuntu-24.04 11 | steps: 12 | - uses: actions/checkout@v4 13 | - run: uname -a 14 | - run: sudo modprobe btrfs 15 | - run: cat /proc/filesystems 16 | - run: gcc --version 17 | - run: df -HT 18 | - run: sudo apt-get update -qqq 19 | - run: sudo apt-get install -y pkg-config gcc liblzo2-dev libzstd-dev libblkid-dev uuid-dev zlib1g-dev libext2fs-dev e2fsprogs libudev-dev python3-sphinx libaio-dev liburing-dev 20 | - name: Configure 21 | run: ./autogen.sh && ./configure 22 | - name: Make 23 | run: make V=1 24 | - name: Musl build 25 | run: sudo docker run kdave/ci-musl-x86_64 ./test-build $GITHUB_REF_NAME --disable-documentation --disable-backtrace --disable-libudev 26 | - name: Tests cli 27 | run: echo sudo make TEST_LOG=dump test-cli 28 | -------------------------------------------------------------------------------- /common/extent-tree-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef _EXTENT_TREE_UTILS_H_ 18 | #define _EXTENT_TREE_UTILS_H_ 19 | 20 | #include "kerncompat.h" 21 | 22 | struct btrfs_inode_item; 23 | struct btrfs_path; 24 | struct btrfs_root; 25 | struct btrfs_trans_handle; 26 | 27 | int btrfs_next_extent_item(struct btrfs_root *root, struct btrfs_path *path, 28 | u64 max_objectid); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /tests/cli-tests/017-fi-show-missing/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test that if a device is missing for a mounted filesystem, btrfs fi show will 4 | # show which device exactly is missing. 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq mkfs.btrfs 9 | check_prereq btrfs 10 | 11 | setup_root_helper 12 | setup_loopdevs 2 13 | prepare_loopdevs 14 | 15 | dev1=${loopdevs[1]} 16 | dev2=${loopdevs[2]} 17 | 18 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 "${loopdevs[@]}" 19 | 20 | # Move the device, changing its path, simulating the device being missing 21 | run_check $SUDO_HELPER mv "$dev2" /dev/loop-non-existent 22 | 23 | cond_wait_for_loopdevs 24 | run_check $SUDO_HELPER mount -o degraded "$dev1" "$TEST_MNT" 25 | 26 | if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" | \ 27 | grep -q -e "devid[[:space:]]\+2.*MISSING"; then 28 | 29 | _fail "didn't find exact missing device" 30 | fi 31 | 32 | run_check $SUDO_HELPER mv /dev/loop-non-existent "$dev2" 33 | 34 | run_check $SUDO_HELPER umount "$TEST_MNT" 35 | 36 | cleanup_loopdevs 37 | -------------------------------------------------------------------------------- /Documentation/ch-flexibility.rst: -------------------------------------------------------------------------------- 1 | The underlying design of BTRFS data structures allows a lot of flexibility and 2 | making changes after filesystem creation, like resizing, adding/removing space 3 | or enabling some features on-the-fly. 4 | 5 | * **dynamic inode creation** -- there's no fixed space or tables for tracking 6 | inodes so the number of inodes that can be created is bounded by the metadata 7 | space and its utilization 8 | 9 | * **block group profile change on-the-fly** -- the block group profiles can be 10 | changed on a mounted filesystem by running the balance operation and 11 | specifying the conversion filters (see :doc:`balance`) 12 | 13 | * **resize** -- the space occupied by the filesystem on each device can be 14 | resized up (grow) or down (shrink) as long as the amount of data can be still 15 | contained on the device 16 | 17 | * **device management** -- devices can be added, removed or replaced without 18 | requiring recreating the filesystem (mkfs), new redundancy options available 19 | on more devices can be also utilized by rebalancing 20 | -------------------------------------------------------------------------------- /common/inject-error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef __INJECT_ERROR_H__ 18 | #define __INJECT_ERROR_H__ 19 | 20 | #include 21 | 22 | #ifdef INJECT 23 | 24 | #define inject_error(cookie) __inject_error((cookie), __FILE__, __LINE__) 25 | bool __inject_error(unsigned long cookie, const char *file, int line); 26 | 27 | #else 28 | 29 | #define inject_error(cookie) (false) 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /crypto/crc32c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Red Hat. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License v2 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | * Boston, MA 021110-1307, USA. 17 | */ 18 | 19 | #ifndef __CRC32C__ 20 | #define __CRC32C__ 21 | 22 | #include 23 | 24 | uint32_t crc32c_le(uint32_t seed, unsigned char const *data, uint32_t length); 25 | void crc32c_init_accel(void); 26 | 27 | #define crc32c(seed, data, length) crc32c_le(seed, (unsigned char const *)data, length) 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tests/convert-tests/027-large-symbolic-link/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Make sure btrfs-convert can handle a symbolic link which is 4095 bytes long 3 | 4 | source "$TEST_TOP/common" || exit 5 | source "$TEST_TOP/common.convert" || exit 6 | 7 | setup_root_helper 8 | prepare_test_dev 1G 9 | check_global_prereq mkfs.ext4 10 | 11 | # This is at the symbolic link size limit (PATH_MAX includes the terminating NUL). 12 | link_target=$(printf "%0.sb" {1..4095}) 13 | 14 | convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096 15 | run_check $SUDO_HELPER ln -s "$link_target" "$TEST_MNT/symbolic_link" 16 | run_check_umount_test_dev 17 | 18 | # For unpatched btrfs-convert, it will always append one byte to the 19 | # link target, causing the above 4095 target to be 4096, exactly one sector, 20 | # resulting in a regular file extent. 21 | convert_test_do_convert 22 | 23 | run_check_mount_test_dev 24 | # If the unpatched btrfs-convert created a regular extent, and the kernel is 25 | # new enough, readlink will be rejected by kernel. 26 | run_check $SUDO_HELPER readlink "$TEST_MNT/symbolic_link" 27 | run_check_umount_test_dev 28 | -------------------------------------------------------------------------------- /Documentation/man-preview.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate manual page preview as rendered to a terminal, without colors or 3 | # text attributes, encapsulated html, usable for CI summary 4 | 5 | if ! [ -f "$1" ]; then 6 | exit 0 7 | fi 8 | 9 | width=120 10 | prefix=Documentation/ 11 | here=$(pwd) 12 | 13 | if [ "$(basename \"$here\")" = 'Documentation' ]; then 14 | prefix= 15 | fi 16 | 17 | fn="$1" 18 | bn=$(basename "$fn" .rst) 19 | 20 | if [ "$bn" = 'btrfs-man5' ]; then 21 | # This is the only page that does not follow from the file name, 22 | # the translation could be done using the man_pages table in conf.py 23 | # but for one entry let's add a exception here 24 | man="${prefix}_build/man/btrfs.5" 25 | else 26 | man=$(find "${prefix}"_build/man -name "$bn".'[0-9]') 27 | fi 28 | 29 | if ! [ -f "$man" ]; then 30 | #echo "ERROR: cannot find manual page '$man' from bn $bn fn $fn
" 31 | exit 0 32 | fi 33 | 34 | cat << EOF 35 |
36 | $fn 37 | 38 | \`\`\` 39 | EOF 40 | 41 | COLUMNS="$width" man -P cat "$man" 42 | 43 | cat << EOF 44 | \`\`\` 45 | 46 |
47 | EOF 48 | -------------------------------------------------------------------------------- /libbtrfs/crc32c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Red Hat. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License v2 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | * Boston, MA 021110-1307, USA. 17 | */ 18 | 19 | #ifndef __CRC32C__ 20 | #define __CRC32C__ 21 | 22 | #include 23 | 24 | uint32_t crc32c_le(uint32_t seed, unsigned char const *data, uint32_t length); 25 | void crc32c_optimization_init(void); 26 | 27 | #define crc32c(seed, data, length) crc32c_le(seed, (unsigned char const *)data, length) 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tests/fsck-tests/060-degraded-check/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Make sure "btrfs check" can handle degraded raid5. 4 | # 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq btrfs 9 | check_prereq mkfs.btrfs 10 | check_global_prereq losetup 11 | check_global_prereq wipefs 12 | 13 | setup_root_helper 14 | 15 | setup_loopdevs 3 16 | prepare_loopdevs 17 | dev1=${loopdevs[1]} 18 | dev2=${loopdevs[2]} 19 | dev3=${loopdevs[3]} 20 | 21 | # Run 1: victim is dev1 22 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" 23 | run_check $SUDO_HELPER wipefs -fa "$dev1" 24 | run_check $SUDO_HELPER "$TOP/btrfs" check "$dev2" 25 | 26 | # Run 2: victim is dev2 27 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" 28 | run_check $SUDO_HELPER wipefs -fa "$dev2" 29 | run_check $SUDO_HELPER "$TOP/btrfs" check "$dev3" 30 | 31 | # Run 3: victim is dev3 32 | run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}" 33 | run_check $SUDO_HELPER wipefs -fa "$dev3" 34 | run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1" 35 | 36 | cleanup_loopdevs 37 | -------------------------------------------------------------------------------- /tests/cli-tests/011-defrag-recursion/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # check how deep does recursive defrag go, currently it has to stop at 3 | # mountpoint and subvolume boundary, ie. only the first file should 4 | # appear in the list of processed files 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | check_prereq mkfs.btrfs 9 | check_prereq btrfs 10 | 11 | setup_root_helper 12 | prepare_test_dev 13 | 14 | run_check_mkfs_test_dev 15 | run_check_mount_test_dev 16 | 17 | run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/file1 18 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/subv1 19 | run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/subv1/file2 20 | run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot "$TEST_MNT"/subv1 "$TEST_MNT"/snap1 21 | run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/snap1/file3 22 | 23 | run_check $SUDO_HELPER find "$TEST_MNT" 24 | run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem defrag -v -r "$TEST_MNT" | 25 | grep -q 'file[23]' && _fail "recursive defrag went to subvolumes" 26 | 27 | run_check_umount_test_dev 28 | -------------------------------------------------------------------------------- /tests/mkfs-tests/026-extent-tree-to-bgt/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test back and forth conversion from extent tree to block-group-tree 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | setup_root_helper 7 | prepare_test_dev 8 | 9 | run_check_mkfs_test_dev -O ^block-group-tree 10 | run_check_mount_test_dev 11 | run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 12 | run_check_umount_test_dev 13 | 14 | run_check "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV" 15 | run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 16 | run_check "$TOP/btrfstune" --convert-to-block-group-tree "$TEST_DEV" 17 | _log "=== AFTER CONVERSION ===" 18 | run_check "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV" 19 | run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 20 | run_check "$TOP/btrfs" check "$TEST_DEV" 21 | _log "=== BACK CONVERSION ===" 22 | run_check "$TOP/btrfstune" --convert-from-block-group-tree "$TEST_DEV" 23 | run_check "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV" 24 | run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 25 | run_check "$TOP/btrfs" check "$TEST_DEV" 26 | -------------------------------------------------------------------------------- /tests/mkfs-tests/007-mix-nodesize-sectorsize/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # iterate over nodesize and sectorsize combinations 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | test_mkfs_single() 13 | { 14 | run_check_mkfs_test_dev "$@" 15 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 16 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 17 | } 18 | 19 | # default 20 | test_mkfs_single 21 | 22 | # nodesize >= sectorsize 23 | for nodesize in 4096 8192 16384 32768 65536; do 24 | for sectorsize in 4096 8192 16384 32768 65536; do 25 | [ "$nodesize" -lt "$sectorsize" ] && continue 26 | test_mkfs_single -n "$nodesize" -s "$sectorsize" -d single -m single 27 | test_mkfs_single -n "$nodesize" -s "$sectorsize" -d single -m dup 28 | done 29 | done 30 | 31 | # nodesize, mixed mode 32 | for nodesize in 4k 8k 16k 32k 64k; do 33 | test_mkfs_single -n "$nodesize" -s "$nodesize" -d single -m single --mixed 34 | test_mkfs_single -n "$nodesize" -s "$nodesize" -d dup -m dup --mixed 35 | done 36 | -------------------------------------------------------------------------------- /tests/mkfs-tests/034-rootdir-extra-hard-links/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test if "mkfs.btrfs --rootdir" would handle hard links where one is inside 4 | # the rootdir, the other out of the rootdir. 5 | 6 | source "$TEST_TOP/common" || exit 7 | 8 | prepare_test_dev 9 | 10 | tmpdir=$(_mktemp_dir mkfs-rootdir-hardlinks) 11 | 12 | run_check mkdir "$tmpdir/rootdir" 13 | run_check touch "$tmpdir/rootdir/inside_link" 14 | run_check ln "$tmpdir/rootdir/inside_link" "$tmpdir/outside_link" 15 | 16 | # Add more links to trigger the warnings 17 | run_check touch "$tmpdir/rootdir/link0" 18 | for i in {1..10}; do 19 | run_check ln "$tmpdir/rootdir/link0" "$tmpdir/rootdir/link$i" 20 | done 21 | 22 | run_check_mkfs_test_dev --rootdir "$tmpdir/rootdir" 23 | 24 | # For older mkfs.btrfs --rootdir we will create inside_link with 2 links, 25 | # but since the other one is out of the rootdir, there should only be one 26 | # 1 link, leading to btrfs check fail. 27 | # 28 | # The new behavior will split all hard links into different inodes, thus 29 | # have correct nlink for each new inode. 30 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 31 | -------------------------------------------------------------------------------- /tests/mkfs-tests/020-basic-checksums-mount/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test creating images with all supported checksums followed by mount 4 | 5 | source "$TEST_TOP/common" || exit 6 | 7 | check_prereq mkfs.btrfs 8 | check_prereq btrfs 9 | 10 | setup_root_helper 11 | prepare_test_dev 12 | 13 | if ! [ -f "/sys/fs/btrfs/features/supported_checksums" ]; then 14 | _not_run "kernel support for checksums missing" 15 | fi 16 | 17 | test_mkfs_mount_checksum() 18 | { 19 | local csum 20 | 21 | csum="$1" 22 | run_check_stdout $SUDO_HELPER "$TOP/mkfs.btrfs" -f --csum "$csum" "$TEST_DEV" | grep -q "Checksum:.*$csum" 23 | run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" 24 | run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" 25 | 26 | run_check_mount_test_dev 27 | run_check "$TOP/btrfs" filesystem df "$TEST_MNT" 28 | run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT" 29 | run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" 30 | run_check_umount_test_dev 31 | } 32 | 33 | for csum in $(cat /sys/fs/btrfs/features/supported_checksums); do 34 | test_mkfs_mount_checksum "$csum" 35 | done 36 | -------------------------------------------------------------------------------- /Documentation/Custom-ioctls.rst: -------------------------------------------------------------------------------- 1 | Custom ioctls 2 | ============= 3 | 4 | Filesystems are usually extended by custom ioctls beyond the standard system 5 | call interface to let user applications access the advanced features. They're 6 | low level and the following list gives only an overview of the capabilities or 7 | a command if available: 8 | 9 | - reverse lookup, from file offset to inode, as command :command:`btrfs inspect-internal logical-resolve` 10 | 11 | - resolve inode number to list of names, as command :command:`btrfs inspect-internal inode-resolve` 12 | 13 | - tree search, given a key range and tree id, lookup and return all b-tree items 14 | found in that range, basically all metadata at your hand but you need to know 15 | what to do with them, the ioctl is privileged as it has full access to all 16 | filesystem metadata 17 | 18 | - informative, about devices, space allocation or the whole filesystem, many of 19 | which is also exported in :file:`/sys/fs/btrfs/` 20 | 21 | - query/set a subset of features on a mounted filesystem 22 | 23 | Programming documentation of the ioctls is in the manual page 24 | :doc:`btrfs-ioctl`. 25 | -------------------------------------------------------------------------------- /image/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef __BTRFS_IMAGE_COMMON_H__ 18 | #define __BTRFS_IMAGE_COMMON_H__ 19 | 20 | #include "kerncompat.h" 21 | #include 22 | 23 | struct btrfs_fs_info; 24 | 25 | void csum_block(u8 *buf, size_t len); 26 | int detect_version(FILE *in); 27 | int update_disk_super_on_device(struct btrfs_fs_info *info, 28 | const char *other_dev, u64 cur_devid); 29 | void write_backup_supers(int fd, u8 *buf); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tests/mkfs-tests/018-multidevice-overflow/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # test if mkfs.btrfs will create file systems that overflow total_bytes 3 | 4 | source "$TEST_TOP/common" || exit 5 | 6 | check_prereq mkfs.btrfs 7 | check_prereq btrfs 8 | 9 | setup_root_helper 10 | prepare_test_dev 11 | 12 | # create a temporary btrfs filesystem for the images to make sure the 13 | # exabyte-scale files will be reliably created 14 | run_check_mkfs_test_dev 15 | run_check_mount_test_dev 16 | 17 | # truncate can fail with EFBIG if the OS cannot create a 6EiB file 18 | out=$(run_mayfail_stdout $SUDO_HELPER truncate -s 6E "$TEST_MNT/img1" 2>&1) 19 | ret=$? 20 | 21 | if [ $ret -ne 0 ]; then 22 | run_check_umount_test_dev 23 | if [[ "$out" == *"File too large"* ]]; then 24 | _not_run "current kernel could not create a 6EiB file" 25 | fi 26 | _fail "command 'truncate -s 6E' failed: $out" 27 | fi 28 | 29 | run_check $SUDO_HELPER truncate -s 6E "$TEST_MNT/img2" 30 | run_check $SUDO_HELPER truncate -s 6E "$TEST_MNT/img3" 31 | 32 | run_mustfail "mkfs for too-large images" \ 33 | $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_MNT"/img[123] 34 | 35 | run_check_umount_test_dev 36 | -------------------------------------------------------------------------------- /cmds/receive-dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Fujitsu. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License v2 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public 14 | * License along with this program; if not, write to the 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 | * Boston, MA 021110-1307, USA. 17 | */ 18 | 19 | #ifndef __BTRFS_SEND_DUMP_H__ 20 | #define __BTRFS_SEND_DUMP_H__ 21 | 22 | #include 23 | #include 24 | #include "common/send-stream.h" 25 | 26 | struct btrfs_dump_send_args { 27 | char full_subvol_path[PATH_MAX]; 28 | char root_path[PATH_MAX]; 29 | }; 30 | 31 | extern struct btrfs_send_ops btrfs_print_send_ops; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /common/filesystem-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public 4 | * License v2 as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9 | * General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public 12 | * License along with this program; if not, write to the 13 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 14 | * Boston, MA 021110-1307, USA. 15 | */ 16 | 17 | #ifndef __BTRFS_FILESYSTEM_UTILS_H__ 18 | #define __BTRFS_FILESYSTEM_UTILS_H__ 19 | 20 | #include "kerncompat.h" 21 | 22 | int lookup_path_rootid(int fd, u64 *rootid); 23 | int get_label(const char *btrfs_dev, char *label); 24 | int set_label(const char *btrfs_dev, const char *label); 25 | int get_label_mounted(const char *mount_path, char *labelp); 26 | int get_label_unmounted(const char *dev, char *label); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tests/scan-results.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Look for some frequent error message templates in test logs 3 | # 4 | # Usage: $0 [test-log.txt] 5 | 6 | ret=0 7 | 8 | scan_log() { 9 | local file="$1" 10 | 11 | echo "Scanning $file" 12 | last= 13 | while read line; do 14 | case "$line" in 15 | ===\ START\ TEST*) last="$line" ;; 16 | *Assertion*failed*) ret=1; echo "ASSERTION FAILED: $last" ;; 17 | *runtime\ error*) ret=1; echo "RUNTIME ERROR (sanitizer): $last" ;; 18 | *AddressSanitizer*heap-use-after-free*) ret=1; echo "RUNTIME ERROR (use after free): $last" ;; 19 | *LeakSanitizer:*leak*) ret=1; echo "SANITIZER REPORT: memory leak: $last" ;; 20 | *Warning:\ assertion*failed*) ret=1; echo "ASSERTION WARNING: $last" ;; 21 | *command\ not\ found*) ret=1; echo "COMMAND NOT FOUND: $last" ;; 22 | *extent\ buffer\ leak*) ret=1; echo "EXTENT BUFFER LEAK: $last" ;; 23 | *) : ;; 24 | esac 25 | done < "$file" 26 | } 27 | 28 | # Scan only the given file 29 | if [ -n "$1" ]; then 30 | scan_log "$1" 31 | exit "$ret" 32 | fi 33 | 34 | # Scan all existing test logs 35 | for file in *.txt; do 36 | scan_log "$file" 37 | done 38 | 39 | exit "$ret" 40 | --------------------------------------------------------------------------------