why fopen() or open() use errno instead of just returning error code?
===

In usual case  `open()` return the new file descriptor, or -1 if an error occurred  and in that case, `errno` is set appropriately.  

I am not understanding why this mechanism of `errno` is used here? whats the purpose of here? why just we can not map all error with some negative return no?


like 

    fd = open("/dev/tty0", O_RDWR | O_SYNC);
    if(fd == -1)
      printf("this is EACCES error");
    else if (fd == -2)
        printf("this is EPERM error");


Is there any benifit of `errno`  mechanism.? if yes then i would like to know/understand then in other things i can also use this mechanism.  