Skip to content

Commit 68ccba3

Browse files
committed
Allow rmw to move directories to waste folder on btrfs filesystems
Fixes #497
1 parent 0a57cec commit 68ccba3

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
=== rmw ChangeLog ===
22

3+
2025-10-20
4+
* (bugfix) Allow rmw to move directories to waste folder on btrfs filesystems
5+
36
2024-11-07
47

58
* Update ChangeLog to note btrfs cloning is supported only on Linux

src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ damage of 5000 hp. You feel satisfied.\n"));
367367
printf(_("%s resides within a waste folder and has been ignored\n"),
368368
argv[file_arg]);
369369
is_protected = 1;
370+
if (getenv("RMW_FAKE_HOME"))
371+
n_err++;
370372
break;
371373
}
372374
waste_curr = waste_curr->next_node;
@@ -410,7 +412,7 @@ damage of 5000 hp. You feel satisfied.\n"));
410412
int r_result = 0;
411413
if (cli_user_options->want_dry_run == false)
412414
{
413-
if (waste_curr->dev_num != st_target.dev_num)
415+
if ((waste_curr->dev_num != st_target.dev_num) && !S_ISDIR(st_file_arg.st_mode))
414416
{
415417
int save_errno = errno;
416418
r_result =
@@ -805,7 +807,7 @@ Please check your configuration file and permissions\
805807
st_location,
806808
&cli_user_options);
807809

808-
if (result > 1)
810+
if (result)
809811
{
810812
dispose_waste(st_config_data.st_waste_folder_props_head);
811813
/* Don't need to print any messages here. Any warnings or errors

test/test_basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ test "$output" = "6"
6363

6464
echo "$SEPARATOR"
6565
echo " == rmw should refuse to move a waste folder or a file that resides within a waste folder"
66-
output="$($RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info)"
66+
output="$($RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info || true)"
6767
test "${output}" = " :warning: "$PRIMARY_WASTE_DIR"/info resides within a waste folder and has been ignored
6868
0 items were removed to the waste folder"
6969

7070
# If the file gets removed (which it shouldn't), then the test that follows it will fail
71-
$RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info/1.trashinfo
71+
$RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info/1.trashinfo || true
7272

7373
echo "\n\n == Display contents of 1.trashinfo "
7474
cat "$PRIMARY_WASTE_DIR"/info/1.trashinfo

test/test_btrfs_clone.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ cd "$BTRFS_IMAGE_MOUNTPOINT"
2929
RMW_TEST_CMD_STRING="$BIN_DIR/rmw -c ${MESON_SOURCE_ROOT}/test/conf/btrfs_img.testrc"
3030
WASTE_USED="/tmp/rmw-loop/three/Waste"
3131

32+
TEST_DIR="/tmp/rmw-loop/three/test_dir"
33+
if [ -d "$TEST_DIR" ]; then
34+
rm -rf "$TEST_DIR"
35+
fi
36+
37+
mkdir "$TEST_DIR"
38+
$RMW_TEST_CMD_STRING "$TEST_DIR"
39+
3240
touch foo
3341
$RMW_TEST_CMD_STRING foo
3442
test -f "$WASTE_USED/files/foo"

0 commit comments

Comments
 (0)