Commit Graph

211 Commits (2e1932e6a380a0cf94501e31f0c0f7814f73378e)

Author SHA1 Message Date
David Sterba 2e1932e6a3 btrfs-progs: build: simplify version tracking
There will be a plain file tracking the last released version.

The rest will be simplified to print it where needed. The version
augmented by the current git status was not working anyway since we've
switched to autoconf. The result of version.h with the potential git
status was generated at configure time, which does not mean it's
accurate regarding the git status.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:01 +01:00
Gu Jinxiang 60fa9e945f btrfs-progs: build: Remove unused variable TESTS
Variable is never used.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 19:25:05 +01:00
Hans van Kranenburg 9303f1dd1b btrfs-progs: Fix progs_extra build dependencies
The Makefile does not have a dependency path that builds dependencies
for tools listed in progs_extra.

E.g. doing make btrfs-show-super in a clean build environment results in:
    gcc: error: cmds-inspect-dump-super.o: No such file or directory
    Makefile:389: recipe for target 'btrfs-show-super' failed

Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 18:18:29 +01:00
Qu Wenruo 075580471e btrfs-progs: mkfs: move image creation of rootdir to its own files
In fact, --rootdir option is getting more and more independent from
normal mkfs code.

So move image creation function, make_image() and its related code to
mkfs/rootdir.[ch], and rename the function to btrfs_mkfs_fill_dir().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 18:11:24 +01:00
David Sterba ea085932dc btrfs-progs: image: move sanitization to new file
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
David Sterba af524c9539 btrfs-progs: build: use variables for btrfs-image images
More separate sources will be created for btrfs-image.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
Naohiro Aota 0792c17028 btrfs-progs: build: set include path relatively
Currently, gcc is passed the include directory with full path. As a result,
dependency files (*.o.d) also record the full path at the build time. Such
full path dependency is annoying for sharing the source between multiple
machines, containers, or anything the path differ.

And this is the same way what other program using autotools e.g. e2fsprogs
is doing:

$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>

Signed-off-by: Naohiro Aota <naota@elisp.net>
[ set TOPDIR=. instead of -I as discussed, does not harm linker ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:16:01 +02:00
David Sterba aafb4593fe btrfs-progs: build: add absolute path for topdir
We'll need TOPDIR to be ./ but library-test is intentionally built
outside of the git repository so we need to make them separate.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:15:58 +02:00
David Sterba 15beadeaa2 btrfs-progs: build: add more sparse warning checks
- declarations after statements (style issue)
- bitfields without defined signedness

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:44 +02:00
David Sterba 5d57bdeb23 btrfs-progs: build: use -std=gnu89 for sparse
Sparse does not seem to support gnu90 that we'd like to keep for the
regular build. Use gnu89 for C=1 build.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:40 +02:00
David Sterba 4498f53707 btrfs-progs: build: add missing defines for the C=1 build
Sparse complains that BTRFSCONVERT_EXT2 and _RESIERFS are not defined.
The per-target options are missing from the default CFLAGS and only
added in the specific rule.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:37 +02:00
Naohiro Aota 3efd322db2 btrfs-progs: build: omit unnecessary -MD flag
According to gcc(1), "-MD is equivalent to -M -MF file, except that -E is not
implied." Since the rule in the Makefile is just generating dependency file
and not building object file, it is no use to have "-MD" here. Also, it's
overridden and conflicting with the following "-MM" flag. I guess we can drop
it.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:45 +02:00
Naohiro Aota fd8c78a47c btrfs-progs: build: generate all dependency files
We're missing several dependency files like:

$ diff -u <(find -name '*.o'|cut -d. -f2|sort) <(find -name '*.o.d'|cut -d. -f2|sort)
@@ -3,7 +3,6 @@
 /btrfs-corrupt-block
 /btrfs-debug-tree
 /btrfs-find-root
-/btrfs-list
 /btrfs-map-logical
 /btrfs-select-super
 /btrfstune
@@ -29,11 +28,6 @@
 /cmds-scrub
 /cmds-send
 /cmds-subvolume
-/convert/common
-/convert/main
-/convert/source-ext2
-/convert/source-fs
-/convert/source-reiserfs
 /ctree
 /dir-item
 /disk-io
<snip>

This is due to moving things out of objects and cmds_objects variables. Such
missing dependency files cause mis-building of some source files (try touch
utils.h; make mkfs/main.o).

This patch introduce a new variable "all_objects" to keep all the objects and
use the variable to generate proper dependency file building rules.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:42 +02:00
David Sterba bcaadc2e49 btrfs-progs: build: whitespace adjustment of [LD] fssum
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:35 +02:00
Nick Terrell 717a8b1e5d btrfs-progs: Add zstd support
Adds zstd support to the btrfs program. An optional dependency on libzstd
>= 1.0.0 is added. Autoconf accepts `--enable-zstd' or `--disable-zstd' and
defaults to detecting if libzstd is present using `pkg-config'.

The patch is also available in my fork of btrfs-progs [1], which passes
Travis-CI with the new tests. The prebuilt binary is available there.

I haven't updated Android.mk.

[1] https://github.com/terrelln/btrfs-progs/tree/devel

Signed-off-by: Nick Terrell <terrelln@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:13 +02:00
David Sterba 37c271b216 btrfs-progs: move transaction implementation out of header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba a31458b966 btrfs-progs: build: fix asan and ubsan build
Probably with a new gcc (7.1.1) I started to see asan/ubsan link failures.
Fixed by explicitly linking the libraries.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 2e5617c9a6 btrfs-progs: build: fix building libbtrfs.so with tsan
Except libbtrfs.so object, all other tools compile fine. The error is:

ld: send-stream.o: relocation R_X86_64_PC32 against symbol
`stderr@@GLIBC_2.2.5' can not be used when making a shared object;
recompile with -fPIC

Compiling with -fPIC fixes the problem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b8c9c457c1 btrfs-progs: build: properly pass the LDFLAGS during tsan build
The variable LD_FLAGS does not exist and the flags are not used, we need
to use the newly added internal debugging linker flags.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 339019c934 btrfs-progs: build: add internal LDFLAGS for the D= features
We might want to pass additional linker flags for various sanitization
features.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 5d8b645f6f btrfs-progs: build: fix PIE build
Patch from Marcus Meissner <meissner@suse.com>. The CFLAGS are passed to
the linker and mix up the compilation and linker flags for PIE support.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Jeff Mahoney 99340c2ef7 btrfs-progs: convert: add support for converting reiserfs
This patch adds support to convert reiserfs file systems in-place to btrfs.

It will convert extended attribute files to btrfs extended attributes,
translate ACLs, coalesce tails that consist of multiple items into one item,
and convert tails that are too big into indirect files.

This requires that libreiserfscore 3.6.27 be available.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Qu Wenruo cd30857ceb btrfs-progs: Specify C standard to gnu90 explicitly
Different C compilers have different default language standard.
This sometimes causes problem on different system.

For distribution like CentOS/RHEL7, its gcc is still 4.8 and will report
error for c90 style declaration, while most developers are using newer
gcc which will just ignore it.
This makes us hard to detect such language standard problem.

This patch will specify standard to gnu90 explicitly to avoid such problem.
Gnu90 is a good mix of c90 while provide a lot of useful gnu extension,
and is supported by all modern gcc and clang.

Reported-by: Marco Lorenzo Crociani <marcoc@prismatelecomtesting.com>
Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:06:33 +02:00
David Sterba f929b62ae8 btrfs-progs: build: do not regenerate kernel-lib/tables.c
As reported in
https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg66765.html
cross-compilation does not work very well with current tables.c. We can
simpy keep the pergenerated file in the repository and update if needed.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:06:12 +02:00
Adam Buchbinder 18aed6a623 btrfs-progs: build: Enable ThreadSanitizer, using D=tsan
Tested with clang-3.9. We have to enable PIE,
(https://clang.llvm.org/docs/ThreadSanitizer.html)

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
Adam Buchbinder 50d037b459 btrfs-progs: tests: Fix missing internal deps in check and misc tests
Doing a straight 'make test' would fail because some misc and fsck
tests require particular tools to already be built. Add dependencies
at the Makefile and shell-script level.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
Qu Wenruo 9604ce49d6 btrfs-progs: raid56: Allow raid6 to recover 2 data stripes
Copied from kernel lib/raid6/recov.c raid6_2data_recov_intx1() function.
With the following modification:
- Rename to raid6_recov_data2() for shorter name
- s/kfree/free/g modification

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Qu Wenruo 084d152407 btrfs-progs: raid56: Introduce tables for RAID6 recovery
Use kernel RAID6 galois tables for later RAID6 recovery.

Galois tables file, kernel-lib/tables.c is generated by user space
program, mktable.

Galois field tables declaration, in kernel-lib/raid56.h, is completely
copied from kernel.

The mktables.c is copied from kernel with minor header/macro
modification, to ensure the generated tables.c works well in
btrfs-progs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Qu Wenruo 5e2a2acc9a btrfs-progs: raid56: Introduce raid56 header for later recovery usage
Introduce a new header, kernel-lib/raid56.h, for later raid56 works.

It contains 2 functions, from original btrfs-progs code:
void raid6_gen_syndrome(int disks, size_t bytes, void **ptrs);
int raid5_gen_result(int nr_devs, size_t stripe_len, int dest, void **data);

Will be expanded later and some part of it(RAID6 recover part) may keep
sync with kernel later.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ unify gpl header, rename header macro ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Sergei Trofimovich 64c2190d94 btrfs-progs: fix missing __error symbol in libbtrfs.so.0
The easiest way to reproduce the error is to try to build
btrfs-progs with
    $ make LDFLAGS=-Wl,--no-undefined

    btrfs-list.o: In function `lookup_ino_path':
    btrfs-list.c:(.text+0x7d2): undefined reference to `__error'

Noticed by Denis Descheneaux when snapper tool
stopped working after upgrade to btrfs-progs-4.10.

As soname didn't change in 4.9 -> 4.10 release
I assume it's just an object file omission
in library depends and not the API/ABI change
of the library error printing.

Cc: linux-btrfs@vger.kernel.org
Cc: Mike Gilbert <floppym@gentoo.org>
Reported-by: Denis Descheneaux
Bug: https://bugs.gentoo.org/show_bug.cgi?id=613890

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-31 14:17:48 +02:00
Qu Wenruo 230092bc48 btrfs-progs: Cleanup kernel-shared dir when execute make clean
Reported-by: Chris <coderight@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-31 14:17:48 +02:00
David Sterba 02947f4105 btrfs-progs: tests: misc/019, use fssum
The fssum utility is now ready to use, test still passes.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba b5d4b3cef3 btrfs-progs: tests: fssum, switch from MD5 to SHA256
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 12cae4c2c6 btrfs-progs: tests: fssum, drop unnecessray build defines
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 9a98589f00 btrfs-progs: tests: add fssum utility
Copy from fstests, originally from
git://git.kernel.org/pub/scm/linux/kernel/git/arne/far-progs.git

Needs libcrypto to link but this check is now missing in configure.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba f3ec118ab7 btrfs-progs: library-test: update test to build outside of topdir
We need to build outside of the topdir so we can use the "btrfs/" prefix
for includes and not accidentally include other files.

Make magic is simple:
- build dependencies inside TOPDIR
- build inside temporary directory, link back to TOPDIR
- library-test.o not built anymore obviously

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 87b971d0cc btrfs-progs: library: distribute sizes.h, fix build
The patch "btrfs-progs: Introduce kernel sizes to cleanup large
intermediate number" (a2203246ae) was taken from kernel but not
properly ported so the build breaks because the header linux/sizes.h is
not exported.

The build tests of library do not cover the case when the macro
BTRFS_FLAT_INCLUDES is not defined (ie. an external build).

Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 2b92a224c7 btrfs-progs: tests: fix library-test rules and deps
The symbol __error was undefined and the rule did not use the
dependencies from the rule definiton, like the rest.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:48 +01:00
David Sterba 886a8565e0 btrfs-progs: move ulist.[ch] to kernel-shared
The implementation of ulist_* is same for kernel and userspace, without
dependencies, so we can keep it separately for code sync.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:47 +01:00
David Sterba eb111e9f39 btrfs-progs: move message helpers implementation out of header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 5eff096b78 btrfs-progs: build: use MAKEOPTS where missing
$(MAKE) should also use MAKEOPTS.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 0c94504d06 btrfs-progs: build: drop deprecated utility from test dependencies
Standalone btrfs-debug-tree has been superseded by
'btrfs inspect-internal dump-tree'.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba ed4c7428b7 btrfs-progs: move mkfs helper implementation out of utils
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba d7e3f1d0b7 btrfs-progs: build: build library by default
Add a convenience rule and build the library by default, not just at the
installation phase.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 663253415f btrfs-progs: build: add rule for building cscope index
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 732056e3d3 btrfs-progs: build: split makefile to generated and stable parts
It's not really necessary to configure and regenerate Makefiles in cases
like adding a new source file. The build environment and optional
features are not affected by that.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
Karel Zak 48e728d112 btrfs-progs: autoconf: add ./configure script
- add ./autogen.sh script (necessary after git clean/clone)
- add ./configure.ac
- copy autotool helper scripts from automake
- modify version.sh to be usable from the configure script
- rename Makefile to Makefile.in and use basic variables from configure.ac

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 17:55:36 +01:00
Dimitri John Ledkov e69e015634 btrfs-progs: drop feature defines from C files, in favour of CFLAGS defines
glibc 2.10+ (5+ years old) enables all the desired features:
_XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a
single _GNU_SOURCE define in the makefile alone. For portability to
other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also
defined.

This also resolves Debian bug report filed by Michael Tautschnig -
"Inconsistent use of _XOPEN_SOURCE results in conflicting
declarations". Whilst I was not able to reproduce the results, the
reported fact is that _XOPEN_SOURCE set to 500 in one set of files
(e.g. cmds-filesystem.c) generates/defines different struct stat from
other files (cmds-replace.c).

This patch thus cleans up all feature defines, and sets them at a
consistent level.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-27 14:45:59 +01:00
David Sterba ca7b429f26 btrfs-progs: tests, adjust alignment of the pretty command name
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:18 +01:00
Qu Wenruo 040b3f11ba btrfs-progs: Makefile: Move linker only option to LDFLAGS
Move the linker only option -rdynamic to LDFLAGS.
This resolve lots of the following warning if using clang as CC:
clang: warning: argument unused during compilation: '-rdynamic'

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-19 15:04:43 +01:00