mirror of https://github.com/mkerrisk/man-pages
stat.2: Use lstat() instead of stat()
It's more logical to use lstat() in the example code, since one can then experiment with sybolic links, and also the S_IFLNK case can also occur. Reported-by: Richard Knutsson <richard.knutsson@abelko.se> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
9dc4485584
commit
133ca6caab
|
@ -634,7 +634,7 @@ or, on some architectures,
|
||||||
.BR newfstatat ().
|
.BR newfstatat ().
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
The following program calls
|
The following program calls
|
||||||
.BR stat ()
|
.BR lstat ()
|
||||||
and displays selected fields in the returned
|
and displays selected fields in the returned
|
||||||
.I stat
|
.I stat
|
||||||
structure.
|
structure.
|
||||||
|
@ -657,8 +657,8 @@ main(int argc, char *argv[])
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(argv[1], &sb) == \-1) {
|
if (lstat(argv[1], &sb) == \-1) {
|
||||||
perror("stat");
|
perror("lstat");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue