Added mode bits copying

This commit is contained in:
Sergiusz Warga 2021-03-03 16:59:11 +01:00
parent 261174c8c4
commit 9a6d1dfbea

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#define BUFFER_SIZE 8
@ -36,6 +37,11 @@ int cp(char *argv[]){
write(new, buffer, read_bytes);
}
struct stat mod_bits;
stat(argv[1], &mod_bits);
chmod(argv[2], mod_bits.st_mode);
close(old);
close(new);