What mean filedescriptor error-codes?
Hi,
I have written the following code:
Code:
#include <stdio.h>
int main(void) {
char *myfile = "/home/username/Desktop/testfile";
FILE *fd;
fd=fopen(myfile, "r");
printf("%i\n",fd);
fclose(fd);
return 0;
}
Executed I get this here: 134520840, which looks like a valid filedescriptor.
If I try now the same with syscalls:
Code:
#include </usr/include/linux/unistd.h>
#include <stdio.h>
int main(void) {
char *myfile = "/home/username/Desktop/testfile";
int fd;
fd = syscall(__NR_open,myfile,"O_RDONLY") ;
printf("%i\n",fd);
return 0;
}
I always get -1 and if I use &myfile in the syscall I get 3 ? What are -1 and 3 meaning?
Can someone see the mistake in my second code?
bye