-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MPR#6120: Windows symlinks and corrected stat implementation #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
otherlibs/unix/unix.mli
Outdated
| operation. Administrators will always need to be running elevated (or with | ||
| UAC disabled) and by default normal user accounts need to be granted the | ||
| SeCreateSymbolicLinkPrivilege via Local Security Policy (secpol.msc) or via | ||
| Active Directory. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should add that {!has_symlink} can be used to check that the process is able to create symbolic links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
otherlibs/win32unix/readlink.c
Outdated
| /* */ | ||
| /* OCaml */ | ||
| /* */ | ||
| /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to set the correct author here. Is this mostly copied from Xavier's code, or is it substantially new code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK - no, all the code's mine, beyond lifting the GC boilerplate macros from the UNIX version (which is how the header remained). I'll push amendments in a few mins...
|
There is a lot of new code in this PR. Have you signed the CLA already? See #342 (comment) for the procedure. I'm settting the milestone to 4.04 because changes in |
|
Ok, I'll get a CLA pinged to Xavier (will probably be tomorrow as I won't be near a scanner for today). I thought from the comment thread in Mantis that this was approved for 4.03 and just awaiting the fstat change (the patch has been in Mantis for a while) - is it definitely too late for 4.03? It will be useful as it enables support for symlinks in ocamlbuild which eases building for certain libraries in OPAM (but the functionality can of course be back-ported there, it needs be) |
I'm not sure about the "likely". Except taking the |
|
FWIW I would also very like to have this in 4.03. |
|
I'm sorry, I forgot to look at the Mantis discussion before I set the milestone. Since we have several Windows stakeholders pushing for inclusion, let's take the risk. |
|
I'll approve as soon as we have the CLA and you fix the author (and date) in both file headers. |
|
OK - given that I've almost totally rewritten stat.c, should the header in that be updated too? |
|
@damiendoligez Correct me if I'm wrong, but people contributing code through a CLA should not only update the code attribution but also the copyright holder. Is that right? |
|
@dra27 Yes, you'll have to update the header in |
|
@dra27 This is one of the last 3 things before I branch 4.03, so it would be good if you fixed the headers ASAP. We'll be fine if we have the CLA by Friday or even next Monday. |
|
Sorry - had to pause for a few hours to do the day job! Should manage this all later this evening... |
The mingw64 headers create an inconsistency between the MSVC and MinGW ports - mingw64 automatically defines _USE_32BIT_TIME_T on 32-bit Windows, where the Microsoft CRT docs state that should be a user define. The effect is that the mingw64 32-bit port suffers from the year 2038 bug, where the MSVC 32-bit port does not. Given that OCaml uses a double for the time fields anyway and OCaml requires sufficiently modern compilers to be able to rely on a working _stat64 (64-bit time_t and 64-bit st_size), switch from the *i64 to the *64 variants.
Unix.symlink requires CreateSymbolicLink which prevents programs from running on Windows XP. Dynamically link the function instead.
|
Trunk seems to be broken for Windows again, not sure how technically correct this is (given that Windows has diff --git a/Makefile.nt b/Makefile.nt
index cda7459..02d8847 100644
--- a/Makefile.nt
+++ b/Makefile.nt
@@ -295,6 +295,14 @@ ocamlc: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
partialclean::
rm -f ocamlc
+# The middle end (whose .cma library is currently only used for linking
+# the "objinfo" program, since we cannot depend on the whole native code
+# compiler for "make world" and the list of dependencies for
+# asmcomp/export_info.cmo is long).
+
+compilerlibs/ocamlmiddleend.cma: $(MIDDLE_END)
+ $(CAMLC) -a -o $@ $(MIDDLE_END)
+
# The native-code compiler
compilerlibs/ocamloptcomp.cma: $(MIDDLE_END) $(ASMCOMP)
@@ -606,7 +614,7 @@ clean::
# Tools
ocamltools: ocamlc ocamlyacc ocamllex asmcomp/cmx_format.cmi \
- asmcomp/printclambda.cmo
+ asmcomp/printclambda.cmo compilerlibs/ocamlmiddleend.cma
cd tools ; $(MAKEREC) all
ocamltoolsopt: |
|
Headers fixed. The only other change, apart from a trunk-rebase, was to remove an obsolete branch of code the algorithm of which was taken from Microsoft's implementation of stat (their old implementation had somewhat weird semantics for UNC and drive roots - e.g. \server\share or C:\ but the new implementation with For ease of review of the copyright headers, here's the diff: diff --git a/otherlibs/win32unix/readlink.c b/otherlibs/win32unix/readlink.c
index ad080c5..1bb9347 100644
--- a/otherlibs/win32unix/readlink.c
+++ b/otherlibs/win32unix/readlink.c
@@ -2,12 +2,12 @@
/* */
/* OCaml */
/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
+/* David Allsopp, MetaStack Solutions Ltd. */
/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. All rights reserved. This file is distributed */
-/* under the terms of the GNU Library General Public License, with */
-/* the special exception on linking described in file ../../LICENSE. */
+/* Copyright 2015 MetaStack Solutions Ltd. All rights reserved. */
+/* This file is distributed under the terms of the GNU Library */
+/* General Public License, with the special exception on linking */
+/* described in file ../../LICENSE. */
/* */
/***********************************************************************/
diff --git a/otherlibs/win32unix/stat.c b/otherlibs/win32unix/stat.c
index 432cf21..ed854b8 100644
--- a/otherlibs/win32unix/stat.c
+++ b/otherlibs/win32unix/stat.c
@@ -2,12 +2,12 @@
/* */
/* OCaml */
/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
+/* David Allsopp, MetaStack Solutions Ltd. */
/* */
-/* Copyright 2002 Institut National de Recherche en Informatique et */
-/* en Automatique. All rights reserved. This file is distributed */
-/* under the terms of the GNU Library General Public License, with */
-/* the special exception on linking described in file ../../LICENSE. */
+/* Copyright 2015 MetaStack Solutions Ltd. All rights reserved. */
+/* This file is distributed under the terms of the GNU Library */
+/* General Public License, with the special exception on linking */
+/* described in file ../../LICENSE. */
/* */
/***********************************************************************/
diff --git a/otherlibs/win32unix/symlink.c b/otherlibs/win32unix/symlink.c
index 37c6810..b684f34 100644
--- a/otherlibs/win32unix/symlink.c
+++ b/otherlibs/win32unix/symlink.c
@@ -2,12 +2,12 @@
/* */
/* OCaml */
/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
+/* David Allsopp, MetaStack Solutions Ltd. */
/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. All rights reserved. This file is distributed */
-/* under the terms of the GNU Library General Public License, with */
-/* the special exception on linking described in file ../../LICENSE. */
+/* Copyright 2015 MetaStack Solutions Ltd. All rights reserved. */
+/* This file is distributed under the terms of the GNU Library */
+/* General Public License, with the special exception on linking */
+/* described in file ../../LICENSE. */
/* */
/***********************************************************************/ |
|
Was anything taken from the Microsoft CRT? That code is proprietary, and nothing based on it can be used in OCaml. |
|
No - the old code in question was mine which allowed an earlier iteration of my |
MPR#6120: Windows symlinks and corrected stat implementation
|
Thanks a lot! |
|
I noticed while working on upgrading Batteries for 4.03 that there are some glitches in the unix.mli documentation; for example, |
Fixed in 4.03 branch (525799b). |
|
Yes, I know it's late. I'm not sure, if anyone will read this, but. ocaml/otherlibs/win32unix/symlink.c Line 50 in d86aa4c
ocaml/otherlibs/win32unix/stat.c Line 304 in d86aa4c
ocaml/otherlibs/win32unix/stat.c Line 156 in d86aa4c
ocaml/otherlibs/win32unix/stat.c Line 210 in d86aa4c
|
|
I believe you are right, and this should be fixed. Would you like to propose a patch? |
|
Gah - good spot. In all those cases, there's no choice but duplicate the string, I guess. Is |
|
@dra27: between enter_blocking_section/leave_blocking_section, both context switches and signal handling can take place, so you should assume that a GC can occur. Copying the Caml string is indeed necessary. The run-time cost of the copy is negligible compared with the cost of the system call. For |
|
I've opened a pair of Mantis issues to track these bugs: |
|
@xavierleroy - thanks for the confirmation! |
Move from travis to Github Actions
See also the discussion in Mantis
Implements
Unix.readlinkandUnix.symlinkfor Windows. Windows symbolic links are a little, both in their implementation and availability - the weirdness of both is documented in unix.mli both inUnix.symlinkand the newUnix.has_symlinkfunction.Microsoft's implementation of
statis, politely put, flaky and there is no implementation oflstat. The stat functions are therefore completely re-implemented - though the algorithm for the Microsoft implementation is maintained in various places (e.g. setting the execute bit). The new implementation populatesst_devusing the device's serial number rather than a simulated value and also populatesst_ino(critical for ocamlbuild to be able to use the new symbolic link support)