OSDN Git Service

* fhandler_disk_file.cc (fhandler_disk_file::link): Fix linking
authorcorinna <corinna>
Thu, 14 Aug 2008 15:00:47 +0000 (15:00 +0000)
committercorinna <corinna>
Thu, 14 Aug 2008 15:00:47 +0000 (15:00 +0000)
against symlinks.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_disk_file.cc

index e6850f6..769bae8 100644 (file)
@@ -1,5 +1,10 @@
 2008-08-14  Corinna Vinschen  <corinna@vinschen.de>
 
+       * fhandler_disk_file.cc (fhandler_disk_file::link): Fix linking
+       against symlinks.
+
+2008-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
        * external.cc (cygwin_internal): Call set_security_attribute with
        additional path_conv argument.
        * fhandler.cc (fhandler_base::open): Ditto.
index 5fc8230..5ec3e34 100644 (file)
@@ -1118,8 +1118,6 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
 int
 fhandler_disk_file::link (const char *newpath)
 {
-  extern bool allow_winsymlinks;
-
   path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes);
   if (newpc.error)
     {
@@ -1137,7 +1135,7 @@ fhandler_disk_file::link (const char *newpath)
   char new_buf[strlen (newpath) + 5];
   if (!newpc.error)
     {
-      if (allow_winsymlinks && pc.is_lnk_special ())
+      if (pc.is_lnk_special ())
        {
          /* Shortcut hack. */
          stpcpy (stpcpy (new_buf, newpath), ".lnk");
@@ -1182,18 +1180,16 @@ fhandler_disk_file::link (const char *newpath)
       if (status == STATUS_INVALID_DEVICE_REQUEST)
        {
          /* FS doesn't support hard links.  Try to copy file. */
-         WCHAR pcw[pc.get_nt_native_path ()->Length + 1];
-         WCHAR newpcw[newpc.get_nt_native_path ()->Length + 1];
+         WCHAR pcw[(pc.get_nt_native_path ()->Length / sizeof (WCHAR)) + 1];
+         WCHAR newpcw[(newpc.get_nt_native_path ()->Length / sizeof (WCHAR))
+                      + 1];
          if (!CopyFileW (pc.get_wide_win32_path (pcw),
                          newpc.get_wide_win32_path (newpcw), TRUE))
            {
              __seterrno ();
              return -1;
            }
-         if (!allow_winsymlinks && pc.is_lnk_special ())
-           SetFileAttributesW (newpcw, pc.file_attributes ()
-                                       | FILE_ATTRIBUTE_SYSTEM
-                                       | FILE_ATTRIBUTE_READONLY);
+         SetFileAttributesW (newpcw, pc.file_attributes ());
        }
       else
        {