add missing Makefile.am in facilities
[lttv.git] / ltt / branches / poly / lttd / lttd.c
index 63d483b6e67b9f7946818b4f0af98272761f323d..01f1dd6dc262a7f5e9bdb6a6200ffefa0699a846 100644 (file)
  *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
  */
 
-#define _GNU_SOURCE
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -195,20 +198,21 @@ int open_channel_trace_pairs(char *subchannel_name, char *subtrace_name,
        char path_trace[PATH_MAX];
        int path_trace_len;
        char *path_trace_ptr;
+  int open_ret = 0;
 
        if(channel_dir == NULL) {
                perror(subchannel_name);
-               return ENOENT;
+               open_ret = ENOENT;
+    goto end;
        }
 
        printf("Creating trace subdirectory %s\n", subtrace_name);
        ret = mkdir(subtrace_name, S_IRWXU|S_IRWXG|S_IRWXO);
        if(ret == -1) {
-               if(errno == EEXIST && append_mode) {
-                       printf("Appending to directory %s as resquested\n", subtrace_name);
-               } else {
+               if(errno != EEXIST) {
                        perror(subtrace_name);
-                       return -1;
+      open_ret = -1;
+                       goto end;
                }
        }
 
@@ -273,7 +277,8 @@ int open_channel_trace_pairs(char *subchannel_name, char *subtrace_name,
                                        }
                                } else {
                                        printf("File %s exists, cannot open. Try append mode.\n", path_trace);
-                                       return -1;
+                                       open_ret = -1;
+          goto end;
                                }
                        } else {
                                if(errno == ENOENT) {
@@ -288,9 +293,10 @@ int open_channel_trace_pairs(char *subchannel_name, char *subtrace_name,
                }
        }
        
+end:
        closedir(channel_dir);
 
-       return 0;
+       return open_ret;
 }
 
 
This page took 0.023988 seconds and 4 git commands to generate.