Commit graph

12 commits

Author SHA1 Message Date
David Sterba 6ea85b680b btrfs-progs: path-utils: rename path_is_mount_point to avoid potential symbol name clash
There's a report that a static build fails when there's a static version
of libudev:

  /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libudev.a(path-util.o): in function `path_is_mount_point':
  path-util.c:(.text+0xbc0): multiple definition of `path_is_mount_point'; common/path-utils.o:path-utils.c:(.text+0x290): first defined here

There's a helper path_is_mount_point in libudev too but not exported so
dynamic library is fine, unlike static build. The static build of
libudev is not common but we can support that with a simple rename.

Issue: #611
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-03 19:14:13 +02:00
David Sterba b19a603d62 btrfs-progs: remove unnecessary linux/*.h includes
Decrease dependency on system headers, remove where they're not needed
or became stale after code moved. The path-utils.h encapsulate path
operations so include linux/limits.h here, that's where PATH_MAX is
defined.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-06 16:41:47 +02:00
Boris Burkov feb8f56ba2 btrfs-progs: receive: fix btrfs_mount_root substring bug
The current mount detection code in btrfs receive is not quite perfect.
For example, suppose /tmp is mounted as a tmpfs. In that case,
btrfs receive /tmp2 will find /tmp as the longest mount that matches a
prefix of /tmp2 and blow up because it is not a btrfs filesystem, even
if /tmp2 is just a directory in / mounted as btrfs.

Fix this by replacing the substring check with a dirname recursion to
only check the directories in the path of the dir, rather than every
substring.

Add a new test for this case.

Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-02-19 16:29:40 +01:00
David Sterba 922eaa7b54 btrfs-progs: build: fix linking with static libmount
The libmount dependency has been added in commit 61ecaff036
("btrfs-progs: build: add libmount dependency"), and static build got
broken. There are functions that do basically the same thing and also
share the name, which in turn fails at link time.

  ld: /../lib64/libmount.a(libcommon_la-canonicalize.o): in function `canonicalize_dm_name':
  util-linux-2.34/lib/canonicalize.c:58: multiple definition of `canonicalize_dm_name';
	  common/path-utils.static.o:btrfs-progs/common/path-utils.c:286: first defined here

In case the collision can be resolved by renaming, it's done
(canonicalize_path and parse_size). There are 2 symbols from selinux
that are substituted by a weak aliases during the static build.

There's one new warning due to use of getgrnam_r in libmount that
depends on dynamic linking and may not work properly with static build.
We're not using the related functions directly or indirectly, so it
should be safe to ignore the warnings.

  ld: ../lib64/libmount.a(la-utils.o): in function `mnt_get_gid':
  util-linux-2.34/libmount/src/utils.c:625: warning: Using 'getgrnam_r' in statically linked applications
  +requires at runtime the shared libraries from the glibc version used for linking

Issue: #333
Signed-off-by: David Sterba <dsterba@suse.com>
2021-01-25 23:31:56 +01:00
David Sterba fbc12fd9ec btrfs-progs: move path_cat_out helpers to path-utils
The path-util.[ch] is the right place, keep the send-utils.h prototypes
as it's part of libbtrfs headers.

Signed-off-by: David Sterba <dsterba@suse.com>
2020-11-04 23:26:43 +01:00
David Sterba b98a984f0b btrfs-progs: path-utils: rename test_isdir
Rename so it follows the path_ conventions.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba fc86737f91 btrfs-progs: path-utils: rename is_existing_blk_or_reg_file
Rename and add path_ prefix.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba 116e27a87a btrfs-progs: path-utils: rename is_path_exist
Rename so it fits the path_ group.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba facc0b130e btrfs-progs: path-utils: rename is_mount_point
Add path_ prefix and update callers.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba 89ad5e9dba btrfs-progs: path-utils: rename is_reg_file
Add path_ prefix and update callers.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba c3b0e6970b btrfs-progs: path-utils: rename is_block_device
Add the path_ prefix and update all callers.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:33 +02:00
David Sterba f83e81c61b btrfs-progs: utils: split path related utils to own file
Group helpers that return some status of a given path to own file so we
debloat utils.c a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:31 +02:00