From: David S. <ds...@ja...> - 2005-05-25 21:58:42
|
Here's a fairly subtle problem, and a possible fix. The problem is that if you export a Fuse filesystem via NFS, and mount it on some clients (OSX, Irix, HPUX, *BSD), getcwd() from within the Fuse filesystem doesn't work (failing with ENOENT). Since pwd calls getcwd() this is a very annoying problem as pwd is used frequently in scripts, etc. The reason for the problem is in how getcwd() is implemented: it stats the current directory ("."), notes the inode number, then opens the directory ".." and reads each entry looking for that inode. Repeat until we reach the root. Unless use_ino is set, fuse does not fill in the d_ino field of a struct dirent (it fills in (ino_t)-1 instead). Since -1 never matches the inode that getcwd() is looking for, getcwd() fails. Here's a patch to fill in d_ino in directory listings. If use_ino is set, the passed-in inode is used of course. This only changes the behavior when use_ino isn't set. Also, this isn't perfect - if the cache no longer has the node in question, then -1 is returned for the inode like it is now. However, this is unlikely and if it does happen, we're no worse off than we are now. David |