cechew@bruce.cs.monash.OZ.AU (Earl Chew) (08/13/90)
Problem: It is impossible to find files of type 'f' (or type 'l' :-):
find /etc -type f -print
Diagnosis: The file type is stored in a long with sign extension. It is
compared against an unsigned short (which gets promoted to
unsigned long).
Fix: 1. sys/stat.h should really read:
#define S_IFREG 0120000U
but that would break K&R compilers. Alternatively
#define S_IFREG ((mode_t) 0120000)
but that would break ANSI compilers using #if S_IFREG.
2. Patch the code that stores the file type.
3. Patch the code that compares the file type.
I chose (2) since it's smaller.
-------------------------------------------------------------------------------
*** find.c~ Mon Aug 13 12:15:31 1990
--- find.c Mon Aug 13 12:15:46 1990
***************
*** 224,230
case OP_NEWER:
return st->st_mtime > n->n_info.n_int.n_val;
case OP_TYPE:
! return(st->st_mode & S_IFMT) == n->n_info.n_int.n_val;
case OP_LINKS:
return ichk((long) (st->st_nlink), n);
case OP_USER:
--- 224,230 -----
case OP_NEWER:
return st->st_mtime > n->n_info.n_int.n_val;
case OP_TYPE:
! return(st->st_mode & S_IFMT) == (mode_t) n->n_info.n_int.n_val;
case OP_LINKS:
return ichk((long) (st->st_nlink), n);
case OP_USER:
-------------------------------------------------------------------------------
--
Earl Chew, Dept of Computer Science, Monash University, Australia 3168
ARPA: cechew%bruce.cs.monash.oz.au@uunet.uu.net ACS : cechew@bruce.oz
----------------------------------------------------------------------