arnold@csu-cs.UUCP (Ed Arnold) (03/09/84)
This fix is for the 4.2bsd version of dtree, although other versions may incorporate the fix for upward compatability. The program doesn't like symbolic links to either files or directories, but especially directories. All stats in the fix reference to the link not to the file the link references to. This fix may be incorporated into any existing source with proper use of the define construct, allowing upward compatability. Depending apon which option is specified the symbolic link to either file or directory will be preceded by a 'l'. All symbolic links to either files or directories will be treated similar to files, again depending apon which option is specified. I'd like to thank Dave Borman for such a nice program. I pulled off the original source when he was still at St. Olaf. It is nice to see that he has revised his source to include other versions of Unix. Cheers, Ed Arnold (denelcor!csu-cs!arnold) Colorado State University Following is a diff between the original source and the new version. 33a34,43 > /* Modified by Ed Arnold CSU-CS (csu-cs!arnold) 3-5-84 > * > * Allows symbolic links to both directories and individual files. > * With a '-l' or '-al' option, links are denoted with a 'l' in front of > * file or directory permissions. In all other instances both links to > * directories and files are represented just as files are. Contents of > * linked directories are not printed due to the possibility of > * recursively linked directories. > */ > 38c48 < /* #define NEWDIR /* directory structure ala Berkeley 4.1c or 4.2 */ --- > #define NEWDIR /* directory structure ala Berkeley 4.1c or 4.2 */ 39a50,52 > #define LINK /* allows links to be processed in Berkeley 4.2 version */ > /* NEWDIR must be defined as well as LINK */ > 41a55,58 > #ifdef LINK > static char Rcsid[] ="$Header: dtree.c,v 2.1 84/03/08 02:24:03 arnold Exp $"; > #endif LINK > 96a114,116 > #ifdef LINK > struct stat Lstat; /* stat of link, if there is one */ > #endif LINK 272c292 < if (stat(top, &Status) == FAIL) { --- > if(stat(top, &Status) == FAIL) { 366a387,392 > #ifdef LINK > if (lstat (sub,&Lstat) == FAIL) { > fprintf(stderr, "%s:lstat can't find\n", sub); > continue; > } > #endif LINK 371c397,405 < if ((Status.st_mode & S_IFMT) == S_IFDIR) --- > #ifdef LINK > if (((Lstat.st_mode & S_IFMT) == S_IFLNK) && > ((Status.st_mode & S_IFMT) == S_IFDIR)) > addr(List,Index)->dir = 0; > else if ((((Lstat.st_mode & S_IFMT) == S_IFLNK) && > ((Status.st_mode & S_IFMT) != S_IFDIR)) && (All)) > addr(List,Index)->dir = 0; > #endif LINK > else if ((Status.st_mode & S_IFMT) == S_IFDIR) 380,386c414,433 < addr(List,Index)->dev = (Device == Status.st_dev); < #ifdef STATS < addr(List,Index)->e_mode = Status.st_mode; < addr(List,Index)->e_uid = Status.st_uid; < addr(List,Index)->e_gid = Status.st_gid; < addr(List,Index)->e_size = Status.st_size; < #endif STATS --- > #ifdef LINK > if ((Lstat.st_mode & S_IFMT) == S_IFLNK) { > addr(List,Index)->dev = (Device == Lstat.st_dev); > addr(List,Index)->e_mode = Lstat.st_mode; > addr(List,Index)->e_uid = Lstat.st_uid; > addr(List,Index)->e_gid = Lstat.st_gid; > addr(List,Index)->e_size = Lstat.st_size; > } > else { > #endif LINK > addr(List,Index)->dev = (Device == Status.st_dev); > #ifdef STATS > addr(List,Index)->e_mode = Status.st_mode; > addr(List,Index)->e_uid = Status.st_uid; > addr(List,Index)->e_gid = Status.st_gid; > addr(List,Index)->e_size = Status.st_size; > #endif STATS > #ifdef LINK > } > #endif LINK 684a732,736 > #ifdef LINK > case S_IFLNK: > a_mode[j++] = 'l'; > break; > #endif LINK