From 592fa176fc13e325b4574b2aac8d4acb1a1f8dd3 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sun, 21 May 2023 20:37:28 +1100
Subject: [PATCH] hard code the location of the resolve symlink

---
 src/lib66/state/state_write.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/lib66/state/state_write.c b/src/lib66/state/state_write.c
index 30f37be3..894946c5 100644
--- a/src/lib66/state/state_write.c
+++ b/src/lib66/state/state_write.c
@@ -29,27 +29,22 @@ int state_write(ss_state_t *sta, resolve_service_t *res)
 {
     log_flow() ;
 
-    size_t len = strlen(res->sa.s + res->path.servicedir) ;
-
-    char target[len + SS_STATE_LEN + 1 + SS_STATUS_LEN + 1] ;
+    size_t len = strlen(res->sa.s + res->path.home) + SS_SYSTEM_LEN + SS_SERVICE_LEN + SS_SVC_LEN + 1 + strlen(res->sa.s + res->name) ;
+    char pack[STATE_STATE_SIZE] ;
+    char dir[len + SS_STATE_LEN + 1] ;
 
-    auto_strings(target, res->sa.s + res->path.servicedir, SS_STATE) ;
+    auto_strings(dir, res->sa.s + res->path.home, SS_SYSTEM, SS_SERVICE, SS_SVC, "/", res->sa.s + res->name, SS_STATE) ;
 
-    if (access(target, F_OK) < 0) {
-        log_trace("create directory: ", target) ;
-        if (!dir_create_parent(target, 0755))
-            log_warnusys_return(LOG_EXIT_ZERO, "create directory: ", target) ;
+    if (access(dir, F_OK) < 0) {
+        log_trace("create directory: ", dir) ;
+        if (!dir_create_parent(dir, 0755))
+            log_warnusys_return(LOG_EXIT_ZERO, "create directory: ", dir) ;
     }
 
-    auto_strings(target + len + SS_STATE_LEN, "/", SS_STATUS) ;
-
-    char pack[STATE_STATE_SIZE] ;
-
     state_pack(pack, sta) ;
 
-    log_trace("write status file at: ", target) ;
-
-    if (!openwritenclose_unsafe(target, pack, STATE_STATE_SIZE))
+    log_trace("write status file at: ", res->sa.s + res->path.status) ;
+    if (!openwritenclose_unsafe(res->sa.s + res->path.status, pack, STATE_STATE_SIZE))
         return 0 ;
 
     return 1 ;
-- 
GitLab