recursion bug: don't follow symlinks
committer: Markus Bröker <mbroeker@largo.homelinux.org>
--- a/lsflib/include/lsf/lsf.h
+++ b/lsflib/include/lsf/lsf.h
@@ -27,9 +27,12 @@
/* isDir returns true, if a fd points to a dir */
int isDir (char *);
-/* isDir returns true, if a fd points to a file */
+/* isFile returns true, if a fd points to a file */
int isFile (char *);
+/* isLink returns true, if a fd points to a link */
+int isLink(char *);
+
/* getdir prints a dir hierarchy */
void getdir (char *, int);
--- a/lsflib/src/getdir.c
+++ b/lsflib/src/getdir.c
@@ -17,7 +17,7 @@
{
struct stat buf;
- if (!stat (filename, &buf))
+ if (!lstat (filename, &buf))
return (S_ISDIR (buf.st_mode));
return 0;
@@ -27,12 +27,22 @@
{
struct stat buf;
- if (!stat (filename, &buf))
+ if (!lstat (filename, &buf))
return (S_ISREG (buf.st_mode));
return 0;
}
+int isLink (char *filename)
+{
+ struct stat buf;
+
+ if (!lstat (filename, &buf))
+ return (S_ISLNK (buf.st_mode));
+
+ return 0;
+}
+
void getdir (char *root, int recursive)
{
struct dirent *entry;
--- a/lsflib/src/md5recursive.c
+++ b/lsflib/src/md5recursive.c
@@ -38,6 +38,7 @@
if (isDir (list)) {
fprintf (stderr, "Directory: %s\n", list);
+
if (recursive) {
md5recursive (list, recursive);
}