[comp.os.minix] Float f'ns & system calls

wtoomey@gara.une.oz (Warren Toomey) (09/14/88)

I'd like to be able to do floating point in Minix, but all the functions
fall into a dummy routine in 'fakfp.s'. Does anybody (Andy?) out there
know what each function declared in fakfp would do if it existed?

Also, a friend of mine, Callum Gibson, is writing a tcsh-like shell for
his Honours project, and I'd love to port it to Minix but there's a few
system/library calls missing. Could anybody who has the code for the
calls below post it to me and/or the net:

closedir
execv		(Done by Terrance Holm?)
execve		(Done by Terrance Holm?)
feof		(A macro somewhere?)
fputc		(Declared in 'fputs'?)
free		(Declared in 'malloc'?)
getcwd		(Done by Terrance Holm?)
getwd
isdigit		(A macro somewhere?)
localtime	(Declared in 'ctime'?)
lstat		(Declared in 'stat'?)
opendir
pclose		(Declared in 'popen'?)
readdir
realloc		(Declared in 'malloc'?)
setpgrp

Thanks !

+--------------------------------------------------------------------------+
|Warren Toomey                                                             |
|Dept. of Computing Science  ACSNET: wtoomey@gara.une.oz                   |
|University of New England   UUCP: ...!uunet!munnari!gara.une.oz!wtoomey   |
|Armidale Australia 2351     ARPA: wtoomey%gara.une.oz@uunet.uu.net        |
+--------------------------------------------------------------------------+
|      "Life isn't as trivial as it seems, it only appears to be."         |
+--------------------------------------------------------------------------+

tnsgvdp@dutrun.UUCP (Karel van Houten) (09/28/88)

In article <273@gara.une.oz> wtoomey@gara.une.oz (Warren Toomey) writes:
>I'd like to be able to do floating point in Minix

***** I WOULD LIKE THAT TOO!!!!!!! ******

******************************************************************************
  Ronald van der Pol
UUCP:     ...!mcvax!dutrun!tnsgvdp
DOMAIN:   tnsgvdp@dutrun.surf
  Be careful! This is an extremely primitive and paranoid culture! - J.T.Kirk
******************************************************************************

rtregn@immd3.informatik.uni-erlangen.de (Robert Regn) (09/29/88)

wtoomey@gara.une.oz (Warren Toomey):
> 
> Also, a friend of mine, Callum Gibson, is writing a tcsh-like shell for
> his Honours project, and I'd love to port it to Minix but there's a few
> system/library calls missing. Could anybody who has the code for the
> calls below post it to me and/or the net:
> 
A very good idea!! 		In the right place my answer:

> closedir					see below
> execv		(Done by Terrance Holm?)	In Minix since 1.1
> execve	(Done by Terrance Holm?)	In Minix since 1.1
> feof		(A macro somewhere?)		Yes in stdio.h
> fputc		(Declared in 'fputs'?)		A macro in stdio.h, same as putc
> free		(Declared in 'malloc'?)		In Minix since 1.1
> getcwd	(Done by Terrance Holm?)	see below
> getwd						see below
> isdigit	(A macro somewhere?)		Yes, In Minix since 1.1
> localtime	(Declared in 'ctime'?)		Yes, in 1.2
> lstat		(Declared in 'stat'?)		see below
> opendir					see below
> pclose	(Declared in 'popen'?)		Yes, in 1.2
> readdir					see below
> realloc	(Declared in 'malloc'?)		Yes, already in 1.1
> setpgrp					see below
> 


A problem are the directory system calls opendir, closedir and  readdir
(standard in BSD systems). Try to get the message 
581@ndsuvax.uucp:Subject: Directory(3) library calls for MINIX

from a minix newsserver (I don't have it). Probably the readdir in traverse
will suffer and  opendir, closedir should be dummies. Look at the code of tcsh.

I think, setpgrp is not existent in Minix yet. Use a dummy routine which
calls signal to ignore int and quit. That works also.

Lstat is only useful if we have symbolic links. Minix don't have. Use 
#define lstat stat

getwd i have never heard. See on the code or ask Callum, what should it do.
getcwd - get current working directory
posted from Terrence Holm in Aug 88. Shell script below

I wish you success and like to get a copy of the source. 

				Robert Regn
				rtregn.faui32.uucp
-------------------------------------------------------------------------
echo x - getcwd.c
gres '^X' '' > getcwd.c << '/'
X/*  getcwd(3)
X *
X *  Author: Terrence W. Holm          Aug. 1988
X *
X *  Directly derived from Adri Koppes' pwd(1).
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X#include <errno.h>
X
X#define  NULL         (char *) 0
X#define  O_RDONLY     0
X#define  DIRECT_SIZE  (sizeof (struct direct))
X#define  PATH_MAX     127
X
Xextern char *rindex();
X
Xextern int errno;
X
X
Xchar *getcwd( buffer, size )
X  char *buffer;
X  int   size;
X
X  {
X  static char path[ PATH_MAX + 1 ];
X  struct stat current;
X
X  if ( buffer == NULL  ||  size == 0 )
X    {
X    errno = EINVAL;
X    return( NULL );
X    }
X
X  path[0] = '\0';
X
X  /*  Get the inode for the current directory  */
X   
X  if ( stat( ".", &current ) == -1 )
X    return( NULL );
X
X  if ( (current.st_mode & S_IFMT) != S_IFDIR )
X    return( NULL );
X
X
X  /*  Run backwards up the directory tree, grabbing 	*/
X  /*  directory names on the way.			*/
X
X  while (1)
X    {
X    struct stat parent;
X    struct direct d;
X    int same_device = 0;
X    int found = 0;
X    int fd;
X
X    /*  Get the inode for the parent directory  */
X
X    if ( chdir( ".." ) == -1 )
X	return( NULL );
X
X    if ( stat( ".", &parent ) == -1 )
X	return( NULL );
X
X    if ( (parent.st_mode & S_IFMT) != S_IFDIR )
X	return( NULL );
X
X    if ( current.st_dev == parent.st_dev )
X	same_device = 1;
X
X
X    /*  At the root, "." is the same as ".."  */
X
X    if ( same_device  &&  current.st_ino == parent.st_ino )
X	break;
X
X
X    /*  Search the parent directory for the current entry  */
X
X    if ( (fd = open( ".", O_RDONLY )) == -1 )
X	return( NULL );
X
X    while ( ! found  &&  read(fd, &d, DIRECT_SIZE) == DIRECT_SIZE )
X	{
X	if ( same_device )
X	    {
X	    if ( current.st_ino == d.d_ino )
X		found = 1;
X	    }
X	else
X	    {
X	    static char temp_name[ DIRSIZ + 1 ];
X	    static struct stat dir_entry;
X
X	    temp_name[0] = '\0';
X	    strncat( temp_name, d.d_name, DIRSIZ );
X
X	    if ( stat( temp_name, &dir_entry ) == -1 )
X		{
X		close( fd );
X		return( NULL );
X		}
X
X	    if ( current.st_dev == dir_entry.st_dev  &&
X	         current.st_ino == dir_entry.st_ino )
X		found = 1;
X	    }
X	}
X
X    close( fd );
X
X    if ( ! found )
X    	return( NULL );
X
X    if ( strlen(path) + DIRSIZ + 1 > PATH_MAX )
X	{
X	errno = ERANGE;
X	return( NULL );
X	}
X
X    strcat( path, "/" );
X    strncat( path, d.d_name, DIRSIZ );
X 
X    current.st_dev = parent.st_dev;
X    current.st_ino = parent.st_ino;
X    }
X
X
X  /*  Copy the reversed path name into <buffer>  */
X
X  if ( strlen(path) + 1 > size )
X    {
X    errno = ERANGE;
X    return( NULL );
X    }
X
X  if ( strlen(path) == 0 )
X    {
X    strcpy( buffer, "/" );
X    return( buffer );
X    }
X
X  *buffer = '\0';
X
X  {
X  char *r;
X
X  while ( (r = rindex( path, '/' )) != NULL )
X    {
X    strcat( buffer, r );
X    *r = '\0';
X    }
X  }
X
X  return( buffer );
X  }
/
-------------------------------------------------------------------------