Skip to content

Commit

Permalink
Merge pull request #259 from skliper/fix173-opencreate_truncate
Browse files Browse the repository at this point in the history
Fix #173, Truncate files when created to avoid stale data
  • Loading branch information
astrogeco authored Jun 8, 2022
2 parents 5423f70 + 79f0f74 commit 13bd673
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ void CF_CFDP_R_Init(CF_Transaction_t *t)
CF_CFDP_ArmAckTimer(t);
}

ret = CF_WrappedOpenCreate(&t->fd, t->history->fnames.dst_filename, OS_FILE_FLAG_CREATE, OS_READ_WRITE);
ret = CF_WrappedOpenCreate(&t->fd, t->history->fnames.dst_filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE,
OS_READ_WRITE);
if (ret < 0)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_CREAT, CFE_EVS_EventType_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg)

/* PTFO: queues can be large. may want to split this work up across the state machine and take several wakeups to
* complete */
ret = CF_WrappedOpenCreate(&fd, wq->filename, OS_FILE_FLAG_CREATE, OS_WRITE_ONLY);
ret = CF_WrappedOpenCreate(&fd, wq->filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY);
if (ret < 0)
{
CFE_EVS_SendEvent(CF_EID_ERR_CMD_WQ_OPEN, CFE_EVS_EventType_ERROR, "CF: write queue failed to open file %s",
Expand Down

0 comments on commit 13bd673

Please sign in to comment.