git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] cygwin: set write permission before unlink

From
RTRei Thiessen <rei.thiessen@gmail.com>
Date
Jun 29, 2011, 07:18 UTC
Message-ID
<1309331898-32247-1-git-send-email-rei.thiessen@gmail.com>

On Cygwin 1.7, if filesystems are mounted with the "noacl" option, files without write permission (in particular, the temp files created in write_loose_object()) have their "read-only" flags set in NTFS. "read-only" files can't be unlinked.

For Cygwin, set write permissions on files that are about to be unlinked.
Signed-off-by: Rei Thiessen <rei.thiessen@gmail.com>
---
 compat/cygwin.c |    7 +++++++
 compat/cygwin.h |    3 +++
 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/compat/cygwin.c b/compat/cygwin.c
index b4a51b9..f40ee6d 100644
--- a/compat/cygwin.c
+++ b/compat/cygwin.c
@@ -141,3 +141,10 @@ static int cygwin_lstat_stub(const char *file_name, struct stat *buf)
 stat_fn_t cygwin_stat_fn = cygwin_stat_stub;
 stat_fn_t cygwin_lstat_fn = cygwin_lstat_stub;
 
+#undef unlink
+int cygwin_unlink(const char *pathname)
+{
+	/* "read-only" files can't be unlinked */
+	chmod(pathname, 0666);
+	return unlink(pathname);
+}
diff --git a/compat/cygwin.h b/compat/cygwin.h
index a3229f5..aa2ba3e 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
 
 #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
 #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
+
+int cygwin_unlink(const char *pathname);
+#define unlink cygwin_unlink
-- 
1.7.4.1
Next: Christof Krüger
Message 1 of 3 in “cygwin: set write permission before unlink”
  1. cygwin: set write permission before unlinkRei Thiessen, Jun 29, 2011
  2. Christof KrügerJun 29, 2011
  3. Rei ThiessenJun 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.