i386 unix with NFS - getcwd() & /bin/pwd inode problem

henry strickland strick at osc.com
Wed Jul 11 17:15:46 AEST 1990


Denny at tss.com (Denny Page) writes:
>When you are in a directory which is mounted via nfs, and the inode of
>the current directory is > 65535 (such as on a sun), /bin/pwd reports
>"read error in .."  Getcwd() uses /bin/pwd to do its work, and as such
>doesn't function.  Is anyone aware of a fix or a work around for this?

Then it sounds like an easy fix:  just rewrite /bin/pwd (seems like you
understand what it takes to do that).  If all your applications
didn''t fork /bin/pwd, you''d be hosed.

I reverse engineered (for the most part) the algorithm used in 
sunos4''s getwd() command by writing a tiny program something like

	#include <sys/param.h>
	
	char pathname[MAXPATHLEN];
	char *getwd();
	extern errno;
	
	main()
	{
		char *cp= getwd(pathname);
		if ( cp ) 
			return printf("getwd: ``%s''\n", pathname), 0;
		else
			return printf("getwd: ERROR: %s\n", pathname), errno;
	}

and then set gdb breakpoints (don''t forget -Bstatic) at all your 
favorite man 2 calls:

	open 
	close 
	creat 
	read 
	write
	stat
	lstat
	fstat
	opendir
	readdir    etc.

and run the program.  Something like "display (char*) ($fp+4)" on a 68k
will display the first arg of each system call, often a filename.

I was surprised to see it open and read "/etc/mtab".  Nice hack.   strick.



More information about the Comp.unix.i386 mailing list