SCCS-vsn: bin/ls/ls.c 5.19
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ls.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)ls.c 5.19 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
f_recursive = 0;
/* if need to stat files */
f_recursive = 0;
/* if need to stat files */
- needstat = f_longform || f_recursive || f_timesort || f_size ||
- f_inode || f_type;
+ needstat = f_longform || f_recursive || f_timesort || f_size || f_type;
/* select a sort function */
if (f_reversesort) {
/* select a sort function */
if (f_reversesort) {
{
register int cnt, maxentry;
register char *p, *names;
{
register int cnt, maxentry;
register char *p, *names;
lp->name, strerror(errno));
return(0);
}
lp->name, strerror(errno));
return(0);
}
- for (cnt = 0; entry = readdir(dirp);) {
+ for (cnt = 0; dp = readdir(dirp);) {
/* this does -A and -a */
/* this does -A and -a */
if (p[0] == '.') {
if (!f_listdot)
continue;
if (p[0] == '.') {
if (!f_listdot)
continue;
(u_int)maxentry * sizeof(LS))))
nomem();
}
(u_int)maxentry * sizeof(LS))))
nomem();
}
- if (needstat && lstat(entry->d_name, &stats[cnt].lstat)) {
+ if (needstat && lstat(dp->d_name, &stats[cnt].lstat)) {
(void)fprintf(stderr, "ls: %s: %s\n",
(void)fprintf(stderr, "ls: %s: %s\n",
- entry->d_name, strerror(errno));
+ dp->d_name, strerror(errno));
if (errno == ENOENT)
continue;
exit(1);
}
if (errno == ENOENT)
continue;
exit(1);
}
+ /*
+ * get the inode from the directory, in case the -f flag
+ * was set and we can't stat the actual file.
+ */
+ stats[cnt].lstat.st_ino = dp->d_ino;
- bcopy(entry->d_name, names, (int)entry->d_namlen);
- names += entry->d_namlen;
+ bcopy(dp->d_name, names, (int)dp->d_namlen);
+ names += dp->d_namlen;
*names++ = '\0';
++cnt;
}
*names++ = '\0';
++cnt;
}