From 9a6d1dfbea2b6fd4c6f866dc86fd62f91293a330 Mon Sep 17 00:00:00 2001 From: EdwardEisenhauer Date: Wed, 3 Mar 2021 16:59:11 +0100 Subject: [PATCH] Added mode bits copying --- Topic-1/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Topic-1/main.c b/Topic-1/main.c index a33bec6..14bc305 100644 --- a/Topic-1/main.c +++ b/Topic-1/main.c @@ -3,6 +3,7 @@ #include #include #include +#include #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);