Commit Graph

267 Commits (d1efe50d0a64e757fac0775858ea92e1266ce16d)

Author SHA1 Message Date
David Sterba d1efe50d0a btrfs-progs: move messages.[ch] to common/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba f63f29e9e9 btrfs-progs: move internal.h to common/
Create directory for all sources that can be used by anything that's not
rellated to a relevant kernel part, all common functions, helpers,
utilities that do not fit any other specific category.

The traditional location would be probably lib/ with all things that are
statically linked to the main binaries, but we have libbtrfs and
libbtrfsutil so this would be confusing.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba 96f58629c6 btrfs-progs: move cmds-send.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba 4f398726d3 btrfs-progs: move all cmds-fi*.c to cmds/
This is the filesystem command group.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba 3bfc7bcfba btrfs-progs: move all cmds-inspect*.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba d8bdd9e6a7 btrfs-progs: move cmds-subvolume.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 4707a1c3b3 btrfs-progs: move cmds-scrub.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba fd88267f71 btrfs-progs: move cmds-receive.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba f40f752bf6 btrfs-progs: move cmds-balance.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 4bee9116bb btrfs-progs: move cmds-restore.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba de6b03ca33 btrfs-progs: move cmds-device.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 87caad49fa btrfs-progs: move cmds-replace.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 4356aa5f34 btrfs-progs: move and rename super-recover.c cmds/
The file now gets the prefix of the command group.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba b0445ccf0a btrfs-progs: move and rename chunk-recover.c cmds/
The file now gets the prefix of the command group.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba ea7e4fb3d7 btrfs-progs: move cmds/property.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 605b8c1295 btrfs-progs: move cmds-rescue.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba fc160f4657 btrfs-progs: move cmds-qgroup.c to cmds/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 64e10d3b6f btrfs-progs: move cmds-quota.c to cmds/
This is first instance of commands files moving to a separate directory,
that will be cmds/, thus the files can drop the prefix. We can further
split files into specific parts of a given command. The quota file was
selected as the smallest.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:02 +02:00
David Sterba 33394a9e9d btrfs-progs: build: support per-file CFLAGS located in directories
Our build allows easy definition of CFLAGs that apply only to a given
file, like cmds_restore_cflags and cmds-restore.c .

This is done by series of transformations that convert the file name to
a variable name, when that is defined it's used.

To support files in directories outside of the top level we need to
convert the / too. The function 'subst' supports only a single string,
so they have to be nested.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:01 +02:00
David Sterba 9a1d86a9ac btrfs-progs: build: disable -Waddress-of-packed-member by default
Gcc 9 adds the flag to default warnings and this produces a lot of
warnings that don't seem to be harmful as we know the address is
aligned, but this could be hidden in the function call chain.
It's still available under W=1.

Issue: #180
Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-14 15:09:53 +02:00
Sergei Trofimovich 8cd7e198ad btrfs-progs: build: apply LDFLAGS to libbtrfsutil.so
libbtrfs.so already has user's LDFLAGS applied.  The change also applies
those to libbtrfsutil.so. A separate variable is used for that though it
currently only copies LDFLAGS. This is to make it obvious that
libbtrfsutils is a standalone library.

Reported-by: Michał Górny
Bug: https://bugs.gentoo.org/686284
Pull-request: #172
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-27 15:57:35 +02:00
Joshua Watt 66cb960705 btrfs-progs: build: Pass CFLAGS and LDFLAGS to Python
Adds Make variables EXTRA_PYTHON_CFLAGS and EXTRA_PYTHON_LDFLAGS which
can be used to pass CFLAGS and LDFLAGS respectively when building the
Python library.

This is required to support reproducible builds, as there are often
compiler and linker flags that must be passed in order to generate
reproducible output (e.g. -fdebug-prefix-map)

Pull-request: #176
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-27 15:49:03 +02:00
Johannes Thumshirn a36d331f03 btrfs-progs: build: provide etags make target
Provide an 'etags' make target to create tags in the Emacs etags
format, similar to the 'tags' target for VIM's ctags.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 18:42:13 +01:00
Su Yanjun 07cead1a1e btrfs-progs: silence build warning caused by gcc 8 '-Wformat-truncation'
When using gcc8 + glibc 2.28.5 compiles utils.c, it complains as below:

  utils.c:852:45: warning: '%s' directive output may be truncated writing
  up to 4095 bytes into a region of size 4084 [-Wformat-truncation=]
     snprintf(path, sizeof(path), "/dev/mapper/%s", name);
                                             ^~   ~~~~
  In file included from /usr/include/stdio.h:873,
                   from utils.c:20:
  /usr/include/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk'
  output between 13 and 4108 bytes into a destination of size 4096
     return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          __bos (__s), __fmt, __va_arg_pack ());
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This isn't a type of warning we care about, particularly when calling
snprintf() we expect string to be truncated.

Use the GCC option -Wno-format-truncation to disable this for default
build and W=1 build, while still keeping it for W=2 and W=3 builds.

Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
[ Use cc-disable-warning to fix the not working CFLAGS setting in configure.ac ]
[ Keep the warning in W=2/W=3 build ]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 16:20:10 +01:00
Josh Soref bc72922789 btrfs-progs: fix typos in Makefile
Besides the comments, there's a slight change as the file config.log
will be deleted by the 'clean-gen' rule.

Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:48:04 +01:00
Nikolay Borisov c6039704c5 btrfs-progs: Add delayed refs infrastructure
This commit pulls those portions of the kernel implementation of
delayed refs which are necessary to have them working in user-space.
I've done the following modifications:

1. Replaced all kmem_cache_alloc calls to kmalloc.

2. Removed all locking-related code, since we are single threaded in
   userspace.

3. Removed code which deals with data refs - delayed refs in user space
   are going to be used only for cowonly trees.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-23 14:48:41 +02:00
Omar Sandoval a4770b0a01 btrfs-progs: build: add --disable-shared and --disable-static
The build system mentioned in the previous commit builds libraries in
both PIC and non-PIC mode. Shared libraries don't work in PIC mode, so
it expects a --disable-shared configure option, which most open source
libraries using autoconf have. Let's add it, too.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:41 +02:00
Omar Sandoval 996a07c602 btrfs-progs: build: add --disable-programs
We have a build system internally which only needs to build and install
the libraries out of a repository, not any binaries. There's no easy way
to do this in btrfs-progs currently. Add --disable-programs to
./configure to support this.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:38 +02:00
Omar Sandoval 0cbcc58b96 btrfs-progs: remove stale dir-test
It does not 't build anymore and we don't have any use for it.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:01:38 +02:00
Gu JinXiang bb9b8bcfd9 btrfs-progs: Add DEBUG_CFLAGS_INTERNAL for libbtrfsutil
Add DEBUG_CFLAGS_INTERNAL to LIBBTRFSUTIL_CFLAGS for libbtrfsutil's
build.

Signed-off-by: Gu JinXiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:38 +02:00
Jeff Mahoney eb7b42003a btrfs-progs: build: detect whether -std=gnu90 is supported
GCC releases prior to 4.5.0 don't support -std=gnu90 so btrfs-progs won't
build at all on older distros.  We can detect whether the compiler
supports -std=gnu90 and fall back to -std=gnu89 if it doesn't.

AX_CHECK_COMPILE_FLAG is the right way to do this, but it depends on
autoconf 2.64.  AX_GCC_VERSION has been deprecated, so we'll use that
only for earlier autoconf versions so we can drop it when we drop
support for older autoconf releases.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:35 +02:00
Baruch Siach cc66055f97 btrfs-progs: build btrfs.static needs libbtrfsutil to build
Add libbtrfsutil objects to btrfs.static link command. This fixes static
build failure:

utils.static.o: In function `parse_qgroupid':
utils.c:(.text.parse_qgroupid+0xb0): undefined reference to `btrfs_util_is_subvolume'
props.static.o: In function `prop_read_only':
props.c:(.text.prop_read_only+0x70): undefined reference to `btrfs_util_set_subvolume_read_only'
...
Makefile:457: recipe for target 'btrfs.static' failed
make[1]: *** [btrfs.static] Error 1

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:12 +02:00
Nikolay Borisov 631bf9f2b9 btrfs-progs: Remove deprecated btrfs-calc-size tool
Its function has been superseded by btrfs inspect-internal tree-stats.
Just remove it.

Deprecated since 4.8.

Issue: #97
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:10 +02:00
Nikolay Borisov 5a87a95115 btrfs-progs: Remove deprecated btrfs-show-super
Its function has been superseded by btrfs inspect-internal show-super.
Furthermore the tools is currently not built by default. Just remove it.

Deprecated since 4.8.

Issue: #97
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:10 +02:00
Nikolay Borisov df9158f20d btrfs-progs: Remove deprecated btrfs-zero-log standalone tool
Its function has been subsumed by "btrfs rescue zero-log". Remove its
source file and adjust make/tests soruces accordingly.

Deprecated since 4.0.

Issue: #97
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:10 +02:00
Nikolay Borisov de34a33a82 btrfs-progs: Remove btrfs-debug-tree command
There is already a replacement in the face of btrfs inspect-internal
dump-tree. And this command is just a simple wrapper around it. Just
remove it and adjust the show-blocks script to call the main btrfs
binary to achieve the same effect.

Informally deprecated since 4.4.

Issue: #97
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:10 +02:00
Peter Kjellerstedt 6cedd68811 btrfs-progs: build: Do not use cp -a to install library links
Using cp -a to install files will preserve the ownership of the original
files (if possible), which is typically not wanted. E.g. if the files
were built by a normal user, but are being installed by root, then the
installed files would maintain the UIDs/GIDs of the user that built the
files rather than be owned by root.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-06 15:06:50 +02:00
Omar Sandoval 7cdd58b2e9 libbtrfsutil: always build libbtrfsutil.so.$MAJOR
Otherwise, make test-libbtrfsutil from a fresh checkout fails.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:54:51 +02:00
Omar Sandoval 660adc0e1c libbtrfsutil: use local mkfs.btrfs for tests if it exists
The system might not have mkfs installed at all.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:54:41 +02:00
Lu Fengqi 3fd6a955f9 btrfs-progs: build: modify cscope/ctags rules to include directories such as check
Modify cscope/ctags rule to include directories such as check/
libbtrfsutil/kernel-lib/kernel-shared.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00
David Sterba e0d173c6c4 libbtrfsutil: add stub for reallocarray
This function is new in glibc 2.26 and breaks build in CI and possibly
other environments.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-06 11:28:37 +01:00
Omar Sandoval 92d4035074 libbtrfsutil: add btrfs_util_is_subvolume() and btrfs_util_subvolume_id()
These are the most trivial helpers in the library and will be used to
implement several of the more involved functions.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-06 11:28:36 +01:00
Omar Sandoval 9615c23d15 libbtrfsutil: add filesystem sync helpers
Namely, sync, start_sync, and wait_sync.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-24 01:37:17 +01:00
Omar Sandoval bad4208da3 libbtrfsutil: add qgroup inheritance helpers
We want to hide struct btrfs_qgroup_inherit from the user because that
comes from the Btrfs UAPI headers. Instead, wrap it in a struct
btrfs_util_qgroup_inherit and provide helpers to manipulate it. This
will be used for subvolume and snapshot creation.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-24 01:37:17 +01:00
Omar Sandoval 23c01b3c1b libbtrfsutil: add Python bindings
The C libbtrfsutil library isn't very useful for scripting, so we also
want bindings for Python. Writing unit tests in Python is also much
easier than doing so in C. Only Python 3 is supported; if someone really
wants Python 2 support, they can write their own bindings. This commit
is just the scaffolding.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-24 01:37:17 +01:00
Omar Sandoval 502e2a3510 Add libbtrfsutil
Currently, users wishing to manage Btrfs filesystems programatically
have to shell out to btrfs-progs and parse the output. This isn't ideal.
The goal of libbtrfsutil is to provide a library version of as many of
the operations of btrfs-progs as possible and to migrate btrfs-progs to
use it.

Rather than simply refactoring the existing btrfs-progs code, the code
has to be written from scratch for a couple of reasons:

* A lot of the btrfs-progs code was not designed with a nice library API
  in mind in terms of reusability, naming, and error reporting.
* libbtrfsutil is licensed under the LGPL, whereas btrfs-progs is under
  the GPL, which makes it dubious to directly copy or move the code.

Eventually, most of the low-level btrfs-progs code should either live in
libbtrfsutil or the shared kernel/userspace filesystem code, and
btrfs-progs will just be the CLI wrapper.

This first commit just includes the build system changes, license,
README, and error reporting helper.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-24 01:37:16 +01:00
David Sterba e6477462d3 btrfs-progs: reorder tests in make target
Run the shorter tests first, convert can take very long, we're more
interested in the misc test.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 16:22:55 +01:00
David Sterba 04cd2c0bca btrfs-progs: rework testsuite export
Move the testsuite to tests/ and make the tarball generation more
deterministic. As there could be many random temporary files left in the
test directories, we can't just copy them. Use 'git ls-tree' to
filter just what we want, this needs a slight extension of the file list
specification.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
Gu Jinxiang eb2fe7d1c4 btrfs-progs: Add make testsuite command for export tests
Export the testsuite files to a separate tar.  Since fsck tests depend
on btrfs-corrupt-block, and misc tests depends on both
btrfs-corrupt-block and fssum, so set it as prerequisites for package
commad.

Because, althougth fssum can be generated by source that are all in
tests directory, and has no rely on the btrfs's structure.  But
btrfs-corrupt-block deeply relys on btrfs's structure.  For consistency,
at the present stage, generete the two when create test tar.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
[ applied without changes, the generated tarball will be different from
  the one after the follow up commits ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
Gu Jinxiang d5238ad711 btrfs-progs: add prerequisite btrfs-convert for test-misc
Since tests/misc-tests/005-convert-progress-thread-crash/test.sh need
the btrfs-convert for prerequisite.  So add the dependency in Makefile.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00