Skip to content

Commit a6b56fc

Browse files
authored
Merge pull request #498 from theimpossibleastronaut/iss-497
Allow rmw to move directories to waste folder on btrfs filesystems
2 parents 0a57cec + cbd6289 commit a6b56fc

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ fi
2727

2828
cd "$BTRFS_IMAGE_MOUNTPOINT"
2929
RMW_TEST_CMD_STRING="$BIN_DIR/rmw -c ${MESON_SOURCE_ROOT}/test/conf/btrfs_img.testrc"
30-
WASTE_USED="/tmp/rmw-loop/three/Waste"
30+
31+
SUBVOLUME_USED="/tmp/rmw-loop/three"
32+
33+
WASTE_USED="$SUBVOLUME_USED/Waste"
34+
if [ -d "$WASTE_USED" ]; then
35+
rm -rf "$WASTE_USED"
36+
fi
37+
38+
TEST_DIR="$SUBVOLUME_USED/test_dir"
39+
if [ -d "$TEST_DIR" ]; then
40+
rm -rf "$TEST_DIR"
41+
fi
42+
43+
mkdir "$TEST_DIR"
44+
$RMW_TEST_CMD_STRING -v "$TEST_DIR"
3145

3246
touch foo
3347
$RMW_TEST_CMD_STRING foo

0 commit comments

Comments
 (0)