]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wrapper.c
t1415: set REFFILES for test specific to storage format
[thirdparty/git.git] / wrapper.c
index bcda41e3744c1f0a94b7717c67a7f85195088821..563ad590df1f2963767858c2d490a3893f34ab7f 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -678,3 +678,19 @@ int is_empty_or_missing_file(const char *filename)
 
        return !st.st_size;
 }
+
+int open_nofollow(const char *path, int flags)
+{
+#ifdef O_NOFOLLOW
+       return open(path, flags | O_NOFOLLOW);
+#else
+       struct stat st;
+       if (lstat(path, &st) < 0)
+               return -1;
+       if (S_ISLNK(st.st_mode)) {
+               errno = ELOOP;
+               return -1;
+       }
+       return open(path, flags);
+#endif
+}