Thread (5 messages) 5 messages, 2 authors, 2016-06-15

[PATCH] file_exists(): dangling symlinks do exist

flat view
DORMANTno replies

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:52
Subsystem: the rest · Maintainer: Linus Torvalds

This function is used to see if a path given by the user does exist
on the filesystem.  A symbolic link that does not point anywhere does
exist but running stat() on it would yield an error, and it incorrectly
said it does not exist.

Signed-off-by: Junio C Hamano <redacted>
---
 dir.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dir.c b/dir.c
index 01790ab..87e5dec 100644
--- a/dir.c
+++ b/dir.c
@@ -688,11 +688,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
 	return dir->nr;
 }
 
-int
-file_exists(const char *f)
+int file_exists(const char *f)
 {
-  struct stat sb;
-  return stat(f, &sb) == 0;
+	struct stat sb;
+	return lstat(f, &sb) == 0;
 }
 
 /*
-- 
1.5.3.5.1815.g9445b
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help