Index: trunk/minix/commands/de/Makefile
===================================================================
--- trunk/minix/commands/de/Makefile	(revision 9)
+++ 	(revision )
@@ -1,22 +1,0 @@
-# Makefile for de
-
-CC	= exec cc
-CFLAGS	= -O -D_MINIX -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2
-
-all:	de
-
-OBJS	= de.o de_stdin.o de_stdout.o de_diskio.o de_recover.o
-
-de:	$(OBJS)
-	$(CC) -i $(OBJS) -o de
-	install -S 4kw de
-
-install:	/usr/bin/de
-
-/usr/bin/de:	de
-	install -cs -o bin de $@
-
-$(OBJS): de.h
-
-clean:
-	rm -f *.bak *.o de
Index: trunk/minix/commands/de/README
===================================================================
--- trunk/minix/commands/de/README	(revision 9)
+++ 	(revision )
@@ -1,156 +1,0 @@
-		de - A Minix Disk Editor
-
-	      Terrence W. Holm, Jan. 1989
-
-
-INTRODUCTION
-
-    The de(1) disk editor allows a system administrator to
-    look at and modify a Minix file system device. Commands
-    allow movement throughout a file system device, displaying
-    information in a couple of formats, writing blocks from
-    the device onto another file, and rewriting words on the
-    disk.
-
-    A few changes to the Minix file system aid recovering files.
-    I-node numbers are retained in directory entries now (they
-    get moved to the end). And all the i-node information is not
-    zeroed-out when a file is unlinked. So, after a file is
-    accidently rm(1)'ed, you can find the old i-node, and then
-    manually (or automatically) go to each of the freed blocks
-    and write them to a new file.
-
-
-USES FOR THE DISK EDITOR
-
-    1)	EDUCATION. Students can look at a file system in
-        a painless manner. For example you don't have to
-	use od(1) to look at the zone numbers in i-nodes.
-
-	A simple assignment is to change the size of an un-mounted
-	floppy disk file system from 360 to 300 blocks. (A more
-	difficult assignment is to explain why this works, even
-	though fsck(1) and df(1) do not report the correct number
-	of free blocks. :-)
-
-    2)  ADMINISTRATION. You can visually check inconsistencies
-	reported by fsck(1) before letting fsck(1) fix them.
-	You can change any word on the disk, this greatly simplifies
-	editing file system information. For example, changing the
-	size of a block special device is actually fun, no more
-	"blind" writing to your partitions.
-
-	Bit maps can be displayed with 2048 "bits" per screen,
-	(on the IBM/PC console), see how your zones are allocated!
-
-    3)  RECOVERING LOST FILES. You can search a disk for an ASCII
-	string, once found, the block can be written out to a file.
-
-	A one line change to fs/path.c allows users to get the i-node
-	number for a file after it has been removed from a directory.
-
-	Another couple lines changed in the file system keep the
-	i-node information available until the i-node is reused
-	(normally this information is zeroed out when an i-node is
-	released.) This allows a de(1) user to go to a released
-	i-node, get all the block numbers, go to these blocks and
-	write them back to a new file.
-
-	The whole recovery process is automated by running "de -r file".
-	So, IF a file is unlink(2)'ed (eg. "rm file"), AND IF no one
-	allocates a new i-node or block in the mean-time, THEN you
-	can recover the file.
-
-
-RECOVERY SECURITY
-
-    Normally Minix hard disk partitions are r/w only by the super-user,
-    and floppy disks are r/w by anyone. This means that only "root"
-    can look at hard disk partitions, but others can use de(1) to play
-    with their floppy disks.
-
-    When recovering files ("de -r file"), a user requires access to
-    the major file system partitions. This can be done by:
-
-	(a) Give everyone access to the hard disks. DON'T DO THIS, it
-	    defeats all the file system protection we already have.
-
-	(b) Make de(1) set-uid "root". This is the way to go, IF you
-	    are running a Minix system that has NO ACCESS from the
-	    outside. This allows anyone to execute "de -r file", but only
-	    root to use "de /dev/hd3". De(1) does some checking when
-	    retrieving lost blocks, eg. making sure they really are
-	    free blocks and making sure the user owned the i-node.
-	    BUT, file system information has been lost when the file
-	    was unlink(2)'ed, so de(1) can not be 100% sure that a
-	    recovered block really belonged to the user. THIS IS A
-	    SECURITY HOLE. [Since the only access to my machine is from
-	    observable terminals and their associated humans, I run
-	    de(1) as set-uid root.]
-
-	(c) Keep the disks rw-------, and don't set-uid de(1). This
-	    means that only the super-user can recover lost files.
-	    So, if you accidently "rm", you must tell the system
-	    administrator to "su" and recover your file, (be sure to
-	    inform the other users to stop whatever they are doing
-	    until the file is restored).
-
-
-INSTALLATION
-
-	- Install de.1 in /usr/man/cat1.
-
-	- Install the files: Makefile, README, de.h, de.c, de_stdin.c,
-	  de_stdout.c, de_diskio.c and de_recover.c in commands/de.
-	  Add -F and -T. to the Makefile, if necessary.
-
-	- "make" de(1). If a header file is not found, don't worry:
-	  You probably have it somewhere, just link it to what de(1)
-	  is looking for. This program also requires the subroutine
-	  tolower(3), see EFTH MINIX report #50, if you don't have it.
-
-	- Do you really want set-uid root on de?
-
-	- Patch the files fs/path.c, fs/link.c and fs/open.c. If
-	  you don't patch the file system then the recover option
-	  "-r" and associated commands ('x' and 'X') will not work,
-	  but de(1) is still functional and useful.
-
-	- "make" a new fs, using -DRECOVER. Rebuild a boot diskette.
-
-
-USING DE(1) FOR THE FIRST TIME
-
-    De(1) starts up in "word" mode at block 0 of the specified
-    device. Hit the PGDN (or space bar) a few times, observing
-    all the information on the screen. Each PGUP/PGDN moves to
-    the next 1024 byte block, (de(1) only knows about 1 block per
-    zone file systems). Note that "word" mode only displays 32
-    bytes at a time, so you are only observing the first 32 bytes
-    in the first few blocks when you skip using PGDN.
-
-    Now go back to block 3, (zone bit map), using "g 3 ENTER".
-    Change to "map" mode "v m", and then use the down arrow key
-    to check each 2 Megs in the zone bit map.
-
-    Now change to "block" mode using "v b". And go to some data
-    block, eg. "g 1000 ENTER". Use PGUP/PGDN to see what data
-    is in each nearby block.
-
-    Remember 'h' gives you a help page.
-
-    Try some more commands, for example: 'END', 'I', '/'.
-    (Note: searching through a whole disk under Minix takes a
-    long time: 30-60 seconds per megabyte, depending on your
-    machine, drive and controller, [Minix is embarrassingly slow].)
-
-    Don't worry about looking at a mounted device, you must specify
-    the "-w" option before the 's' command is operational, and
-    this command is the only one which will try to modify the
-    contents of the device.
-
-
-MINIX-ST
-
-    Please contact me if you are interesting in attempting a port
-    to MINIX-ST.
Index: trunk/minix/commands/de/build
===================================================================
--- trunk/minix/commands/de/build	(revision 9)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/sh
-make clean
-make && make install
Index: trunk/minix/commands/de/de.c
===================================================================
--- trunk/minix/commands/de/de.c	(revision 9)
+++ 	(revision )
@@ -1,1335 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de.c							*/
-/*								*/
-/*		Main loop of the "Disk editor".			*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-15        Terrence W. Holm	*/
-/****************************************************************/
-
-
-#include <minix/config.h>
-#include <sys/types.h>
-#include <sys/dir.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <errno.h>
-#undef ERROR			/* arrgghh, errno.h has this pollution */
-#include <fcntl.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <minix/const.h>
-#include <minix/type.h>
-#include "../../servers/fs/const.h"
-#include "../../servers/fs/type.h"
-#include "../../servers/fs/inode.h"
-
-#include "de.h"
-
-static char copyright[] = "de  (c) Terrence W. Holm 1989";
-
-
-_PROTOTYPE(void Push , (de_state *s ));
-_PROTOTYPE(int Get_Base , (int *base ));
-_PROTOTYPE(int Get_Filename , (de_state *s ));
-_PROTOTYPE(int Get_Count , (char *units , unsigned long *result ));
-_PROTOTYPE(void Exec_Shell , (void));
-_PROTOTYPE(void Sigint , (int));
-
-
-
-/****************************************************************/
-/*								*/
-/*	main()							*/
-/*								*/
-/*		Initialize. Handle the "-r" recovery option if	*/
-/*		specified, else enter the main processing loop.	*/
-/*								*/
-/****************************************************************/
-
-
-void main( argc, argv )
-  int   argc;
-  char *argv[];
-
-  {
-  static de_state s;		/* it is safer not to put it on the stack
-				 * and some things probably now rely on zero
-				 * initialization
-				 */  
-  char *command_name = argv[0];
-  int   recover = 0;
-
-
-  s.device_mode = O_RDONLY;
-
-
-  /*  Parse arguments  */
-
-  if ( argc == 3  &&  strcmp( argv[1], "-r" ) == 0 )
-    {
-    recover = 1;
-    --argc;
-    ++argv;
-    }
-  else if ( argc == 3  &&  strcmp( argv[1], "-w" ) == 0 )
-    {
-    s.device_mode = O_RDWR;
-    --argc;
-    ++argv;
-    }
-
-  if ( argc != 2  ||  *argv[1] == '-' )
-    {
-    fprintf( stderr, "Usage: %s [-w] /dev/device\n", command_name );
-    fprintf( stderr, "       %s -r lost_file_name\n", command_name );
-    exit( 1 );
-    }
-
-
-  /*  Set the effective id to the real id. This eliminates	*/
-  /*  any increase in privilege done by a set-uid bit on the	*/
-  /*  executable file. We want to be "root" for recovering 	*/
-  /*  files, because we must be able to read the device.	*/
-  /*  However, in normal usage, de(1) should not let just 	*/
-  /*  anyone look at a file system, thus we drop the privilege.	*/
-  /*								*/
-  /*  NOTE: There is a security hole when using "-r" with a	*/
-  /*  set-uid de(1). Do not use set-uid root if there is any	*/
-  /*  way to externally access your Minix system.		*/
-
-  if ( ! recover )
-    {
-    setuid( getuid() );
-    setgid( getgid() );
-    }
-
-
-  /*  Set terminal characteristics, and ^C interrupt handler  */
-
-  Save_Term();
-
-  if ( signal( SIGINT, SIG_IGN ) != SIG_IGN )
-    {
-    signal( SIGINT,  Sigint );
-    signal( SIGQUIT, Sigint );
-    }
-
-  Set_Term();
-
-  if ( ! Init_Termcap() )
-    Error( "Requires a termcap entry" );
-
-
-
-  /*  Get the device file name. If recovering, also open an output file.  */
-
-  if ( recover )
-    {
-    char *dir_name;
-    char *file_name;
-    struct stat device_stat;
-    struct stat tmp_stat;
-
-    /*  Split the path name into a directory and a file name.  */
-
-    if ( strlen(argv[1]) > MAX_STRING )
-      Error( "Path name too long" );
-
-    if ( ! Path_Dir_File( argv[1], &dir_name, &file_name ) )
-      Error( "Recover aborted" );
-
-    /*  Find the device holding the directory.  */
-
-    if ( (s.device_name = File_Device( dir_name )) == NULL )
-      Error( "Recover aborted" );
-
-
-    /*  The output file will be in /tmp with the same file name.  */
-
-    strcpy( s.file_name, TMP );
-    strcat( s.file_name, "/" );
-    strcat( s.file_name, file_name );
-
-
-    /*  Make sure /tmp is not on the same device as the file we	   */
-    /*  are trying to recover (we don't want to use up the free	   */
-    /*  i-node and blocks before we get a chance to recover them). */
-
-    if ( stat( s.device_name, &device_stat ) == -1 )
-      Error( "Can not stat(2) device %s", s.device_name );
-
-    if ( stat( TMP, &tmp_stat ) == -1 )
-      Error( "Can not stat(2) directory %s", TMP );
-
-    if ( device_stat.st_rdev == tmp_stat.st_dev )
-      Error( "Will not recover files on the same device as %s", TMP );
-
-    if ( access( s.file_name, F_OK ) == 0 )
-      Error( "Will not overwrite file %s", s.file_name );
-
-
-    /*  Open the output file.  */
-
-    if ( (s.file_f = fopen( s.file_name, "w" )) == NULL )
-      Error( "Can not open file %s", s.file_name );
-
-    /*  Don't let anyone else look at the recovered file  */
-
-    chmod( s.file_name, 0700 );
-
-    /*  If running as root then change the owner of the  */
-    /*  restored file. If not running as root then the   */
-    /*  chown(2) will fail.				 */
-
-    chown( s.file_name, getuid(), getgid() );
-    }
-  else
-    {
-    s.device_name = argv[1];
-    s.file_name[ 0 ] = '\0';
-    }
-
-
-  /*  Open the device file.  */
-
-  {
-  struct stat device_stat;
-  off_t size;
-
-  if ( stat( s.device_name, &device_stat ) == -1 )
-    Error( "Can not find file %s", s.device_name );
-
-  if ( (device_stat.st_mode & S_IFMT) != S_IFBLK  &&
-       (device_stat.st_mode & S_IFMT) != S_IFREG )
-    Error( "Can only edit block special or regular files" );
-
-
-  if ( (s.device_d = open( s.device_name, s.device_mode )) == -1 )
-    Error( "Can not open %s", s.device_name );
-
-  if ( (size = lseek( s.device_d, 0L, SEEK_END )) == -1 )
-    Error( "Error seeking %s", s.device_name );
-
-  if ( size % K != 0 )
-    {
-    Warning( "Device size is not a multiple of 1024" );
-    Warning( "The (partial) last block will not be accessible" );
-    }
-  }
-
-
-  /*  Initialize the rest of the state record  */
-
-  s.mode = WORD;
-  s.output_base = 10;
-  s.search_string[ 0 ] = '\0';
-
-  {
-  int i;
-
-  for ( i = 0;  i < MAX_PREV;  ++i )
-    {
-    s.prev_addr[ i ] = 0L;
-    s.prev_mode[ i ] = WORD;
-    }
-  }
-
-
-  sync();
-
-  Read_Super_Block( &s );
-
-  Read_Bit_Maps( &s );
-
-  s.address = 0L;
-
-
-
-  /*  Recover mode basically performs an 'x' and an 'X'  */
-
-  if ( recover )
-    {
-    ino_t inode = Find_Deleted_Entry( &s, argv[1] );
-    off_t size;
-
-    if ( inode == 0 )
-      {
-      unlink( s.file_name );
-      Error( "Recover aborted" );
-      }
-
-    s.address = ( (long) s.first_data - s.inode_blocks ) * K
-		      + (long) (inode - 1) * s.inode_size;
-
-    Read_Block( &s, s.buffer );
-
-
-    /*  Have found the lost i-node, now extract the blocks.  */
-
-    if ( (size = Recover_Blocks( &s )) == -1L )
-      {
-      unlink( s.file_name );
-      Error( "Recover aborted" );
-      }
-
-    Reset_Term();
-
-    printf( "Recovered %ld bytes, written to file %s\n", size, s.file_name );
-
-    exit( 0 );
-    }
-
-
-  /*  Enter the main loop, first time redraw the screen  */
-  {
-  int rc = REDRAW;
-
-
-  do
-    {
-    if ( rc == REDRAW )
-      {
-      Read_Block( &s, s.buffer );
-      Draw_Screen( &s );
-      s.last_addr = s.address;
-      Draw_Pointers( &s );
-      }
-
-    else if ( rc == REDRAW_POINTERS )
-      {
-      s.offset = (unsigned) (s.address & ~ K_MASK);
-      Draw_Pointers( &s );
-      }
-
-    else if ( rc == ERROR )
-      {
-      Erase_Prompt();
-      putchar( BELL );
-      }
-    } while ( (rc = Process( &s, Arrow_Esc(Get_Char()) )) != EOF );
-  }
-
-
-  /*  If there is an open output file that was never written to  */
-  /*  then remove its directory entry. This occurs when no 'w' 	 */
-  /*  or 'W' command occurred between a 'c' command and exiting	 */
-  /*  the program.						 */
-
-  if ( s.file_name[0] != '\0'  &&  ! s.file_written )
-    unlink( s.file_name );
-
-
-  Reset_Term();	   /*  Restore terminal characteristics  */
-
-  exit( 0 );
-  }
-
-
-
-/****************************************************************/
-/*								*/
-/*	Get_Base( base )					*/
-/*								*/
-/*		Get a new base value.				*/
-/*		Returns REDRAW or ERROR.			*/
-/*								*/
-/****************************************************************/
-
-
-
-int Get_Base( base )
-  int *base;
-  {
-	switch ( Get_Char() )
-	  {
-	  case 'h' :	*base = 16;
-			break;
-
-	  case 'd' :	*base = 10;
-			break;
-
-	  case 'o' :	*base = 8;
-			break;
-
-	  case 'b' :	*base = 2;
-			break;
-
-	  default  :	return( ERROR );
-	  }
-
-		return( REDRAW );
-  }
-
-
-
-/****************************************************************/
-/*								*/
-/*	Process( state, input_char )				*/
-/*								*/
-/*		Determine the function requested by the 	*/
-/*		input character. Returns OK, REDRAW,		*/
-/*		REDRAW_POINTERS,  ERROR or EOF.			*/
-/*								*/
-/****************************************************************/
-
-
-int Process( s, c )
-  de_state  *s;
-  int  c;
-
-  {
-  switch ( c )
-    {
-    case 'b' :				/*  Back up one block	*/
-    case ESC_PGUP :
-
-		if ( s->address == 0 )
-		  return( ERROR );
-
-		s->address = (s->address - K) & K_MASK;
-
-		return( REDRAW );
-
-
-    case 'B' :				/*  Back up to home	*/
-    case ESC_HOME :
-
-		if ( s->address == 0 )
-		  return( OK );
-
-		Push( s );
-
-		s->address = 0L;
-
-		return( REDRAW );
-
-
-    case 'c' :				/*  Change file name	*/
-
-		{
-		int rc = Get_Filename( s );
-
-		return( rc == OK ? REDRAW : rc );
-		}
-
-
-    case 'd' :				/*  Down		*/
-    case ESC_DOWN :
-
-		{
-		s->last_addr = s->address;
-
-		switch ( s->mode )
-		  {
-		  case WORD :	s->address += 2;
-
-				if ( (s->address & PAGE_MASK) == 0 )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case BLOCK :	s->address += 64;
-
-				if ( (s->last_addr & K_MASK) !=
-				     (s->address   & K_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case MAP :	s->address += 256;
-
-				return( REDRAW );
-
-		  default :	Error( "Internal fault (mode)" );
-		  }
-		}
-
-
-    case 'f' :				/*  Forward one block	*/
-    case ' ' :
-    case ESC_PGDN :
-
-		if ( s->block == s->device_size - 1 )
-		  return( ERROR );
-
-		s->address = (s->address + K) & K_MASK;
-
-		return( REDRAW );
-
-
-    case 'F' :				/*  Forward to end	*/
-    case ESC_END :
-
-		{
-		off_t  last_block = ( (long) s->device_size - 1 ) * K;
-
-		if ( s->address == last_block )
-		  return( OK );
-
-		Push( s );
-
-		s->address = last_block;
-
-		return( REDRAW );
-		}
-
-
-    case 'g' :				/*  Goto block		*/
-
-		{
-		unsigned long block;
-
-		if ( Get_Count( "Block?", &block ) )
-		  {
-		  if ( block >= s->zones )
-		    {
-		    Warning( "Block number too large" );
-		    return( REDRAW );
-		    }
-
-		  Push( s );
-
-		  s->address = (off_t) block * K;
-
-		  return( REDRAW );
-		  }
-		else
-		  return( ERROR );
-		}
-
-
-    case 'G' :				/*  Goto block indirect	*/
-
-		{
-		unsigned block = *( (word_t *) &s->buffer[ s->offset ] );
-
-		if ( s->mode != WORD )
-		  {
-		  Warning( "Must be in visual mode \"word\"" );
-		  return( REDRAW );
-		  }
-
-		if ( block >= s->zones )
-		  {
-		  Warning( "Block number too large" );
-		  return( REDRAW );
-		  }
-
-		Push( s );
-
-		s->mode = BLOCK;
-		s->address = (long) block * K;
-
-		return( REDRAW );
-		}
-
-
-    case 'h' :				/*  Help		*/
-    case '?' :
-
-		Draw_Help_Screen( s );
-
-		Wait_For_Key();
-
-		return( REDRAW );
-
-
-    case 'i' :				/*  Goto i-node		*/
-
-		{
-		unsigned long inode;
-
-		if ( Get_Count( "I-node?", &inode ) )
-		  {
-		  if ( inode < 1  || inode > s->inodes )
-		    {
-		    Warning( "Illegal i-node number" );
-		    return( REDRAW );
-		    }
-
-		  Push( s );
-
-		  s->mode = WORD;
-		  s->address = (off_t) (s->first_data - s->inode_blocks) * K
-				  + (off_t) (inode - 1) * s->inode_size;
-
-		  return( REDRAW );
-		  }
-		else
-		  return( ERROR );
-		}
-
-
-    case 'I' :				/*  Filename to i-node	*/
-
-		{
-		ino_t inode;
-		char *filename;
-
-		Draw_Prompt( "File name?" );
-
-		filename = Get_Line();
-
-		if ( filename == NULL  ||  filename[0] == '\0' )
-		  return( ERROR );
-
-		inode = Find_Inode( s, filename );
-
-		if ( inode )
-		  {
-		  Push( s );
-
-		  s->mode = WORD;
-		  s->address = ( (long) s->first_data - s->inode_blocks ) * K
-				  + (long) (inode - 1) * s->inode_size;
-		  }
-
-		return( REDRAW );
-		}
-
-
-    case 'l' :				/*  Left		*/
-    case ESC_LEFT :
-
-		{
-		s->last_addr = s->address;
-
-		switch ( s->mode )
-		  {
-		  case WORD :	s->address = s->address - 32;
-
-				return( REDRAW );
-
-		  case BLOCK :	s->address -= 1;
-
-				if ( (s->last_addr & K_MASK) !=
-				     (s->address   & K_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case MAP :	s->address -= 4;
-
-				if ( (s->last_addr & ~ MAP_MASK) !=
-				     (s->address   & ~ MAP_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  default :	Error( "Internal fault (mode)" );
-		  }
-		}
-
-
-    case 'm' :				/*  Invoke a Minix shell */
-
-		Reset_Term();
-
-		Exec_Shell();
-
-		Set_Term();
-
-		return( REDRAW );
-
-
-    case 'n' :				/*  Search for next	*/
-
-		{
-		off_t addr;
-
-		if ( s->search_string[0] == '\0' )
-		  {
-		  Warning( "No search string defined" );
-		  return( REDRAW );
-		  }
-
-		Draw_Prompt( "Searching..." );
-
-		if ( (addr = Search( s, s->search_string )) == -1L )
-		  {
-		  Warning( "Search string not found" );
-
-		  Wait_For_Key();
-
-		  return( REDRAW );
-		  }
-
-		Push( s );
-		s->address = addr;
-
-		return( REDRAW );
-		}
-
-
-    case 'o' :				/*  Set output base	*/
-
-		Draw_Prompt( "Output base?" );
-
-		return( Get_Base( &s->output_base ) );
-
-
-    case 'p' :				/*  Previous address	*/
-
-		{
-		int  i;
-
-		s->address = s->prev_addr[ 0 ];
-		s->mode    = s->prev_mode[ 0 ];
-
-  		for ( i = 0;  i < MAX_PREV - 1;  ++i )
-		  {
-    		  s->prev_addr[ i ] = s->prev_addr[ i + 1 ];
-		  s->prev_mode[ i ] = s->prev_mode[ i + 1 ];
-		  }
-
-		return( REDRAW );
-		}
-
-
-    case 'q' :				/*  Quit		 */
-    case EOF :
-    case CTRL_D :
-
-		return( EOF );
-
-
-    case 'r' :				/*  Right		*/
-    case ESC_RIGHT :
-
-		{
-		s->last_addr = s->address;
-
-		switch ( s->mode )
-		  {
-		  case WORD :	s->address += 32;
-
-				return( REDRAW );
-
-		  case BLOCK :	s->address += 1;
-
-				if ( (s->last_addr & K_MASK) !=
-				     (s->address   & K_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case MAP :	s->address += 4;
-
-				if ( (s->last_addr & ~ MAP_MASK) !=
-				     (s->address   & ~ MAP_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  default :	Error( "Internal fault (mode)" );
-		  }
-		}
-
-    case 's' :				/*  Store word		*/
-
-		{
-		unsigned long word;
-
-		if ( s->mode != WORD )
-		  {
-		  Warning( "Must be in visual mode \"word\"" );
-		  return( REDRAW );
-		  }
-
-		if ( s->device_mode == O_RDONLY )
-		  {
-		  Warning( "Use -w option to open device for writing" );
-		  return( REDRAW );
-		  }
-
-		if ( Get_Count( "Store word?", &word ) )
-		  {
-		  if ( word != (word_t) word )
-		    {
-		      Warning( "Word is more than 16 bits" );
-		      return( REDRAW );
-		    }
-		  Write_Word( s, (word_t) word );
-
-		  return( REDRAW );
-		  }
-		else
-		  return( ERROR );
-		}
-
-
-    case 'u' :				/*  Up			*/
-    case ESC_UP :
-
-		{
-		s->last_addr = s->address;
-
-		switch ( s->mode )
-		  {
-		  case WORD :	s->address -= 2;
-
-				if ( (s->last_addr & PAGE_MASK) == 0 )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case BLOCK :	s->address -= 64;
-
-				if ( (s->last_addr & K_MASK) !=
-				     (s->address   & K_MASK) )
-				  return( REDRAW );
-
-				return( REDRAW_POINTERS );
-
-		  case MAP :	s->address -= 256;
-
-				return( REDRAW );
-
-		  default :	Error( "Internal fault (mode)" );
-		  }
-		}
-
-
-    case 'v' :				/*  Visual mode		*/
-
-		Draw_Prompt( "Visual mode?" );
-
-		switch ( Get_Char() )
-		  {
-		  case 'w' :	s->mode = WORD;
-				break;
-
-		  case 'b' :	s->mode = BLOCK;
-				break;
-
-		  case 'm' :	{
-				/* Assume user knows if map mode is possible
-				char *tty = ttyname( 0 );
-
-				if ( tty == NULL  ||
-				    strcmp( tty, "/dev/tty0" ) != 0 )
-				  Warning( "Must be at console" );
-				else
-				*/
-				  s->mode = MAP;
-
-				break;
-				}
-
-		  default  :	return( ERROR );
-		  }
-
-		return( REDRAW );
-
-
-    case 'w' :				/*  Write ASCII block	*/
-
-		if ( s->file_name[0] == '\0' )
-		  {
-		  int  rc = Get_Filename( s );
-
-		  if ( rc != OK )
-		    return( rc );
-		  }
-
-		/*  We have a successfully opened file  */
-
-		/*  Eliminate non-ASCII characters	*/
-		{
-		int i;
-		char buf[ K ];
-		char *from = s->buffer;
-		char *to = buf;
-
-		for ( i = 0;  i < K;  ++i, ++from )
-		  {
-		  *to = *from & 0x7f;
-
-		  if ( *to != '\0'  &&  *to != '\177' )
-		    ++to;
-		  }
-
-		if ( fwrite( buf, 1, (int)(to - buf), s->file_f ) != to - buf )
-		  Warning( "Problem writing out buffer" );
-
-		s->file_written = 1;
-
-		return( REDRAW );
-		}
-
-
-    case 'W' :				/*  Write block exactly	*/
-
-		if ( s->file_name[0] == '\0' )
-		  {
-		  int  rc = Get_Filename( s );
-
-		  if ( rc != OK )
-		    return( rc );
-		  }
-
-		/*  We have a successfully opened file  */
-
-		if ( fwrite( s->buffer, 1, K, s->file_f ) != K )
-		  Warning( "Problem writing out buffer" );
-
-		s->file_written = 1;
-
-		return( REDRAW );
-
-
-    case 'x' :				/*  eXtract lost entry	*/
-
-		{
-		ino_t inode;
-		char *filename;
-
-		Draw_Prompt( "Lost file name?" );
-
-		filename = Get_Line();
-
-		if ( filename == NULL  ||  filename[0] == '\0' )
-		  return( ERROR );
-
-		inode = Find_Deleted_Entry( s, filename );
-
-		if ( inode )
-		  {
-		  Push( s );
-
-		  s->mode = WORD;
-		  s->address = ( (long) s->first_data - s->inode_blocks ) * K
-				  + (long) (inode - 1) * s->inode_size;
-		  }
-
-		return( REDRAW );
-		}
-
-
-    case 'X' :				/*  eXtract lost blocks	*/
-
-		{
-		int  rc;
-
-		if ( s->mode != WORD )
-		  {
-		  Warning( "Must be in visual mode \"word\"" );
-		  return( REDRAW );
-		  }
-
-
-		/*  Force a new output file name.  */
-
-		if ( (rc = Get_Filename( s )) != OK )
-		  return( rc );
-
-
-		Draw_Strings( s );
-
-		Erase_Prompt();
-		Draw_Prompt( "Recovering..." );
-
-		if ( Recover_Blocks( s ) == -1L )
-		  unlink( s->file_name );
-
-		/*  Force closure of output file.  */
-
-		fclose( s->file_f );
-		s->file_name[ 0 ] = '\0';
-
-		return( REDRAW );
-		}
-
-
-    case '/' :				/*  Search		*/
-    case ESC_PLUS :
-
-		{
-		off_t addr;
-		char *string;
-
-		Draw_Prompt( "Search string?" );
-
-		string = Get_Line();
-
-		if ( string == NULL )
-		  return( ERROR );
-
-		if ( string[0] != '\0' )
-		  {
-		  strcpy( s->search_string, string );
-		  Draw_Strings( s );
-		  }
-
-		else if ( s->search_string[0] == '\0' )
-		  {
-		  Warning( "No search string defined" );
-		  return( REDRAW );
-		  }
-
-		Erase_Prompt();
-		Draw_Prompt( "Searching..." );
-
-		if ( (addr = Search( s, s->search_string )) == -1L )
-		  {
-		  Warning( "Search string not found" );
-
-		  Wait_For_Key();
-
-		  return( REDRAW );
-		  }
-
-		Push( s );
-
-		s->mode = BLOCK;
-		s->address = addr;
-
-		return( REDRAW );
-		}
-
-
-    default:
-		return( ERROR );
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Push( state )						*/
-/*								*/
-/*		Push current address and mode, used by the	*/
-/*		commands B, F, g, G, i, I, n, x and /.  This	*/
-/*		information is popped by the 'p' command.	*/
-/*								*/
-/****************************************************************/
-
-
-void Push( s )
-  de_state *s;
-
-  {
-  int  i;
-
-  for ( i = MAX_PREV - 1;  i > 0;  --i )
-    {
-    s->prev_addr[ i ] = s->prev_addr[ i - 1 ];
-    s->prev_mode[ i ] = s->prev_mode[ i - 1 ];
-    }
-
-  s->prev_addr[ 0 ] = s->address;
-  s->prev_mode[ 0 ] = s->mode;
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Get_Filename( state )					*/
-/*								*/
-/*		Read and check a filename.			*/
-/*								*/
-/****************************************************************/
-
-
-int Get_Filename( s )
-  de_state *s;
-
-  {
-  char *filename;
-  char *name;
-  FILE *f;
-
-  Draw_Prompt( "File name?" );
-
-  filename = Get_Line();
-
-  if ( filename == NULL  ||  filename[0] == '\0' )
-    return( ERROR );
-
-
-  for ( name = filename;  *name != '\0';  ++name )
-    if ( ! isgraph( *name ) )
-      {
-      Warning( "File name contains non-graphic characters" );
-      return( REDRAW );
-      }
-
-
-  if ( access( filename, F_OK ) == 0 )
-    {
-    Warning( "Will not overwrite file %s", filename );
-    return( REDRAW );
-    }
-
-  if ( (f = fopen( filename, "w" )) == NULL )
-    {
-    Warning( "Can not open file %s", filename );
-    return( REDRAW );
-    }
-
-  /*  If there is already an open output file then  */
-  /*  close it. If it was never written to then	    */
-  /*  remove its directory entry.		    */
-
-  if ( s->file_name[0] != '\0' )
-    {
-    if ( ! s->file_written )
-      unlink( s->file_name );
-
-    fclose( s->file_f );
-    }
-
-  strcpy( s->file_name, filename );
-  s->file_f = f;
-  s->file_written = 0;
-
-  return( OK );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Get_Count()						*/
-/*								*/
-/*		Read and check a number. Returns non-zero	*/
-/*		if successful.					*/
-/*								*/
-/****************************************************************/
-
-
-int Get_Count( units, result )
-  char *units;
-  unsigned long *result;
-
-  {
-  char *number;
-
-  Draw_Prompt( units );
-
-  number = Get_Line();
-
-  if ( number == NULL  ||  number[0] == '\0' )
-    return( 0 );
-
-  errno = 0;
-  *result = strtoul( number, (char **) NULL, 0 );
-  return( errno == 0 );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	In_Use( bit, map )					*/
-/*								*/
-/*		Is the bit set in the map?			*/
-/*								*/
-/****************************************************************/
-
-
-int In_Use( bit, map )
-  bit_t bit;
-  bitchunk_t *map;
-
-  {
-  return( map[ (int) (bit / (CHAR_BIT * sizeof (bitchunk_t))) ] &
-	  (1 << ((unsigned) bit % (CHAR_BIT * sizeof (bitchunk_t)))) );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Find_Inode( state, filename )				*/
-/*								*/
-/*		Find the i-node for the given file name.	*/
-/*								*/
-/****************************************************************/
-
-
-ino_t Find_Inode( s, filename )
-  de_state *s;
-  char *filename;
-
-  {
-  struct stat device_stat;
-  struct stat file_stat;
-  ino_t inode;
-
-
-  if ( fstat( s->device_d, &device_stat ) == -1 )
-    Error( "Can not fstat(2) file system device" );
-
-#ifdef S_IFLNK
-  if ( lstat( filename, &file_stat ) == -1 )
-#else
-  if ( stat( filename, &file_stat ) == -1 )
-#endif
-    {
-    Warning( "Can not find file %s", filename );
-    return( 0 );
-    }
-
-  if ( device_stat.st_rdev != file_stat.st_dev )
-    {
-    Warning( "File is not on device %s", s->device_name );
-    return( 0 );
-    }
-
-
-  inode = file_stat.st_ino;
-
-  if ( inode < 1  || inode > s->inodes )
-    {
-    Warning( "Illegal i-node number" );
-    return( 0 );
-    }
-
-  return( inode );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Exec_Shell()						*/
-/*								*/
-/*		Fork off a sub-process to exec() the shell.	*/
-/*								*/
-/****************************************************************/
-
-
-void Exec_Shell()
-
-  {
-  int pid = fork();
-
-  if ( pid == -1 )
-    return;
-
-
-  if ( pid == 0 )
-    {
-    /*  The child process  */
-
-    extern char **environ;
-    char *shell  =  getenv( "SHELL" );
-
-    if ( shell == NULL )
-      shell = "/bin/sh";
-
-    execle( shell, shell, (char *) 0, environ );
-
-    perror( shell );
-    exit( 127 );
-    }
-
-
-  /*  The parent process: ignore signals, wait for sub-process	*/
-
-  signal( SIGINT,  SIG_IGN );
-  signal( SIGQUIT, SIG_IGN );
-
-  {
-  int  status;
-  int  w;
-
-  while ( (w=wait(&status)) != pid  &&  w != -1 );
-  }
-
-  signal( SIGINT,  Sigint );
-  signal( SIGQUIT, Sigint );
-
-  return;
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Sigint()						*/
-/*								*/
-/*		Terminate the program on an interrupt (^C)	*/
-/*		or quit (^\) signal.				*/
-/*								*/
-/****************************************************************/
-
-
-void Sigint(n)
-int n;
-  {
-  Reset_Term();		/*  Restore terminal characteristics	*/
-
-  putchar( '\n' );
-
-  exit( 1 );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Error( text, ... )					*/
-/*								*/
-/*		Print an error message on stderr.		*/
-/*								*/
-/****************************************************************/
-
-
-#if __STDC__
-void Error( const char *text, ... )
-#else
-void Error( text )
-  char *text;
-#endif  
-
-  {
-  va_list argp;
-
-  Reset_Term();
-
-  fprintf( stderr, "\nde: " );
-  va_start( argp, text );
-  vfprintf( stderr, text, argp );
-  va_end( argp );
-  if ( errno != 0 )
-    fprintf( stderr, ": %s", strerror( errno ) );
-  fprintf( stderr, "\n" );
-
-  exit( 1 );
-  }
Index: trunk/minix/commands/de/de.h
===================================================================
--- trunk/minix/commands/de/de.h	(revision 9)
+++ 	(revision )
@@ -1,363 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de.h							*/
-/*								*/
-/*		Definitions for the "Disk editor".		*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-15        Terrence W. Holm	*/
-/****************************************************************/
-
-
-/****************************************************************/
-/*								*/
-/*	de(1)							*/
-/*								*/
-/*  This is the MINIX disk editor. It allows the user to	*/
-/*  observe and modify a file system. It can also be used	*/
-/*  to recover unlink(2)'ed files				*/
-/*								*/
-/*  See the de(1) man page.					*/
-/*								*/
-/****************************************************************/
-
-
-/****************************************************************/
-/*								*/
-/*	de		   Copyright  Terrence W. Holm  1989	*/
-/*								*/
-/* This program was written for users of the Minix operating	*/
-/* system, and in the spirit of other public domain software	*/
-/* written for said system, this source code is made available	*/
-/* at no cost to everyone. I assume no responsibility for	*/
-/* damage to file systems caused by this program.		*/
-/*								*/
-/* This program (one .h, five .c's and a "man" page) may be	*/
-/* copied and/or modified subject to (1) no charge must be	*/
-/* made for distribution, other than for the medium, (2) all	*/
-/* modified sources must be clearly marked as such, (3) all	*/
-/* sources must carry this copyright.				*/
-/*								*/
-/****************************************************************/
-
-
-/****************************************************************/
-/*								*/
-/*	files							*/
-/*								*/
-/*	    de.h		Definitions			*/
-/*	    de.c		The main loop			*/
-/*	    de_stdin.c		Character input routines	*/
-/*	    de_stdout.c		Output routines			*/
-/*	    de_diskio.c		File system read/write		*/
-/*	    de_recover.c	File restoration routines	*/
-/*								*/
-/*	    de.1		"Man" page			*/
-/*	    Makefile		For "make"			*/
-/*	    README		Installation help		*/
-/*								*/
-/*								*/
-/*	fs/path.c was modified to support the 'x' command.	*/
-/*	fs/link.c and fs/open.c were changed for 'X'.		*/
-/*								*/
-/****************************************************************/
-#undef printf
-#include <stdio.h>
-#include <dirent.h>
-
-/*  General constants  */
-
-#define   MAX_STRING	60		/*  For all input lines	*/
-#define   MAX_PREV	8		/*  For 'p' command	*/
-#define   SEARCH_BUFFER (4*K)		/*  For '/' and 'n'	*/
-
-
-/*  Files  */
-
-#define   TMP      "/tmp"		/*  For "-r" output	*/
-#define   DEV	   "/dev"		/*  Where devices are	*/
-
-
-/*  a.out header constants  (see a.out.h, if you have it)  */
-
-#if (CHIP == INTEL)
-#define   A_OUT    0x0301
-#define   SPLIT    0x0420
-#endif
-
-#if (CHIP == M68000)
-#define   A_OUT    0x0301
-#define   SPLIT	   0x0B20
-#endif
-
-#if (CHIP == SPARC)
-#define   A_OUT    0x0301
-#define   SPLIT    0x0B20
-#endif
-
-/*  Each buffer is 1k.  In WORD mode 16 words (32 bytes) can be	*/
-/*  displayed at once. In BLOCK mode 1K bytes can be displayed.	*/
-/*  In MAP mode 2048 bits (256 bytes) are displayed.		*/
-
-#define   K		1024		/*  STD_BLK		*/
-#define   K_MASK	(~(K-1))	/*  Round to K boundary	*/
-#define   K_SHIFT	10		/*  Ie. 1<<10 = K	*/
-#define   PAGE_MASK	0x1f		/*  Word mode: 32 bytes	*/
-#define   PAGE_SHIFT    5		/*  Ie. 1<<5 = 32	*/
-#define   MAP_BITS_PER_BLOCK (8 * K)    /*  1k block, 8192 bits */
-#define   MAP_MASK	0xff		/*  256 bytes/screen	*/
-
-
-
-/*  Terminal i/o codes  */
-
-#define   CTRL_D	'\004'		/*  ASCII ^D		*/
-#define   BELL		'\007'		/*  ASCII bell code     */
-#define   BS		'\010'		/*  ASCII back space	*/
-#define   CTRL_U	'\025'		/*  ASCII ^U		*/
-#define	  ESCAPE  	'\033'		/*  ASCII escape code	*/
-#define   DEL           '\177'		/*  ASCII delete code   */
-
-
-/*  Input escape codes generated by the	Minix console.	*/
-/*  Format: ESC [ X. 					*/
-
-#define   ESC_HOME	('H' + 0x80)
-#define   ESC_UP	('A' + 0x80)
-#define   ESC_PGUP	('V' + 0x80)
-#define   ESC_LEFT	('D' + 0x80)
-#define   ESC_5		('G' + 0x80)
-#define   ESC_RIGHT	('C' + 0x80)
-#define   ESC_END	('Y' + 0x80)
-#define   ESC_DOWN	('B' + 0x80)
-#define   ESC_PGDN	('U' + 0x80)
-#define   ESC_PLUS	('T' + 0x80)
-#define   ESC_MINUS	('S' + 0x80)
-
-
-/*  Graphic box codes - only applicable for console display  */
-/*  in visual mode "map".				     */
-
-#if (CHIP == INTEL)
-#define   BOX_CLR	' '		/*  Empty box		*/
-#define   BOX_ALL	'\333'		/*  Filled box		*/
-#define   BOX_TOP	'\337'		/*  Filled upper half	*/
-#define   BOX_BOT	'\334'		/*  Filled lower half   */
-#endif
-
-#if (CHIP == M68000)
-/*  Please change these.  */
-#define   BOX_CLR	' '		/*  Empty box		*/
-#define   BOX_ALL	'='		/*  Filled box		*/
-#define   BOX_TOP	'-'		/*  Filled upper half	*/
-#define   BOX_BOT	'_'		/*  Filled lower half   */
-#endif
-
-#if (CHIP == SPARC)
-/*  Please change these.  */
-#define   BOX_CLR	' '		/*  Empty box		*/
-#define   BOX_ALL	'='		/*  Filled box		*/
-#define   BOX_TOP	'-'		/*  Filled upper half	*/
-#define   BOX_BOT	'_'		/*  Filled lower half   */
-#endif
-
-/*  Move positions for the output display.  */
-
-#define   STATUS_COLUMN	 2
-#define   STATUS_LINE    0
-#define   BLOCK_COLUMN	 4
-#define   BLOCK_LINE	 4
-#define   INFO_COLUMN	 30
-#define   INFO_LINE	 BLOCK_LINE
-#define   PROMPT_COLUMN	 0
-#define   PROMPT_LINE	 23
-#define   WARNING_COLUMN 5
-#define   WARNING_LINE   10
-
-
-
-/*  Values returned by Process() and Get_Filename()  */
-
-#define   OK		  0		/*  No update required	*/
-#define   REDRAW	  1		/*  Redraw whole screen	*/
-#define   REDRAW_POINTERS 2		/*  Redraw just ptrs	*/
-#define   ERROR		  3		/*  Beep		*/
-
-
-/*  Visual modes  */
-
-#define   WORD	   1
-#define   BLOCK    2
-#define   MAP	   3
-
-typedef  unsigned short word_t;		/*  For most user i/o	*/
-#if _WORD_SIZE == 2
-typedef  unsigned int Word_t;		/*  What it should always be */
-#else
-typedef  int Word_t;			/*  Unsigned promotion under ANSI C */
-#endif
-
-#ifndef I_MAP_SLOTS
-/* Max number of inode and zone map blocks we can handle. */
-#define I_MAP_SLOTS	8
-#define Z_MAP_SLOTS	(sizeof(char *) == 2 ? 16 : 128)
-#endif
-
-typedef  struct  de_state		/*  State of disk ed.	*/
-  {
-  /*  Information from super block  */
-  /*  The types here are mostly promoted types for simplicity	*/
-  /*  and efficiency.						*/
-
-  unsigned inodes;			/*  Number of i-nodes	*/
-  zone_t zones;				/*  Total # of blocks	*/
-  unsigned inode_maps;			/*  I-node map blocks	*/
-  unsigned zone_maps;			/*  Zone map blocks	*/
-  unsigned inode_blocks;		/*  I-node blocks	*/
-  unsigned first_data;			/*  Total non-data blks	*/
-  int magic;				/*  Magic number	*/
-
-  /* Numbers derived from the magic number */  
-  
-  unsigned char is_fs;			/*  Nonzero for good fs	*/
-  unsigned char v1;			/*  Nonzero for V1 fs	*/
-  unsigned inode_size;			/*  Size of disk inode	*/
-  unsigned nr_indirects;		/*  # indirect blocks	*/
-  unsigned zone_num_size;		/*  Size of disk z num	*/
-  int block_size;			/*  FS block size       */
-
-  /* Other derived numbers */  
-  
-  bit_t inodes_in_map;			/*  Bits in i-node map	*/
-  bit_t zones_in_map;			/*  Bits in zone map	*/
-  int ndzones;				/*  # direct zones in an inode */
-
-  /*  Information from map blocks  */
-
-  bitchunk_t inode_map[ I_MAP_SLOTS * K / sizeof (bitchunk_t) ];
-  bitchunk_t zone_map[ Z_MAP_SLOTS * K / sizeof (bitchunk_t) ];
-
-  /*  Information for current block  */
-
-  off_t address;			/*  Current address	*/
-  off_t last_addr;			/*  For erasing ptrs	*/
-  zone_t block;				/*  Current block (1K)	*/
-  unsigned offset;			/*  Offset within block	*/
-
-  char buffer[ _MAX_BLOCK_SIZE ];
-
-  /*  Display state  */
-
-  int  mode;				/*  WORD, BLOCK or MAP	*/
-  int  output_base;			/*  2, 8, 10, or 16	*/
-
-  /*  Search information  */
-
-  char search_string[ MAX_STRING + 1 ];	/*  For '/' and 'n'	*/
-  off_t prev_addr[ MAX_PREV ];		/*  For 'p' command	*/
-  int   prev_mode[ MAX_PREV ];
-
-  /*  File information  */
-
-  char *device_name;			/*  From command line	*/
-  int   device_d;
-  int   device_mode;			/*  O_RDONLY or O_RDWR	*/
-  zone_t device_size;			/*  Number of blocks	*/
-
-  char  file_name[ MAX_STRING + 1 ];	/*  For 'w' and 'W'	*/
-  FILE *file_f;
-  int   file_written;			/*  Flag if written to	*/
-
-  }  de_state;
-
-
-
-/*  Forward references for external routines  */
-
-/*  de.c  */
-
-_PROTOTYPE(void main , (int argc , char *argv []));
-_PROTOTYPE(int Process , (de_state *s , int c ));
-
-#if __STDC__
-void  Error( const char *text, ... );
-#else
-void  Error();
-#endif
-
-_PROTOTYPE(int In_Use , (bit_t bit , bitchunk_t *map ));
-_PROTOTYPE(ino_t Find_Inode , (de_state *s , char *filename ));
-
-
-/*  de_stdin.c  */
-
-_PROTOTYPE(void Save_Term , (void));
-_PROTOTYPE(void Set_Term , (void));
-_PROTOTYPE(void Reset_Term , (void));
-_PROTOTYPE(int Get_Char , (void));
-_PROTOTYPE(char *Get_Line , (void));
-_PROTOTYPE(int Arrow_Esc , (int c ));
-
-/*  de_stdout.c  */
-
-_PROTOTYPE(int Init_Termcap , (void));
-_PROTOTYPE(void Draw_Help_Screen , (de_state *s ));
-_PROTOTYPE(void Wait_For_Key , (void));
-_PROTOTYPE(void Draw_Prompt , (char *string ));
-_PROTOTYPE(void Erase_Prompt , (void));
-
-_PROTOTYPE(void Draw_Screen , (de_state *s ));
-_PROTOTYPE(void Draw_Strings , (de_state *s ));
-_PROTOTYPE(void Draw_Pointers , (de_state *s ));
-_PROTOTYPE(void Print_Ascii , (int c ));
-
-_PROTOTYPE(void Goto , (int column , int line ));
-_PROTOTYPE(void Block_Type , (de_state *s ));
-_PROTOTYPE(void Draw_Words , (de_state *s ));
-_PROTOTYPE(void Draw_Info , (de_state *s ));
-_PROTOTYPE(void Draw_Block , (char *block ));
-_PROTOTYPE(void Draw_Map , (char *block , int max_bits ));
-_PROTOTYPE(void Draw_Offset , (de_state *s ));
-_PROTOTYPE(void Word_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Block_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Map_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Print_Number , (Word_t number , int output_base ));
-_PROTOTYPE(void Draw_Zone_Numbers , (de_state *s , struct inode *inode ,
-						int zindex , int zrow ));
-
-#if __STDC__
-void  Warning( const char *text, ... );
-#else
-void  Warning();
-#endif
-
-
-/*  de_diskio.c  */
-
-_PROTOTYPE(void Read_Disk , (de_state *s , off_t block_addr , char *buffer ));
-_PROTOTYPE(void Read_Block , (de_state *s , char *buffer ));
-_PROTOTYPE(void Read_Super_Block , (de_state *s ));
-_PROTOTYPE(void Read_Bit_Maps , (de_state *s ));
-_PROTOTYPE(off_t Search , (de_state *s , char *string ));
-_PROTOTYPE(void Write_Word , (de_state *s , Word_t word ));
-
-
-/*  de_recover.c  */
-
-_PROTOTYPE(int Path_Dir_File , (char *path_name , char **dir_name ,
-							char **file_name ));
-_PROTOTYPE(char *File_Device , (char *file_name ));
-_PROTOTYPE(ino_t Find_Deleted_Entry , (de_state *s , char *path_name ));
-_PROTOTYPE(off_t Recover_Blocks , (de_state *s ));
-
-
-#undef    printf			/*  Because fs/const.h	*/
-					/*  defines it.		*/
-
-
-/*  Static functions are all pre-declared FORWARD but none are	*/
-/*  declared static yet - this can wait until all functions are	*/
-/*  declared with prototypes.					*/
-
-#undef FORWARD
-#define FORWARD /* static */
Index: trunk/minix/commands/de/de_diskio.c
===================================================================
--- trunk/minix/commands/de/de_diskio.c	(revision 9)
+++ 	(revision )
@@ -1,352 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de_diskio.c						*/
-/*								*/
-/*		Reading and writing to a file system device.	*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-15        Terrence W. Holm	*/
-/****************************************************************/
-
-
-#include <minix/config.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <limits.h>
-#include <string.h>
-#include <dirent.h>
-
-#include <minix/const.h>
-#include <minix/type.h>
-#include "../../servers/fs/const.h"
-#include "../../servers/fs/type.h"
-#include "../../servers/fs/super.h"
-#include "../../servers/fs/inode.h"
-#include <minix/fslib.h>
-
-#include "de.h"
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Read_Disk( state, block_addr, buffer )			*/
-/*								*/
-/*		Reads a 1k block at "block_addr" into "buffer".	*/
-/*								*/
-/****************************************************************/
-
-
-void Read_Disk( s, block_addr, buffer )
-  de_state *s;
-  off_t  block_addr;
-  char  *buffer;
-
-  {
-  if ( lseek( s->device_d, block_addr, SEEK_SET ) == -1 )
-    Error( "Error seeking %s", s->device_name );
-
-  if ( read( s->device_d, buffer, s->block_size ) != s->block_size )
-    Error( "Error reading %s", s->device_name );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Read_Block( state, buffer )				*/
-/*								*/
-/*		Reads a 1k block from "state->address" into	*/
-/*		"buffer". Checks "address", and updates		*/
-/*		"block" and "offset".				*/
-/*								*/
-/****************************************************************/
-
-
-void Read_Block( s, buffer )
-  de_state *s;
-  char *buffer;
-
-  {
-  off_t end_addr;
-  off_t block_addr;
-  end_addr = (long) s->device_size * s->block_size - 1;
-
-  if ( s->address < 0 )
-    s->address = 0L;
-
-  if ( s->address > end_addr )
-    s->address = end_addr;
-
-  /*  The address must be rounded off for  */
-  /*  certain visual display modes.        */
-
-  if ( s->mode == WORD )
-    s->address &= ~1L;
-  else if ( s->mode == MAP )
-    s->address &= ~3L;
-
-
-  block_addr = s->address & K_MASK;
-
-  s->block  = (zone_t) (block_addr >> K_SHIFT);
-  s->offset = (unsigned) (s->address - block_addr);
-
-  Read_Disk( s, block_addr, buffer );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Read_Super_Block( state )				*/
-/*								*/
-/*		Read and check the super block.			*/
-/*								*/
-/****************************************************************/
-
-
-void Read_Super_Block( s )
-  de_state *s;
-
-  {
-  struct super_block *super = (struct super_block *) s->buffer;
-  unsigned inodes_per_block;
-  off_t size;
-
-  s->block_size = K;
-  Read_Disk( s, (long) SUPER_BLOCK_BYTES, s->buffer );
-
-  s->magic = super->s_magic;
-  if ( s->magic == SUPER_MAGIC )
-    {
-    s->is_fs = TRUE;
-    s->v1 = TRUE;
-    s->inode_size = V1_INODE_SIZE;
-    inodes_per_block = V1_INODES_PER_BLOCK;
-    s->nr_indirects = V1_INDIRECTS;
-    s->zone_num_size = V1_ZONE_NUM_SIZE;
-    s->zones = super->s_nzones;
-    s->ndzones = V1_NR_DZONES;
-    s->block_size = _STATIC_BLOCK_SIZE;
-    }
-  else if ( s->magic == SUPER_V2 || s->magic == SUPER_V3)
-    {
-    if(s->magic == SUPER_V3)
-    	s->block_size = super->s_block_size;
-    else
-    	s->block_size = _STATIC_BLOCK_SIZE;
-    s->is_fs = TRUE;
-    s->v1 = FALSE;
-    s->inode_size = V2_INODE_SIZE;
-    inodes_per_block = V2_INODES_PER_BLOCK(s->block_size);
-    s->nr_indirects = V2_INDIRECTS(s->block_size);
-    s->zone_num_size = V2_ZONE_NUM_SIZE;
-    s->zones = super->s_zones;
-    s->ndzones = V2_NR_DZONES;
-    }
-  else  
-    {
-    if ( super->s_magic == SUPER_REV )
-      Warning( "V1-bytes-swapped file system (?)" );
-    else if ( super->s_magic == SUPER_V2_REV )
-      Warning( "V2-bytes-swapped file system (?)" );
-    else  
-      Warning( "Not a Minix file system" );
-    Warning( "The file system features will not be available" );  
-    s->zones = 100000L;
-    return;
-    }
-
-  s->inodes = super->s_ninodes;
-  s->inode_maps = bitmapsize( (bit_t) s->inodes + 1 , s->block_size);
-  if ( s->inode_maps != super->s_imap_blocks )
-    {
-    if ( s->inode_maps > super->s_imap_blocks )
-      Error( "Corrupted inode map count or inode count in super block" );
-    else  
-      Warning( "Count of inode map blocks in super block suspiciously high" );
-    s->inode_maps = super->s_imap_blocks;
-    }
-
-  s->zone_maps = bitmapsize( (bit_t) s->zones , s->block_size);
-  if ( s->zone_maps != super->s_zmap_blocks )
-    {
-    if ( s->zone_maps > super->s_zmap_blocks )
-      Error( "Corrupted zone map count or zone count in super block" );
-    else
-      Warning( "Count of zone map blocks in super block suspiciously high" );
-    s->zone_maps = super->s_zmap_blocks;
-    }
-
-  s->inode_blocks = (s->inodes + inodes_per_block - 1) / inodes_per_block;
-  s->first_data   = 2 + s->inode_maps + s->zone_maps + s->inode_blocks;
-  if ( s->first_data != super->s_firstdatazone )
-  {
-    if ( s->first_data > super->s_firstdatazone )
-      Error( "Corrupted first data zone offset or inode count in super block" );
-    else
-      Warning( "First data zone in super block suspiciously high" );
-    s->first_data = super->s_firstdatazone;
-  }  
-
-  s->inodes_in_map = s->inodes + 1;
-  s->zones_in_map  = s->zones + 1 - s->first_data;
-
-  /*
-  if ( s->zones != s->device_size )
-    Warning( "Zone count does not equal device size" );
-  */
-
-  s->device_size = s->zones;
-
-  if ( super->s_log_zone_size != 0 )
-    Error( "Can not handle multiple blocks per zone" );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Read_Bit_Maps( state )					*/
-/*								*/
-/*		Read in the i-node and zone bit maps from the	*/
-/*		specified file system device.			*/
-/*								*/
-/****************************************************************/
-
-
-void Read_Bit_Maps( s )
-  de_state *s;
-
-  {
-  int i;
-
-  if ( s->inode_maps > I_MAP_SLOTS  ||  s->zone_maps > Z_MAP_SLOTS )
-    {
-    Warning( "Super block specifies too many bit map blocks" );
-    return;
-    }
-
-  for ( i = 0;  i < s->inode_maps;  ++i )
-    {
-    Read_Disk( s, (long) (2 + i) * K,
-	       (char *) &s->inode_map[ i * K / sizeof (bitchunk_t ) ] );
-    }
-
-  for ( i = 0;  i < s->zone_maps;  ++i )
-    {
-    Read_Disk( s, (long) (2 + s->inode_maps + i) * K,
-	       (char *) &s->zone_map[ i * K / sizeof (bitchunk_t ) ] );
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Search( state, string )					*/
-/*								*/
-/*		Search from the current address for the ASCII	*/
-/*		"string" on the device.				*/
-/*								*/
-/****************************************************************/
-
-
-off_t Search( s, string )
-  de_state *s;
-  char *string;
-
-  {
-  off_t address   = s->address + 1;
-  off_t last_addr = address;
-  char  buffer[ SEARCH_BUFFER ];
-  int   offset;
-  int   tail_length = strlen( string ) - 1;
-  int   count = SEARCH_BUFFER;
-  int   last_offset;
-
-
-  for (  ;  count == SEARCH_BUFFER;  address += SEARCH_BUFFER - tail_length )
-    {
-    if ( lseek( s->device_d, address, SEEK_SET ) == -1 )
-      Error( "Error seeking %s", s->device_name );
-
-    if ( (count = read( s->device_d, buffer, SEARCH_BUFFER)) == -1 )
-      Error( "Error reading %s", s->device_name );
-
-
-    if ( address - last_addr >= 500L * K )
-      {
-      putchar( '.' );
-      fflush( stdout );
-
-      last_addr += 500L * K;
-      }
-
-
-    last_offset = count - tail_length;
-
-    for ( offset = 0;  offset < last_offset;  ++offset )
-      {
-      register char c = buffer[ offset ];
-
-      if ( c == *string )
-	{
-	char *tail_buffer = &buffer[ offset + 1 ];
-	char *tail_string = string + 1;
-
-	do
-	  {
-	  if ( *tail_string == '\0' )
-	    return( address + offset );
-	  }
-          while ( *tail_buffer++ == *tail_string++ );
-        }
-      }  /*  end for ( offset )  */
-    }  /*  end for ( address )  */
-
-  return( -1L );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Write_Word( state, word )				*/
-/*								*/
-/*		Write a word at address.			*/
-/*								*/
-/****************************************************************/
-
-
-void Write_Word( s, word )
-  de_state *s;
-  word_t word;
-
-  {
-  if ( s->address & 01 )
-    Error( "Internal fault (unaligned address)" );
-
-  if ( lseek( s->device_d, s->address, SEEK_SET ) == -1 )
-    Error( "Error seeking %s", s->device_name );
-
-  if ( write( s->device_d, (char *) &word, sizeof word ) != sizeof word )
-    Error( "Error writing %s", s->device_name );
-  }
Index: trunk/minix/commands/de/de_recover.c
===================================================================
--- trunk/minix/commands/de/de_recover.c	(revision 9)
+++ 	(revision )
@@ -1,612 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de_recover.c						*/
-/*								*/
-/*		File restoration routines.			*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-21        Terrence W. Holm	*/
-/*  handle "holes"	1989-Jan-28	   Terrence W. Holm	*/
-/****************************************************************/
-
-
-#include <minix/config.h>
-#include <sys/types.h>
-#include <sys/dir.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <pwd.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <minix/const.h>
-#include <minix/type.h>
-#include "../../servers/fs/const.h"
-#include "../../servers/fs/type.h"
-#include "../../servers/fs/inode.h"
-#include <minix/fslib.h>
-
-#include "de.h"
-
-_PROTOTYPE(int Indirect, (de_state *s, zone_t block, off_t *size, int dblind));
-_PROTOTYPE(int Data_Block, (de_state *s, zone_t block, off_t *file_size ));
-_PROTOTYPE(int Free_Block, (de_state *s, zone_t block ));
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Path_Dir_File( path_name, dir_name, file_name )		*/
-/*								*/
-/*		Split "path_name" into a directory name and	*/
-/*		a file name.					*/
-/*								*/
-/*		Zero is returned on error conditions.		*/
-/*								*/
-/****************************************************************/
-
-
-int Path_Dir_File( path_name, dir_name, file_name )
-  char  *path_name;
-  char **dir_name;
-  char **file_name;
-
-  {
-  char *p;
-  static char directory[ MAX_STRING + 1 ];
-  static char filename[ MAX_STRING + 1 ];
-
-
-  if ( (p = strrchr( path_name, '/' )) == NULL )
-    {
-    strcpy( directory, "." );
-    strcpy( filename, path_name );
-    }
-  else
-    {
-    *directory = '\0';
-    strncat( directory, path_name, p - path_name );
-    strcpy( filename, p + 1 );
-    }
-
-  if ( *directory == '\0' )
-    strcpy( directory, "/" );
-
-  if ( *filename == '\0' )
-    {
-    Warning( "A file name must follow the directory name" );
-    return( 0 );
-    }
-
-  *dir_name  = directory;
-  *file_name = filename;
-
-  return( 1 );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	File_Device( file_name )				*/
-/*								*/
-/*		Return the name of the file system device	*/
-/*		containing the file "file_name".		*/
-/*								*/
-/*		This is used if the "-r" option was specified.	*/
-/*		In this case we have only been given a file	*/
-/*		name, and must determine which file system	*/
-/*		device to open.					*/
-/*								*/
-/*		NULL is returned on error conditions.		*/
-/*								*/
-/****************************************************************/
-
-
-
-char *File_Device( file_name )
-  char *file_name;
-
-  {
-  struct stat file_stat;
-  struct stat device_stat;
-  int dev_d;
-  struct direct entry;
-  static char device_name[ NAME_MAX + 1 ];
-
-
-  if ( access( file_name, R_OK ) != 0 )
-    {
-    Warning( "Can not find %s", file_name );
-    return( NULL );
-    }
-
-
-  if ( stat( file_name, &file_stat ) == -1 )
-    {
-    Warning( "Can not stat(2) %s", file_name );
-    return( NULL );
-    }
-
-
-  /*  Open /dev for reading  */
-
-  if ( (dev_d = open( DEV, O_RDONLY )) == -1 )
-    {
-    Warning( "Can not read %s", DEV );
-    return( NULL );
-    }
-
-
-  while ( read( dev_d, (char *) &entry, sizeof(struct direct) )
-				     == sizeof(struct direct) )
-    {
-    if ( entry.d_ino == 0 )
-      continue;
-
-    strcpy( device_name, DEV );
-    strcat( device_name, "/" );
-    strncat( device_name, entry.d_name, NAME_MAX );
-
-    if ( stat( device_name, &device_stat ) == -1 )
-      continue;
-
-    if ( (device_stat.st_mode & S_IFMT) != S_IFBLK )
-      continue;
-
-    if ( file_stat.st_dev == device_stat.st_rdev )
-      {
-      close( dev_d );
-      return( device_name );
-      }
-    }
-
-  close( dev_d );
-
-  Warning( "The device containing file %s is not in %s", file_name, DEV );
-
-  return( NULL );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Find_Deleted_Entry( state, path_name )			*/
-/*								*/
-/*		Split "path_name" into a directory name and	*/
-/*		a file name. Then search the directory for	*/
-/*		an entry that would match the deleted file	*/
-/*		name. (Deleted entries have a zero i-node	*/
-/*		number, but the original i-node number is 	*/
-/*		placed at the end of the file name.)		*/
-/*								*/
-/*		If successful an i-node number is returned,	*/
-/*		else zero is returned.				*/
-/*								*/
-/****************************************************************/
-
-
-ino_t Find_Deleted_Entry( s, path_name )
-  de_state *s;
-  char *path_name;
-
-  {
-  char *dir_name;
-  char *file_name;
-
-
-  /*  Check if the file exists  */
-
-  if ( access( path_name, F_OK ) == 0 )
-    {
-    Warning( "File has not been deleted" );
-    return( 0 );
-    }
-
-
-  /*  Split the path name into a directory and a file name  */
-
-  if ( ! Path_Dir_File( path_name, &dir_name, &file_name ) )
-    return( 0 );
-
-
-  /*  Check to make sure the user has read permission on  */
-  /*  the directory.					  */
-
-  if ( access( dir_name, R_OK ) != 0 )
-    {
-    Warning( "Can not find %s", dir_name );
-    return( 0 );
-    }
-
-
-  /*  Make sure "dir_name" is really a directory. */
-  {
-  struct stat dir_stat;
-
-  if ( stat( dir_name, &dir_stat ) == -1   ||
-		 (dir_stat.st_mode & S_IFMT) != S_IFDIR )
-    {
-    Warning( "Can not find directory %s", dir_name );
-    return( 0 );
-    }
-  }
-
-
-  /*  Make sure the directory is on the current  */
-  /*  file system device.                        */
-
-  if ( Find_Inode( s, dir_name ) == 0 )
-    return( 0 );
-
-
-  /*  Open the directory and search for the lost file name.  */
-  {
-  int   dir_d;
-  int   count;
-  struct direct entry;
-
-  if ( (dir_d = open( dir_name, O_RDONLY )) == -1 )
-    {
-    Warning( "Can not read directory %s", dir_name );
-    return( 0 );
-    }
-
-  while ( (count = read( dir_d, (char *) &entry, sizeof(struct direct) ))
-					      == sizeof(struct direct) )
-    {
-    if ( entry.d_ino == 0  &&
-	strncmp( file_name, entry.d_name, NAME_MAX - sizeof(ino_t) ) == 0 )
-      {
-      ino_t inode = *( (ino_t *) &entry.d_name[ NAME_MAX - sizeof(ino_t) ] );
-
-      close( dir_d );
-
-      if ( inode < 1  || inode > s->inodes )
-    	{
-    	Warning( "Illegal i-node number" );
-    	return( 0 );
-    	}
-
-      return( inode );
-      }
-    }
-
-  close( dir_d );
-
-  if ( count == 0 )
-    Warning( "Can not find a deleted entry for %s", file_name );
-  else
-    Warning( "Problem reading directory %s", dir_name );
-
-  return( 0 );
-  }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Recover_Blocks( state )					*/
-/*								*/
-/*		Try to recover all the blocks for the i-node	*/
-/*		currently pointed to by "s->address". The	*/
-/*		i-node and all of the blocks must be marked	*/
-/*		as FREE in the bit maps. The owner of the	*/
-/*		i-node must match the current real user name.	*/
-/*								*/
-/*		"Holes" in the original file are maintained.	*/
-/*		This allows moving sparse files from one device	*/
-/*		to another.					*/
-/*								*/
-/*		On any error -1L is returned, otherwise the	*/
-/*		size of the recovered file is returned.		*/
-/*								*/
-/*								*/
-/*		NOTE: Once a user has read access to a device,	*/
-/*		there is a security hole, as we lose the	*/
-/*		normal file system protection. For convenience,	*/
-/*		de(1) is sometimes set-uid root, this allows	*/
-/*		anyone to use the "-r" option. When recovering,	*/
-/*		Recover_Blocks() can only superficially check	*/
-/*		the validity of a request.			*/
-/*								*/
-/****************************************************************/
-
-
-off_t Recover_Blocks( s )
-  de_state *s;
-
-  {
-  struct inode core_inode;
-  d1_inode *dip1;
-  d2_inode *dip2;
-  struct inode *inode = &core_inode;
-  bit_t node = (s->address - (s->first_data - s->inode_blocks) * K) /
-		s->inode_size + 1;
-
-  dip1 = (d1_inode *) &s->buffer[ s->offset & ~ PAGE_MASK ];
-  dip2 = (d2_inode *) &s->buffer[ s->offset & ~ PAGE_MASK
-					    & ~ (V2_INODE_SIZE-1) ];
-  conv_inode( inode, dip1, dip2, READING, s->magic );
-
-  if ( s->block < s->first_data - s->inode_blocks  ||
-	    s->block >= s->first_data )
-    {
-    Warning( "Not in an inode block" );
-    return( -1L );
-    }
-
-
-  /*  Is this a valid, but free i-node?  */
-
-  if ( node > s->inodes )
-    {
-    Warning( "Not an inode" );
-    return( -1L );
-    }
-
-  if ( In_Use(node, s->inode_map) )
-    {
-    Warning( "I-node is in use" );
-    return( -1L );
-    }
-
-
-  /*  Only recover files that belonged to the real user.  */
-
-  {
-  uid_t real_uid = getuid();
-  struct passwd *user = getpwuid( real_uid );
-
-  if ( real_uid != SU_UID  &&  real_uid != inode->i_uid )
-    {
-    Warning( "I-node did not belong to user %s", user ? user->pw_name : "" );
-    return( -1L );
-    }
-  }
-
-
-  /*  Recover all the blocks of the file.  */
-
-  {
-  off_t file_size = inode->i_size;
-  int i;
-
-
-  /*  Up to s->ndzones pointers are stored in the i-node.  */
-
-  for ( i = 0;  i < s->ndzones;  ++i )
-    {
-    if ( file_size == 0 )
-	return( inode->i_size );
-
-    if ( ! Data_Block( s, inode->i_zone[ i ], &file_size ) )
-      return( -1L );
-    }
-
-  if ( file_size == 0 )
-    return( inode->i_size );
-
-
-  /*  An indirect block can contain up to inode->i_indirects more blk ptrs.  */
-
-  if ( ! Indirect( s, inode->i_zone[ s->ndzones ], &file_size, 0 ) )
-    return( -1L );
-
-  if ( file_size == 0 )
-    return( inode->i_size );
-
-
-  /*  A double indirect block can contain up to inode->i_indirects blk ptrs. */
-
-  if ( ! Indirect( s, inode->i_zone[ s->ndzones+1 ], &file_size, 1 ) )
-    return( -1L );
-
-  if ( file_size == 0 )
-    return( inode->i_size );
-
-  Error( "Internal fault (file_size != 0)" );
-  }
-
-  /* NOTREACHED */
-  return( -1L );
-  }
-
-
-
-
-
-
-/*  Indirect( state, block, &file_size, double )
- *
- *  Recover all the blocks pointed to by the indirect block
- *  "block",  up to "file_size" bytes. If "double" is true,
- *  then "block" is a double-indirect block pointing to
- *  V*_INDIRECTS indirect blocks.
- *
- *  If a "hole" is encountered, then just seek ahead in the
- *  output file.
- */
-
-
-int Indirect( s, block, file_size, dblind )
-  de_state *s;
-  zone_t   block;
-  off_t    *file_size;
-  int       dblind;
-
-  {
-  union
-    {
-    zone1_t ind1[ V1_INDIRECTS ];
-    zone_t  ind2[ V2_INDIRECTS(_MAX_BLOCK_SIZE) ];
-    } indirect;
-  int  i;
-  zone_t zone;
-
-  /*  Check for a "hole".  */
-
-  if ( block == NO_ZONE )
-    {
-    off_t skip = (off_t) s->nr_indirects * K;
-
-    if ( *file_size < skip  ||  dblind )
-      {
-      Warning( "File has a hole at the end" );
-      return( 0 );
-      }
-
-    if ( fseek( s->file_f, skip, SEEK_CUR ) == -1 )
-      {
-      Warning( "Problem seeking %s", s->file_name );
-      return( 0 );
-      }
-
-    *file_size -= skip;
-    return( 1 );
-    }
-
-
-  /*  Not a "hole". Recover indirect block, if not in use.  */
-
-  if ( ! Free_Block( s, block ) )
-    return( 0 );
-
-
-  Read_Disk( s, (long) block << K_SHIFT, (char *) &indirect );
-
-  for ( i = 0;  i < s->nr_indirects;  ++i )
-    {
-    if ( *file_size == 0 )
-	return( 1 );
-
-    zone = (s->v1 ? indirect.ind1[ i ] : indirect.ind2[ i ]);
-    if ( dblind )
-      {
-      if ( ! Indirect( s, zone, file_size, 0 ) )
-	return( 0 );
-      }
-    else
-      {
-      if ( ! Data_Block( s, zone, file_size ) )
-        return( 0 );
-      }
-    }
-
-  return( 1 );
-  }
-
-
-
-
-
-
-/*  Data_Block( state, block, &file_size )
- *
- *  If "block" is free then write  Min(file_size, k)
- *  bytes from it onto the current output file.
- *
- *  If "block" is zero, this means that a 1k "hole"
- *  is in the file. The recovered file maintains
- *  the reduced size by not allocating the block.
- *
- *  The file size is decremented accordingly.
- */
-
-
-int Data_Block( s, block, file_size )
-  de_state *s;
-  zone_t   block;
-  off_t    *file_size;
-
-  {
-  char buffer[ K ];
-  off_t block_size = *file_size > K ? K : *file_size;
-
-
-  /*  Check for a "hole".  */
-
-  if ( block == NO_ZONE )
-    {
-    if ( block_size < K )
-      {
-      Warning( "File has a hole at the end" );
-      return( 0 );
-      }
-
-    if ( fseek( s->file_f, block_size, SEEK_CUR ) == -1 )
-      {
-      Warning( "Problem seeking %s", s->file_name );
-      return( 0 );
-      }
-
-    *file_size -= block_size;
-    return( 1 );
-    }
-
-
-  /*  Block is not a "hole". Copy it to output file, if not in use.  */
-
-  if ( ! Free_Block( s, block ) )
-    return( 0 );
-
-  Read_Disk( s, (long) block << K_SHIFT, buffer );
-
-
-  if ( fwrite( buffer, 1, (size_t) block_size, s->file_f )
-       != (size_t) block_size )
-    {
-    Warning( "Problem writing %s", s->file_name );
-    return( 0 );
-    }
-
-  *file_size -= block_size;
-  return( 1 );
-  }
-
-
-
-
-
-
-/*  Free_Block( state, block )
- *
- *  Make sure "block" is a valid data block number, and it
- *  has not been allocated to another file.
- */
-
-
-int Free_Block( s, block )
-  de_state *s;
-  zone_t  block;
-
-  {
-  if ( block < s->first_data  ||  block >= s->zones )
-    {
-    Warning( "Illegal block number" );
-    return( 0 );
-    }
-
-  if ( In_Use( (bit_t) (block - (s->first_data - 1)), s->zone_map ) )
-    {
-    Warning( "Encountered an \"in use\" data block" );
-    return( 0 );
-    }
-
-  return( 1 );
-  }
-
Index: trunk/minix/commands/de/de_stdin.c
===================================================================
--- trunk/minix/commands/de/de_stdin.c	(revision 9)
+++ 	(revision )
@@ -1,298 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de_stdin.c						*/
-/*								*/
-/*		Processing input from the "de" user.		*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-15        Terrence W. Holm	*/
-/****************************************************************/
-
-
-#include <sys/types.h>
-#include <termios.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include <minix/config.h>
-#include <minix/const.h>
-#include "../../servers/fs/const.h"
-#include "../../servers/fs/inode.h"
-
-#include "de.h"
-
-FORWARD _PROTOTYPE(int Timed_Get_Char , (int time ));
-FORWARD _PROTOTYPE(void Timed_Out , (int sig));
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Save_Term()						*/
-/*								*/
-/*		Save the current terminal characteristics.	*/
-/*								*/
-/*								*/
-/*	Set_Term()						*/
-/*								*/
-/*		Set up the terminal characteristics.		*/
-/*								*/
-/*								*/
-/*	Reset_Term()						*/
-/*								*/
-/*		Restore the terminal characteristics.		*/
-/*								*/
-/****************************************************************/
-
-
-static struct termios saved_term;
-
-
-void Save_Term()
-
-  {
-  tcgetattr( 0, &saved_term );
-  }
-
-
-
-
-void Set_Term()
-
-  {
-  struct termios term;
-
-  term = saved_term;
-
-
-  /*  No tab expansion, no echo, don't map ^M to ^J, cbreak mode  */
-
-  term.c_iflag &= ~ICRNL;
-  term.c_oflag &= ~OPOST;
-  term.c_lflag &= ~ICANON & ~ECHO;
-
-
-  /*  Change the interrupt character to ^C  */
-
-  term.c_cc[VINTR] = '\003';
-
-  tcsetattr( 0, TCSANOW, &term );
-  }
-
-
-
-
-void Reset_Term()
-
-  {
-  tcsetattr( 0, TCSANOW, &saved_term );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Get_Char()						*/
-/*								*/
-/*		Return the next input character. Escape		*/
-/*		sequences are mapped to special codes.		*/
-/*								*/
-/****************************************************************/
-
-
-int Get_Char()
-  {
-  int c;
-  static int unget_char = EOF;
-
-
-  /*  Flush the output to the screen before waiting  */
-  /*  for input from the user.			     */
-
-  fflush( stdout );
-
-  if ( unget_char == EOF )
-    {
-    while ( (c = Timed_Get_Char( 60 * 60 )) < EOF )
-      printf( "%c", BELL );
-    }
-  else
-    {
-    c = unget_char;
-    unget_char = EOF;
-    }
-
-  if ( c == EOF )
-    return( EOF );
-
-  if ( c != ESCAPE )
-    return( c );
-
-  if ( (c = Timed_Get_Char( 1 )) <= EOF )
-    return( ESCAPE );
-
-  if ( c != '[' )
-    {
-    unget_char = c;
-    return( ESCAPE );
-    }
-
-  if ( (c = Timed_Get_Char( 1 )) <= EOF )
-    {
-    unget_char = '[';
-    return( ESCAPE );
-    }
-
-  return( c | 0x80 );   /* Flag ESC [ x  */
-  }
-
-
-
-
-
-
-int Timed_Get_Char( time )
-  int time;
-
-  {
-  char c;
-  int  count;
-
-  signal( SIGALRM, Timed_Out );
-
-  alarm( time );
-  count = read( 0, &c, 1 );
-  alarm( 0 );
-
-  if ( count <= 0 )
-    return( EOF + count );
-
-  return( c & 0x7f );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Get_Line()						*/
-/*								*/
-/*		Read a line from the user. Returns a pointer	*/
-/*		to a local buffer, or NULL if DEL or a non-	*/
-/*		ASCII character was typed. Processes ^H and	*/
-/*		^U. ^M terminates the input.			*/
-/*								*/
-/****************************************************************/
-
-
-char *Get_Line()
-
-  {
-  int c;
-  int i;
-  static char line[ MAX_STRING + 1 ];
-
-  for ( i = 0;  i <= MAX_STRING;  ++i )
-    {
-    c = Get_Char();
-
-    if ( c == EOF  ||  c == DEL  ||  (c & 0x80) )
-	return( NULL );
-
-    if ( c == BS )
-	{
-	if ( --i >= 0 )
-	  {
-	  printf( "\b \b" );
-	  --i;
-	  }
-	}
-
-    else if ( c == CTRL_U )
-	{
-	for ( --i;  i >= 0;  --i )
-	  printf( "\b \b" );
-	}
-
-    else if ( c == '\r' )
-	{
-	line[ i ] = '\0';
-	return( line );
-	}
-
-    else if ( i < MAX_STRING )
-	{
-	line[ i ] = c;
-	Print_Ascii( c );
-	}
-
-    else  /*  Line buffer is full, don't add any more to it.  */
-	{
-	putchar( BELL );
-	--i;
-	}
-    }
-
-  Error( "Internal fault (line buffer overflow)" );
-
-  /* NOTREACHED */
-  return( NULL );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Arrow_Esc( char )					*/
-/*								*/
-/*		If the keyboard does not generate Ansi escape	*/
-/*		codes for the arrow keys, but does generate	*/
-/*		single byte control codes, then map these	*/
-/*		codes to the special characters we are using	*/
-/*		to denote the Ansi escape codes.		*/
-/*								*/
-/****************************************************************/
-
-
-extern  char   Kup;		/* (ku) - Up arrow key		*/
-extern  char   Kdown;		/* (kd) - Down arrow key	*/
-extern  char   Kleft;		/* (kl) - Left arrow key	*/
-extern  char   Kright;		/* (kr) - Right arrow key	*/
-
-
-int Arrow_Esc( c )
-  int c;
-
-  {
-  if ( c == Kup )
-    return( ESC_UP );
-
-  if ( c == Kdown )
-    return( ESC_DOWN );
-
-  if ( c == Kleft )
-    return( ESC_LEFT );
-
-  if ( c == Kright )
-    return( ESC_RIGHT );
-
-  return( c );
-  }
-
-void Timed_Out(sig)
-int sig;
-  {}
-
-/*
- * $PchHeader: /mount/hd2/minix/sys/cmd/de/RCS/de_stdin.c,v 1.3 1995/02/10 08:01:30 philip Exp $
- */
Index: trunk/minix/commands/de/de_stdout.c
===================================================================
--- trunk/minix/commands/de/de_stdout.c	(revision 9)
+++ 	(revision )
@@ -1,1173 +1,0 @@
-/****************************************************************/
-/*								*/
-/*	de_stdout.c						*/
-/*								*/
-/*		Displaying information from the "Disk editor".	*/
-/*								*/
-/****************************************************************/
-/*  origination         1989-Jan-15        Terrence W. Holm	*/
-/****************************************************************/
-
-
-#include <minix/config.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <grp.h>
-#include <pwd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termcap.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <minix/const.h>
-#include <minix/type.h>
-#include "../../servers/fs/const.h"
-#include "../../servers/fs/type.h"
-#include "../../servers/fs/inode.h"
-#include <minix/fslib.h>
-
-#include "de.h"
-
-#ifndef major
-#define major(x) ( (x>>8) & 0377)
-#define minor(x) (x & 0377)
-#endif
-
-/****************************************************************/
-/*   		Code for handling termcap			*/
-/****************************************************************/
-
-
-#define  TC_BUFFER  1024	/* Size of termcap(3) buffer	*/
-#define  TC_STRINGS  200	/* Enough room for cm,cl,so,se	*/
-
-
-static  char  *Tmove;		/* (cm) - Format for tgoto	*/
-static  char  *Tclr_all;	/* (cl) - Clear screen  	*/
-static  char  *Treverse;	/* (so) - Start reverse mode 	*/
-static  char  *Tnormal;		/* (se) - End reverse mode	*/
-
-char   Kup    = 0;		/* (ku) - Up arrow key		*/
-char   Kdown  = 0;		/* (kd) - Down arrow key	*/
-char   Kleft  = 0;		/* (kl) - Left arrow key	*/
-char   Kright = 0;		/* (kr) - Right arrow key	*/
-
-_PROTOTYPE(void Goto , (int column , int line ));
-_PROTOTYPE(void Block_Type , (de_state *s ));
-_PROTOTYPE(void Draw_Words , (de_state *s ));
-_PROTOTYPE(void Draw_Info , (de_state *s ));
-_PROTOTYPE(void Draw_Block , (char *block ));
-_PROTOTYPE(void Draw_Map , (char *block , int max_bits ));
-_PROTOTYPE(void Draw_Offset , (de_state *s ));
-_PROTOTYPE(void Word_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Block_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Map_Pointers , (off_t old_addr , off_t new_addr ));
-_PROTOTYPE(void Print_Number , (Word_t number , int output_base ));
-_PROTOTYPE(void Draw_Zone_Numbers , (de_state *s , struct inode *inode ,
-						int zindex , int zrow ));
-
-
-
-/****************************************************************/
-/*								*/
-/*	Init_Termcap()						*/
-/*								*/
-/*		Initializes the external variables for the	*/
-/*		current terminal.				*/
-/*								*/
-/****************************************************************/
-
-
-int Init_Termcap()
-
-  {
-  char  *term;
-  char   buffer[ TC_BUFFER ];
-  static char strings[ TC_STRINGS ];
-  char  *s = &strings[0];
-  char  *Kcode;
-
-
-  term = getenv( "TERM" );
-
-  if ( term == NULL )
-    return( 0 );
-
-  if ( tgetent( buffer, term ) != 1 )
-    return( 0 );
-
-
-  if ( (Tmove = tgetstr( "cm", &s )) == NULL )
-    return( 0 );
-
-  if ( (Tclr_all = tgetstr( "cl", &s )) == NULL )
-    return( 0 );
-
-  if ( (Treverse = tgetstr( "so", &s )) == NULL )
-    {
-    Treverse = Tnormal = s;
-    *s = '\0';
-    ++s;
-    }
-  else if ( (Tnormal = tgetstr( "se", &s )) == NULL )
-    return( 0 );
-
-
-  /*  See if there are single character arrow key codes  */
-
-  if ( (Kcode = tgetstr( "ku", &s )) != NULL  &&  strlen( Kcode ) == 1 )
-    Kup = Kcode[0];
-
-  if ( (Kcode = tgetstr( "kd", &s )) != NULL  &&  strlen( Kcode ) == 1 )
-    Kdown = Kcode[0];
-
-  if ( (Kcode = tgetstr( "kl", &s )) != NULL  &&  strlen( Kcode ) == 1 )
-    Kleft = Kcode[0];
-
-  if ( (Kcode = tgetstr( "kr", &s )) != NULL  &&  strlen( Kcode ) == 1 )
-    Kright = Kcode[0];
-
-
-  return( 1 );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Goto( column, line )					*/
-/*								*/
-/*		Use the termcap string to move the cursor.	*/
-/*								*/
-/****************************************************************/
-
-
-void Goto( column, line )
-  int  column;
-  int  line;
-
-  {
-  fputs( tgoto( Tmove, column, line ), stdout );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*   		       Output routines				*/
-/****************************************************************/
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Help_Screen()					*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Help_Screen( s )
-  de_state *s;
-
-  {
-  int down;
-  int right;
-
-  switch ( s->mode )
-    {
-    case WORD  :   down = 2;    right = 32;  break;
-    case BLOCK :   down = 64;   right = 1;   break;
-    case MAP   :   down = 256;  right = 4;   break;
-    }
-
-  printf( "%s                             ", Tclr_all );
-  printf( "%sDE  COMMANDS%s\r\n\n\n", Treverse, Tnormal );
-
-
-  printf( "   PGUP   b   Back one block              h   Help\r\n" );
-  printf( "   PGDN   f   Forward one block           q   Quit\r\n" );
-  printf( "   HOME   B   Goto first block            m   Minix shell\r\n" );
-  printf( "   END    F   Goto last block\r\n" );
-  printf( "                                          v   Visual mode (w b m)\r\n" );
-  printf( "          g   Goto specified block        o   Output base (h d o b)\r\n" );
-  printf( "          G   Goto block indirectly\r\n" );
-  printf( "          i   Goto i-node                 c   Change file name\r\n" );
-  printf( "          I   Filename to i-node          w   Write ASCII block\r\n" );
-  printf( "                                          W   Write block exactly\r\n" );
-  printf( "          /   Search\r\n" );
-  printf( "          n   Next occurrence             x   Extract lost entry\r\n" );
-  printf( "          p   Previous address            X   Extract lost blocks\r\n" );
-  printf( "                                          s   Store word\r\n" );
-  printf( "   UP     u   Move back %d bytes\r\n", down );
-  printf( "   DOWN   d   Move forward %d bytes\r\n", down );
-  printf( "   LEFT   l   Move back %d byte%s\r\n", right,
-					right == 1 ? "" : "s" );
-  printf( "   RIGHT  r   Move forward %d byte%s\r\n\n\n", right,
-					right == 1 ? "" : "s" );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Wait_For_Key()						*/
-/*								*/
-/*		The user must press a key to continue.		*/
-/*								*/
-/****************************************************************/
-
-
-void Wait_For_Key()
-
-  {
-  Draw_Prompt( "Press a key to continue..." );
-
-  Get_Char();
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Prompt( string )					*/
-/*								*/
-/*		Write a message in the "prompt" area.		*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Prompt( string )
-  char  *string;
-
-  {
-  Goto( PROMPT_COLUMN, PROMPT_LINE );
-
-  printf( "%s%s%s ", Treverse, string, Tnormal );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Erase_Prompt()						*/
-/*								*/
-/*		Erase the message in the "prompt" area.		*/
-/*								*/
-/****************************************************************/
-
-
-void Erase_Prompt()
-
-  {
-  Goto( PROMPT_COLUMN, PROMPT_LINE );
-
-  printf( "%77c", ' ' );
-
-  Goto( PROMPT_COLUMN, PROMPT_LINE );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Screen( state )					*/
-/*								*/
-/*		Redraw everything, except pointers.		*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Screen( s )
-  de_state *s;
-
-  {
-  fputs( Tclr_all, stdout );
-
-  Draw_Strings( s );
-  Block_Type( s );
-
-  switch ( s->mode )
-    {
-    case WORD :   Draw_Words( s );
-		  Draw_Info( s );
-		  break;
-
-    case BLOCK :  Draw_Block( s->buffer );
-		  break;
-
-    case MAP :	  {
-		  int max_bits = 2 * K;
-
-		  /*  Don't display the bits after the end  */
-		  /*  of the i-node or zone bit maps.	    */
-
-		  if ( s->block == 2 + s->inode_maps - 1 )
-		    max_bits = (int)
-			       (s->inodes_in_map
-				- CHAR_BIT * K * (ino_t) (s->inode_maps - 1)
-				- CHAR_BIT * (ino_t) (s->offset & ~ MAP_MASK));
-
-		  else if ( s->block == 2 + s->inode_maps + s->zone_maps - 1 )
-		    max_bits = (int)
-			       (s->zones_in_map
-			        - CHAR_BIT * K * (zone_t) (s->zone_maps - 1)
-				- CHAR_BIT * (zone_t) (s->offset & ~ MAP_MASK));
-
-		  if ( max_bits < 0 )
-		      max_bits = 0;
-
-		  Draw_Map( &s->buffer[ s->offset & ~ MAP_MASK ], max_bits );
-		  break;
-		  }
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Strings( state )					*/
-/*								*/
-/*		The first status line contains the device name,	*/
-/*		the current write file name (if one is open)	*/
-/*		and the current search string (if one has	*/
-/*		been defined).					*/
-/*								*/
-/*		Long strings are truncated.			*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Strings( s )
-  de_state *s;
-
-  {
-  int len;
-  int i;
-
-  Goto( STATUS_COLUMN, STATUS_LINE );
-
-  printf( "Device %s= %-14.14s  ",
-	     s->device_mode == O_RDONLY ? "" : "(w) ", s->device_name );
-
-  switch ( s->magic )
-    {
-    case SUPER_MAGIC :	printf( "V1 file system  ");
-			break;
-    case SUPER_REV :	printf( "V1-bytes-swapped file system (?)  ");
-			break;
-    case SUPER_V2 :	printf( "V2 file system  ");
-			break;
-    case SUPER_V2_REV :	printf( "V2-bytes-swapped file system (?)  ");
-			break;
-    case SUPER_V3 :	printf( "V3 file system  ");
-			break;
-    default :		printf( "not a Minix file system  ");
-			break;
-    }
-
-  len = strlen( s->file_name );
-
-  if ( len == 0 )
-    printf( "%29s", " " );
-  else if ( len <= 20 )
-    printf( "File = %-20s  ", s->file_name );
-  else
-    printf( "File = ...%17.17s  ", s->file_name + len - 17 );
-
-
-  len = strlen( s->search_string );
-
-  if ( len == 0 )
-    printf( "%20s", " " );
-  else
-    {
-    printf( "Search = " );
-
-    if ( len <= 11 )
-      {
-      for ( i = 0;  i < len;  ++i )
-        Print_Ascii( s->search_string[ i ] );
-
-      for ( ;  i < 11;  ++i )
-	putchar( ' ' );
-      }
-    else
-      {
-      for ( i = 0;  i < 8;  ++i )
-        Print_Ascii( s->search_string[ i ] );
-
-      printf( "..." );
-      }
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Block_Type( state )					*/
-/*								*/
-/*		Display the current block type.			*/
-/*								*/
-/****************************************************************/
-
-
-void Block_Type( s )
-  de_state *s;
-
-  {
-  Goto( STATUS_COLUMN, STATUS_LINE + 1 );
-
-  printf( "Block  = %5u of %-5u  ", s->block, s->zones );
-
-  if ( !s->is_fs )
-    return;
-
-  if ( s->block == BOOT_BLOCK )
-    printf( "Boot block" );
-
-  else if ( s->block == 1 )
-    printf( "Super block" );
-
-  else if ( s->block < 2 + s->inode_maps )
-    printf( "I-node bit map" );
-
-  else if ( s->block < 2 + s->inode_maps + s->zone_maps )
-    printf( "Zone bit map" );
-
-  else if ( s->block < s->first_data )
-    printf( "I-nodes" );
-
-  else
-    printf( "Data block  (%sin use)",
-	In_Use( (bit_t) (s->block - (s->first_data - 1)), s->zone_map )
-	? "" : "not " );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Words( state )					*/
-/*								*/
-/*		Draw a page in word format.			*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Words( s )
-  de_state *s;
-
-  {
-  int line;
-  int addr = s->offset & ~ PAGE_MASK;
-
-
-  for ( line = 0;  line < 16;  ++line, addr += 2 )
-    {
-    Goto( BLOCK_COLUMN, BLOCK_LINE + line );
-
-    printf( "%5d  ", addr );
-
-    Print_Number( *( (word_t *) &s->buffer[ addr ] ), s->output_base );
-    }
-
-  Goto( BLOCK_COLUMN + 64, BLOCK_LINE  );
-  printf( "(base %d)", s->output_base );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Info( state )					*/
-/*								*/
-/*		Add information to a page drawn in word format.	*/
-/*		The routine recognizes the super block, inodes,	*/
-/*		executables and "ar" archives. If the current	*/
-/*		page is not one of these, then ASCII characters	*/
-/*		are printed from the data words.		*/
-/*								*/
-/****************************************************************/
-
-
-char *super_block_info[] =  {	"number of inodes",
-				"V1 number of zones",
-				"inode bit map blocks",
-				"zone bit map blocks",
-				"first data zone",
-				"blocks per zone shift & flags",
-				"maximum file size",
-				"",
-				"magic number",
-				"fsck magic number",
-				"V2 number of zones"  };
-
-
-void Draw_Info( s )
-  de_state *s;
-
-  {
-  int i;
-  int page = s->offset >> PAGE_SHIFT;
-  dev_t dev;
-
-
-  if ( s->is_fs  &&  s->block == 1  &&  page == 0 )
-      for ( i = 0;  i < 11;  ++i )
- 	{
-	Goto( INFO_COLUMN, INFO_LINE + i );
-	printf( "%s", super_block_info[ i ] );
-	}
-
-  else if ( s->is_fs  &&  s->block >= s->first_data - s->inode_blocks  &&
-	    s->block < s->first_data )
-      {
-      struct inode core_inode;
-      d1_inode *dip1;
-      d2_inode *dip2;
-      struct inode *inode = &core_inode;
-      int special = 0;
-      int m;
-      struct passwd *user;
-      struct group *grp;
-
-      dip1 = (d1_inode *) &s->buffer[ s->offset & ~ PAGE_MASK ];
-      dip2 = (d2_inode *) &s->buffer[ s->offset & ~ PAGE_MASK
-						& ~ (V2_INODE_SIZE-1) ];
-      conv_inode( inode, dip1, dip2, READING, s->magic );
-
-      user = getpwuid( inode->i_uid );
-      grp  = getgrgid( inode->i_gid );
-
-      if ( s->magic != SUPER_MAGIC  &&  page & 1 )
-	{
-	Draw_Zone_Numbers( s, inode, 2, 0 );
-	return;
-	}
-
-      Goto( INFO_COLUMN, INFO_LINE  );
-
-      switch( inode->i_mode & S_IFMT )
-    	{
-    	case S_IFDIR :  printf( "directory  " );
-		    	break;
-
-    	case S_IFCHR :  printf( "character  " );
-		    	special = 1;
-		    	break;
-
-    	case S_IFBLK :  printf( "block  " );
-		   	special = 1;
-		    	break;
-
-    	case S_IFREG :  printf( "regular  " );
-		    	break;
-#ifdef S_IFIFO
-    	case S_IFIFO :  printf( "fifo  " );
-		    	break;
-#endif
-#ifdef S_IFLNK
-    	case S_IFLNK :  printf( "symlink  " );
-		    	break;
-#endif
-#ifdef S_IFSOCK
-    	case S_IFSOCK:  printf( "socket  " );
-		    	break;
-#endif
-    	default      :  printf( "unknown  " );
-    	}
-
-	for ( m = 11;  m >= 0;  --m )
-	  putchar( (inode->i_mode & (1<<m)) ? "xwrxwrxwrtgu"[m] : '-' );
-
-	if ( s->magic == SUPER_MAGIC )
-	  {
-	  /* V1 file system */
-	  Goto( INFO_COLUMN, INFO_LINE + 1 );
-	  printf( "user %s", user ? user->pw_name : "" );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 2 );
-	  printf( "file size %lu", inode->i_size );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 4 );
-	  printf( "m_time %s", ctime( &inode->i_mtime ) );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 6 );
-	  printf( "links %d, group %s",
-		  inode->i_nlinks, grp ? grp->gr_name : "" );
-
-	  Draw_Zone_Numbers( s, inode, 0, 7 );
-	  }
-	else
-	  {
-	  /* V2 file system, even page. */
-	  Goto( INFO_COLUMN, INFO_LINE + 1 );
-	  printf( "links %d ", inode->i_nlinks);
-
-	  Goto( INFO_COLUMN, INFO_LINE + 2 );
-	  printf( "user %s", user ? user->pw_name : "" );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 3 );
-	  printf( "group %s", grp ? grp->gr_name : "" );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 4 );
-	  printf( "file size %lu", inode->i_size );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 6 );
-	  printf( "a_time %s", ctime( &inode->i_atime ) );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 8 );
-	  printf( "m_time %s", ctime( &inode->i_mtime ) );
-
-	  Goto( INFO_COLUMN, INFO_LINE + 10 );
-	  printf( "c_time %s", ctime( &inode->i_ctime ) );
-
-	  Draw_Zone_Numbers( s, inode, 0, 12 );
-	}
-
-      if ( special )
-	{
-	Goto( INFO_COLUMN, INFO_LINE + 7 );
-	dev = (dev_t) inode->i_zone[0];
-	printf( "major %d, minor %d", major(dev), minor(dev) );
-	}
-      }
-
-  else  /*  Print ASCII characters for each byte in page  */
-      {
-      char *p = &s->buffer[ s->offset & ~ PAGE_MASK ];
-
-      for ( i = 0;  i < 16;  ++i )
-        {
-        Goto( INFO_COLUMN, INFO_LINE + i );
-        Print_Ascii( *p++ );
-        Print_Ascii( *p++ );
-        }
-
-      if ( s->block >= s->first_data  &&  page == 0 )
-	{
-	unsigned magic  = ((s->buffer[1] & 0xff) << 8) | (s->buffer[0] & 0xff);
-	unsigned second = ((s->buffer[3] & 0xff) << 8) | (s->buffer[2] & 0xff);
-
-	/*  Is this block the start of an executable file?  */
-
-	if ( magic == (unsigned) A_OUT )
-	  {
-          Goto( INFO_COLUMN, INFO_LINE );
-	  printf( "executable" );
-
-          Goto( INFO_COLUMN, INFO_LINE + 1 );
-
-	  if ( second == (unsigned) SPLIT )
-	    printf( "separate I & D" );
-	  else
-	    printf( "combined I & D" );
-	  }
-	}
-      }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Block( block )					*/
-/*								*/
-/*		Redraw a 1k block in character format.		*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Block( block )
-  char *block;
-
-  {
-  int line;
-  int column;
-  int reverse = 0;
-  int msb_flag = 0;
-
-
-  for ( line = 0;  line < 16;  ++line )
-    {
-    Goto( BLOCK_COLUMN, BLOCK_LINE + line );
-
-    for ( column = 0;  column < 64;  ++column )
-      {
-      char c = *block++;
-
-      if ( c & 0x80 )
-	{
-	msb_flag = 1;
-	c &= 0x7f;
-	}
-
-      if ( c >= ' '  &&  c < DEL )
-	{
-	if ( reverse )
-	  { fputs( Tnormal, stdout ); reverse = 0; }
-
-        putchar( c );
-	}
-      else
-	{
-	if ( ! reverse )
-	  { fputs( Treverse, stdout ); reverse = 1; }
-
-	putchar( c == DEL ? '?' : '@' + c );
-	}
-      }  /*  end for ( column )  */
-    }  /*  end for ( line )  */
-
-  if ( reverse )
-    { fputs( Tnormal, stdout ); reverse = 0; }
-
-  if ( msb_flag )
-    {
-    Goto( BLOCK_COLUMN + 68, BLOCK_LINE + 6 );
-    fputs( "(MSB)", stdout );
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Map( block, max_bits )				*/
-/*								*/
-/*		Redraw a block in a bit map format.		*/
-/*		Display min( max_bits, 2048 ) bits.		*/
-/*								*/
-/*		The 256 bytes in "block" are displayed from	*/
-/*		top to bottom and left to right. Bit 0 of	*/
-/*		a byte is towards the top of the screen.	*/
-/*								*/
-/*		Special graphic codes are used to generate	*/
-/*		two "bits" per character position. So a 16	*/
-/*		line by 64 column display is 32 "bits" by	*/
-/*		64 "bits". Or 4 bytes by 64 bytes.		*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Map( block, max_bits )
-  char *block;
-  int   max_bits;
-
-  {
-  int line;
-  int column;
-  int bit_count = 0;
-
-  for ( line = 0;  line < 16;  ++line )
-    {
-    char *p = &block[ (line & 0xC) >> 2 ];
-    int shift = (line & 0x3) << 1;
-
-    Goto( BLOCK_COLUMN, BLOCK_LINE + line );
-
-    for ( column = 0;  column < 64;  ++column, p += 4 )
-      {
-      char c = (*p >> shift) & 0x3;
-      int current_bit = ((p - block) << 3) + shift;
-
-      /*  Don't display bits past "max_bits"  */
-
-      if ( current_bit >= max_bits )
-	break;
-
-      /*  If "max_bits" occurs in between the two bits  */
-      /*  I am trying to display as one character, then	*/
-      /*  zero off the high-order bit.			*/
-
-      if ( current_bit + 1 == max_bits )
-	c &= 1;
-
-      switch ( c )
-	{
-	case 0 :  putchar( BOX_CLR );
-		  break;
-
-	case 1 :  putchar( BOX_TOP );
-		  ++bit_count;
-		  break;
-
-	case 2 :  putchar( BOX_BOT );
-		  ++bit_count;
-		  break;
-
-	case 3 :  putchar( BOX_ALL );
-		  bit_count += 2;
-		  break;
-	}
-      }  /*  end for ( column )  */
-    }  /*  end for ( line )  */
-
-
-  Goto( BLOCK_COLUMN + 68, BLOCK_LINE + 6 );
-  printf( "(%d)", bit_count );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Pointers( state )					*/
-/*								*/
-/*		Redraw the pointers and the offset field.	*/
-/*		The rest of the screen stays intact.		*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Pointers( s )
-  de_state *s;
-
-  {
-  Draw_Offset( s );
-
-  switch ( s->mode )
-    {
-    case WORD :   Word_Pointers( s->last_addr, s->address );
-		  break;
-
-    case BLOCK :  Block_Pointers( s->last_addr, s->address );
-		  break;
-
-    case MAP :	  Map_Pointers( s->last_addr, s->address );
-		  break;
-    }
-
-  Goto( PROMPT_COLUMN, PROMPT_LINE );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Draw_Offset( state )					*/
-/*								*/
-/*		Display the offset in the current buffer	*/
-/*		and the relative position if within a map	*/
-/*		or i-node block.				*/
-/*								*/
-/****************************************************************/
-
-
-void Draw_Offset( s )
-  de_state *s;
-
-  {
-  Goto( STATUS_COLUMN, STATUS_LINE + 2 );
-
-  printf( "Offset = %5d           ", s->offset );
-
-
-  if ( s->block < 2 )
-    return;
-
-  if ( s->block < 2 + s->inode_maps )
-    {
-    long bit = (s->address - 2 * K) * 8;
-
-    if ( bit < s->inodes_in_map )
-	printf( "I-node %ld of %d     ", bit, s->inodes );
-    else
-	printf( "(padding)                " );
-    }
-
-  else if ( s->block < 2 + s->inode_maps + s->zone_maps )
-    {
-    long bit = (s->address - (2 + s->inode_maps) * K) * 8;
-
-    if ( bit < s->zones_in_map )
-	printf( "Block %ld of %u     ", bit + s->first_data - 1, s->zones );
-    else
-	printf( "(padding)                " );
-    }
-
-  else if ( s->block < s->first_data )
-    {
-    bit_t node = (s->address - (2 + s->inode_maps + s->zone_maps) * K) /
-		s->inode_size + 1;
-
-    if ( node <= s->inodes )
-	printf( "I-node %lu of %lu  (%sin use)       ",
-		(unsigned long) node, (unsigned long) s->inodes,
-		In_Use( node, s->inode_map ) ? "" : "not " );
-    else
-	printf( "(padding)                             " );
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Word_Pointers( old_addr, new_addr )			*/
-/*								*/
-/*	Block_Pointers( old_addr, new_addr )			*/
-/*								*/
-/*	Map_Pointers( old_addr, new_addr )			*/
-/*								*/
-/*		Redraw the index pointers for a each type	*/
-/*		of display. The pointer at "old_addr" is	*/
-/*		erased and a new pointer is positioned		*/
-/*		for "new_addr". This makes the screen		*/
-/*		update faster and more pleasant for the user.	*/
-/*								*/
-/****************************************************************/
-
-
-void Word_Pointers( old_addr, new_addr )
-  off_t old_addr;
-  off_t new_addr;
-
-  {
-  int from = ( (int) old_addr & PAGE_MASK ) >> 1;
-  int to   = ( (int) new_addr & PAGE_MASK ) >> 1;
-
-  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + from );
-  putchar( ' ' );
-
-  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + to );
-  putchar( '>' );
-  }
-
-
-
-
-void Block_Pointers( old_addr, new_addr )
-  off_t old_addr;
-  off_t new_addr;
-
-  {
-  int from = (int) old_addr & ~K_MASK;
-  int to   = (int) new_addr & ~K_MASK;
-
-  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + from / 64 );
-  putchar( ' ' );
-
-  Goto( BLOCK_COLUMN - 2, BLOCK_LINE + to / 64 );
-  putchar( '>' );
-
-  Goto( BLOCK_COLUMN + from % 64, BLOCK_LINE + 17 );
-  putchar( ' ' );
-
-  Goto( BLOCK_COLUMN + to % 64, BLOCK_LINE + 17 );
-  putchar( '^' );
-  }
-
-
-
-
-void Map_Pointers( old_addr, new_addr )
-  off_t old_addr;
-  off_t new_addr;
-
-  {
-  int from = ( (int) old_addr & MAP_MASK ) >> 2;
-  int to   = ( (int) new_addr & MAP_MASK ) >> 2;
-
-  Goto( BLOCK_COLUMN + from, BLOCK_LINE + 17 );
-  putchar( ' ' );
-
-  Goto( BLOCK_COLUMN + to, BLOCK_LINE + 17 );
-  putchar( '^' );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Print_Number( number, output_base )			*/
-/*								*/
-/*		Output "number" in the output base.		*/
-/*								*/
-/****************************************************************/
-
-
-void Print_Number( number, output_base )
-  word_t number;
-  int output_base;
-
-  {
-  switch ( output_base )
-    {
-    case 16 :	printf( "%5x", number );
-		break;
-
-    case 10 :	printf( "%7u", number );
-		break;
-
-    case 8 :	printf( "%7o", number );
-		break;
-
-    case 2 :	{
-      		unsigned int mask;
-      		char pad = ' ';
-
-      		for ( mask = 0x8000;  mask > 1;  mask >>= 1 )
-		  putchar( (mask & number) ? (pad = '0', '1') : pad );
-
-      		putchar( (0x01 & number) ? '1' : '0' );
-
-		break;
-      		}
-
-    default :	Error( "Internal fault (output_base)" );
-    }
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Print_Ascii( char )					*/
-/*								*/
-/*		Display a character in reverse mode if it	*/
-/*		is not a normal printable ASCII character.	*/
-/*								*/
-/****************************************************************/
-
-
-void Print_Ascii( c )
-  char c;
-
-  {
-  c &= 0x7f;
-
-  if ( c < ' ' )
-    printf( "%s%c%s", Treverse, '@' + c, Tnormal );
-  else if ( c == DEL )
-    printf( "%s?%s", Treverse, Tnormal );
-  else
-    putchar( c );
-  }
-
-
-
-
-
-
-/****************************************************************/
-/*								*/
-/*	Warning( text, arg1, arg2 )				*/
-/*								*/
-/*		Display a message for 2 seconds.		*/
-/*								*/
-/****************************************************************/
-
-
-#if __STDC__
-void Warning( const char *text, ... )
-#else
-void Warning( text )
-  char *text;
-#endif  
-
-  {
-  va_list argp;
-  
-  printf( "%c%s", BELL, Tclr_all );
-
-  Goto( WARNING_COLUMN, WARNING_LINE );
-
-  printf( "%s Warning: ", Treverse );
-  va_start( argp, text );
-  vprintf( text, argp );
-  va_end( argp );
-  printf( " %s", Tnormal );
-
-  fflush(stdout);		/* why does everyone forget this? */
-
-  sleep( 2 );
-  }
-
-
-void Draw_Zone_Numbers( s, inode, zindex, zrow )
-  de_state *s;
-  struct inode *inode;
-  int zindex;
-  int zrow;
-
-  {
-  static char *plurals[] = { "", "double ", "triple " };
-  zone_t zone;
-
-  for ( ; zrow < 16;
-	++zindex, zrow += s->zone_num_size / sizeof (word_t) )
-    {
-    Goto( INFO_COLUMN, INFO_LINE + zrow );
-    if ( zindex < s->ndzones )
-      printf( "zone %d", zindex );
-    else
-      printf( "%sindirect", plurals[ zindex - s->ndzones ] );
-    if ( s->magic != SUPER_MAGIC )
-      {
-      zone = inode->i_zone[ zindex ];
-      if ( zone != (word_t) zone )
-	{
-	Goto( INFO_COLUMN + 16, INFO_LINE + zrow );
-	printf("%ld", (long) zone );
-	}
-      }
-    }
-  }
