Good job, Changyong.
Regarding R_OK, I
#include <sys/unistd.h>.
Here is what has been included in unistd.h:
/* Symbolic constants for the "access" routine: */
#define R_OK 4 /* Test for Read permission */
#define W_OK 2 /* Test for Write permission */
#define X_OK 1 /* Test for eXecute permission */
#define F_OK 0 /* Test for existence of File */
--Xin