From 926d54732abf235cd099e496ec4bc98edffb1fbf Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Tue, 5 Mar 2024 02:35:24 +0000
Subject: archiver api: record the associated path upon openat() related
 errors.x

---
 src/arbits/slbt_archive_dlsyms.c  | 2 +-
 src/arbits/slbt_archive_mapfile.c | 2 +-
 src/arbits/slbt_archive_store.c   | 6 +++---
 src/arbits/slbt_archive_symfile.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

(limited to 'src/arbits')

diff --git a/src/arbits/slbt_archive_dlsyms.c b/src/arbits/slbt_archive_dlsyms.c
index 10201b4..6cacccd 100644
--- a/src/arbits/slbt_archive_dlsyms.c
+++ b/src/arbits/slbt_archive_dlsyms.c
@@ -359,7 +359,7 @@ static int slbt_ar_create_dlsyms_impl(
 				fdctx.fdcwd,path,
 				O_WRONLY|O_CREAT|O_TRUNC,
 				mode)) < 0)
-			return SLBT_SYSTEM_ERROR(dctx,0);
+			return SLBT_SYSTEM_ERROR(dctx,path);
 	} else {
 		fdout = fdctx.fdout;
 	}
diff --git a/src/arbits/slbt_archive_mapfile.c b/src/arbits/slbt_archive_mapfile.c
index 07d947d..27d2b45 100644
--- a/src/arbits/slbt_archive_mapfile.c
+++ b/src/arbits/slbt_archive_mapfile.c
@@ -120,7 +120,7 @@ static int slbt_ar_create_mapfile_impl(
 				fdctx.fdcwd,path,
 				O_WRONLY|O_CREAT|O_TRUNC,
 				mode)) < 0)
-			return SLBT_SYSTEM_ERROR(dctx,0);
+			return SLBT_SYSTEM_ERROR(dctx,path);
 	} else {
 		fdout = fdctx.fdout;
 	}
diff --git a/src/arbits/slbt_archive_store.c b/src/arbits/slbt_archive_store.c
index cbf2704..293643a 100644
--- a/src/arbits/slbt_archive_store.c
+++ b/src/arbits/slbt_archive_store.c
@@ -82,7 +82,7 @@ int slbt_ar_store_archive(
 
 		if (fstatat(fdat,buf,&st,0) < 0)
 			return SLBT_SYSTEM_ERROR(
-				dctx,0);
+				dctx,buf);
 	} else {
 		if (fstatat(fdat,".",&st,0) < 0)
 			return SLBT_SYSTEM_ERROR(
@@ -109,7 +109,7 @@ int slbt_ar_store_archive(
 			SLBT_ERR_FLOW_ERROR);
 
 	if ((fdtmp = openat(fdat,buf,O_WRONLY|O_CREAT|O_EXCL,mode)) < 0)
-		return SLBT_SYSTEM_ERROR(dctx,0);
+		return SLBT_SYSTEM_ERROR(dctx,buf);
 
 	/* set archive size */
 	if (ftruncate(fdtmp,arctx->map->map_size) < 0)
@@ -137,7 +137,7 @@ int slbt_ar_store_archive(
 	/* finalize (atomically) */
 	if (renameat(fdat,buf,fdat,path) < 0) {
 		unlinkat(fdat,buf,0);
-		return SLBT_SYSTEM_ERROR(dctx,0);
+		return SLBT_SYSTEM_ERROR(dctx,buf);
 	}
 
 	/* yay */
diff --git a/src/arbits/slbt_archive_symfile.c b/src/arbits/slbt_archive_symfile.c
index 498851f..b88791e 100644
--- a/src/arbits/slbt_archive_symfile.c
+++ b/src/arbits/slbt_archive_symfile.c
@@ -98,7 +98,7 @@ static int slbt_ar_create_symfile_impl(
 				fdctx.fdcwd,path,
 				O_WRONLY|O_CREAT|O_TRUNC,
 				mode)) < 0)
-			return SLBT_SYSTEM_ERROR(dctx,0);
+			return SLBT_SYSTEM_ERROR(dctx,path);
 	} else {
 		fdout = fdctx.fdout;
 	}
-- 
cgit v1.2.3