Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / arch / um / drivers / mconsole_user.c
index 4b109fe7fff8bac6eeee1b658c2e46cea830b42d..f02634fbf32ad0e95be61d11c7d911f11a318cd0 100644 (file)
 #include <sys/un.h>
 #include <unistd.h>
 #include "user.h"
+#include "sysdep/ptrace.h"
 #include "mconsole.h"
-#include "umid.h"
+#include "os.h"
+#include "user_util.h"
 
 static struct mconsole_command commands[] = {
-       { "version", mconsole_version, MCONSOLE_INTR },
+       /* With uts namespaces, uts information becomes process-specific, so
+        * we need a process context.  If we try handling this in interrupt
+        * context, we may hit an exiting process without a valid uts
+        * namespace.
+        */
+       { "version", mconsole_version, MCONSOLE_PROC },
        { "halt", mconsole_halt, MCONSOLE_PROC },
        { "reboot", mconsole_reboot, MCONSOLE_PROC },
        { "config", mconsole_config, MCONSOLE_PROC },
@@ -60,14 +67,14 @@ static struct mconsole_command *mconsole_parse(struct mc_request *req)
        struct mconsole_command *cmd;
        int i;
 
-       for(i=0;i<sizeof(commands)/sizeof(commands[0]);i++){
+       for(i = 0; i < ARRAY_SIZE(commands); i++){
                cmd = &commands[i];
                if(!strncmp(req->request.data, cmd->command, 
                            strlen(cmd->command))){
-                       return(cmd);
+                       return cmd;
                }
        }
-       return(NULL);
+       return NULL;
 }
 
 #define MIN(a,b) ((a)<(b) ? (a):(b))
@@ -125,6 +132,10 @@ int mconsole_get_request(int fd, struct mc_request *req)
 int mconsole_reply_len(struct mc_request *req, const char *str, int total,
                       int err, int more)
 {
+       /* XXX This is a stack consumption problem.  It'd be nice to
+        * make it global and serialize access to it, but there are a
+        * ton of callers to this function.
+        */
        struct mconsole_reply reply;
        int len, n;