summaryrefslogtreecommitdiffstats
path: root/src/testdisk.c
diff options
context:
space:
mode:
authorChristophe Grenier <[email protected]>2013-04-27 18:12:23 +0200
committerChristophe Grenier <[email protected]>2013-04-27 18:12:23 +0200
commita3d8937a1918db7ac21968f0729c54f582eec711 (patch)
tree970b2079bc9ca1bcfbd73c2f8d412b51fcc40e92 /src/testdisk.c
parentb40eee6a327a9474d4986cf723f236a8b556a60d (diff)
Use the correct value of errno to display a warning when log file creation failed
Diffstat (limited to 'src/testdisk.c')
-rw-r--r--src/testdisk.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/testdisk.c b/src/testdisk.c
index 9d52c855..9ab70175 100644
--- a/src/testdisk.c
+++ b/src/testdisk.c
@@ -49,6 +49,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <errno.h>
#include "intrface.h"
#include "fnctdsk.h"
#include "dir.h"
@@ -105,6 +106,7 @@ int main( int argc, char **argv )
char *cmd_run=NULL;
const char *logfile="testdisk.log";
FILE *log_handle=NULL;
+ int log_errno=0;
/* srand needed for GPT creation (weak is ok) */
srand(time(NULL));
#ifdef HAVE_SIGACTION
@@ -142,7 +144,7 @@ int main( int argc, char **argv )
if(create_log==TD_LOG_NONE)
create_log=TD_LOG_APPEND;
if(log_handle==NULL)
- log_handle=log_open(logfile, create_log);
+ log_handle=log_open(logfile, create_log, &log_errno);
}
else if((strcmp(argv[i],"/debug")==0) || (strcmp(argv[i],"-debug")==0))
{
@@ -150,7 +152,7 @@ int main( int argc, char **argv )
if(create_log==TD_LOG_NONE)
create_log=TD_LOG_APPEND;
if(log_handle==NULL)
- log_handle=log_open(logfile, create_log);
+ log_handle=log_open(logfile, create_log, &log_errno);
}
else if((strcmp(argv[i],"/all")==0) || (strcmp(argv[i],"-all")==0))
testdisk_mode|=TESTDISK_O_ALL;
@@ -322,7 +324,7 @@ int main( int argc, char **argv )
}
#endif
if(create_log!=TD_LOG_NONE && log_handle==NULL)
- log_handle=log_open_default(logfile, create_log);
+ log_handle=log_open_default(logfile, create_log, &log_errno);
#ifdef HAVE_NCURSES
/* ncurses need locale for correct unicode support */
if(start_ncurses("TestDisk",argv[0]))
@@ -332,15 +334,15 @@ int main( int argc, char **argv )
verbose=1;
create_log=ask_testdisk_log_creation();
if(create_log==TD_LOG_CREATE || create_log==TD_LOG_APPEND)
- log_handle=log_open(logfile, create_log);
+ log_handle=log_open(logfile, create_log, &log_errno);
}
{
const char*filename=logfile;
while(create_log!=TD_LOG_NONE && log_handle==NULL)
{
- filename=ask_log_location(filename);
+ filename=ask_log_location(filename, log_errno);
if(filename!=NULL)
- log_handle=log_open(filename, create_log);
+ log_handle=log_open(filename, create_log, &log_errno);
else
create_log=TD_LOG_NONE;
}