Author: Stan Eisenstat
Subject: Re: [Cs323] Lstat vs stat
Date: Monday, 07 Sep 2020, 08:41:08
> Message Posted By: Unknown > > I get that for -P we use Lstat and -L we use stat, but why do we use > lstat() for symbolic links? > > From the man page, it says that lstat looks at info about the link and > stat looks at the target, but I am confused why its different for when we > traverse symbolic vs non-symbolic only links. With -P, the traversal treats symbolic links as if they were regular files, which requires getting information about the links themselves, not the files to which they refer. Thus you use lstat(). With -L, the traversal treats symbolic links as if they were the files to which they refer, which requires getting information about those files, not the links themselves. Thus you use stat(). --Stan-PREV INDEX NEXT