[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

disk change crash, more patches



another one :)

dosfile.c: ++bjarne@goedel.uni-muenster.de
	Make f_open and f_create reentrant.

 do a forced disk change (desktop: esc) and it crashes...

Index: filesys.c
@@ -391,7 +391,8 @@
 	for (p = proclist; p; p = p->gl_next) {
 	/* invalidate all open files on this device */
 		for (i = MIN_HANDLE; i < MAX_OPEN; i++) {
-			if (((f = p->handle[i]) != 0) && (f->fc.dev == d)) {
+			if (((f = p->handle[i]) != 0) && f != (FILEPTR *)1 &&
+				(f->fc.dev == d)) {
 			    if (!warned) {
 				ALERT(
 "Files were open on a changed drive (0x%x)!", d);
Index: dosdir.c
@@ -1318,7 +1318,8 @@
 		if (p->wait_q == ZOMBIE_Q || p->wait_q == TSR_Q)
 			continue;
 		for (i = MIN_HANDLE; i < MAX_OPEN; i++) {
-			if ( ((f = p->handle[i]) != 0) && (f->fc.dev == dev) ) {
+			if ( ((f = p->handle[i]) != 0) && f != (FILEPTR *)1 &&
+				(f->fc.dev == dev) ) {
 		DEBUG(("Dlock: process %d has an open handle on the drive", p->pid));
 				if (p->pid == 0) return EACCDN;
 				return (mode & 2) ? p->pid : EACCDN;
Index: dosfile.c
@@ -265,6 +265,7 @@
 	long r = 0;
 
 	if (!f) return EIHNDL;
+	if (f == (FILEPTR *)1) return 0;
 
 /* if this file is "select'd" by this process, unselect it
  * (this is just in case we were killed by a signal)
Index: proc.c
@@ -142,7 +142,7 @@
 /* copy open handles */
 	for (i = MIN_HANDLE; i < MAX_OPEN; i++) {
 		if ((f = p->handle[i]) != 0) {
-			if (f->flags & O_NOINHERIT)
+			if (f == (FILEPTR *)1 || f->flags & O_NOINHERIT)
 		/* oops, we didn't really want to copy this handle */
 				p->handle[i] = 0;
 			else

 and another stack thing... (don't use parents user stack here)

Index: dosmem.c
@@ -1276,7 +1276,11 @@
 			post_sig(p, SIGKILL);	/* then kill it */
 			p->ctxt[CURRENT].pc = (long)check_sigs;
 				/* just to make sure it dies */
+			p->ctxt[CURRENT].sr |= 0x2000;
+				/* but do it in super mode */
+#if 0				/* set up in fork_proc() */
 			p->ctxt[CURRENT].ssp = (long)(p->stack + ISTKSIZE);
+#endif
 			p->pri = MAX_NICE+1;
 			run_next(p, 1);
 			yield();

 these 2 were not necessary i think:

Index: dosmem.c
@@ -644,7 +644,6 @@
 		/* we guarantee ourselves at least 2 timeslices to do an Mshrink */
 			assert(curproc->magic == CTXT_MAGIC);
 			fresh_slices(2);
-			spl7();
 			leave_kernel();
 			change_context(&(curproc->ctxt[CURRENT]));
 		}
Index: proc.c
@@ -573,11 +573,10 @@
 	curproc->ctxt[CURRENT].regs[0] = 1;
 	curproc = p;
 	proc_clock = TIME_SLICE;	/* fresh time */
-	assert(p->magic == CTXT_MAGIC);
-	spl7();
 	if ((p->ctxt[CURRENT].sr & 0x2000) == 0) {	/* user mode? */
 		leave_kernel();
 	}
+	assert(p->magic == CTXT_MAGIC);
 	change_context(&(p->ctxt[CURRENT]));
 	/* not reached */
 	return 0;

-- 
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
								...ohne Gewehr
PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA