Skip to content

Commit d8bb304

Browse files
committed
bugfix: Get path to 'mv' using meson (fixes #509)
1 parent 52634ca commit d8bb304

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

ChangeLog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
=== rmw ChangeLog ===
22

3+
2025-12-29
4+
5+
* bugfix: Get path to 'mv' using meson (fixes #509)
6+
37
2025-11-06
48

59
* Release v0.9.4
610

711
2025-10-20
8-
* (bugfix) Allow rmw to move directories to waste folder on btrfs filesystems
12+
* bugfix: Allow rmw to move directories to waste folder on btrfs filesystems
913
(#497)
1014

1115
2024-11-07

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ foreach h : check_headers
6161
endif
6262
endforeach
6363

64+
mv_prog = find_program('mv', required: true)
65+
add_project_arguments('-DMV_PATH="' + mv_prog.full_path() + '"', language: 'c')
66+
6467
localedir = join_paths(get_option('prefix'), get_option('localedir'))
6568
subdir('po')
6669

src/utils.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,19 @@ safe_mv_via_exec(const char *src, const char *dst, int *out_errno)
517517

518518
if (pid == 0)
519519
{
520-
/* child: exec /bin/mv directly (argv[0] is "mv") */
521-
char *const argv_mv[] = { "mv", (char *) src, (char *) dst, NULL };
522-
execv("/bin/mv", argv_mv);
523-
/* if execv fails, set errno and exit with a distinct code */
524-
_exit(127);
520+
/* child: exec mv using path discovered by Meson */
521+
char *const argv_mv[] = {
522+
MV_PATH, /* argv[0] should match the executed path */
523+
(char *) src,
524+
(char *) dst,
525+
NULL
526+
};
527+
528+
execv(MV_PATH, argv_mv);
529+
_exit(127); /* only reached on execv failure */
525530
}
526531

532+
527533
/* parent: wait for child */
528534
if (waitpid(pid, &status, 0) < 0)
529535
{

0 commit comments

Comments
 (0)