hbetel@watserv1.uwaterloo.ca (Richard Betel) (04/19/91)
I suppose it is the dream of every aspiring minix guru to post lots of neat patches. Well, I am firm beleiver in starting small. So here is that first small step for me, and an even smaller step for minix: I recently found in the depths of include/minix/consts.h a reference to named pipes. I checked FS, and they're implemented. It suprised me. I didn't know they were there, because the book never mentions them ( they weren't implemented at the time the book was written). So I modified mknod to be able to make the "file", in the same way as mknod on BSD systems. I also patched ls to tell you about it when you do an ls -l. Here are those two patches: *** ../mknod.c Thu Feb 22 06:15:39 1990 --- mknod.c Tue Apr 16 18:46:52 1991 *************** *** 4,31 **** int argc; char *argv[]; { ! /* mknod name b/c major minor [size] makes a node. */ int mode, major, minor, dev; unsigned int size; ! if (argc < 5) badcomm(); ! if (*argv[2] != 'b' && *argv[2] != 'c') badcomm(); ! if (*argv[2] == 'c' && argc != 5) badchar(); ! if (*argv[2] == 'b' && argc != 6) badblock(); ! mode = (*argv[2] == 'b' ? 060666 : 020666); ! major = atoi(argv[3]); ! minor = atoi(argv[4]); ! size = (*argv[2] == 'b' ? atoi(argv[5]) : 0); ! if (major < 0 || minor < 0) badcomm(); ! dev = (major << 8) | minor; if (mknod(argv[1], mode, dev, size) < 0) perror("mknod"); exit(0); } badcomm() { ! std_err("Usage: mknod name b/c major minor [size_in_blocks]\n"); exit(1); } --- 4,37 ---- int argc; char *argv[]; { ! /* mknod name p/b/c [major minor [size]] makes a node. */ int mode, major, minor, dev; unsigned int size; ! if (*argv[2] != 'b' && *argv[2] != 'c' && *argv[2] != 'p') badcomm(); ! if (*argv[2] == 'c' && argc != 5) badchar(); ! if (*argv[2] == 'b' && argc != 6) badblock(); ! if (*argv[2] == 'p' && argc != 3) badpipe(); ! if (*argv[2] != 'p') { ! mode = (*argv[2] == 'b' ? 060666 : 020666); ! major = atoi(argv[3]); ! minor = atoi(argv[4]); ! size = (*argv[2] == 'b' ? atoi(argv[5]) : 0); ! if (major < 0 || minor < 0) badcomm(); ! dev = (major << 8) | minor; ! } else { ! mode = 010666; ! dev = 0; ! size = 0; ! } if (mknod(argv[1], mode, dev, size) < 0) perror("mknod"); exit(0); } badcomm() { ! std_err("Usage: mknod name p/b/c [major minor [size_in_blocks]]\n"); exit(1); } *************** *** 41,43 **** --- 47,54 ---- exit(1); } + badpipe() + { + std_err("Usage: mknod pipename p\n"); + exit(1); + } *** ls.c Fri Apr 13 04:27:10 1990 --- ls.new.c Tue Apr 16 19:05:16 1991 *************** *** 501,506 **** --- 501,507 ---- case S_IFDIR: bits[0] = 'd'; break; case S_IFBLK: bits[0] = 'b'; break; case S_IFCHR: bits[0] = 'c'; break; + case S_IFIFO: bits[0] = 'p'; break; default: bits[0] = '-'; break; } That's all folks. Have fun. I expect to see talk and mtrek develloped within the month ;-) Richard