 
                            ...
| Code Block | ||
|---|---|---|
| 
 | ||
| 
struct stat st;
char *file_name;
/* initialize file_name */
int fd = open(file_name, O_RDONLY);
if (fd == -1) {
  /* Handle Error */
}
if ((fstat(fd, &st) == -1) ||
   (st.st_uid != getuid()) ||
   (st.st_gid != getgid())) {
  /* file does not belong to user */
}
/*... read from file ...*/
close(fd);
fd = -1;
 | 
...