Kernel support for set_errstr()
authorBarret Rhoden <brho@cs.berkeley.edu>
Sun, 4 Aug 2013 01:34:37 +0000 (18:34 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sun, 4 Aug 2013 01:34:37 +0000 (18:34 -0700)
kern/include/ros/syscall.h
kern/include/syscall.h
kern/src/syscall.c

index 1263d42..1bad241 100644 (file)
@@ -13,6 +13,8 @@
 #define SC_UEVENT                              0x0004          /* user has an ev_q */
 #define SC_K_LOCK                              0x0008          /* kernel locked sysc */
 
+#define MAX_ERRSTR_LEN                 32
+
 struct syscall {
        unsigned int                            num;
        int                                                     err;                    /* errno */
@@ -26,7 +28,7 @@ struct syscall {
        long                                            arg3;
        long                                            arg4;
        long                                            arg5;
-       char                                            errstr[32];
+       char                                            errstr[MAX_ERRSTR_LEN];
 };
 
 #ifndef ROS_KERNEL
index e84ebbe..665c946 100644 (file)
@@ -45,6 +45,7 @@ void run_local_syscall(struct syscall *sysc);
 intreg_t syscall(struct proc *p, uintreg_t sc_num, uintreg_t a0, uintreg_t a1,
                  uintreg_t a2, uintreg_t a3, uintreg_t a4, uintreg_t a5);
 void set_errno(int errno);
+void set_errstr(char *errstr);
 void __signal_syscall(struct syscall *sysc, struct proc *p);
 
 /* Tracing functions */
index bea3c9c..22d2e25 100644 (file)
@@ -102,6 +102,18 @@ void set_errno(int errno)
                pcpui->cur_sysc->err = errno;
 }
 
+void set_errstr(char *errstr)
+{
+       struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
+       size_t errstrlen;
+       if (!pcpui->cur_sysc)
+               return;
+       errstrlen = MIN(strlen(errstr) + 1, MAX_ERRSTR_LEN);
+       memcpy(pcpui->cur_sysc->errstr, errstr, errstrlen);
+       /* enforce null termination */
+       pcpui->cur_sysc->errstr[MAX_ERRSTR_LEN - 1] = '\0';
+}
+
 /************** Utility Syscalls **************/
 
 static int sys_null(void)