2 dosyayı karşılaştıran ve eşit olup olmadıklarını gösteren bir program yazmaya çalışıyorum. fork
, dup
, dup2
, open
, write
, exec
ve read
:bash: ./comp.out: İzin reddedildi
Sadece işlevlerini kullanabilirsiniz. Ben linux gcc programı derlerken
, bu döndürür:
yalanladı kodu:bash: ./comp.out: İzin
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int CheckSimilar(char *path1, char *path2);
int main(int argc, char **argv) {
int returnValue = CheckSimilar(argv[1], argv[2]);
switch (returnValue){
case 1:
write(1, "1\n", 3);
break;
case 2:
write(1, "2\n", 3);
break;
case 3:
write(1, "3\n", 3);
break;
default:
break;
}
return 0;
}
/*
* This function checks if the files are similar or similar by case sensitive
* it gets 2 files, and returns: 3 if identical, 2 if identical but only if not
* case sensitive or 1 else.
*/
Nasıl İzinleri değiştirir miyim?
[email protected] ~/workspace/targ1OS $ gcc -c ec11.c -o comp.out
[email protected] ~/workspace/targ1OS $ ls
comp.out Debug ec11.c
[email protected] ~/workspace/targ1OS $ ./comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
bash: ./comp.out: Permission denied
[email protected] ~/workspace/targ1OS $ comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
comp.out: command not found
[email protected] ~/workspace/targ1OS $ ./comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
bash: ./comp.out: Permission denied
[email protected] ~/workspace/targ1OS $ ^C
[email protected] ~/workspace/targ1OS $ ls -al ./comp.out
-rw-r--r-- 1 shay shay 2640 Mar 30 10:05 ./comp.out
[email protected] ~/workspace/targ1OS $ chmod ogu+x ./comp.out
[email protected] ~/workspace/targ1OS $ ./comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
bash: ./comp.out: cannot execute binary file: Exec format error
[email protected] ~/workspace/targ1OS $ gcc -c ec11.c -o comp.out
[email protected] ~/workspace/targ1OS $ ./comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
bash: ./comp.out: Permission denied
[email protected] ~/workspace/targ1OS $ chmod ogu+x ./comp.out
[email protected] ~/workspace/targ1OS $ ./comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
bash: ./comp.out: cannot execute binary file: Exec format error
[email protected] ~/workspace/targ1OS $ comp.out /home/shay/Downloads/input.txt /home/shay/Downloads/input.txt
comp.out: command not found
Çalıştırmak sudo./Comp.out', belki? –
Ancak terminalde komutları kullanamıyorum. –
Ne demek istiyorsun? Bunları bir sebepten dolayı kullanma izniniz yok mu? –