libutil/recurse: Use a single path buffer, and directory fd

This way, we don't use PATH_MAX bytes on the stack per path component,
and don't have to keep copying the complete path around.
This commit is contained in:
Michael Forney
2019-12-22 13:53:46 -08:00
parent 039b54aa51
commit edbcc223ea
10 changed files with 72 additions and 57 deletions

3
mv.c
View File

@@ -2,6 +2,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include "fs.h"
@@ -21,7 +22,7 @@ mv(const char *s1, const char *s2, int depth)
cp_aflag = cp_rflag = cp_pflag = 1;
cp_follow = 'P';
cp(s1, s2, depth);
recurse(s1, NULL, &r);
recurse(AT_FDCWD, s1, NULL, &r);
return (mv_status = cp_status || rm_status);
}
mv_status = 1;