aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/patch.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/patch.c')
-rw-r--r--toys/posix/patch.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/toys/posix/patch.c b/toys/posix/patch.c
index ae24ff94..27828015 100644
--- a/toys/posix/patch.c
+++ b/toys/posix/patch.c
@@ -385,12 +385,8 @@ void patch_main(void)
if ((!strcmp(oldname, "/dev/null") || !oldsum) && access(name, F_OK))
{
printf("creating %s\n", name);
- s = strrchr(name, '/');
- if (s) {
- *s = 0;
- xmkpath(name, -1);
- *s = '/';
- }
+ if (mkpathat(AT_FDCWD, name, 0, 2))
+ perror_exit("mkpath %s", name);
TT.filein = xcreate(name, O_CREAT|O_EXCL|O_RDWR, 0666);
} else {
printf("patching %s\n", name);