changeset 304:e0ca3ca46a06

fc-fsio: ll reads and shows symlinks
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 02 Mar 2014 05:40:05 +0000
parents 61c68a55f2a2
children 4dccc9d3305f
files rvinterf/etmsync/fsread.c rvinterf/etmsync/symlink.c
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/fsread.c	Sun Mar 02 04:48:33 2014 +0000
+++ b/rvinterf/etmsync/fsread.c	Sun Mar 02 05:40:05 2014 +0000
@@ -27,6 +27,7 @@
 	struct stat_info *stat;
 {
 	char readonly;
+	char rlbuf[256];
 
 	if (stat->flags & OF_READONLY)
 		readonly = 'r';
@@ -40,7 +41,9 @@
 		printf("d%c         %s\n", readonly, pathname);
 		return;
 	case OT_LINK:
-		printf("l%c         %s\n", readonly, pathname);
+		if (do_readlink_sancheck(pathname, rlbuf))
+			strcpy(rlbuf, "<invalid>");
+		printf("l%c         %s -> %s\n", readonly, pathname, rlbuf);
 		return;
 	default:
 		printf("?%c         %s\n", readonly, pathname);
--- a/rvinterf/etmsync/symlink.c	Sun Mar 02 04:48:33 2014 +0000
+++ b/rvinterf/etmsync/symlink.c	Sun Mar 02 05:40:05 2014 +0000
@@ -123,3 +123,19 @@
 	}
 	return(0);
 }
+
+do_readlink_sancheck(pathname, databuf)
+	char *pathname;
+	u_char *databuf;
+{
+	int rc, sz;
+
+	rc = do_readlink(pathname, databuf, &sz);
+	if (rc)
+		return(rc);
+	if (sz < 2 || databuf[sz-1]) {
+		printf("error: readlink on %s returned garbage\n", pathname);
+		return(ERROR_TARGET);
+	}
+	return(0);
+}