More functions converted to use threaded file handling.
- lgs_file_rename_hfop(..)

diff --git a/osaf/services/saf/logsv/lgs/lgs.h 
b/osaf/services/saf/logsv/lgs/lgs.h
--- a/osaf/services/saf/logsv/lgs/lgs.h
+++ b/osaf/services/saf/logsv/lgs/lgs.h
@@ -117,7 +117,7 @@ extern uint32_t lgs_mds_msg_send(lgs_cb_
 
 extern void lgs_giveup_imm_applier(lgs_cb_t *cb);
 extern SaAisErrorT lgs_become_imm_applier(lgs_cb_t *cb);
-extern SaAisErrorT lgs_imm_activate_fop(lgs_cb_t *cb);
+extern SaAisErrorT lgs_imm_activate_hfop(lgs_cb_t *cb);
 extern void lgs_imm_impl_set(lgs_cb_t *cb);
 extern SaAisErrorT lgs_imm_init(lgs_cb_t *cb);
 extern const void *lgs_imm_logconf_get(lgs_logconfGet_t param, bool *noteflag);
diff --git a/osaf/services/saf/logsv/lgs/lgs_evt.c 
b/osaf/services/saf/logsv/lgs/lgs_evt.c
--- a/osaf/services/saf/logsv/lgs/lgs_evt.c
+++ b/osaf/services/saf/logsv/lgs/lgs_evt.c
@@ -155,7 +155,7 @@ int lgs_client_delete(uint32_t client_id
                lgs_stream_list_t *tmp_rec;
                log_stream_t *stream = 
log_stream_get_by_id_nof(cur_rec->stream_id);
                TRACE_4("client_id: %u, REMOVE stream id: %u", 
client->client_id, cur_rec->stream_id);
-               log_stream_close_efop(&stream);
+               log_stream_close_hfop(&stream);
                tmp_rec = cur_rec->next;
                free(cur_rec);
                cur_rec = tmp_rec;
@@ -895,7 +895,7 @@ static uint32_t proc_stream_open_msg(lgs
                app_stream_created = true;
        }
 
-       ais_rv = log_stream_open_efop(logStream);
+       ais_rv = log_stream_open_fh(logStream);
        if (ais_rv != SA_AIS_OK) {
                /* If stream object was created in context of this function
                 * but we have afile system problem, delete stream object.
@@ -916,7 +916,7 @@ static uint32_t proc_stream_open_msg(lgs
        /* Create an association between this client and the stream */
        rc = lgs_client_stream_add(open_sync_param->client_id, 
logStream->streamId);
        if (rc != 0) {
-               log_stream_close_efop(&logStream);
+               log_stream_close_hfop(&logStream);
                ais_rv = SA_AIS_ERR_TRY_AGAIN;
                goto snd_rsp;
        }
@@ -979,7 +979,7 @@ static uint32_t proc_stream_close_msg(lg
        }
 
        streamId = stream->streamId;
-       if (log_stream_close_efop(&stream) != 0) {
+       if (log_stream_close_hfop(&stream) != 0) {
                ais_rc = SA_AIS_ERR_TRY_AGAIN;
                goto snd_rsp;
        }
@@ -1062,7 +1062,7 @@ static uint32_t proc_write_log_async_msg
                goto done;
        }
 
-       if (log_stream_write_efop(stream, logOutputString, n) == -1) {
+       if (log_stream_write_hfop(stream, logOutputString, n) == -1) {
                error = SA_AIS_ERR_TRY_AGAIN;
                goto done;
        }
diff --git a/osaf/services/saf/logsv/lgs/lgs_file.c 
b/osaf/services/saf/logsv/lgs/lgs_file.c
--- a/osaf/services/saf/logsv/lgs/lgs_file.c
+++ b/osaf/services/saf/logsv/lgs/lgs_file.c
@@ -182,12 +182,16 @@ static void *file_hndl_thread(void *nopa
                                break;
                        case LGSF_WRITELOGREC:
                                TRACE("LLDTEST: %s - LGSF_WRITELOGREC 
received",__FUNCTION__);
-                               hndl_rc = write_log_record(inbuf, outbuf, 
max_outsize);
+                               hndl_rc = write_log_record_hdl(inbuf, outbuf, 
max_outsize);
                                break;
                        case LGSF_CREATECFGFILE:
                                TRACE("LLDTEST: %s - LGSF_CREATECFGFILE 
received",__FUNCTION__);
                                hndl_rc = create_config_file_hdl(inbuf, outbuf, 
max_outsize);
                                break;
+                       case LGSF_RENAME_FILE:
+                               TRACE("LLDTEST: %s - LGSF_RENAME_FILE 
received",__FUNCTION__);
+                               hndl_rc = rename_file_hdl(inbuf, outbuf, 
max_outsize);
+                               break;
                        default:
                                break;
                        }
@@ -262,8 +266,8 @@ static int start_file_thread(void)
                goto done;
        }
 
-       TRACE_LEAVE2("LLDTEST");
 done:
+       TRACE_LEAVE2("LLDTEST rc=%d",rc);
        return rc;
 }
 
@@ -274,10 +278,13 @@ uint32_t lgs_file_init(void)
 {
        uint32_t rc = NCSCC_RC_SUCCESS;
        
+       TRACE_ENTER2("LLDTEST");
+       
        if (start_file_thread() != 0) {
                rc = NCSCC_RC_FAILURE;
        }
        
+       TRACE_LEAVE2("LLDTEST rc=%d",rc);
        return rc;
 }
 
diff --git a/osaf/services/saf/logsv/lgs/lgs_file.h 
b/osaf/services/saf/logsv/lgs/lgs_file.h
--- a/osaf/services/saf/logsv/lgs/lgs_file.h
+++ b/osaf/services/saf/logsv/lgs/lgs_file.h
@@ -43,6 +43,7 @@ typedef enum {
        LGSF_MAKELOGDIR,
        LGSF_WRITELOGREC,
        LGSF_CREATECFGFILE,
+       LGSF_RENAME_FILE,
        LGSF_NOREQ
 }lgsf_treq_t;
 
diff --git a/osaf/services/saf/logsv/lgs/lgs_filehdl.c 
b/osaf/services/saf/logsv/lgs/lgs_filehdl.c
--- a/osaf/services/saf/logsv/lgs/lgs_filehdl.c
+++ b/osaf/services/saf/logsv/lgs/lgs_filehdl.c
@@ -56,13 +56,37 @@
  *****************************************************************************/
 
 /**
+ * Rename a file
+ * 
+ * @param indata[in] old_path[], new_path[]
+ * @param outdata[out] Not used
+ * @param max_outsize[in] Must be 0
+ * @return (-1) on error, errno is logged
+ */
+int rename_file_hdl(void *indata, void *outdata, size_t max_outsize)
+{
+       int rc = 0;
+       
+       TRACE_ENTER2("LLDTEST1");
+       size_t old_path_size = *((size_t *) indata);
+       char *old_path = (char *) indata + sizeof(size_t);
+       char *new_path = old_path + old_path_size;
+       
+       if ((rc = rename(old_path, new_path)) == -1)
+               LOG_NO("rename: FAILED - %s", strerror(errno));
+
+       TRACE_LEAVE2("LLDTEST1");
+       return rc;
+}
+
+/**
  * Create a configuration file.
  * Creates the file, write its content and close the file
  * 
- * @param indata[in]
+ * @param indata[in] ccfh_t, logFileFormat string, file_path string
  * @param outdata[out] Not used
  * @param max_outsize[in] Must be 0
- * @return (-1) on error
+ * @return (-1) on error, errno is logged
  */
 int create_config_file_hdl(void *indata, void *outdata, size_t max_outsize)
 {
@@ -132,7 +156,7 @@ done:
  * @param max_outsize[in] Must be 0
  * @return (-1) on error or number of written bytes
  */
-int write_log_record(void *indata, void *outdata, size_t max_outsize)
+int write_log_record_hdl(void *indata, void *outdata, size_t max_outsize)
 {
        int rc, bytes_written = 0;
        wlrh_t *params_in = (wlrh_t *) indata;
@@ -150,7 +174,8 @@ int write_log_record(void *indata, void 
                if (errno == EINTR)
                        goto retry;
 
-               LOG_ER("write FAILED: %s", strerror(errno));
+               LOG_ER("LLDTEST write FAILED: %s", strerror(errno));
+               TRACE("LLDTEST %s - fd = %d",__FUNCTION__,params_in->fd);
                goto done;
        } else {
                /* Handle partial writes */
diff --git a/osaf/services/saf/logsv/lgs/lgs_filehdl.h 
b/osaf/services/saf/logsv/lgs/lgs_filehdl.h
--- a/osaf/services/saf/logsv/lgs/lgs_filehdl.h
+++ b/osaf/services/saf/logsv/lgs/lgs_filehdl.h
@@ -25,7 +25,8 @@ extern "C" {
  * Defines for in and out parameters for each handler
  *****************************************************************************/
 
-/* fileopen_hdl
+/* 
+ * fileopen_hdl(..)
  * Inpar char str[]
  * No typedef needed
  * Ret code file descriptor or -1 if error
@@ -33,19 +34,22 @@ extern "C" {
  * No typedef needed
  */
 
-/* fileclose_hdl
+/* 
+ * fileclose_hdl(..)
  * Inpar int fd
  * No typedef needed
  * No out parameters
  */
 
-/* delete_file_hdl
+/* 
+ * delete_file_hdl(..)
  * Inpar char str[]
  * No typedef needed
  * No out parameters
  */
 
-/* make_log_dir_hdl
+/* 
+ * make_log_dir_hdl(..)
  * Ret code -1 if error
  * Out parameter is a string of max PATH_MAX
  * Parameter data_out_size must be set to PATH_MAX
@@ -55,7 +59,8 @@ typedef struct {
        char rel_path[PATH_MAX+1]; /* Path to create */
 }mld_in_t;
 
-/* get_number_of_log_files_hdl(..)
+/* 
+ * get_number_of_log_files_hdl(..)
  */
 typedef struct {
        /* File name prefix (name part before time stamps) */
@@ -74,7 +79,8 @@ typedef struct {
         * Parameter data_out_size must be set to PATH_MAX + NAME_MAX.
         */
 
-/* write_log_record_hdl(..)
+/* 
+ * write_log_record_hdl(..)
  * No out parameters
  */
 typedef struct {
@@ -82,12 +88,13 @@ typedef struct {
        size_t record_size; /* Size of logrecord including '\0' */
        SaUint32T fixedLogRecordSize;
 }wlrh_t;
-/* logrecord:
- * Is a string of varying length.
- * Shall be added to the indata buffer directly after the wlrh_t
- */
+       /* logrecord:
+        * Is a string of varying length.
+        * Shall be added to the indata buffer directly after the wlrh_t
+        */
 
-/* create_config_file_hdl(..)
+/* 
+ * create_config_file_hdl(..)
  * No out parameters
  */
 typedef struct {
@@ -100,14 +107,26 @@ typedef struct {
        /* File information */
        size_t file_path_size; /* Size of file_path incl. '\0' */
 }ccfh_t;
-/* char logFileFormat[]
- * char file_path[]
- * Strings of varying length that shall be added
- * to the indata buffer directly after the ccfh_t
+       /* char logFileFormat[]
+        * char file_path[]
+        * Strings of varying length that shall be added
+        * to the indata buffer directly after the ccfh_t
+        */
+
+/*
+ * rename_file_hdl(..)
+ * 
+ * Inpar:
+ * size_t oldpath_str_size
+ * char oldpath_str[], string of varying size
+ * char newpath_str[], string of varying size
+ * 
+ * No out parameters
  */
 
+int rename_file_hdl(void *indata, void *outdata, size_t max_outsize);
 int create_config_file_hdl(void *indata, void *outdata, size_t max_outsize);
-int write_log_record(void *indata, void *outdata, size_t max_outsize);
+int write_log_record_hdl(void *indata, void *outdata, size_t max_outsize);
 int make_log_dir_hdl(void *indata, void *outdata, size_t max_outsize);
 int fileopen_hdl(void *indata, void *outdata, size_t max_outsize);
 int fileclose_hdl(void *indata, void *outdata, size_t max_outsize);
diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c 
b/osaf/services/saf/logsv/lgs/lgs_imm.c
--- a/osaf/services/saf/logsv/lgs/lgs_imm.c
+++ b/osaf/services/saf/logsv/lgs/lgs_imm.c
@@ -790,7 +790,7 @@ static void logRootDirectory_set(const c
        while (stream != NULL) {
                TRACE("Handling file %s", stream->logFileCurrent);
                // TODO: restore/refactor log_stream_config_change back to 
original
-               if (log_stream_config_change_efop(!LGS_STREAM_CREATE_FILES, 
stream, stream->fileName) != 0) {
+               if (log_stream_config_change_hfop(!LGS_STREAM_CREATE_FILES, 
stream, stream->fileName) != 0) {
                        LOG_ER("Old log files could not be renamed and closed, 
root-dir: %s",
                                        lgs_cb->logsv_root_dir);
                }
@@ -802,7 +802,7 @@ static void logRootDirectory_set(const c
        /* Create new files at new path */
        stream = log_stream_getnext_by_name_nof(NULL);
        while (stream != NULL) {
-               if (lgs_create_config_file_ufop(stream) != 0) {
+               if (lgs_create_config_file_hfop(stream) != 0) {
                        LOG_ER("New config file could not be created for 
stream: %s",
                                        stream->name);
                }
@@ -980,7 +980,7 @@ static SaAisErrorT stream_create_and_con
        return rc;
 }
 
-static void stream_ccb_apply_create_fop(const CcbUtilOperationData_t *opdata)
+static void stream_ccb_apply_create_hfop(const CcbUtilOperationData_t *opdata)
 {
        SaAisErrorT rc;
        log_stream_t *stream;
@@ -988,7 +988,7 @@ static void stream_ccb_apply_create_fop(
        TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, 
opdata->objectName.value);
 
        if ((rc = stream_create_and_configure1_nof(opdata, &stream)) == 
SA_AIS_OK) {
-               if (log_stream_open_efop(stream) == SA_AIS_OK) {
+               if (log_stream_open_fh(stream) == SA_AIS_OK) {
                        ckpt_stream_open_close(stream, LGS_CKPT_OPEN_STREAM);
                } else {
                        ; // what?
@@ -1000,7 +1000,7 @@ static void stream_ccb_apply_create_fop(
        TRACE_LEAVE();
 }
 
-static void stream_ccb_apply_modify_fop(const CcbUtilOperationData_t *opdata)
+static void stream_ccb_apply_modify_hfop(const CcbUtilOperationData_t *opdata)
 {
        const SaImmAttrModificationT_2 *attrMod;
        int i = 0;
@@ -1065,7 +1065,7 @@ static void stream_ccb_apply_modify_fop(
 
        if (new_cfg_file_needed) {
                int rc;
-               if ((rc = 
log_stream_config_change_efop(LGS_STREAM_CREATE_FILES, stream, 
current_file_name))
+               if ((rc = 
log_stream_config_change_hfop(LGS_STREAM_CREATE_FILES, stream, 
current_file_name))
                                != 0) {
                        LOG_ER("log_stream_config_change failed: %d", rc);
                }
@@ -1087,7 +1087,7 @@ static void stream_ccb_apply_delete(cons
 
        /* Checkpoint to standby LOG server */
        ckpt_stream_open_close(stream, LGS_CKPT_CLOSE_STREAM);
-       log_stream_close_efop(&stream);
+       log_stream_close_hfop(&stream);
 }
 
 static void stream_ccb_apply(const CcbUtilOperationData_t *opdata)
@@ -1096,10 +1096,10 @@ static void stream_ccb_apply(const CcbUt
 
        switch (opdata->operationType) {
        case CCBUTIL_CREATE:
-               stream_ccb_apply_create_fop(opdata);
+               stream_ccb_apply_create_hfop(opdata);
                break;
        case CCBUTIL_MODIFY:
-               stream_ccb_apply_modify_fop(opdata);
+               stream_ccb_apply_modify_hfop(opdata);
                break;
        case CCBUTIL_DELETE:
                stream_ccb_apply_delete(opdata);
@@ -1796,7 +1796,7 @@ static void getConfigNames(char configNa
  * in the LOG control block. Initialize the LOG IMM-OI
  * interface. Become class implementer.
  */
-SaAisErrorT lgs_imm_activate_fop(lgs_cb_t *cb)
+SaAisErrorT lgs_imm_activate_hfop(lgs_cb_t *cb)
 {
        SaAisErrorT rc = SA_AIS_OK;
        log_stream_t *stream;
@@ -1852,7 +1852,7 @@ SaAisErrorT lgs_imm_activate_fop(lgs_cb_
        /* Open all streams */
        stream = log_stream_getnext_by_name_nof(NULL);
        while (stream != NULL) {
-               if (log_stream_open_efop(stream) != SA_AIS_OK)
+               if (log_stream_open_fh(stream) != SA_AIS_OK)
                        goto done;
 
                stream = log_stream_getnext_by_name_nof(stream->name);
diff --git a/osaf/services/saf/logsv/lgs/lgs_main.c 
b/osaf/services/saf/logsv/lgs/lgs_main.c
--- a/osaf/services/saf/logsv/lgs/lgs_main.c
+++ b/osaf/services/saf/logsv/lgs/lgs_main.c
@@ -307,7 +307,7 @@ static uint32_t log_initialize(void)
        }
 
        if (lgs_cb->ha_state == SA_AMF_HA_ACTIVE) {
-               if (lgs_imm_activate_fop(lgs_cb) != SA_AIS_OK) {
+               if (lgs_imm_activate_hfop(lgs_cb) != SA_AIS_OK) {
                        LOG_ER("lgs_imm_activate FAILED");
                        rc = NCSCC_RC_FAILURE;
                        goto done;
diff --git a/osaf/services/saf/logsv/lgs/lgs_mbcsv.c 
b/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
--- a/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
+++ b/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
@@ -738,6 +738,7 @@ static uint32_t ckpt_decode_async_update
        TRACE_ENTER();
 
        /* Decode the message header */
+       TRACE("LLDTEST: %s - Decode the message header START",__FUNCTION__);
        hdr = &ckpt_msg->header;
        rc = m_NCS_EDU_EXEC(&cb->edu_hdl, edp_ed_header_rec, 
&cbk_arg->info.decode.i_uba,
                            EDP_OP_TYPE_DEC, &hdr, &ederror);
@@ -746,6 +747,7 @@ static uint32_t ckpt_decode_async_update
                m_NCS_EDU_PRINT_ERROR_STRING(ederror);
                goto done;
        }
+       TRACE("LLDTEST: %s - Decode the message header DONE",__FUNCTION__);
 
        ederror = 0;
        TRACE_2("ckpt_rec_type: %d ", (int)hdr->ckpt_rec_type);
@@ -1130,7 +1132,7 @@ static uint32_t ckpt_proc_close_stream(l
 
        (void)lgs_client_stream_rmv(param->clientId, param->streamId);
 
-       if (log_stream_close_efop(&stream) != 0) {
+       if (log_stream_close_hfop(&stream) != 0) {
                /* Do not allow standby to get out of sync */
                lgs_exit("Client attributes differ", SA_AMF_COMPONENT_RESTART);
        }
diff --git a/osaf/services/saf/logsv/lgs/lgs_stream.c 
b/osaf/services/saf/logsv/lgs/lgs_stream.c
--- a/osaf/services/saf/logsv/lgs/lgs_stream.c
+++ b/osaf/services/saf/logsv/lgs/lgs_stream.c
@@ -633,7 +633,7 @@ int log_file_open_fh(log_stream_t *strea
        return fd;
 }
 
-SaAisErrorT log_stream_open_efop(log_stream_t *stream)
+SaAisErrorT log_stream_open_fh(log_stream_t *stream)
 {
        SaAisErrorT rc = SA_AIS_OK;
        int errno_save;
@@ -659,7 +659,7 @@ SaAisErrorT log_stream_open_efop(log_str
                        goto done;
                }
 
-               if (lgs_create_config_file_ufop(stream) != 0) {
+               if (lgs_create_config_file_hfop(stream) != 0) {
                        rc = SA_AIS_ERR_TRY_AGAIN;
                        goto done;
                }
@@ -684,7 +684,7 @@ SaAisErrorT log_stream_open_efop(log_str
                }
 
                /* be nice to those without a shared file system, see #1138 */
-               if (lgs_create_config_file_ufop(stream) != 0) {
+               if (lgs_create_config_file_hfop(stream) != 0) {
                        LOG_ER("%s: Creating config file failed", __FUNCTION__);
                        rc = SA_AIS_ERR_TRY_AGAIN;
                        goto done;
@@ -708,7 +708,7 @@ SaAisErrorT log_stream_open_efop(log_str
  * 
  * @return int
  */
-int log_stream_close_efop(log_stream_t **s)
+int log_stream_close_hfop(log_stream_t **s)
 {
        int rc = 0;
        log_stream_t *stream = *s;
@@ -729,11 +729,11 @@ int log_stream_close_efop(log_stream_t *
                                goto done;
                        }
 
-                       rc = lgs_file_rename_ufop(stream->pathName, 
stream->logFileCurrent, timeString, LGS_LOG_FILE_EXT);
+                       rc = lgs_file_rename_hfop(stream->pathName, 
stream->logFileCurrent, timeString, LGS_LOG_FILE_EXT);
                        if (rc == -1)
                                goto done;
 
-                       rc = lgs_file_rename_ufop(stream->pathName, 
stream->fileName, timeString, LGS_LOG_FILE_CONFIG_EXT);
+                       rc = lgs_file_rename_hfop(stream->pathName, 
stream->fileName, timeString, LGS_LOG_FILE_CONFIG_EXT);
                        if (rc == -1)
                                goto done;
                }
@@ -825,7 +825,7 @@ static int get_number_of_log_files_hfop(
  * 
  * @return int -1 on error, 0 otherwise
  */
-int log_stream_write_efop(log_stream_t *stream, const char *buf, size_t count)
+int log_stream_write_hfop(log_stream_t *stream, const char *buf, size_t count)
 {
        int rc = 0;
        lgsf_apipar_t apipar;
@@ -850,7 +850,7 @@ int log_stream_write_efop(log_stream_t *
                        goto done;
                }
                /* Creating config file on new ACTIVE */
-               if (lgs_create_config_file_ufop(stream) != 0) {
+               if (lgs_create_config_file_hfop(stream) != 0) {
                        TRACE("Creating config file failed");
                        rc = -1;
                        goto done;
@@ -864,6 +864,7 @@ int log_stream_write_efop(log_stream_t *
                TRACE("stream %s now opened", stream->name);
        }
 
+       TRACE("LLDTEST: %s - stream->fd = %d",__FUNCTION__,stream->fd);
        /* Write the log record
         */
        /* allocate memory for header + log record */
@@ -914,7 +915,7 @@ int log_stream_write_efop(log_stream_t *
                }
                stream->fd = -1;
 
-               rc = lgs_file_rename_ufop(stream->pathName, 
stream->logFileCurrent, current_time, LGS_LOG_FILE_EXT);
+               rc = lgs_file_rename_hfop(stream->pathName, 
stream->logFileCurrent, current_time, LGS_LOG_FILE_EXT);
                if (rc == -1)
                        goto done;
 
@@ -1100,7 +1101,7 @@ uint32_t log_stream_init_nof(void)
  * 
  * @return int
  */
-int log_stream_config_change_efop(bool create_files_f, log_stream_t *stream, 
const char *current_file_name)
+int log_stream_config_change_hfop(bool create_files_f, log_stream_t *stream, 
const char *current_file_name)
 {
        int rc;
        char *current_time;
@@ -1123,18 +1124,18 @@ int log_stream_config_change_efop(bool c
                        goto done;
                }
 
-               if ((rc = lgs_file_rename_ufop(stream->pathName, 
stream->logFileCurrent, current_time, LGS_LOG_FILE_EXT)) == -1) {
+               if ((rc = lgs_file_rename_hfop(stream->pathName, 
stream->logFileCurrent, current_time, LGS_LOG_FILE_EXT)) == -1) {
                        goto done;
                }
 
-               if ((rc = lgs_file_rename_ufop(stream->pathName, 
current_file_name, current_time, LGS_LOG_FILE_CONFIG_EXT)) == -1) {
+               if ((rc = lgs_file_rename_hfop(stream->pathName, 
current_file_name, current_time, LGS_LOG_FILE_CONFIG_EXT)) == -1) {
                        goto done;
                }
        }
 
        /* Creating the new config file */
        if (create_files_f == LGS_STREAM_CREATE_FILES) {
-               if ((rc = lgs_create_config_file_ufop(stream)) != 0)
+               if ((rc = lgs_create_config_file_hfop(stream)) != 0)
                        goto done;
 
                sprintf(stream->logFileCurrent, "%s_%s", stream->fileName, 
current_time);
diff --git a/osaf/services/saf/logsv/lgs/lgs_stream.h 
b/osaf/services/saf/logsv/lgs/lgs_stream.h
--- a/osaf/services/saf/logsv/lgs/lgs_stream.h
+++ b/osaf/services/saf/logsv/lgs/lgs_stream.h
@@ -74,15 +74,15 @@ extern log_stream_t *log_stream_new_nof(
 
 extern log_stream_t *log_stream_new_2_nof(SaNameT *name, int stream_id);
 
-extern SaAisErrorT log_stream_open_efop(log_stream_t *stream);
+extern SaAisErrorT log_stream_open_fh(log_stream_t *stream);
 
-extern int log_stream_close_efop(log_stream_t **stream);
+extern int log_stream_close_hfop(log_stream_t **stream);
 extern int log_stream_file_close_hf(log_stream_t *stream);
-extern int log_stream_write_efop(log_stream_t *stream, const char *buf, size_t 
count);
+extern int log_stream_write_hfop(log_stream_t *stream, const char *buf, size_t 
count);
 extern void log_stream_id_print(void);
 
 #define LGS_STREAM_CREATE_FILES true
-extern int log_stream_config_change_efop(bool create_files_f, log_stream_t 
*stream, const char *current_file_name);
+extern int log_stream_config_change_hfop(bool create_files_f, log_stream_t 
*stream, const char *current_file_name);
 extern int log_file_open_fh(log_stream_t *stream, int *errno_save);
 
 /* Accessor functions */
diff --git a/osaf/services/saf/logsv/lgs/lgs_util.c 
b/osaf/services/saf/logsv/lgs/lgs_util.c
--- a/osaf/services/saf/logsv/lgs/lgs_util.c
+++ b/osaf/services/saf/logsv/lgs/lgs_util.c
@@ -26,13 +26,6 @@
  * Examples can be found in file lgs_stream.c, e.g. function fileopen(...)
  */
 
-/* TODO LLDTEST:
- * Move all _fop to lgs_filehdl.c
- * Handle all _efop via file thread
- * Make sure that all functions used by _fop and _efop are thread safe. For
- * such functions, add info "Must be thread safe" in header (-ts function)
- */
-
 #include "lgs_util.h"
 #include <stdlib.h>
 #include <inttypes.h>
@@ -50,7 +43,6 @@
 #define LGS_CREATE_CLOSE_TIME_LEN 16
 #define START_YEAR 1900
 
-#if 0
 /**
  * Create config file according to spec.
  * @param abspath
@@ -58,91 +50,7 @@
  * 
  * @return int
  */
-int lgs_create_config_file_ufop(log_stream_t *stream)
-{
-       int rc, n;
-       char pathname[PATH_MAX + NAME_MAX];
-       FILE *filp;
-
-       TRACE_ENTER();
-
-       /* check the existence of logsv_root_dir/pathName, create the path if 
it doesn't */
-       snprintf(pathname, PATH_MAX, "%s/%s", lgs_cb->logsv_root_dir, 
stream->pathName);
-       struct stat statbuf;
-       if (lgs_relative_path_check_ts(pathname) || lstat(pathname, &statbuf) 
!= 0) {
-               if (lgs_make_dir_hfop(stream->pathName) != 0) {
-                       LOG_NO("Create directory '%s/%s' failed", 
lgs_cb->logsv_root_dir, stream->pathName);
-                       rc = -1;
-                       goto done;
-               }
-       }
-       /* create absolute path for config file */
-       n = snprintf(&pathname[strlen(pathname)], PATH_MAX, "/%s.cfg", 
stream->fileName);
-
-       /* Check if path got truncated */
-       if (n == sizeof(pathname)) {
-               LOG_ER("Path too long");
-               rc = -1;
-               goto done;
-       }
-
-fopen_retry:
-       if ((filp = fopen(pathname, "w")) == NULL) {
-               if (errno == EINTR)
-                       goto fopen_retry;
-
-               LOG_NO("Could not open '%s' - %s", pathname, strerror(errno));
-               rc = -1;
-               goto done;
-       }
-
-       /* version */
-       if ((rc = fprintf(filp, "%s %c.%d.%d\n", LOG_VER_EXP,
-                         lgs_cb->log_version.releaseCode,
-                         lgs_cb->log_version.majorVersion, 
lgs_cb->log_version.minorVersion)) == -1)
-               goto fprintf_done;
-
-       /* Format expression */
-       if ((rc = fprintf(filp, "%s%s\n", FMAT_EXP, stream->logFileFormat)) == 
-1)
-               goto fprintf_done;
-
-       /* Max logfile size */
-       if ((rc = fprintf(filp, "%s %llu\n", CFG_EXP_MAX_FILE_SIZE, 
stream->maxLogFileSize)) == -1)
-               goto fprintf_done;
-
-       /* Fixed log record size */
-       if ((rc = fprintf(filp, "%s %d\n", CFG_EXP_FIXED_LOG_REC_SIZE, 
stream->fixedLogRecordSize)) == -1)
-               goto fprintf_done;
-
-       /* Log file full action */
-       rc = fprintf(filp, "%s %s %d\n", CFG_EXP_LOG_FULL_ACTION, 
DEFAULT_ALM_ACTION, stream->maxFilesRotated);
-
- fprintf_done:
-       if (rc == -1)
-               LOG_NO("Could not write to '%s'", pathname);
-
-fclose_retry:
-       if ((rc = fclose(filp)) == -1) {
-               if (errno == EINTR)
-                       goto fclose_retry;
-
-               LOG_NO("Could not close '%s' - '%s'", pathname, 
strerror(errno));
-       }
-
-done:
-       TRACE_LEAVE2("%u", rc);
-       return rc;
-}
-#endif
-
-/**
- * Create config file according to spec.
- * @param abspath
- * @param stream
- * 
- * @return int
- */
-int lgs_create_config_file_ufop(log_stream_t *stream)
+int lgs_create_config_file_hfop(log_stream_t *stream)
 {
        lgsf_apipar_t apipar;
        lgsf_retcode_t api_rc;
@@ -294,20 +202,77 @@ SaTimeT lgs_get_SaTime(void)
  * 
  * @return int
  */
-int lgs_file_rename_ufop(const char *path, const char *old_name, const char 
*time_stamp, const char *suffix)
+int lgs_file_rename_hfop(
+               const char *path,
+               const char *old_name,
+               const char *time_stamp,
+               const char *suffix)
 {
-       int ret;
+       int rc;
        char oldpath[PATH_MAX + NAME_MAX];
        char newpath[PATH_MAX + NAME_MAX];
+       const size_t maxsize = PATH_MAX + NAME_MAX;
+       size_t n;
+       lgsf_apipar_t apipar;
+       void *params_in_p;
+       size_t params_in_size;
+       lgsf_retcode_t api_rc;
+       char *oldpath_in_p;
+       char *newpath_in_p;
+       size_t *oldpath_str_size_p;
+       
+       TRACE_ENTER2("LLDTEST");
+       LOG_NO("LLDTEST: lgs_file_rename_hfop >>");
 
-       sprintf(oldpath, "%s/%s/%s%s", lgs_cb->logsv_root_dir, path, old_name, 
suffix);
-       sprintf(newpath, "%s/%s/%s_%s%s", lgs_cb->logsv_root_dir, path, 
old_name, time_stamp, suffix);
-       TRACE_4("Rename file from %s", oldpath);
-       TRACE_4("              to %s", newpath);
-       if ((ret = rename(oldpath, newpath)) == -1)
-               LOG_NO("rename: FAILED - %s", strerror(errno));
+       n = snprintf(oldpath, maxsize, "%s/%s/%s%s",
+                       lgs_cb->logsv_root_dir, path, old_name, suffix);
+       if (n >= maxsize) osafassert(0);
 
-       return ret;
+       n = snprintf(newpath, maxsize, "%s/%s/%s_%s%s",
+                       lgs_cb->logsv_root_dir, path, old_name, time_stamp, 
suffix);
+       if (n >= maxsize) osafassert(0);
+       
+       TRACE_4("LLDTEST: Rename file from %s", oldpath);
+       TRACE_4("LLDTEST:               to %s", newpath);
+       
+       /* Allocate memory for parameters */
+       size_t oldpath_size = strlen(oldpath)+1;
+       size_t newpath_size = strlen(newpath)+1;
+       params_in_size = sizeof(size_t) + oldpath_size + newpath_size;
+       
+       params_in_p = malloc(params_in_size);
+       
+       /* Fill in pointer addresses */
+       oldpath_str_size_p = params_in_p;
+       oldpath_in_p = params_in_p + sizeof(size_t);
+       newpath_in_p = oldpath_in_p + oldpath_size;
+       
+       /* Fill in parameters */
+       *oldpath_str_size_p = oldpath_size;
+       memcpy(oldpath_in_p, oldpath, oldpath_size);
+       memcpy(newpath_in_p, newpath, newpath_size);
+       
+       /* Fill in API structure */
+       apipar.req_code_in = LGSF_RENAME_FILE;
+       apipar.data_in_size = params_in_size;
+       apipar.data_in = params_in_p;
+       apipar.data_out_size = 0;
+       apipar.data_out = NULL;
+       
+       api_rc = log_file_api(&apipar);
+       if (api_rc != LGSF_SUCESS) {
+               TRACE("%s - API error %d",__FUNCTION__,api_rc);
+               rc = -1;
+       } else {
+               rc = apipar.hdl_ret_code_out;
+       }
+       
+       free(params_in_p);
+       
+       LOG_NO("LLDTEST: lgs_file_rename_hfop <<");
+       TRACE_LEAVE2("LLDTEST");
+       
+       return rc;
 }
 
 void lgs_exit(const char *msg, SaAmfRecommendedRecoveryT rec_rcvr)
diff --git a/osaf/services/saf/logsv/lgs/lgs_util.h 
b/osaf/services/saf/logsv/lgs/lgs_util.h
--- a/osaf/services/saf/logsv/lgs/lgs_util.h
+++ b/osaf/services/saf/logsv/lgs/lgs_util.h
@@ -50,10 +50,10 @@
  */
 
 extern char *lgs_get_time(void);
-extern int lgs_create_config_file_ufop(log_stream_t *stream);
+extern int lgs_create_config_file_hfop(log_stream_t *stream);
 extern void lgs_evt_destroy(lgsv_lgs_evt_t *evt);
 extern SaTimeT lgs_get_SaTime(void);
-extern int lgs_file_rename_ufop(const char *path, const char *old_name, const 
char *time_stamp, const char *suffix);
+extern int lgs_file_rename_hfop(const char *path, const char *old_name, const 
char *time_stamp, const char *suffix);
 //extern uint32_t lgs_create_known_streams(lgs_cb_t *lgs_cb); /* Not used, no 
code */
 extern void lgs_exit(const char *msg, SaAmfRecommendedRecoveryT rec_rcvr);
 extern bool lgs_relative_path_check_ts(const char* path);

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to