NSH: Extend ls command to show type of symbolic link.
@@ -178,6 +178,19 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
if ((lsflags & LSFLAGS_LONG) != 0)
{
char details[] = "----------";
+#ifdef CONFIG_PSEUDOFS_SOFTLINKS
+ /* Temporary kludge: stat does not return link type because it
+ * follows the link and returns the type of the link target.
+ * readdir(), however, does correctly return the correct type of
+ * the symbolic link.
+ */
+
+ if (DIRENT_ISLINK(entryp->d_type))
+ {
+ details[0] = 'l';
+ }
+ else
+#endif
if (S_ISDIR(buf.st_mode))
{
details[0] = 'd';
@@ -190,6 +203,12 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
{
details[0] = 'b';
}
+#if 0 /* ifdef CONFIG_PSEUDOFS_SOFTLINKS See Kludge above. */
+ else if (S_ISLNK(buf.st_mode))
+ {
+ details[0] = 'l';
+ }
+#endif
else if (!S_ISREG(buf.st_mode))
{
details[0] = '?';
