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

[PATCH 2/2] use make_absolute_path() in lock_file()

From
Bradford C Smith <bradford.carl.smith@gmail.com>
Date
Jul 27, 2007, 19:10 UTC
Message-ID
<1185563460165-git-send-email-bradford.carl.smith@gmail.com>
In-Reply-To
<11855634582686-git-send-email-bradford.carl.smith@gmail.com>
From: Bradford C. Smith <bradford.carl.smith@gmail.com>

Use make_absolute_path() to get fully resolved path name for creating the lock file.

Signed-off-by: Bradford C. Smith <bradford.carl.smith@gmail.com>
---
 lockfile.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/lockfile.c b/lockfile.c
index 9202472..57f850f 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -28,20 +28,10 @@ static void remove_lock_file_on_signal(int signo)
 static int lock_file(struct lock_file *lk, const char *path)
 {
 	int fd;
-	struct stat st;
 
-	if ((!lstat(path, &st)) && S_ISLNK(st.st_mode)) {
-		ssize_t sz;
-		static char target[PATH_MAX];
-		sz = readlink(path, target, sizeof(target));
-		if (sz < 0)
-			warning("Cannot readlink %s", path);
-		else if (target[0] != '/')
-			warning("Cannot lock target of relative symlink %s", path);
-		else
-			path = target;
-	}
-	sprintf(lk->filename, "%s.lock", path);
+	strcpy(lk->filename, path);
+	make_absolute_path(lk->filename);
+	strcat(lk->filename, ".lock");
 	fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
 	if (0 <= fd) {
 		if (!lock_file_list) {
-- 
1.5.3.rc3.9.g9ef91
Previous: Bradford C SmithNext: Johannes Schindelin
Message 3 of 4 in “another attempt at make_absolute_path()”
  1. 0/2 another attempt at make_absolute_path()Bradford C Smith, Jul 27, 2007
  2. 1/2 added file path helper routinesBradford C Smith, Jul 27, 2007
  3. 2/2 use make_absolute_path() in lock_file()Bradford C Smith, Jul 27, 2007
  4. Johannes SchindelinJul 27, 2007

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.