[comp.os.minix] ls 2.0 -> 2.1 patches

cechew@bruce.OZ (Earl Chew) (11/10/89)

This shar file contains patches to ls 2.0 to bring it up to 2.1. Mostly
cosmetic fixes for symbolic link processing.

I have also included a makefile for minix, bsd, etc.

Al Donaldson reported some problems listing _medium sized_ directories. I
haven't heard from him since. Have you solved your problem Al?

Earl

-------------------------------------------------------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  ls.dif makefile.cpp makefile.min makefile.pyr makefile.sun
# Wrapped by cechew@bruce on Fri Nov 10 09:41:18 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ls.dif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ls.dif'\"
else
echo shar: Extracting \"'ls.dif'\" \(7023 characters\)
sed "s/^X//" >'ls.dif' <<'END_OF_FILE'
X*** ls.old	Fri Nov 10 09:36:54 1989
X--- ls.c	Fri Nov 10 09:29:51 1989
X***************
X*** 13,19
X   * are no restrictions with regard to the size of the directory file
X   * since memory is allocated dynamically.
X   *
X!  * Patchlevel 2.0
X   *
X   * Edit History:
X   * 21-Sep-1989	Changed names to _BSD and _MINIX. Use #ifdef for
X
X--- 13,19 -----
X   * are no restrictions with regard to the size of the directory file
X   * since memory is allocated dynamically.
X   *
X!  * Patchlevel 2.1
X   *
X   * Edit History:
X   * 20-Oct-1989	Change suffix for failed symbolic links.
X***************
X*** 16,21
X   * Patchlevel 2.0
X   *
X   * Edit History:
X   * 21-Sep-1989	Changed names to _BSD and _MINIX. Use #ifdef for
X   *		portability.
X   * 19-Sep-1989	Sizes in kb rather than `blocks'.
X
X--- 16,22 -----
X   * Patchlevel 2.1
X   *
X   * Edit History:
X+  * 20-Oct-1989	Change suffix for failed symbolic links.
X   * 21-Sep-1989	Changed names to _BSD and _MINIX. Use #ifdef for
X   *		portability.
X   * 19-Sep-1989	Sizes in kb rather than `blocks'.
X***************
X*** 1119,1124
X  #ifdef		S_IFLNK
X    BOOL(dolink);				/* follow link */
X    char *link;				/* link to */
X  #endif
X  
X    p->length = 0;
X
X--- 1120,1126 -----
X  #ifdef		S_IFLNK
X    BOOL(dolink);				/* follow link */
X    char *link;				/* link to */
X+   int fstat;				/* result from filestat */
X  #endif
X  
X    p->length = 0;
X***************
X*** 1124,1129
X    p->length = 0;
X  
X  #ifdef		S_IFLNK
X    if (EVAL(dolink, TEST('o') || TEST('g')) &&
X        (p->status->st_mode & S_IFMT) == S_IFLNK) {
X      if (! filestat(1, stat, link = followlink(p->name), &lsb)) {
X
X--- 1126,1132 -----
X    p->length = 0;
X  
X  #ifdef		S_IFLNK
X+   link = (char *) NIL;
X    if (EVAL(dolink, TEST('o') || TEST('g')) &&
X        (p->status->st_mode & S_IFMT) == S_IFLNK) {
X      fstat = filestat(1, stat, link = followlink(p->name), &lsb);
X***************
X*** 1126,1132
X  #ifdef		S_IFLNK
X    if (EVAL(dolink, TEST('o') || TEST('g')) &&
X        (p->status->st_mode & S_IFMT) == S_IFLNK) {
X!     if (! filestat(1, stat, link = followlink(p->name), &lsb)) {
X        *p->status = lsb;
X        p->length += 4 + stringlength(link);
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X
X--- 1129,1140 -----
X    link = (char *) NIL;
X    if (EVAL(dolink, TEST('o') || TEST('g')) &&
X        (p->status->st_mode & S_IFMT) == S_IFLNK) {
X!     fstat = filestat(1, stat, link = followlink(p->name), &lsb);
X!     p->length += 4 + stringlength(link);
X! 
X! /* Follow link and obtain status for final target */
X!     if (! fstat) {
X! 
X        *p->status = lsb;
X  
X  /* Malloc extra space for null and possible type indicator */
X***************
X*** 1128,1134
X        (p->status->st_mode & S_IFMT) == S_IFLNK) {
X      if (! filestat(1, stat, link = followlink(p->name), &lsb)) {
X        *p->status = lsb;
X!       p->length += 4 + stringlength(link);
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X        (void) strcat(p->suffix, " -> ");
X        (void) strcat(p->suffix, link);
X
X--- 1136,1143 -----
X      if (! fstat) {
X  
X        *p->status = lsb;
X! 
X! /* Malloc extra space for null and possible type indicator */
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X  
X        (void) strcat(p->suffix, " -> ");
X***************
X*** 1130,1135
X        *p->status = lsb;
X        p->length += 4 + stringlength(link);
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X        (void) strcat(p->suffix, " -> ");
X        (void) strcat(p->suffix, link);
X      }
X
X--- 1139,1145 -----
X  
X  /* Malloc extra space for null and possible type indicator */
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X+ 
X        (void) strcat(p->suffix, " -> ");
X        (void) strcat(p->suffix, link);
X        link = (char *) NIL;
X***************
X*** 1132,1137
X        *(p->suffix = (char *) safemalloc((unsigned int) p->length+2)) = 0;
X        (void) strcat(p->suffix, " -> ");
X        (void) strcat(p->suffix, link);
X      }
X    }
X  #endif
X
X--- 1142,1148 -----
X  
X        (void) strcat(p->suffix, " -> ");
X        (void) strcat(p->suffix, link);
X+       link = (char *) NIL;
X      }
X    }
X  #endif
X***************
X*** 1152,1158
X  
X    p->length += stringlength(p->name) + strlen(type);
X  
X!   if (p->suffix == NIL)
X      p->suffix = type;
X    else if (*type != 0)
X      (void) strcat(p->suffix, type);
X
X--- 1163,1181 -----
X  
X    p->length += stringlength(p->name) + strlen(type);
X  
X!   if (p->suffix == NIL) {
X! #ifdef	S_IFLNK
X!     if (link == (char *) NIL)
X!       p->suffix = type;
X! 
X! /* Link followed but target non-existent --- file type shows link */
X!     else {
X!       p->suffix = (char *) safemalloc((unsigned int) p->length+1);
X!       (void) strcpy(p->suffix, type);
X!       (void) strcat(p->suffix, " -> ");
X!       (void) strcat(p->suffix, link);
X!     }
X! #else
X      p->suffix = type;
X  #endif
X    }
X***************
X*** 1154,1159
X  
X    if (p->suffix == NIL)
X      p->suffix = type;
X    else if (*type != 0)
X      (void) strcat(p->suffix, type);
X  }
X
X--- 1177,1184 -----
X      }
X  #else
X      p->suffix = type;
X+ #endif
X+   }
X    else if (*type != 0)
X      (void) strcat(p->suffix, type);
X  }
X***************
X*** 1209,1217
X  
X    if ((*status)(name, statbuf)
X  #ifdef		S_IFLNK
X!       && (status == lstat  ||
X! 	  errno  != ENOENT ||
X!           lstat(name, statbuf))
X  #endif
X       ) {
X      if (errno == ENOENT) {
X
X--- 1234,1240 -----
X  
X    if ((*status)(name, statbuf)
X  #ifdef		S_IFLNK
X!       && (status == lstat || lstat(name, statbuf))
X  #endif
X       ) {
X      if (! silent) {
X***************
X*** 1214,1221
X            lstat(name, statbuf))
X  #endif
X       ) {
X!     if (errno == ENOENT) {
X!       if (! silent)
X  	(void) fprintf(stderr, "%s not found\n", name);
X        return 1;
X      }
X
X--- 1237,1244 -----
X        && (status == lstat || lstat(name, statbuf))
X  #endif
X       ) {
X!     if (! silent) {
X!       if (errno == ENOENT)
X  	(void) fprintf(stderr, "%s not found\n", name);
X        else
X  	(void) fprintf(stderr, "%s stat failure: %s\n", name, strerror(errno));
X***************
X*** 1217,1223
X      if (errno == ENOENT) {
X        if (! silent)
X  	(void) fprintf(stderr, "%s not found\n", name);
X!       return 1;
X      }
X      else {
X        (void) fprintf(stderr, "%s stat failure: %s\n", name, strerror(errno));
X
X--- 1240,1247 -----
X      if (! silent) {
X        if (errno == ENOENT)
X  	(void) fprintf(stderr, "%s not found\n", name);
X!       else
X! 	(void) fprintf(stderr, "%s stat failure: %s\n", name, strerror(errno));
X      }
X      return 1;
X    }
X***************
X*** 1219,1228
X  	(void) fprintf(stderr, "%s not found\n", name);
X        return 1;
X      }
X!     else {
X!       (void) fprintf(stderr, "%s stat failure: %s\n", name, strerror(errno));
X!       exit(1);
X!     }
X    }
X    return *endpath = 0;
X  }
X
X--- 1243,1249 -----
X        else
X  	(void) fprintf(stderr, "%s stat failure: %s\n", name, strerror(errno));
X      }
X!     return 1;
X    }
X    return *endpath = 0;
X  }
END_OF_FILE
if test 7023 -ne `wc -c <'ls.dif'`; then
    echo shar: \"'ls.dif'\" unpacked with wrong size!
fi
# end of 'ls.dif'
fi
if test -f 'makefile.cpp' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.cpp'\"
else
echo shar: Extracting \"'makefile.cpp'\" \(1921 characters\)
sed "s/^X//" >'makefile.cpp' <<'END_OF_FILE'
X#ifdef _MSDOS
X#define ARC		pkarc
X#undef _MSDOS
X#endif
X
X#ifdef	sun
X#undef sun
X#sun sun
X#define WHOAMI		sun
X#define DEFINES		-D_BSD
X#define INCLUDES
X#define LIBRARY
X#define LIBRARIES
X#define CCFLAGS
X#define OBJECT(x)	x.o
X#define AOUT(x)		x
X#define	CC		cc
X#define EXE(x)		-o x
X#define ARC		arc
X#endif
X
X#ifdef	pyr
X#undef pyr
X#pyr pyr
X#define WHOAMI		pyr
X#define DEFINES		-D_BSD
X#define INCLUDES
X#define LIBRARY
X#define LIBRARIES
X#define CCFLAGS
X#define OBJECT(x)	x.o
X#define AOUT(x)		x
X#define	CC		cc
X#define EXE(x)		-o x
X#define ARC		arc
X#endif
X
X#ifdef	_MINIX
X#undef _MINIX
X#min _MINIX
X#define WHOAMI		min
X#define DEFINES		-D_MINIX -Di8088
X#define LIBRARY
X#define LIBRARIES
X#define INCLUDES
X#define CCFLAGS
X#define OBJECT(x)	x.s
X#define AOUT(x)		x
X#define	CC		cc
X#define EXE(x)		-o x
X#define ARC		arc
X#endif
X
X#define NONAME
X#define NAME		ls
X
Xall= *.c makefile.* *.man *.doc
X
Xeveryone= sun pyr min
X
XCFLAGS= DEFINES INCLUDES CCFLAGS
X
XLFLAGS= LIBRARY
X
Xsource= ls.c
Xobject= OBJECT(ls)
Xlibraries= LIBRARIES
X
X.SUFFIXES:	OBJECT(NONAME) .c
X
X.c##OBJECT(NONAME):
X	CC -c $(CFLAGS) $<
X
XAOUT(NAME):	$(object)
X	CC EXE(NAME) $(LFLAGS) $(object) $(libraries)
X
X$(object):
X
X# Everything
Xall:	ls.doc AOUT(NAME)
X
X# Documentation
X
Xls.doc:	ls.man
X	nroff -man ls.man | col -b > ls.doc
X
X# Lint checking
X
Xlint:
X	lint $(define) $(source)
X
X# Packing
X
Xarc:
X	rm -f NAME.arc
X	ARC a NAME.arc $(all)
X
X# Makefiles
X
Xmakefiles:
X	-for w in $(everyone) ; \
X	do \
X	n=`awk "/^#$$w / "'{ print $$2 }' <CPPMAKEFILE` ; \
X	if test WHOAMI = $$n ; then \
X	cppmake -o makefile.$$w ; \
X	else \
X	cppmake -U##WHOAMI -D$$n -o makefile.$$w ; \
X	fi ; \
X	done
X
X# Shell Archive
Xshar:
X	ls $(all) | \
X	sed -e 's/^.*\.doc/&	Formatted documentation/' \
X	    -e 's/^.*\.man/&	Manual page source/' \
X	    -e 's/^makefile\.cpp$$/&	Cppmakefile/' \
X	    -e 's/^makefile\.[a-z]*$$/&	Site dependent makefiles/' \
X	    -e 's/^.*\.c$$/&	Source code/' | \
X	makekit -n##NAME. -s40k -oMANIFEST
END_OF_FILE
if test 1921 -ne `wc -c <'makefile.cpp'`; then
    echo shar: \"'makefile.cpp'\" unpacked with wrong size!
fi
# end of 'makefile.cpp'
fi
if test -f 'makefile.min' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.min'\"
else
echo shar: Extracting \"'makefile.min'\" \(1005 characters\)
sed "s/^X//" >'makefile.min' <<'END_OF_FILE'
X
X
X#min _MINIX
X
X
Xall= *.c makefile.* *.man *.doc
X
Xeveryone= sun pyr min
X
XCFLAGS= -D_MINIX -Di8088
X
XLFLAGS=
X
Xsource= ls.c
Xobject= ls.s
Xlibraries=
X
X.SUFFIXES:	.s .c
X
X.c.s:
X	cc -c $(CFLAGS) $<
X
Xls:	$(object)
X	cc -o ls $(LFLAGS) $(object) $(libraries)
X
X$(object):
X
X# Everything
Xall:	ls.doc ls
X
X# Documentation
X
Xls.doc:	ls.man
X	nroff -man ls.man | col -b > ls.doc
X
X# Lint checking
X
Xlint:
X	lint $(define) $(source)
X
X# Packing
X
Xarc:
X	rm -f ls.arc
X	arc a ls.arc $(all)
X
X# Makefiles
X
Xmakefiles:
X	-for w in $(everyone) ; \
X	do \
X	n=`awk "/^#$$w / "'{ print $$2 }' <Makefile.cpp` ; \
X	if test min = $$n ; then \
X	cppmake -o makefile.$$w ; \
X	else \
X	cppmake -Umin -D$$n -o makefile.$$w ; \
X	fi ; \
X	done
X
X# Shell Archive
Xshar:
X	ls $(all) | \
X	sed -e 's/^.*\.doc/&	Formatted documentation/' \
X	    -e 's/^.*\.man/&	Manual page source/' \
X	    -e 's/^makefile\.cpp$$/&	Cppmakefile/' \
X	    -e 's/^makefile\.[a-z]*$$/&	Site dependent makefiles/' \
X	    -e 's/^.*\.c$$/&	Source code/' | \
X	makekit -nls. -s40k -oMANIFEST
END_OF_FILE
if test 1005 -ne `wc -c <'makefile.min'`; then
    echo shar: \"'makefile.min'\" unpacked with wrong size!
fi
# end of 'makefile.min'
fi
if test -f 'makefile.pyr' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.pyr'\"
else
echo shar: Extracting \"'makefile.pyr'\" \(993 characters\)
sed "s/^X//" >'makefile.pyr' <<'END_OF_FILE'
X
X
X#pyr pyr
X
X
X
Xall= *.c makefile.* *.man *.doc
X
Xeveryone= sun pyr min
X
XCFLAGS= -D_BSD
X
XLFLAGS=
X
Xsource= ls.c
Xobject= ls.o
Xlibraries=
X
X.SUFFIXES:	.o .c
X
X.c.o:
X	cc -c $(CFLAGS) $<
X
Xls:	$(object)
X	cc -o ls $(LFLAGS) $(object) $(libraries)
X
X$(object):
X
X# Everything
Xall:	ls.doc ls
X
X# Documentation
X
Xls.doc:	ls.man
X	nroff -man ls.man | col -b > ls.doc
X
X# Lint checking
X
Xlint:
X	lint $(define) $(source)
X
X# Packing
X
Xarc:
X	rm -f ls.arc
X	arc a ls.arc $(all)
X
X# Makefiles
X
Xmakefiles:
X	-for w in $(everyone) ; \
X	do \
X	n=`awk "/^#$$w / "'{ print $$2 }' <Makefile.cpp` ; \
X	if test pyr = $$n ; then \
X	cppmake -o makefile.$$w ; \
X	else \
X	cppmake -Upyr -D$$n -o makefile.$$w ; \
X	fi ; \
X	done
X
X# Shell Archive
Xshar:
X	ls $(all) | \
X	sed -e 's/^.*\.doc/&	Formatted documentation/' \
X	    -e 's/^.*\.man/&	Manual page source/' \
X	    -e 's/^makefile\.cpp$$/&	Cppmakefile/' \
X	    -e 's/^makefile\.[a-z]*$$/&	Site dependent makefiles/' \
X	    -e 's/^.*\.c$$/&	Source code/' | \
X	makekit -nls. -s40k -oMANIFEST
END_OF_FILE
if test 993 -ne `wc -c <'makefile.pyr'`; then
    echo shar: \"'makefile.pyr'\" unpacked with wrong size!
fi
# end of 'makefile.pyr'
fi
if test -f 'makefile.sun' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.sun'\"
else
echo shar: Extracting \"'makefile.sun'\" \(993 characters\)
sed "s/^X//" >'makefile.sun' <<'END_OF_FILE'
X
X#sun sun
X
X
X
X
Xall= *.c makefile.* *.man *.doc
X
Xeveryone= sun pyr min
X
XCFLAGS= -D_BSD
X
XLFLAGS=
X
Xsource= ls.c
Xobject= ls.o
Xlibraries=
X
X.SUFFIXES:	.o .c
X
X.c.o:
X	cc -c $(CFLAGS) $<
X
Xls:	$(object)
X	cc -o ls $(LFLAGS) $(object) $(libraries)
X
X$(object):
X
X# Everything
Xall:	ls.doc ls
X
X# Documentation
X
Xls.doc:	ls.man
X	nroff -man ls.man | col -b > ls.doc
X
X# Lint checking
X
Xlint:
X	lint $(define) $(source)
X
X# Packing
X
Xarc:
X	rm -f ls.arc
X	arc a ls.arc $(all)
X
X# Makefiles
X
Xmakefiles:
X	-for w in $(everyone) ; \
X	do \
X	n=`awk "/^#$$w / "'{ print $$2 }' <Makefile.cpp` ; \
X	if test sun = $$n ; then \
X	cppmake -o makefile.$$w ; \
X	else \
X	cppmake -Usun -D$$n -o makefile.$$w ; \
X	fi ; \
X	done
X
X# Shell Archive
Xshar:
X	ls $(all) | \
X	sed -e 's/^.*\.doc/&	Formatted documentation/' \
X	    -e 's/^.*\.man/&	Manual page source/' \
X	    -e 's/^makefile\.cpp$$/&	Cppmakefile/' \
X	    -e 's/^makefile\.[a-z]*$$/&	Site dependent makefiles/' \
X	    -e 's/^.*\.c$$/&	Source code/' | \
X	makekit -nls. -s40k -oMANIFEST
END_OF_FILE
if test 993 -ne `wc -c <'makefile.sun'`; then
    echo shar: \"'makefile.sun'\" unpacked with wrong size!
fi
# end of 'makefile.sun'
fi
echo shar: End of shell archive.
exit 0
-------------------------------------------------------------------------------
-- 
Earl Chew, Dept of Computer Science, Monash University, Australia 3168
ARPA: cechew%bruce.cs.monash.oz.au@uunet.uu.net  ACS : cechew@bruce.oz
----------------------------------------------------------------------