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

MiNT 1.10: misc bug fixes



Note: these patches assume that you already applied my previous
patches about optimizations. There will be some conflicts otherwise.

biosfs.c:
- bios_remove, bios_fscntl: `dir' is no longer unused
- bios_symlink: the \dev\fd directory supports no symlinks (the link
would go into the root directory instead)
- bios_ioctl (TCURS[GS]RATE): the mode TCURSSRATE of Cursconf doesn't
return anything useful.
- bios_select: inverted sense of collision check
- bios_close: wake processes waiting for lock

fasttext.c:
- screen_select: return 2 on collision

main.c:
- do_file: don't close the file twice

pipefs.c:
- pipe_open: O_CREAT only means "create *if not existing*", use
O_TRUNC to check for Fcreate.

proc.c:
- fork_proc: only copy the first 128 bytes of the command line, it is
not required to be zero-terminated.

procfs.c:
- proc_getname: look at size

signal.c:
- handle_sig: only count signals that call a user routine, in the
other cases the system call is not really interrupted.

tosfs.c:
- tos_lookup, tos_getxattr: preserve the FA_DELETE flag
- tos_ioctl: implement FIONREAD correctly

tty.c:
- tty_ioctl (TIOCSETP): set the tty state accordingly

unifs.c:
- do_ulookup, uni_rename: only use the first NAME_MAX characters of
the file name
- uni_remove: use case insensitive compare

-------------------- cut here --------------------
diff -ur orig/biosfs.c ./biosfs.c
--- orig/biosfs.c	Thu Feb 17 23:19:02 1994
+++ ./biosfs.c	Thu Feb 17 20:58:18 1994
@@ -489,8 +489,6 @@
 {
 	struct bios_file *b, **lastb;
 
-	UNUSED(dir);
-
 	if (curproc->euid)
 		return EACCDN;
 
@@ -736,8 +734,6 @@
 	struct bios_file *b;
 	static int devindex = 0;
 
-	UNUSED(dir);
-
 	if (curproc->euid) {
 		DEBUG(("biosfs: Dcntl() by non-privileged process"));
 		return ((unsigned)cmd == DEV_INSTALL) ? 0 : EACCDN;
@@ -816,6 +812,9 @@
 	if (curproc->euid)
 		return EACCDN;
 
+	if (IS_FD_DIR (dir))
+	  return EACCDN;
+
 	r = bios_lookup(dir, name, &fc);
 	if (r == 0) return EACCDN;	/* file already exists */
 	if (r != EFILNF) return r;	/* some other error */
@@ -1510,7 +1509,7 @@
 		if (f->fc.aux != 2)
 		  return EINVFN;
 		r = Cursconf(mode - TCURSOFF, *((short *)buf));
-		if (r >= 0) {
+		if (r >= 0 && mode == TCURSGRATE) {
 			*(short *)buf = r;
 			r = 0;
 		}
@@ -1581,7 +1580,7 @@
 		}
 		if (tty) {
 		/* avoid collisions with other processes */
-			if (!tty->rsel)
+			if (tty->rsel)
 				return 2;	/* collision */
 			tty->rsel = p;
 		}
@@ -1592,7 +1591,7 @@
 			return 1;
 		}
 		if (tty) {
-			if (!tty->wsel)
+			if (tty->wsel)
 				return 2;	/* collision */
 			tty->wsel = p;
 		}
@@ -1628,6 +1627,8 @@
 	b = (struct bios_file *)f->fc.index;
 	if ((f->flags & O_LOCK) && (b->lockpid == pid)) {
 		b->lockpid = 0;
+		f->flags &= ~O_LOCK;
+		wake (IO_Q, (long)b);	/* wake anyone waiting for this lock */
 	}
 	return 0;
 }
diff -ur orig/fasttext.c ./fasttext.c
--- orig/fasttext.c	Wed Feb  9 22:39:50 1994
+++ ./fasttext.c	Thu Feb 17 20:13:24 1994
@@ -1373,6 +1373,8 @@
 		/* avoid collisions with other processes */
 			if (!tty->rsel)
 				tty->rsel = p;
+			else
+			  return 2; /* collision */
 		}
 		return 0;
 	} else if (mode == O_WRONLY) {
diff -ur orig/main.c ./main.c
--- orig/main.c	Fri Feb 11 19:37:16 1994
+++ ./main.c	Thu Feb 17 20:20:08 1994
@@ -1468,7 +1468,6 @@
 		line[count] = 0;
 		do_line(line);
 	}
-	f_close(fd);
 }
 
 void
diff -ur orig/pipefs.c ./pipefs.c
--- orig/pipefs.c	Thu Feb 17 23:19:10 1994
+++ ./pipefs.c	Thu Feb 17 21:19:24 1994
@@ -544,7 +544,7 @@
 		}
 		p->flags &= ~O_HEAD;
 	} else {
-		if (f->flags & O_CREAT) {
+		if (f->flags & O_TRUNC) {
 			DEBUG(("pipe_open: fifo already exists"));
 			return EACCDN;
 		}
diff -ur orig/proc.c ./proc.c
--- orig/proc.c	Fri Feb 11 22:34:08 1994
+++ ./proc.c	Thu Feb 17 22:06:20 1994
@@ -157,7 +157,7 @@
 	}
 
 /* jr: copy ploadinfo */
-	strcpy (p->cmdlin, curproc->cmdlin);
+	strncpy (p->cmdlin, curproc->cmdlin, 128);
 	strcpy (p->fname, curproc->fname);
 
 /* clear directory search info */
diff -ur orig/procfs.c ./procfs.c
--- orig/procfs.c	Tue Feb 15 23:23:34 1994
+++ ./procfs.c	Thu Feb 17 20:32:38 1994
@@ -271,17 +271,20 @@
 	int size;
 {
 	PROC *p;
+	char buffer[20]; /* enough if proc names no longer than 8 chars */
 
 	UNUSED(root);
-/* BUG: we ought to look at size */
-	UNUSED(size);
 
 	if (dir->index == 0)
-		*pathname = 0;
+		*buffer = 0;
 	else {
 		p = (PROC *)dir->index;
-		ksprintf(pathname, "%s.03d", p->name, p->pid);
+		ksprintf(buffer, "%s.03d", p->name, p->pid);
 	}
+	if (strlen (buffer) < size)
+	  strcpy (pathname, buffer);
+	else
+	  return ERANGE;
 	return 0;
 }
 
diff -ur orig/proto.h ./proto.h
--- orig/proto.h	Fri Feb 11 19:35:00 1994
+++ ./proto.h	Thu Feb 17 21:21:24 1994
@@ -353,8 +353,8 @@
 void ARGS_ON_STACK ALERT P_((const char *s, ...));
 void ARGS_ON_STACK FORCE P_((const char *s, ...));
 void PAUSE P_((void));
-EXITING void ARGS_ON_STACK FATAL P_((const char *s, ...));
-EXITING void HALT P_((void));
+EXITING void ARGS_ON_STACK FATAL P_((const char *, ...)) NORETURN;
+EXITING void HALT P_((void)) NORETURN;
 void DUMPLOG P_((void));
 void do_func_key P_((int));
 
diff -ur orig/signal.c ./signal.c
--- orig/signal.c	Thu Feb 17 23:19:10 1994
+++ ./signal.c	Thu Feb 17 20:36:14 1994
@@ -264,7 +264,6 @@
 
 	if (curproc->sighandle[sig] == SIG_IGN)
 		return;
-	++curproc->nsigs;
 	if (curproc->sighandle[sig] == SIG_DFL) {
 _default:
 		switch(sig) {
@@ -347,6 +346,7 @@
 			}
 		}
 
+		++curproc->nsigs;
 		call = &curproc->ctxt[SYSCALL];
 /*
  * what we do is build two fake stack frames; the bottom one is
diff -ur orig/tosfs.c ./tosfs.c
--- orig/tosfs.c	Thu Feb 17 23:19:14 1994
+++ ./tosfs.c	Thu Feb 17 20:43:22 1994
@@ -507,7 +507,7 @@
 		ti->size = foo.dta_size;
 		ti->date = foo.dta_date;
 		ti->time = foo.dta_time;
-		ti->attr = foo.dta_attrib;
+		ti->attr = foo.dta_attrib | (ti->attr & FA_DELETE);
 		if (executable_extension(foo.dta_name))
 			ti->attr |= FA_EXEC;
 		ti->valid = 1;
@@ -561,7 +561,7 @@
 		ti->size = foo.dta_size;
 		ti->date = foo.dta_date;
 		ti->time = foo.dta_time;
-		ti->attr = foo.dta_attrib;
+		ti->attr = foo.dta_attrib | (ti->attr & FA_DELETE);
 		if (executable_extension(foo.dta_name))
 			ti->attr |= FA_EXEC;
 around:
@@ -1152,6 +1152,10 @@
 
 	switch (mode) {
 	case FIONREAD:
+		r = Fseek (0L, (int) f->devinfo, 1);
+		*(long *) buf = Fseek (0L, (int) f->devinfo, 2) - r;
+		(void) Fseek (r, (int) f->devinfo, 0);
+		return 0;
 	case FIONWRITE:
 		*((long *)buf) = 1;
 		return 0;
diff -ur orig/tty.c ./tty.c
--- orig/tty.c	Tue Feb  1 04:19:52 1994
+++ ./tty.c	Thu Feb 17 20:46:40 1994
@@ -483,6 +483,11 @@
 	case TIOCSETP:
 		sg = (struct sgttyb *)arg;
 		tty->sg = *sg;
+		/* set the tty state for checking control characters */
+		if (sg->sg_flags & T_RAW)
+		  tty->state &= ~TS_COOKED;
+		else
+		  tty->state |= TS_COOKED;
 	/* set baud rates */
 		baud = tosbaud(sg->sg_ispeed);
 		(*f->dev->ioctl)(f, TIOCIBAUD, &baud);
diff -ur orig/unifs.c ./unifs.c
--- orig/unifs.c	Thu Feb 17 23:19:16 1994
+++ ./unifs.c	Thu Feb 17 21:32:06 1994
@@ -175,7 +175,7 @@
  * OK, check the list of aliases and special directories
  */
 	for (u = u_root; u; u = u->next) {
-		if (!stricmp(name, u->name)) {
+		if (!strnicmp(name, u->name, NAME_MAX)) {
 			if ( (u->mode & S_IFMT) == S_IFDIR ) {
 				if (u->dev >= NUM_DRIVES) {
 					fs = u->fs;
@@ -295,7 +295,7 @@
 	lastu = 0;
 	u = u_root;
 	while (u) {
-		if (!strncmp(u->name, name, NAME_MAX)) {
+		if (!strnicmp(u->name, name, NAME_MAX)) {
 			if ( (u->mode & S_IFMT) != S_IFLNK ) return EFILNF;
 			kfree(u->data);
 			if (lastu)
@@ -406,7 +406,7 @@
 	UNUSED(olddir);
 
 	for (u = u_root; u; u = u->next) {
-		if (!stricmp(u->name, oldname))
+		if (!strnicmp(u->name, oldname, NAME_MAX))
 			break;
 	}