Skip to content

Commit d47f9c0

Browse files
andy5995claude
andcommitted
refactor/test: bcachefs test improvements and ficlone rename
- test/COMMON: add SKIP=77 for Meson skip exit code - test/test_bcachefs.sh: use pre-existing image from test dir instead of creating one; skip if kernel bcachefs support or image is absent; guard against stale mounts/loop devices and leftover files from previous runs - .github/workflows/c-cpp.yml: add bcachefs image cache/download step - test/rmw-bcachefs-test.img.sha256sum: add checksum file for CI caching - man/rmw.1: add BTRFS AND BCACHEFS subsection under NOTES - Rename want_btrfs_clone option to want_ficlone - Rename HAVE_LINUX_BTRFS macro to HAVE_FICLONE - Rename has_btrfs_header variable to has_linux_fs_header - Rename src/btrfs.c and src/btrfs.h to src/ficlone.c and src/ficlone.h - Rename is_btrfs() to is_ficlone_fs() and do_btrfs_clone() to do_ficlone() - Rename is_btrfs struct field in st_waste to is_ficlone_fs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 465332e commit d47f9c0

17 files changed

Lines changed: 86 additions & 43 deletions

.github/workflows/c-cpp.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ jobs:
189189
- name: Test btrfs image existence
190190
run: test -f test/rmw-btrfs-test.img
191191

192+
- name: Cache bcachefs Image
193+
uses: actions/cache@v5
194+
id: bcachefs-img-cache
195+
with:
196+
path: test/rmw-bcachefs-test.img
197+
key: ${{ hashFiles('test/rmw-bcachefs-test.img.sha256sum') }}
198+
199+
- if: ${{ steps.bcachefs-img-cache.outputs.cache-hit != 'true' }}
200+
run: curl -L -o test/rmw-bcachefs-test.img '<BCACHEFS_IMAGE_URL>'
201+
202+
- name: Test bcachefs image existence
203+
run: test -f test/rmw-bcachefs-test.img
204+
192205
- name: Install Dependencies
193206
run: |
194207
sudo apt update

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ subprojects/**
1717
!subprojects/**/*.wrap
1818
/packaging/appimage/.env
1919
/test/rmw-btrfs-test.img
20+
/test/rmw-bcachefs-test.img

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rmw-0.9.5
1+
# rmw-0.10.0-dev
22
## Description
33

44
rmw (ReMove to Waste) is a trashcan/recycle bin utility for the command line.

man/rmw.1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ directory will not be used for the current run of rmw.
192192
With the media mounted, once you manually create the waste directory
193193
for that device (e.g. "/mnt/flash/.Trash-$UID") and run rmw, it will
194194
automatically create the two required child directories "files" and "info".
195+
.SS BTRFS AND BCACHEFS
196+
rmw supports moving files across subvolumes on btrfs and bcachefs
197+
filesystems. Because the kernel treats subvolumes as separate
198+
filesystems, a cross-subvolume move would normally fail; rmw detects
199+
this case and performs a copy-then-delete instead, preserving the
200+
expected trash semantics.
201+
202+
To use this feature, define a WASTE directory on the destination
203+
subvolume in your configuration file. For example, if your waste
204+
directory is on a different subvolume than the files you want to
205+
remove, rmw will handle the move transparently.
195206
.SH EXAMPLES
196207
.SS RESTORING
197208
rmw -z ~/.local/share/Waste/files/foo

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(
22
'rmw',
33
'c',
4-
version: '0.9.5',
4+
version: '0.10.0-dev',
55
meson_version: '>= 0.59.0',
66
default_options: [
77
'c_std=gnu99',

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
option('build_tests', type : 'boolean', value : true,
22
description : 'build tests')
33
option(
4-
'want_btrfs_clone',
4+
'want_ficlone',
55
type : 'boolean',
66
value: 'true',
77
description: 'Include support for cloning files between subvolumes using FICLONE (btrfs, bcachefs, xfs, etc.)')

src/config_rmw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020

2121
#include <unistd.h>
2222

23-
#include "btrfs.h"
23+
#include "ficlone.h"
2424
#include "config_rmw.h"
2525
#include "utils.h"
2626
#include "main.h"
@@ -275,7 +275,7 @@ parse_line_waste(st_waste *waste_curr, struct Canfigger *node,
275275
else if (p_state == -1)
276276
exit(p_state);
277277

278-
waste_curr->is_btrfs = is_btrfs(waste_curr->parent);
278+
waste_curr->is_ficlone_fs = is_ficlone_fs(waste_curr->parent);
279279

280280
// get device number to use later for rename
281281
struct stat st, mp_st;

src/btrfs.c renamed to src/ficlone.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
#include "globals.h"
2424
#endif
2525

26-
#ifdef HAVE_LINUX_BTRFS
26+
#ifdef HAVE_FICLONE
2727
#include <fcntl.h>
2828
#include <linux/fs.h>
2929
#include <sys/ioctl.h>
@@ -32,13 +32,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3232
#include <unistd.h>
3333
#endif
3434

35-
#include "btrfs.h"
35+
#include "ficlone.h"
3636
#include "messages.h"
3737

3838
bool
39-
is_btrfs(const char *path)
39+
is_ficlone_fs(const char *path)
4040
{
41-
#ifdef HAVE_LINUX_BTRFS
41+
#ifdef HAVE_FICLONE
4242
struct statfs buf;
4343

4444
if (statfs(path, &buf) == -1)
@@ -57,9 +57,9 @@ is_btrfs(const char *path)
5757

5858

5959
int
60-
do_btrfs_clone(const char *source, const char *dest, int *save_errno)
60+
do_ficlone(const char *source, const char *dest, int *save_errno)
6161
{
62-
#ifdef HAVE_LINUX_BTRFS
62+
#ifdef HAVE_FICLONE
6363
int src_fd, dest_fd;
6464
struct stat src_stat;
6565

src/btrfs.h renamed to src/ficlone.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
#ifndef _INC_BTRFS_H
22-
#define _INC_BTRFS_H
21+
#ifndef _INC_FICLONE_H
22+
#define _INC_FICLONE_H
2323

2424
#include <stdbool.h>
2525

2626
#define BTRFS_SUPER_MAGIC 0x9123683E
2727

28-
bool is_btrfs(const char *path);
28+
bool is_ficlone_fs(const char *path);
2929

30-
int do_btrfs_clone(const char *source, const char *dest, int *save_errno);
30+
int do_ficlone(const char *source, const char *dest, int *save_errno);
3131

3232
#endif

src/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626
#include "purging.h"
2727
#include "strings_rmw.h"
2828
#include "messages.h"
29-
#include "btrfs.h"
29+
#include "ficlone.h"
3030
#include "trashinfo.h"
3131

3232

@@ -387,7 +387,7 @@ damage of 5000 hp. You feel satisfied.\n"));
387387
while (waste_curr != NULL)
388388
{
389389
if (waste_curr->dev_num == st_target.dev_num ||
390-
(waste_curr->is_btrfs && is_btrfs(argv[file_arg])))
390+
(waste_curr->is_ficlone_fs && is_ficlone_fs(argv[file_arg])))
391391
{
392392
char *tmp_str = join_paths(waste_curr->files, st_target.base_name);
393393
// *st_target.waste_dest_name = '\0';
@@ -421,7 +421,7 @@ damage of 5000 hp. You feel satisfied.\n"));
421421
if (!S_ISDIR(st_file_arg.st_mode))
422422
{
423423
/* attempt btrfs clone if not a directory */
424-
r_result = do_btrfs_clone(src, dst, &save_errno);
424+
r_result = do_ficlone(src, dst, &save_errno);
425425
errno = save_errno;
426426
}
427427
else
@@ -708,10 +708,10 @@ main(const int argc, char *const argv[])
708708
printf("PATH_MAX = %d\n", PATH_MAX);
709709

710710
if (verbose > 0)
711-
#ifdef HAVE_LINUX_BTRFS
712-
puts("btrfs_clone support: true");
711+
#ifdef HAVE_FICLONE
712+
puts("ficlone support: true");
713713
#else
714-
puts("btrfs_clone support: false");
714+
puts("ficlone support: false");
715715
#endif
716716

717717
const st_loc *st_location = get_locations(cli_user_options.alt_config_file);

0 commit comments

Comments
 (0)