I'm using syscall stat, it returns 0/-1. When -1 is returned it means, error occurred and errno is set as it should be (source: man 2 stat).
stat
man 2 stat
But I want to access errno and print it, how to do that?
You can get it from errno.
Also you can print the error using strerror