The wrapper does two things:
- Requests to open /dev/null are redirected to open the nul pseudo file.
- A request to open a file that currently exists as a directory on
Windows fails with EACCES; this is changed to EISDIR.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
compat/mingw.c | 20 ++++++++++++++++++++
git-compat-util.h | 7 +++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 0c87e43..faa6df3 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2,6 +2,26 @@
unsigned int _CRT_fmode = _O_BINARY;
+#undef open
+int mingw_open (const char *filename, int oflags, ...)
+{
+ va_list args;
+ unsigned mode;
+ va_start(args, oflags);
+ mode = va_arg(args, int);
+ va_end(args);
+
+ if (!strcmp(filename, "/dev/null"))
+ filename = "nul";
+ int fd = open(filename, oflags, mode);
+ if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
+ DWORD attrs = GetFileAttributes(filename);
+ if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
+ errno = EISDIR;
+ }
+ return fd;
+}
+
unsigned int sleep (unsigned int seconds)
{
Sleep(seconds*1000);
diff --git a/git-compat-util.h b/git-compat-util.h
index b1f3f92..672c074 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -577,6 +577,13 @@ struct passwd *getpwuid(int uid);
int setitimer(int type, struct itimerval *in, struct itimerval *out);
int sigaction(int sig, struct sigaction *in, struct sigaction *out);
+/*
+ * replacements of existing functions
+ */
+
+int mingw_open (const char *filename, int oflags, ...);
+#define open mingw_open
+
#endif /* __MINGW32__ */
#endif
--
1.5.4.1.126.ge5a7d
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Tomasz Kłoczko | Is it time for remove (crap) ALSA from kernel tree ? |
| Greg Kroah-Hartman | [PATCH 008/196] Chinese: add translation of volatile-considered-harmful.txt |
| David Miller | Slow DOWN, please!!! |
| Aubrey | O_DIRECT question |
git: | |
| Martin Langhoff | Re: pack operation is thrashing my server |
| Francis Moreau | emacs and git... |
| Mirko Stocker | Working with Git and CVS in a team. |
| Keith Packard | Re: parsecvs tool now creates git repositories |
| Chris Peterson | [PATCH] drivers/net: remove network drivers' last few uses of IRQF_SAMPLE_RANDOM |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| Karen Xie | [RFC][PATCH 1/1] cxgb3i: cxgb3 iSCSI initiator |
| Jeff Garzik | [git patches] net driver updates for .27 |
| Jonathan Thornburg | svnd questions (encrypting all of a partition or disk) |
| Richard Stallman | Real men don't attack straw men |
| Daniel Ouellet | identifying sparse files and get ride of them trick available? |
| Brandon Lee | DELL PERC 5iR slow performance |
| high memory | 3 hours ago | Linux kernel |
| semaphore access speed | 6 hours ago | Applications and Utilities |
| the kernel how to power off the machine | 7 hours ago | Linux kernel |
| Easter Eggs in windows XP | 10 hours ago | Windows |
| Shared swap partition | 11 hours ago | Linux general |
| Root password | 11 hours ago | Linux general |
| Where/when DNOTIFY is used? | 13 hours ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 15 hours ago | Linux kernel |
| Linux 2.6.24 and I/O schedulers | 16 hours ago | Linux kernel |
| USB Driver -- Interrupt Polling -- A Little Help Please | 21 hours ago | Linux general |
