Hi,
some time ago I asked here it is possible to test a valid key is mounted, in a
autofs managed directory.
I've written a function which does that for me, from within a FUSE module. SO
now it's not necessary anymore to do this via autofs. THis does not mean for
me that communicating with a automount process via /dev/autofs is not a good
thing.
My function:
static signed int Md5KeyIsMounted(const char *testmd5key)
{
int nreturn=-1;
DIR *dp;
struct dirent *de;
// only check when this directory is an option
syslog(MY_LOG, "Md5KeyIsMounted, key: %s", testmd5key);
if ( strlen(testmd5key) != MD5_DIR_LEN ) goto out;
if ( options.autofs_mount_path != NULL ) {
dp = opendir(options.autofs_mount_path);
if (dp == NULL) goto out;
while ((de = readdir(dp)) != NULL) {
syslog(MY_LOG, "md5key found: %s", de->d_name);
if ( strcmp(de->d_name,testmd5key) == 0 ) {
nreturn=1;
goto out;
}
}
closedir(dp);
}
out:
return nreturn;
}
It just looks at the directory where autofs creates the autofs managed (key)
directories. If mounted it exists.
Now when in my fs there is a lookup of a .directory file, which is in a autofs
managed directory, it's able to determine it's mounted or not, and depending
on the result of that test, present a different .directory.
Note that my fuse fs intercept calls to this .directory file and present
.directory file from a predefined place. If t does not do that, it will just
try to look at the .directory file in the autofs managed mount point, causing
it to be mounted.
Stef
_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs