delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/22/08:08:21

Message-ID: <39A26379.35FF3497@softhome.net>
Date: Tue, 22 Aug 2000 13:26:49 +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 chmod()
Reply-To: djgpp-workers AT delorie DOT com

Is there anything else I could say?

Comments?

Laurynas

Index: djgpp/src/libc/posix/sys/stat/chmod.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/chmod.c,v
retrieving revision 1.1
diff -u -p -r1.1 chmod.c
--- chmod.c	1995/08/28 03:42:36	1.1
+++ chmod.c	2000/08/22 10:02:43
@@ -1,14 +1,23 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <libc/symlink.h>
 #include <sys/stat.h>
 #include <io.h>
+#include <stdio.h>
  
 int
 chmod(const char *filename, int pmode)
 {
   int dmode;
-  unsigned attr = _chmod(filename, 0, 0);
- 
+  char real_name[FILENAME_MAX];
+  int attr;
+
+  if (!__solve_symlinks(filename, real_name))
+     return -1;
+  
+  attr = _chmod(real_name, 0, 0);
+
   if (attr == -1)
     return -1;
  
@@ -19,7 +28,7 @@ chmod(const char *filename, int pmode)
  
   /* Must clear the directory and volume bits, otherwise 214301 fails.
      Unused bits left alone (some network redirectors use them).  */
-  if (_chmod(filename, 1, (attr & 0xffe6) | dmode) == -1)
+  if (_chmod(real_name, 1, (attr & 0xffe6) | dmode) == -1)
     return -1;
   return 0;
 }

- Raw text -


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