MCPcopy Index your code
hub / github.com/git/git / open_nofollow

Function open_nofollow

wrapper.c:750–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750int open_nofollow(const char *path, int flags)
751{
752#ifdef O_NOFOLLOW
753 int ret = open(path, flags | O_NOFOLLOW);
754 /*
755 * NetBSD sets errno to EFTYPE when path is a symlink. The only other
756 * time this errno occurs when O_REGULAR is used. Since we don't use
757 * it anywhere we can avoid an lstat here. FreeBSD does the same with
758 * EMLINK.
759 */
760# ifdef __NetBSD__
761# define SYMLINK_ERRNO EFTYPE
762# elif defined(__FreeBSD__)
763# define SYMLINK_ERRNO EMLINK
764# endif
765# if SYMLINK_ERRNO
766 if (ret < 0 && errno == SYMLINK_ERRNO) {
767 errno = ELOOP;
768 return -1;
769 }
770# undef SYMLINK_ERRNO
771# endif
772 return ret;
773#else
774 struct stat st;
775 if (lstat(path, &st) < 0)
776 return -1;
777 if (S_ISLNK(st.st_mode)) {
778 errno = ELOOP;
779 return -1;
780 }
781 return open(path, flags);
782#endif
783}
784
785int csprng_bytes(void *buf, size_t len, MAYBE_UNUSED unsigned flags)
786{

Callers 4

read_mailmap_fileFunction · 0.85
add_patternsFunction · 0.85
read_attr_from_fileFunction · 0.85
packed_fsckFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected