[Patch]: st_size for symlinks

Pierre A. Humblet pierre@phumblet.no-ip.org
Wed Apr 14 02:19:00 GMT 2004


This patch sets st_size correctly for symlinks.

Pierre

2004-04-14  Pierre Humblet <pierre.humblet@ieee.org>

	* path.h (path_conv::set_symlink): Add argument.
	(path_conv::get_symlink_length): New method. 
	(path_conv::symlink_length): New member.
	* path.cc (path_conv::check): Pass symlen to set_symlink.
	* fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks
	set st_size from get_symlink_length.	
-------------- next part --------------
Index: path.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.h,v
retrieving revision 1.62
diff -u -p -r1.62 path.h
--- path.h	13 Apr 2004 09:04:22 -0000	1.62
+++ path.h	14 Apr 2004 01:09:13 -0000
@@ -162,7 +162,7 @@ class path_conv
   }

   void set_binary () {path_flags |= PATH_BINARY;}
-  void set_symlink () {path_flags |= PATH_SYMLINK;}
+  void set_symlink (DWORD n) {path_flags |= PATH_SYMLINK; symlink_length = n;}
   void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;}
   void set_isdisk () {path_flags |= PATH_ISDISK; dev.devn = FH_FS;}
   void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;}
@@ -215,7 +215,9 @@ class path_conv
   char *normalized_path;
   size_t normalized_path_size;
   void set_normalized_path (const char *) __attribute__ ((regparm (2)));
+  DWORD get_symlink_length () { return symlink_length; };
  private:
+  DWORD symlink_length;
   char path[CYG_MAX_PATH];
 };

Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.300
diff -u -p -r1.300 path.cc
--- path.cc	13 Apr 2004 20:36:58 -0000	1.300
+++ path.cc	14 Apr 2004 01:09:19 -0000
@@ -705,7 +705,7 @@ path_conv::check (const char *src, unsig
 		  saw_symlinks = 1;
 		  if (component == 0 && !need_directory && !(opt & PC_SYM_FOLLOW))
 		    {
-		      set_symlink (); // last component of path is a symlink.
+		      set_symlink (symlen); // last component of path is a symlink.
 		      if (opt & PC_SYM_CONTENTS)
 			{
 			  strcpy (path, sym.contents);
Index: fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.83
diff -u -p -r1.83 fhandler_disk_file.cc
--- fhandler_disk_file.cc	13 Apr 2004 20:36:58 -0000	1.83
+++ fhandler_disk_file.cc	14 Apr 2004 01:09:20 -0000
@@ -282,6 +282,7 @@ fhandler_base::fstat_helper (struct __st
     buf->st_mode = S_IFDIR;
   else if (pc.issymlink ())
     {
+      buf->st_size = pc.get_symlink_length ();
       /* symlinks are everything for everyone! */
       buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
       get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (),


More information about the Cygwin-patches mailing list