From 4559bbac7e1dee27f06986ee160c4bbbf514672a Mon Sep 17 00:00:00 2001 From: Ian Darwin Date: Sun, 28 Feb 1988 10:50:50 +0000 Subject: [PATCH] Read symbolic links using readlink(2) - code from Peter Collinson, Univ of Kent, Canterbury, UK. --- src/fsmagic.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/fsmagic.c b/src/fsmagic.c index 6ca7d9ce..88afc4a6 100644 --- a/src/fsmagic.c +++ b/src/fsmagic.c @@ -42,7 +42,7 @@ #ifndef lint static char *moduleid = - "@(#)$Header: /home/glen/git/file/cvs/file/src/fsmagic.c,v 1.7 1987/09/23 21:14:28 ian Exp $"; + "@(#)$Header: /home/glen/git/file/cvs/file/src/fsmagic.c,v 1.8 1988/02/28 10:50:50 ian Exp $"; #endif /* lint */ extern char *progname; @@ -94,6 +94,7 @@ char *fn; #ifdef S_IFLNK case S_IFLNK: ckfputs("symbolic link", stdout); + readsymbolic(fn); return 1; #endif #ifdef S_IFSOCK @@ -117,3 +118,17 @@ char *fn; return 0; } +#ifdef S_IFLNK +readsymbolic(fn) +char *fn; +{ char buf[BUFSIZ+4]; + register int cc; + + strcpy(buf, " to "); + cc = readlink(fn, &buf[4], BUFSIZ-1); + if (cc <= 0) + return; + buf[cc+4] = '\0'; + ckfputs(buf, stdout); +} +#endif -- 2.40.0