Update of /cvsroot/libsysio/libsysio/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2364/tests
Modified Files:
test_path.c
Log Message:
Kevin Pedretti wanted readlink(2). Here it is.
Index: test_path.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -b -B -p -r1.7 -r1.8
--- test_path.c 14 Feb 2004 19:43:00 -0000 1.7
+++ test_path.c 28 May 2004 11:51:53 -0000 1.8
@@ -149,6 +149,8 @@ statit(const char *path)
int err;
struct stat stbuf;
char t;
+ static char buf[4096];
+ ssize_t cc;
/*
* Get file attrs.
@@ -200,7 +202,17 @@ statit(const char *path)
/*
* Print path and type.
*/
- (void )printf("%s: %c\n", path, t);
+ if (S_ISLNK(stbuf.st_mode)) {
+ cc = readlink(path, buf, sizeof(buf));
+ if (cc < 0) {
+ perror(path);
+ return -1;
+ }
+ }
+ (void )printf("%s: %c", path, t);
+ if (S_ISLNK(stbuf.st_mode) && (size_t )cc < sizeof(buf))
+ (void )printf(" %.*s", cc, buf);
+ (void )putchar('\n');
return 0;
}
|