Add support for the childfdmap for Go
authorRonald G. Minnich <rminnich@gmail.com>
Mon, 25 Aug 2014 17:51:20 +0000 (17:51 +0000)
committerRonald G. Minnich <rminnich@gmail.com>
Mon, 25 Aug 2014 17:51:20 +0000 (17:51 +0000)
Sorry for this mess, but I'm hoping someone can fix the include mess.
We need a gerrit or something where we can post draft patches.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
kern/include/ros/procinfo.h
kern/include/ros/syscall.h

index e54b184..89e0a81 100644 (file)
@@ -100,6 +100,29 @@ procinfo_pack_args(procinfo_t* p, char* const* argv, char* const* envp)
                pos += len;
        }
        p->argp[nargv+nenvp+1] = 0;
+
+       return 0;
+}
+#ifndef STRUCT_CHILDFDMAP_DEFINED
+#define STRUCT_CHILDFDMAP_DEFINED
+struct childfdmap {
+  int parentfd;
+  int childfd;
+  int ok;
+};
+#endif
+
+// the fdlist is an map: list[childfd] ->parentfd
+static int
+childfdmap_pack(struct childfdmap *cfdmap, int *fdlist, int len)
+{
+       int i;
+
+       for (i = 0; i < len; i++) {
+               cfdmap[i].ok = -1;
+               cfdmap[i].childfd = i;
+               cfdmap[i].parentfd = fdlist[i];
+       }
        
        return 0;
 }
index 567f713..8d47c45 100644 (file)
@@ -32,11 +32,15 @@ struct syscall {
        char                                            errstr[MAX_ERRSTR_LEN];
 };
 
+// include hell with go and friends.
+#ifndef STRUCT_CHILDFDMAP_DEFINED
+#define STRUCT_CHILDFDMAP_DEFINED
 struct childfdmap {
-       unsigned int                            parentfd;
-       unsigned int                            childfd;
-       int                                                     ok;
+  int parentfd;
+  int childfd;
+  int ok;
 };
+#endif
 
 #ifndef ROS_KERNEL