aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-04-08 22:12:08 -0500
committerRob Landley <rob@landley.net>2018-04-08 22:12:08 -0500
commit221439164eb6683a5af35540b24b5620e5d8ab19 (patch)
tree5460bd0d03042863cb6b3ddf12a9473c84da8689 /toys/posix
parentcd3f81ebe5c82f1fd5f610b0f2e0fa07ac27903e (diff)
downloadtoybox-221439164eb6683a5af35540b24b5620e5d8ab19.tar.gz
Add mkpath() for common case of mkpathat(), and #define magic constants.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cpio.c2
-rw-r--r--toys/posix/patch.c3
2 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c
index 90c8107f..6ce3ef1c 100644
--- a/toys/posix/cpio.c
+++ b/toys/posix/cpio.c
@@ -134,7 +134,7 @@ void cpio_main(void)
if (toys.optflags & (FLAG_t|FLAG_v)) puts(name);
- if (!test && strrchr(name, '/') && mkpathat(AT_FDCWD, name, 0, 2)) {
+ if (!test && strrchr(name, '/') && mkpath(name)) {
perror_msg("mkpath '%s'", name);
test++;
}
diff --git a/toys/posix/patch.c b/toys/posix/patch.c
index fbad1fb9..181af2a1 100644
--- a/toys/posix/patch.c
+++ b/toys/posix/patch.c
@@ -397,8 +397,7 @@ void patch_main(void)
if ((!strcmp(oldname, "/dev/null") || !oldsum) && access(name, F_OK))
{
printf("creating %s\n", name);
- if (mkpathat(AT_FDCWD, name, 0, 2))
- perror_exit("mkpath %s", name);
+ if (mkpath(name)) perror_exit("mkpath %s", name);
TT.filein = xcreate(name, O_CREAT|O_EXCL|O_RDWR, 0666);
} else {
printf("patching %s\n", name);