smk (03/10/83)
The following is a bug fix to the 4.1bsd ncheck program. It may also apply to other systems. If you use the -s option of ncheck, it is supposed to print out special and setuid files. However, if there are none in the file system, it instead prints out normal directories. The fix does the right thing. There may be a simpler bug fix, but this does the job. *** /usr/src/cmd/ncheck.c Wed Oct 1 20:58:42 1980 --- ncheck.c Thu Mar 10 12:22:12 1983 *************** *** 38,43 daddr_t bmap(); long atol(); struct htab *lookup(); main(argc, argv) char *argv[]; --- 38,44 ----- daddr_t bmap(); long atol(); struct htab *lookup(); + int file_count; main(argc, argv) char *argv[]; *************** *** 68,73 case 's': sflg++; continue; default: --- 69,75 ----- case 's': sflg++; + file_count = 0; continue; default: *************** *** 143,148 return; if ((ip->di_mode&IFMT)==IFBLK || (ip->di_mode&IFMT)==IFCHR || ip->di_mode&(ISUID|ISGID)) ilist[nxfile++] = ino; return; } --- 145,152 ----- return; if ((ip->di_mode&IFMT)==IFBLK || (ip->di_mode&IFMT)==IFCHR || ip->di_mode&(ISUID|ISGID)) + { + file_count++; ilist[nxfile++] = ino; } return; *************** *** 144,149 if ((ip->di_mode&IFMT)==IFBLK || (ip->di_mode&IFMT)==IFCHR || ip->di_mode&(ISUID|ISGID)) ilist[nxfile++] = ino; return; } lookup(ino, 1); --- 148,154 ----- { file_count++; ilist[nxfile++] = ino; + } return; } lookup(ino, 1); *************** *** 203,209 daddr_t d; ino_t kno; ! if((ip->di_mode&IFMT) != IFDIR) return; l3tol(iaddr, ip->di_addr, NADDR); doff = 0; --- 208,214 ----- daddr_t d; ino_t kno; ! if(((ip->di_mode&IFMT) != IFDIR) || ((sflg == 1) && (file_count == 0))) return; l3tol(iaddr, ip->di_addr, NADDR); doff = 0;