Skip to content

Remove stray newline in filesystem show #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
87c3fb5
libbtrfsutil: update python setup.py for distribution
kdave Jul 30, 2024
720b1f3
btrfs-progs: docs: fix new typos
kdave Jul 30, 2024
75a789b
btrfs-progs: README: add uClibc-ng and btrfsutil
kdave Jul 30, 2024
8a6cec2
btrfs-progs: ci: enable sanitizer workflow for devel
kdave Jul 31, 2024
880651b
btrfs-progs: change-csum: switch to UASSERT
kdave Aug 6, 2024
afae10d
btrfs-progs: constify the name parameter of btrfs_add_link()
adam900710 Jul 31, 2024
c6464d3
btrfs-progs: mkfs: rework how we traverse rootdir
adam900710 Jul 31, 2024
27974ed
btrfs-progs: mkfs: warn about hard links with --rootdir
adam900710 Jul 31, 2024
aa5469d
btrfs-progs: tests: a new test case to verify handling of hard links
adam900710 Aug 1, 2024
cdb9aaa
btrfs-progs: tests: verify cross mount point behavior for rootdir
adam900710 Aug 1, 2024
e5aeb39
btrfs-progs: mkfs: use correct ctree.h include
kdave Aug 6, 2024
2830e84
libbtrfs: remove unused definitions from kerncompat.h
kdave Aug 6, 2024
d7bd967
libbtrfs: drop BUG_ONs from ctree.h
kdave Aug 6, 2024
f04463e
libbtrfs: drop pointless assertion when reading send stream
kdave Aug 6, 2024
e4afa23
libbtrfs: remove error reporting from kerncomat.h
kdave Aug 6, 2024
9b5ae7c
libbtrfs: drop BUILD_ASSERT macros
kdave Aug 6, 2024
2f29735
libbtrfs: remove unneeded includes from kerncompat.h
kdave Aug 6, 2024
674b50c
libbtrfs: use stub for list_head and drop list.h
kdave Aug 6, 2024
03735ff
libbtrfs: reduce rbtree includes and ship only rbtree_types.h
kdave Aug 6, 2024
1edc6ac
libbtrfs: move __bitwise definitions
kdave Aug 6, 2024
41331c7
libbtrfs: bump to version 0.1.4
kdave Aug 6, 2024
2b9f491
btrfs-progs: removed unused helpers from kerncompat.h
kdave Aug 7, 2024
a5b7e41
btrfs-progs: kernel-shared: update const of parameters accessors.h
kdave Aug 7, 2024
957b614
btrfs-progs: kerncompat: update definition of container_of
kdave Aug 7, 2024
28eb473
btrfs-progs: receive: cannot find clone source subvol when receiving …
ettavolt Jun 18, 2023
07b8c74
btrfs-progs: docs: clarify btrfs-send checksum
rhn May 11, 2024
8b36a29
btrfs-progs: mkfs: print only first warning when --rootdir finds a ha…
kdave Aug 14, 2024
a521bf6
btrfs-progs: update CHANGES for 6.10.1
kdave Jul 30, 2024
a00c2b2
Btrfs progs v6.10.1
kdave Aug 15, 2024
0e11b21
btrfs-progs: subvolume delete: add new option for recursive deletion
osandov Jun 27, 2024
082ce75
btrfs-progs: mkfs: add new option --subvol
maharmstone Aug 7, 2024
3c2c4fa
Remove stray newline in filesystem show
mattlangford Aug 8, 2024
fabbe9b
Keep spaces between filesystem entries
mattlangford Aug 9, 2024
e4eeaa2
address comments
mattlangford Aug 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Run tests with sanitizers enabled
# - UBSAN - undefined behaviour (default)
# - ASAN - memory leaks etc
#
# There are known problems, for now only for targeted testing
# - TSAN - multi-threading issues

name: Sanitizer checks
run-name: Sanitizer checks
on:
push:
branches:
- devel
- sanitize-test
- master
jobs:
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
run: sudo make D=tsan TEST_LOG=dump test-convert
- name: Test internal APIs
run: make D=tsan test-api
# Temporary: the library or python bindings are not linked with ASAN and test cannot be run
# Temporary: the library or python bindings are not linked with TSAN and test cannot be run
# - name: Libbtrfsutil test
# run: make D=tsan test-libbtrfsutil
# - name: Libbtrfs build test
Expand Down
14 changes: 14 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ btrfs-progs-6.10 (2024-07-30)
* build fix for python 3.13
* documentation updates

btrfs-progs-6.10.1 (2024-08-15)
"""""""""""""""""""""""""""""""
* mkfs: rework --rootdir traversal, skip hardlinks and create new inodes
instead, also warn about them, this did not work as expected and will be
fixed in the future
* receive: search in older trees for UUIDs when detecting clone sources
* libbtrfsutil: bindings available at https://pypi.org/project/btrfsutil
* libbtrfs:
* patchlevel version update 0.1.4
* cleanup in headers, removed unused definitions, no functional changes
* don't ship list.h and rbtree.h
* other:
* documentation updates

btrfs-progs-6.9 (2024-06-07)
----------------------------
* mkfs:
Expand Down
5 changes: 3 additions & 2 deletions Documentation/Send-receive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ The stream is a sequence of encoded commands that change e.g. file metadata
(owner, permissions, extended attributes), data extents (create, clone,
truncate), whole file operations (rename, delete). The stream can be sent over
network, piped directly to the receive command or saved to a file. Each command
in the stream is protected by a CRC32C checksum. See :doc:`btrfs-send`
and :doc:`btrfs-receive` for more.
in the stream is protected by a CRC32C checksum, with 0 as the initial value
and no inversion. See :doc:`btrfs-send` and :doc:`btrfs-receive` for more,
for protocol description :doc:`dev-send-stream`.
9 changes: 9 additions & 0 deletions Documentation/btrfs-subvolume.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ delete [options] [<subvolume> [<subvolume>...]], delete -i|--subvolid <subvolid>
-i|--subvolid <subvolid>
subvolume id to be removed instead of the <path> that should point to the
filesystem with the subvolume

-R|--recursive
delete subvolumes beneath each subvolume recursively

This requires either `CAP_SYS_ADMIN` or the filesystem must be
mounted with `user_subvol_rm_allowed` mount option.
In the unprivileged case, subvolumes which cannot be accessed
are skipped. The deletion is not atomic.

-v|--verbose
(deprecated) alias for global *-v* option

Expand Down
2 changes: 1 addition & 1 deletion Documentation/ch-subvolume-intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ layouts.
256 0 drwxr-xr-x 1 user users 14 Jul 30 12:34 ./snap1
2 0 drwxr-xr-x 1 user users 0 Jul 30 12:34 ./snap1/subvol2

The numbers in the first colums are inode numbers, 256 is for a regular
The numbers in the first columns are inode numbers, 256 is for a regular
subvolume (or snapshot), 2 is the *empty subvolume*. The snapshotted directory
representing *subvol2* does not contain the *file*.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/ch-sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ commit_stats
total_commit_ms 170840

* *commits* - number of transaction commits since the first mount
* *last_commit_ms* - duration in miliseconds of the last commit
* *last_commit_ms* - duration in milliseconds of the last commit
* *max_commit_ms* - maximum time a transaction commit took since first mount or last reset
* *total_commit_ms* - sum of all transaction commit times

Expand Down
5 changes: 5 additions & 0 deletions Documentation/mkfs.btrfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ OPTIONS
contain the files from *rootdir*. Since version 4.14.1 the filesystem size is
not minimized. Please see option *--shrink* if you need that functionality.

-u|--subvol <subdir>
Specify that *subdir* is to be created as a subvolume rather than a regular
directory. The option *--rootdir* must also be specified, and *subdir* must be an
existing subdirectory within it. This option can be specified multiple times.

--shrink
Shrink the filesystem to its minimal size, only works with *--rootdir* option.

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ libbtrfs_objects = \
libbtrfs/send-utils.o \
libbtrfs/crc32c.o

libbtrfs_headers = libbtrfs/send-stream.h libbtrfs/send-utils.h libbtrfs/send.h kernel-lib/rbtree.h \
kernel-lib/list.h kernel-lib/rbtree_types.h libbtrfs/kerncompat.h \
libbtrfs_headers = libbtrfs/send-stream.h libbtrfs/send-utils.h libbtrfs/send.h \
kernel-lib/rbtree_types.h libbtrfs/kerncompat.h \
libbtrfs/ioctl.h libbtrfs/ctree.h libbtrfs/version.h
libbtrfs_version = $(LIBBTRFS_MAJOR).$(LIBBTRFS_MINOR).$(LIBBTRFS_PATCHLEVEL)

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This repository hosts following utilities and also documentation:
* **mkfs.btrfs** &mdash; utility to create the filesystem ([manual page](https://btrfs.readthedocs.io/en/latest/mkfs.btrfs.html))
* all-in-one binary in the busybox style with mkfs.btrfs, btrfs-image and other tools built-in ([standalone tools](https://btrfs.readthedocs.io/en/latest/btrfs.html#standalone-tools))
* **libbtrfsutil** (LGPL v2.1) &mdash; C and python 3 bindings, see [libbtrfsutil/README.md](libbtrfsutil/README.md) for more
* **btrfsutil** python bindings published at https://pypi.org/project/btrfsutil
* manual pages and documentation source published at [btrfs.readthedocs.io](https://btrfs.readthedocs.io) (RTD)

See [INSTALL](INSTALL) for build instructions, [tests/README.md](tests/README.md) for
Expand Down Expand Up @@ -58,7 +59,8 @@ provided by the kernel.
### Build compatibility

Build is supported on the [GNU C library](https://www.gnu.org/software/libc/)
as the primary target, and on the [musl libc](https://musl.libc.org/).
as the primary target, and on the [musl libc](https://musl.libc.org/)
and [uClibc-ng](https://www.uclibc-ng.org/).

The supported compilers are [gcc](https://gcc.gnu.org/) (minimal version 4.8)
and [clang](https://clang.llvm.org/) (minimal version 3.4).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.10
v6.10.1
18 changes: 15 additions & 3 deletions cmds/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices,
if (devs_found < total) {
pr_verbose(LOG_DEFAULT, "\t*** Some devices missing\n");
}
pr_verbose(LOG_DEFAULT, "\n");
}

/* adds up all the used spaces as reported by the space info ioctl
Expand Down Expand Up @@ -431,7 +430,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
free(canonical_path);
}

pr_verbose(LOG_DEFAULT, "\n");
return 0;
}

Expand Down Expand Up @@ -481,6 +479,10 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode)

fd = open(mnt->mnt_dir, O_RDONLY);
if ((fd != -1) && !get_df(fd, &space_info_arg)) {
/* put spacing between filesystem entries for readability */
if (found != 0)
pr_verbose(LOG_DEFAULT, "\n");

print_one_fs(&fs_info_arg, dev_info_arg,
space_info_arg, label, unit_mode);
free(space_info_arg);
Expand Down Expand Up @@ -757,6 +759,7 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd,
char uuid_buf[BTRFS_UUID_UNPARSED_SIZE];
unsigned unit_mode;
int found = 0;
bool needs_newline = false;

unit_mode = get_unit_mode_from_arg(&argc, argv, 0);

Expand Down Expand Up @@ -845,6 +848,9 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd,
goto out;
}

/* the above call will return 0 if it found anything, in those cases we need an extra newline below */
needs_newline = !ret;

/* shows mounted only */
if (where == BTRFS_SCAN_MOUNTED)
goto out;
Expand Down Expand Up @@ -882,8 +888,14 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd,
goto out;
}

list_for_each_entry(fs_devices, &all_uuids, fs_list)
list_for_each_entry(fs_devices, &all_uuids, fs_list) {
/* put spacing between filesystem entries for readability */
if (needs_newline)
pr_verbose(LOG_DEFAULT, "\n");

print_one_uuid(fs_devices, unit_mode);
needs_newline = true;
}

if (search && !found) {
error("not a valid btrfs filesystem: %s", search);
Expand Down
34 changes: 23 additions & 11 deletions cmds/receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,25 @@ static int process_subvol(const char *path, const u8 *uuid, u64 ctransid,
return ret;
}

/*
* Search for the @subvol_uuid, try received_uuid and subvolume as a fallback
* if it's not found.
*/
static struct subvol_info *search_source_subvol(int mnt_fd, const u8 *subvol_uuid,
u64 transid)
{
struct subvol_info *found;

found = subvol_uuid_search(mnt_fd, 0, subvol_uuid, transid, NULL,
subvol_search_by_received_uuid);
if (IS_ERR_OR_NULL(found)) {
found = subvol_uuid_search(mnt_fd, 0, subvol_uuid, transid,
NULL, subvol_search_by_uuid);
}

return found;
}

static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid,
const u8 *parent_uuid, u64 parent_ctransid,
void *user)
Expand Down Expand Up @@ -283,14 +302,8 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid,
memset(&args_v2, 0, sizeof(args_v2));
strncpy_null(args_v2.name, path, sizeof(args_v2.name));

parent_subvol = subvol_uuid_search(rctx->mnt_fd, 0, parent_uuid,
parent_ctransid, NULL,
subvol_search_by_received_uuid);
if (IS_ERR_OR_NULL(parent_subvol)) {
parent_subvol = subvol_uuid_search(rctx->mnt_fd, 0, parent_uuid,
parent_ctransid, NULL,
subvol_search_by_uuid);
}
parent_subvol = search_source_subvol(rctx->mnt_fd, parent_uuid,
parent_ctransid);
if (IS_ERR_OR_NULL(parent_subvol)) {
if (!parent_subvol)
ret = -ENOENT;
Expand Down Expand Up @@ -745,9 +758,8 @@ static int process_clone(const char *path, u64 offset, u64 len,
BTRFS_UUID_SIZE) == 0) {
subvol_path = rctx->cur_subvol_path;
} else {
si = subvol_uuid_search(rctx->mnt_fd, 0, clone_uuid, clone_ctransid,
NULL,
subvol_search_by_received_uuid);
si = search_source_subvol(rctx->mnt_fd, clone_uuid,
clone_ctransid);
if (IS_ERR_OR_NULL(si)) {
char uuid_str[BTRFS_UUID_UNPARSED_SIZE];

Expand Down
16 changes: 14 additions & 2 deletions cmds/subvolume.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ static const char * const cmd_subvolume_delete_usage[] = {
OPTLINE("-c|--commit-after", "wait for transaction commit at the end of the operation"),
OPTLINE("-C|--commit-each", "wait for transaction commit after deleting each subvolume"),
OPTLINE("-i|--subvolid", "subvolume id of the to be removed subvolume"),
OPTLINE("-R|--recursive", "delete accessible subvolumes beneath each subvolume recursively, "
"this is not atomic, may need root to delete subvolumes not accessible by the user"),
OPTLINE("-v|--verbose", "deprecated, alias for global -v option"),
HELPINFO_INSERT_GLOBALS,
HELPINFO_INSERT_VERBOSE,
Expand All @@ -367,6 +369,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
char *path = NULL;
int commit_mode = 0;
bool subvol_path_not_found = false;
int flags = 0;
u8 fsid[BTRFS_FSID_SIZE];
u64 subvolid = 0;
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
Expand All @@ -383,11 +386,12 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
{"commit-after", no_argument, NULL, 'c'},
{"commit-each", no_argument, NULL, 'C'},
{"subvolid", required_argument, NULL, 'i'},
{"recursive", no_argument, NULL, 'R'},
{"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};

c = getopt_long(argc, argv, "cCi:v", long_options, NULL);
c = getopt_long(argc, argv, "cCi:Rv", long_options, NULL);
if (c < 0)
break;

Expand All @@ -401,6 +405,9 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
case 'i':
subvolid = arg_strtou64(optarg);
break;
case 'R':
flags |= BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE;
break;
case 'v':
bconf_be_verbose();
break;
Expand All @@ -416,6 +423,11 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
if (subvolid > 0 && check_argc_exact(argc - optind, 1))
return 1;

if (subvolid > 0 && flags & BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE) {
error("option --recursive is not supported with --subvolid");
return 1;
}

pr_verbose(LOG_INFO, "Transaction commit: %s\n",
!commit_mode ? "none (default)" :
commit_mode == COMMIT_AFTER ? "at the end" : "after each");
Expand Down Expand Up @@ -528,7 +540,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a

/* Start deleting. */
if (subvolid == 0)
err = btrfs_util_delete_subvolume_fd(fd, vname, 0);
err = btrfs_util_delete_subvolume_fd(fd, vname, flags);
else
err = btrfs_util_delete_subvolume_by_id_fd(fd, subvolid);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BTRFS_VERSION_PATCHLEVEL=`echo "${BTRFS_VERSION_PLAIN#v*}" | awk -F. '{print $3}
dnl libbtrfs .so version
LIBBTRFS_MAJOR=0
LIBBTRFS_MINOR=1
LIBBTRFS_PATCHLEVEL=3
LIBBTRFS_PATCHLEVEL=4

dnl libbtrfsutil .so version
BTRFS_UTIL_VERSION_MAJOR=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_MAJOR ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h`
Expand Down
61 changes: 33 additions & 28 deletions include/kerncompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,31 +313,6 @@ static inline void up_read(struct rw_semaphore *sem)
# define fallthrough do {} while (0) /* fallthrough */
#endif

/**
* __set_bit - Set a bit in memory
* @nr: the bit to set
* @addr: the address to start counting from
*
* Unlike set_bit(), this function is non-atomic and may be reordered.
* If it's called on the same region of memory simultaneously, the effect
* may be that only one operation succeeds.
*/
static inline void __set_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = BITOP_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);

*p |= mask;
}

static inline void __clear_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = BITOP_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);

*p &= ~mask;
}

/**
* test_bit - Determine whether a bit is set
* @nr: bit number to test
Expand Down Expand Up @@ -481,9 +456,39 @@ do { \

#define IS_ENABLED(c) 0

#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
/* Are two types/vars the same type (ignoring qualifiers)? */
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))

#define typeof_member(T, m) typeof(((T*)0)->m)

/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
* WARNING: any const qualifier of @ptr is lost.
*/
#define container_of(ptr, type, member) ({ \
void *__mptr = (void *)(ptr); \
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
((type *)(__mptr - offsetof(type, member))); })

/**
* container_of_const - cast a member of a structure out to the containing
* structure and preserve the const-ness of the pointer
* @ptr: the pointer to the member
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*/
#define container_of_const(ptr, type, member) \
_Generic(ptr, \
const typeof(*(ptr)) *: ((const type *)container_of(ptr, type, member)),\
default: ((type *)container_of(ptr, type, member)) \
)

#ifndef __bitwise
#ifdef __CHECKER__
#define __bitwise __bitwise__
Expand Down
Loading