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

[PATCH 1/2] packfile: remove redundant fcntl F_GETFD/F_SETFD

From
EWEric Wong <e@80x24.org>
Date
Dec 26, 2019, 10:42 UTC
Message-ID
<20191226104220.27325-2-e@80x24.org>
In-Reply-To
<20191226104220.27325-1-e@80x24.org>

git_open sets close-on-exec since cd66ada06588f797 ("sha1_file: open window into packfiles with O_CLOEXEC"). There's no reason to keep using fcntl to set the close-on-exec flag, anymore.

Signed-off-by: Eric Wong <e@80x24.org>
---
 packfile.c | 11 -----------
 1 file changed, 11 deletions(-)
diff --git a/packfile.c b/packfile.c
index f0dc63e92f..1821cb7a3d 100644
--- a/packfile.c
+++ b/packfile.c
@@ -510,7 +510,6 @@ static int open_packed_git_1(struct packed_git *p)
 	struct pack_header hdr;
 	unsigned char hash[GIT_MAX_RAWSZ];
 	unsigned char *idx_hash;
-	long fd_flag;
 	ssize_t read_result;
 	const unsigned hashsz = the_hash_algo->rawsz;
 
@@ -554,16 +553,6 @@ static int open_packed_git_1(struct packed_git *p)
 	} else if (p->pack_size != st.st_size)
 		return error("packfile %s size changed", p->pack_name);
 
-	/* We leave these file descriptors open with sliding mmap;
-	 * there is no point keeping them open across exec(), though.
-	 */
-	fd_flag = fcntl(p->pack_fd, F_GETFD, 0);
-	if (fd_flag < 0)
-		return error("cannot determine file descriptor flags");
-	fd_flag |= FD_CLOEXEC;
-	if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1)
-		return error("cannot set FD_CLOEXEC");
-
 	/* Verify we recognize this pack file format. */
 	read_result = read_in_full(p->pack_fd, &hdr, sizeof(hdr));
 	if (read_result < 0)
Previous: Eric WongNext: Eric Wong
Message 2 of 6 in “packfile: small syscall reductions”
  1. 0/2 packfile: small syscall reductionsEric Wong, Dec 26, 2019
  2. 1/2 packfile: remove redundant fcntl F_GETFD/F_SETFDEric Wong, Dec 26, 2019
  3. 2/2 packfile: replace lseek+read with preadEric Wong, Dec 26, 2019
  4. Junio C HamanoDec 26, 2019
  5. Junio C HamanoDec 26, 2019
  6. Eric WongDec 26, 2019

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.