Commit f839f849 authored by Jeff Dike's avatar Jeff Dike

Fixed the time locking bug.

The mconsole and switch protocols are now 64-bit clean.
Fixed some smaller bugs.
parent 2ab010ff
......@@ -7,6 +7,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
......@@ -24,8 +25,8 @@ enum request_type { REQ_NEW_CONTROL };
#define SWITCH_MAGIC 0xfeedface
struct request_v3 {
unsigned long magic;
int version;
uint32_t magic;
uint32_t version;
enum request_type type;
struct sockaddr_un sock;
};
......
......@@ -7,30 +7,35 @@
#ifndef __MCONSOLE_H__
#define __MCONSOLE_H__
#ifndef __KERNEL__
#include <stdint.h>
#define u32 uint32_t
#endif
#define MCONSOLE_MAGIC (0xcafebabe)
#define MCONSOLE_MAX_DATA (512)
#define MCONSOLE_VERSION 2
struct mconsole_request {
unsigned long magic;
int version;
int len;
u32 magic;
u32 version;
u32 len;
char data[MCONSOLE_MAX_DATA];
};
struct mconsole_reply {
int err;
int more;
int len;
u32 err;
u32 more;
u32 len;
char data[MCONSOLE_MAX_DATA];
};
struct mconsole_notify {
unsigned long magic;
int version;
u32 magic;
u32 version;
enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG,
MCONSOLE_USER_NOTIFY } type;
int len;
u32 len;
char data[MCONSOLE_MAX_DATA];
};
......
......@@ -11,7 +11,7 @@ extern void switch_timers(int to_real);
extern void set_interval(int timer_type);
extern void idle_sleep(int secs);
extern void enable_timer(void);
extern void time_lock(void);
extern void time_unlock(void);
extern unsigned long time_lock(void);
extern void time_unlock(unsigned long);
#endif
......@@ -23,11 +23,11 @@ static void __init find_tempdir(void)
if(tempdir != NULL) return; /* We've already been called */
for(i = 0; dirs[i]; i++){
dir = getenv(dirs[i]);
if(dir != NULL) break;
if((dir != NULL) && (*dir != '\0'))
break;
}
if(dir == NULL) dir = "/tmp";
else if(*dir == '\0') dir = NULL;
if(dir != NULL) {
if((dir == NULL) || (*dir == '\0'))
dir = "/tmp";
tempdir = malloc(strlen(dir) + 2);
if(tempdir == NULL){
fprintf(stderr, "Failed to malloc tempdir, "
......@@ -36,7 +36,6 @@ static void __init find_tempdir(void)
}
strcpy(tempdir, dir);
strcat(tempdir, "/");
}
}
int make_tempfile(const char *template, char **out_tempname, int do_unlink)
......
......@@ -86,20 +86,23 @@ struct timeval local_offset = { 0, 0 };
void do_gettimeofday(struct timeval *tv)
{
time_lock();
unsigned long flags;
flags = time_lock();
gettimeofday(tv, NULL);
timeradd(tv, &local_offset, tv);
time_unlock();
time_unlock(flags);
}
void do_settimeofday(struct timeval *tv)
{
struct timeval now;
unsigned long flags;
time_lock();
flags = time_lock();
gettimeofday(&now, NULL);
timersub(tv, &now, &local_offset);
time_unlock();
time_unlock(flags);
}
void idle_sleep(int secs)
......
......@@ -131,14 +131,16 @@ void timer_handler(int sig, union uml_pt_regs *regs)
static spinlock_t timer_spinlock = SPIN_LOCK_UNLOCKED;
void time_lock(void)
unsigned long time_lock(void)
{
spin_lock(&timer_spinlock);
unsigned long flags;
spin_lock_irqsave(&timer_spinlock, flags);
return(flags);
}
void time_unlock(void)
void time_unlock(unsigned long flags)
{
spin_unlock(&timer_spinlock);
spin_unlock_irqrestore(&timer_spinlock, flags);
}
int __init timer_init(void)
......
......@@ -169,7 +169,7 @@ void finish_fork_handler(int sig)
#endif
enable_timer();
change_sig(SIGVTALRM, 1);
local_irq_disable();
local_irq_enable();
force_flush_all();
if(current->mm != current->parent->mm)
protect_memory(uml_reserved, high_physmem - uml_reserved, 1,
......@@ -189,7 +189,7 @@ int fork_tramp(void *stack)
{
int sig = sigusr1;
local_irq_enable();
local_irq_disable();
init_new_thread_stack(stack, finish_fork_handler);
kill(os_getpid(), sig);
......
......@@ -106,7 +106,7 @@ int os_map_memory(void *virt, int fd, unsigned long off, unsigned long len,
loc = mmap((void *) virt, len, prot, MAP_SHARED | MAP_FIXED,
fd, off);
if(loc < 0)
if(loc == MAP_FAILED)
return(-errno);
return(0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment