Loading...
emulated/lchmod.c Libc-1725.40.4 Libc-498
--- Libc/Libc-1725.40.4/emulated/lchmod.c
+++ Libc/Libc-498/emulated/lchmod.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -21,8 +21,6 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 
-// NOTE: This system call emulation should move to libsystem_kernel.dylib
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/attr.h>
@@ -32,9 +30,14 @@
 int
 lchmod(const char *path, mode_t mode)
 {
+	struct stat s;
 	struct attrlist a;
 	int m;
 
+	if(lstat(path, &s) < 0)
+		return -1;
+	if((s.st_mode & S_IFMT) != S_IFLNK)
+		return chmod(path, mode);
 	bzero(&a, sizeof(a));
 	a.bitmapcount = ATTR_BIT_MAP_COUNT;
 	a.commonattr = ATTR_CMN_ACCESSMASK;