Fix bug in userprog-merge where file writes were denied in the wrong thread
This commit is contained in:
@@ -260,6 +260,7 @@ lock_acquire (struct lock *lock)
|
|||||||
ASSERT (!lock_held_by_current_thread (lock));
|
ASSERT (!lock_held_by_current_thread (lock));
|
||||||
|
|
||||||
struct thread *t = thread_current ();
|
struct thread *t = thread_current ();
|
||||||
|
ASSERT (t->waiting_lock == NULL);
|
||||||
|
|
||||||
enum intr_level old_level = intr_disable ();
|
enum intr_level old_level = intr_disable ();
|
||||||
if (lock->holder != NULL)
|
if (lock->holder != NULL)
|
||||||
|
|||||||
@@ -126,9 +126,16 @@ start_process (void *proc_start_data)
|
|||||||
if_.gs = if_.fs = if_.es = if_.ds = if_.ss = SEL_UDSEG;
|
if_.gs = if_.fs = if_.es = if_.ds = if_.ss = SEL_UDSEG;
|
||||||
if_.cs = SEL_UCSEG;
|
if_.cs = SEL_UCSEG;
|
||||||
if_.eflags = FLAG_IF | FLAG_MBS;
|
if_.eflags = FLAG_IF | FLAG_MBS;
|
||||||
|
|
||||||
lock_acquire (&filesys_lock);
|
lock_acquire (&filesys_lock);
|
||||||
|
|
||||||
|
/* Prevent writing to the file being executed. */
|
||||||
|
struct file *exec_file = filesys_open (data->file_name);
|
||||||
|
thread_current ()->exec_file = exec_file;
|
||||||
|
file_deny_write(exec_file);
|
||||||
|
|
||||||
success = load (data->file_name, &if_.eip, &if_.esp);
|
success = load (data->file_name, &if_.eip, &if_.esp);
|
||||||
|
|
||||||
lock_release (&filesys_lock);
|
lock_release (&filesys_lock);
|
||||||
|
|
||||||
/* If load failed, quit. */
|
/* If load failed, quit. */
|
||||||
|
|||||||
Reference in New Issue
Block a user