Skip to content

Commit

Permalink
otrunc err?
Browse files Browse the repository at this point in the history
  • Loading branch information
stamrakar authored and stamrakar committed Oct 28, 2024
1 parent ea5f21b commit e0fd834
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions server/aesdsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void *threadfunc(void *args)
syslog(LOG_DEBUG, "PACKET SUCCESSFULLY VALIDATED");

#if (USE_AESD_CHAR_DEVICE == 1)
recvfile_fd = open(recvfile, O_RDWR | O_CREAT | O_APPEND, 0644);
recvfile_fd = open(recvfile, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
if (recvfile_fd == -1)
{
/*error*/
Expand All @@ -407,7 +407,7 @@ void *threadfunc(void *args)
perror("pthread mutex_lock failed");
}

lseek(recvfile_fd, 0, SEEK_END);
//lseek(recvfile_fd, 0, SEEK_END);

nr = write(recvfile_fd, my_buffer, supplementBuf);

Expand Down Expand Up @@ -449,12 +449,7 @@ void *threadfunc(void *args)
free(my_buffer);
my_buffer = NULL;

rc = pthread_mutex_lock(&writeSocket);
if (rc != 0)
{
syslog(LOG_ERR, "pthread_mutex_lock failed, error was %d", rc);
perror("pthread mutex_lock failed");
}


#if (USE_AESD_CHAR_DEVICE==0)
if(lseek(recvfile_fd, 0, SEEK_SET) == -1)
Expand All @@ -464,7 +459,7 @@ void *threadfunc(void *args)
closeAll(EXIT_FAILURE);
}
#else
recvfile_fd = open(recvfile, O_RDWR | O_CREAT | O_APPEND, 0644);
recvfile_fd = open(recvfile, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH);
if (recvfile_fd == -1)
{
/*error*/
Expand All @@ -480,6 +475,13 @@ void *threadfunc(void *args)
#endif


rc = pthread_mutex_lock(&writeSocket);
if (rc != 0)
{
syslog(LOG_ERR, "pthread_mutex_lock failed, error was %d", rc);
perror("pthread mutex_lock failed");
}



send_my_buffer = (char *) malloc(BUF_SIZE);
Expand Down

0 comments on commit e0fd834

Please sign in to comment.