commit 1e6061a94db267071b35531f9c604ace386b3a6e
parent 904ce83c3b73e531989d753a2fb3473266441dc3
Author: Jacob R. Edwards <n/a>
Date: Mon, 7 Feb 2022 18:21:25 -0800
Use /bin/cp for copying in module program
Diffstat:
| M | lib/module.c | | | 49 | ------------------------------------------------- |
1 file changed, 0 insertions(+), 49 deletions(-)
diff --git a/lib/module.c b/lib/module.c
@@ -1,12 +1,7 @@
#define const
#include <sys/stat.h>
-
-#ifdef PROGCOPY
#include <sys/wait.h>
-#else
-#include <fcntl.h>
-#endif
#include <errno.h>
#include <fts.h>
@@ -30,10 +25,6 @@ die(char *s)
exit(1);
}
-/*
- * I'm on the debating as to which one to use, keeping both for now.
- */
-#ifdef PROGCOPY
int
copy(char *a, char *b)
{
@@ -51,46 +42,6 @@ copy(char *a, char *b)
return 1;
return WEXITSTATUS(status);
}
-#else
-int
-copy(char *a, char *b)
-{
- char buf[4096];
- int af, bf;
- int len;
- struct stat as;
-
- af = open(a, O_RDONLY);
- if (af < 0)
- return 1;
-
- if (fstat(af, &as)) {
- close(af);
- return 1;
- }
-
- bf = open(b, O_WRONLY | O_CREAT | O_EXCL, as.st_mode);
- if (bf < 0) {
- close(af);
- return 1;
- }
-
- /* Leave owner and group untouched for global module. */
- if (fchflags(bf, as.st_flags)) {
- close(af);
- close(bf);
- return 1;
- }
-
- while ((len = read(af, buf, sizeof(buf))) > 0 && write(bf, buf, len) == len)
- ;
- if (close(af) + close(bf) || len != 0) {
- unlink(b);
- return 1;
- }
- return 0;
-}
-#endif
int
none(char *a, char *b)