www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/21/16:27:55

Message-ID: <39A190F3.6DBCF24F@softhome.net>
Date: Mon, 21 Aug 2000 22:28:35 +0200
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.74 [en] (Win98; U)
X-Accept-Language: lt,en
MIME-Version: 1.0
To: DJGPP Workers <djgpp-workers AT delorie DOT com>
Subject: Patch: symlinks in ftw.c
Reply-To: djgpp-workers AT delorie DOT com

Yet Another One Patch For Symlink Support.

Any comments?

Laurynas

Index: ftw.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/dir/ftw.c,v
retrieving revision 1.1
diff -p -u -r1.1 ftw.c
--- ftw.c	1995/08/28 03:38:52	1.1
+++ ftw.c	2000/08/21 20:25:42
@@ -1,3 +1,4 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 /* ftw() for DJGPP.
  *
@@ -12,6 +13,7 @@
  */
 
 #include <libc/stubs.h>
+#include <libc/symlink.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -107,6 +109,7 @@ ftw(const char *dir, int (*func)(const c
 {
   int flag;
   unsigned char pathbuf[FILENAME_MAX];
+  unsigned char real_path[FILENAME_MAX];
   int dirattr;
   int len;
   int e = errno;
@@ -135,7 +138,18 @@ ftw(const char *dir, int (*func)(const c
 
   /* Fail for non-directories.  */
   errno = 0;
-  dirattr = _chmod(pathbuf, 0, 0);
+  /* __chmod() does not recognize symlinks,  */
+  /* so we give real name instead.          */
+  if (!__solve_symlinks(pathbuf, real_path))
+  {
+     /* The errno is set by __solve_symlinks() */
+     return -1;
+  }
+  /* Note that symlink-clean name is not used further: 
+   * functions that are called from here understand symlinks anyway.
+   */
+  
+  dirattr = _chmod(real_path, 0, 0);
   if (errno == ENOENT)
     return -1;
   else if ((dirattr & 0x10) != 0x10)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019