This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Today's long path name patch


Corinna Vinschen wrote:

> as I threatened the community with today, I've now checked in my patch
> which finally enables long path names in Cygwin.  I tested it on XP,
> 2008, and 2008 x64.  What this patch does:

Hmm.  I was playing with this code using the attached testcase.  It
simply tries to open(O_RDWR | O_CREAT | O_TRUNC) a filename that
contains 256 chars, nothing else.  The call to open fails with errno =
ENOENT.  The strace from fhandler_base::open and on looks like this:

   42   40698 [main] tc 3304 fhandler_base::open:
(\??\C:\cygwin\home\brian\testcases\long-file-name-create\256charfilename[+241
underscores], 0x100602)
  121   40819 [main] tc 3304 alloc_sd: uid 1003, gid 513, attribute 9
   38   40857 [main] tc 3304 cygsid::debug_print: alloc_sd: owner SID =
S-1-5-21-790525478-117609710-839522115-1003 (+)
   30   40887 [main] tc 3304 cygsid::debug_print: alloc_sd: group SID =
S-1-5-21-790525478-117609710-839522115-513 (+)
   51   40938 [main] tc 3304 alloc_sd: ACL-Size: 136
   71   41009 [main] tc 3304 alloc_sd: Created SD-Size: 212
   59   41068 [main] tc 3304 seterrno_from_win_error:
/usr/src/sourceware/winsup/cygwin/fhandler.cc:599 windows error 123
   33   41101 [main] tc 3304 geterrno_from_win_error: windows error 123
== errno 2
   26   41127 [main] tc 3304 __set_errno: void
seterrno_from_win_error(const char*, int, DWORD):316 val 2
   25   41152 [main] tc 3304 fhandler_base::open: C0000033 =
NtCreateFile (0x0, C0100000,
\??\C:\cygwin\home\brian\testcases\long-file-name-create\256charfilename[+241
underscores], io, NULL, 81, 7, 5, 4420, NULL, 0)
   72   41224 [main] tc 3304 fhandler_base::open: 0 =
fhandler_base::open (r^B~^B<E8><D5>"a
^A, 0x100602)
  134   41358 [main] tc 3304 fhandler_base::open_fs: 0 =
fhandler_disk_file::open
(\??\C:\cygwin\home\brian\testcases\long-file-name-create\256charfilename[+241
underscores], 0x602)
   77   41435 [main] tc 3304 open: -1 = open (256charfilename[+241
underscores], 0x602)

So NtCreateFile is returning STATUS_OBJECT_NAME_INVALID.  Did I
misunderstand what's supported, is there a limitation on each
path-component or just the total length of the absolute path?  I checked
the attr.ObjectName and it appears to be correctly set.

> - Plain stupid bug fixing.

I did notice two cases where %s was accidently used with PUNICODE_STRING
in a foobar_printf(), see attached patch.

Brian
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

#define FILENAME "256charfilename_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________"
#define WRITEWHAT "hello"

int main (int argc, char **argv)
{
  int fd = open(FILENAME, O_RDWR | O_CREAT | O_TRUNC);
  
  if (fd < 0)
    {
      perror ("open");
      return (1);
    }
    
  if (write (fd, WRITEWHAT, strlen(WRITEWHAT)) < 0)
    {
      perror ("write");
      return (1);
    }
  
  if (close(fd) < 0)
    {
      perror ("close");
      return (1);
    }
  return (0);
}

2008-03-07  Brian Dessent  <brian@dessent.net>

	* fhandler.cc (fhandler_base::open): Use %S for PUNICODE_STRING.
	* syscalls.cc (setmode): Ditto.


Index: fhandler.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v
retrieving revision 1.314
diff -u -p -r1.314 fhandler.cc
--- fhandler.cc	6 Mar 2008 10:16:07 -0000	1.314
+++ fhandler.cc	8 Mar 2008 00:57:24 -0000
@@ -612,7 +612,7 @@ done:
 		status, x, access, pc.get_nt_native_path (), file_attributes,
 		shared, create_disposition, create_options);
 
-  syscall_printf ("%d = fhandler_base::open (%s, %p)",
+  syscall_printf ("%d = fhandler_base::open (%S, %p)",
 		  res, pc.get_nt_native_path (), flags);
   return res;
 }
Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.473
diff -u -p -r1.473 syscalls.cc
--- syscalls.cc	7 Mar 2008 11:24:51 -0000	1.473
+++ syscalls.cc	8 Mar 2008 00:57:24 -0000
@@ -2053,7 +2053,7 @@ setmode (int fd, int mode)
   else
     cfd->set_flags ((cfd->get_flags () & ~(O_TEXT | O_BINARY)) | mode);
 
-  syscall_printf ("(%d<%s>, %p) returning %s", fd,
+  syscall_printf ("(%d<%S>, %p) returning %s", fd,
 		  cfd->pc.get_nt_native_path (), mode,
 		  res & O_TEXT ? "text" : "binary");
   return res;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]