cechew@bruce.OZ (Earl Chew) (08/29/89)
Here are some patches for my recent ls to bring it up to patchlevel 1.7.
Problems fixed are:
o long user names and group names truncated to prevent columns being corrupted
o declare errno on behalf of error.h
o support for fifo's and limited support for symbolic links
o char *malloc() instead of void *malloc()
There has been a patch posted for getdents by Bruce Culbertson.
This file contains patches for ls.c ls.man and ls.doc.
Earl
-------------------------------------------------------------------------------
diff -c old/ls.c new/ls.c
*** old/ls.c Tue Aug 29 10:08:11 1989
--- new/ls.c Sun Aug 27 23:59:24 1989
***************
*** 13,19
* are no restrictions with regard to the size of the directory file
* since memory is allocated dynamically.
*
! * Patchlevel 1.6
*
* Edit History:
*
--- 13,19 -----
* are no restrictions with regard to the size of the directory file
* since memory is allocated dynamically.
*
! * Patchlevel 1.7
*
* Edit History:
*
***************
*** 17,22
*
* Edit History:
*
* 16-May-1989 Option -n shouldn't look in /etc/passwd. Use new
* strerror in string.h, add prototype for itoa().
* 30-Apr-1989 Changed stat failure message to not found. Include
--- 17,28 -----
*
* Edit History:
*
+ * 27-Aug-1989 Added declaration of errno for old errno.h and
+ * char *malloc() for old include files. Added
+ * support for named FIFO's. Changed user and group
+ * name format to %6.6s so that long names won't
+ * muck up columns. Later will have to add
+ * symbolic link support for -l and -L.
* 16-May-1989 Option -n shouldn't look in /etc/passwd. Use new
* strerror in string.h, add prototype for itoa().
* 30-Apr-1989 Changed stat failure message to not found. Include
***************
*** 119,125
struct group *getgrgid(); /* get group from gid */
int getuid(); /* get uid of this process */
int getopt(); /* parse the options */
- void *malloc(); /* memory allocator */
void free(); /* free memory */
int isatty(); /* stdout is a terminal */
void exit(); /* terminate */
--- 125,130 -----
struct group *getgrgid(); /* get group from gid */
int getuid(); /* get uid of this process */
int getopt(); /* parse the options */
void free(); /* free memory */
int isatty(); /* stdout is a terminal */
void exit(); /* terminate */
***************
*** 124,129
int isatty(); /* stdout is a terminal */
void exit(); /* terminate */
/*
* External Variables.
*/
--- 129,140 -----
int isatty(); /* stdout is a terminal */
void exit(); /* terminate */
+ #ifdef MINIX
+ char *malloc(); /* memory allocator */
+ #else
+ void *malloc(); /* memory allocator */
+ #endif
+
/*
* External Variables.
*/
***************
*** 130,135
extern int optind; /* next argument */
/*
* Forward declarations.
*/
--- 141,150 -----
extern int optind; /* next argument */
+ #ifdef MINIX
+ extern int errno; /* error code */
+ #endif
+
/*
* Forward declarations.
*/
***************
*** 764,769
pad++;
else {
if ((p->status->st_mode & S_IFMT) == S_IFDIR) (void) putchar('/');
else if (TEST('F') && p->status->st_mode & 0111) (void) putchar('*');
else pad++;
}
--- 779,787 -----
pad++;
else {
if ((p->status->st_mode & S_IFMT) == S_IFDIR) (void) putchar('/');
+ #ifdef S_IFLNK
+ if ((p->status->st_mode & S_IFMT) == S_IFLNK) (void) putchar('@');
+ #endif
else if (TEST('F') && p->status->st_mode & 0111) (void) putchar('*');
else pad++;
}
***************
*** 812,817
if (filetype == S_IFDIR) filecode = 'd';
else if (filetype == S_IFBLK) filecode = 'b';
else if (filetype == S_IFCHR) filecode = 'c';
else filecode = '-';
for (i = 0, mode = sp->st_mode; i < 3; mode >>= 3, i++)
--- 830,841 -----
if (filetype == S_IFDIR) filecode = 'd';
else if (filetype == S_IFBLK) filecode = 'b';
else if (filetype == S_IFCHR) filecode = 'c';
+ #ifdef S_IFIFO
+ else if (filetype == S_IFIFO) filecode = 'p';
+ #endif
+ #ifdef S_IFLNK
+ else if (filetype == S_IFLNK) filecode = 'l';
+ #endif
else filecode = '-';
for (i = 0, mode = sp->st_mode; i < 3; mode >>= 3, i++)
***************
*** 823,829
if (TEST('o')) {
if (! TEST('n') && ((pwent && pwent->pw_uid == sp->st_uid) ||
(pwent = getpwuid(sp->st_uid)) != NIL))
! (void) printf("%6s ", pwent->pw_name);
else
(void) printf("%6d ", sp->st_uid);
}
--- 847,853 -----
if (TEST('o')) {
if (! TEST('n') && ((pwent && pwent->pw_uid == sp->st_uid) ||
(pwent = getpwuid(sp->st_uid)) != NIL))
! (void) printf("%6.6s ", pwent->pw_name);
else
(void) printf("%6d ", sp->st_uid);
}
***************
*** 831,837
if (TEST('g')) {
if (! TEST('n') && ((grent && grent->gr_gid == sp->st_gid) ||
(grent = getgrgid(sp->st_gid)) != NIL))
! (void) printf("%6s ", grent->gr_name);
else
(void) printf("%6d ", sp->st_gid);
}
--- 855,861 -----
if (TEST('g')) {
if (! TEST('n') && ((grent && grent->gr_gid == sp->st_gid) ||
(grent = getgrgid(sp->st_gid)) != NIL))
! (void) printf("%6.6s ", grent->gr_name);
else
(void) printf("%6d ", sp->st_gid);
}
diff -c old/ls.doc new/ls.doc
*** old/ls.doc Tue Aug 29 10:09:20 1989
--- new/ls.doc Tue Aug 29 10:17:58 1989
***************
*** 60,66
! Printed 3/23/89 MINIX 1
--- 60,66 -----
! Printed 8/29/89 MINIX 1
***************
*** 113,120
-C Multicolumn output with entries sorted down the columns.
! -F Cause directories to be marked with a trailing / and
! executables to be marked with a trailing *.
-R Recursively list subdirectories encountered.
--- 113,121 -----
-C Multicolumn output with entries sorted down the columns.
! -F Cause directories to be marked with a trailing /, sym-
! bolic links with a trailing @ and executables with a
! trailing *.
-R Recursively list subdirectories encountered.
***************
*** 121,128
The mode printed under the -l option consists of 10 charac-
ters that are interpreted as follows:
- The first character is:
- d if the entry is a directory
--- 122,127 -----
The mode printed under the -l option consists of 10 charac-
ters that are interpreted as follows:
***************
*** 126,132
- Printed 3/23/89 MINIX 2
--- 125,130 -----
Printed 8/29/89 MINIX 2
***************
*** 128,133
Printed 3/23/89 MINIX 2
--- 126,132 -----
+ Printed 8/29/89 MINIX 2
***************
*** 133,138
LS(1) Minix Programmer's Manual LS(1)
--- 132,138 -----
+
LS(1) Minix Programmer's Manual LS(1)
***************
*** 137,142
b if the entry is a block special file
c if the entry is a character special file
- if the entry is an ordinary file
--- 137,144 -----
+ The first character is:
+ d if the entry is a directory
b if the entry is a block special file
c if the entry is a character special file
p if the entry is a FIFO special file
***************
*** 139,144
b if the entry is a block special file
c if the entry is a character special file
- if the entry is an ordinary file
The next 9 characters are interpreted as three sets of three
--- 141,148 -----
d if the entry is a directory
b if the entry is a block special file
c if the entry is a character special file
+ p if the entry is a FIFO special file
+ l if the entry is a symbolic link
- if the entry is an ordinary file
The next 9 characters are interpreted as three sets of three
***************
*** 188,198
!
!
!
!
! Printed 3/23/89 MINIX 3
--- 192,198 -----
! Printed 8/29/89 MINIX 3
diff -c old/ls.man new/ls.man
*** old/ls.man Tue Aug 29 10:09:22 1989
--- new/ls.man Tue Aug 29 10:15:03 1989
***************
*** 104,111
Multicolumn output with entries sorted down the columns.
.TP 4
\-F
! Cause directories to be marked with a trailing / and executables to be
! marked with a trailing *.
.TP 4
\-R
Recursively list subdirectories encountered.
--- 104,111 -----
Multicolumn output with entries sorted down the columns.
.TP 4
\-F
! Cause directories to be marked with a trailing /, symbolic links
! with a trailing @ and executables with a trailing *.
.TP 4
\-R
Recursively list subdirectories encountered.
***************
*** 120,125
b if the entry is a block special file
.br
c if the entry is a character special file
.br
- if the entry is an ordinary file
.PP
--- 120,129 -----
b if the entry is a block special file
.br
c if the entry is a character special file
+ .br
+ p if the entry is a FIFO special file
+ .br
+ l if the entry is a symbolic link
.br
- if the entry is an ordinary file
.PP
-------------------------------------------------------------------------------