fixed do-display-dir behavior
[util-vserver.git] / util-vserver / src / vserver-stat.c
index c8ff681..d4c6dc4 100644 (file)
@@ -37,9 +37,6 @@
 #include "vserver.h"
 #include "util.h"
 #include "internal.h"
-#include "wrappers.h"
-#include "wrappers-dirent.h"
-#include "wrappers-vserver.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <stdbool.h>
 
+#define ENSC_WRAPPERS_DIRENT   1
+#define ENSC_WRAPPERS_VSERVER  1
+#define ENSC_WRAPPERS_FCNTL    1
+#define ENSC_WRAPPERS_UNISTD   1
+#include "wrappers.h"
+
 #define PROC_DIR_NAME "/proc"
 #define CTX_DIR_NAME "/var/run/vservers/"
 #define CTX_NAME_MAX_LEN 50
@@ -205,24 +208,21 @@ add_ctx(struct ctx_list *list, struct process_info *process)
 
 // increment the count number in the ctx record using ctx number
 static void
-count_ctx(struct ctx_list **list, struct process_info *process)
+count_ctx(struct ctx_list **ptr, struct process_info *process)
 {
-  struct ctx_list      **ptr = list;
-
   for (;;) {
     if (*ptr==0 || (*ptr)->ctx > process->s_context) {
       *ptr = insert_ctx(process->s_context, *ptr);
-      add_ctx(*ptr, process);
-      return;
+      break;
     }
 
-    if ((*ptr)->ctx == process->s_context) {
-      add_ctx(*ptr, process);
-      return;
-    }
+    if ((*ptr)->ctx == process->s_context)
+      break;
 
     ptr = &(*ptr)->next;
   }
+
+  add_ctx(*ptr, process);
 }
 
 // free mem
@@ -256,6 +256,7 @@ struct process_info *get_process_info(char *pid)
     WRITE_STR(2, pid);
     WRITE_MSG(2, "): ");
     WRITE_STR(2, strerror(err));
+    WRITE_MSG(2, "\n");
   }
   
   memcpy(buffer,     "/proc/", 6); idx  = 6;