Add option and method to disable/enable directory caching

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2016-02-07 16:06:00 -08:00
parent 6d5628bcab
commit 458f6c2be5
4 changed files with 22 additions and 3 deletions

1
README
View File

@ -43,6 +43,7 @@ Arguments supported by libnfs are :
auto-traverse-mounts=<0|1>
: Should libnfs try to traverse across nested mounts
automatically or not. Default is 1 == enabled.
dircache=<0|1> : Disable/enable directory caching. Enabled by default.
Auto_traverse_mounts
====================

View File

@ -170,6 +170,10 @@ EXTERN void nfs_destroy_context(struct nfs_context *nfs);
* default it 65534 on Windows and getgid() on unixen.
* readahead=<int> : Enable readahead for files and set the maximum amount
* of readahead to <int>.
* auto-traverse-mounts=<0|1>
* : Should libnfs try to traverse across nested mounts
* automatically or not. Default is 1 == enabled.
* dircache=<0|1> : Disable/enable directory caching. Enabled by default.
*/
/*
* Parse a complete NFS URL including, server, path and
@ -217,6 +221,7 @@ EXTERN void nfs_set_uid(struct nfs_context *nfs, int uid);
EXTERN void nfs_set_gid(struct nfs_context *nfs, int gid);
EXTERN void nfs_set_readahead(struct nfs_context *nfs, uint32_t v);
EXTERN void nfs_set_debug(struct nfs_context *nfs, int level);
EXTERN void nfs_set_dircache(struct nfs_context *nfs, int enabled);
/*
* MOUNT THE EXPORT

View File

@ -67,11 +67,12 @@ nfs_rmdir
nfs_rmdir_async
nfs_service
nfs_set_auth
nfs_set_debug
nfs_set_dircache
nfs_set_gid
nfs_set_readahead
nfs_set_tcp_syncnt
nfs_set_uid
nfs_set_readahead
nfs_set_debug
nfs_stat
nfs_stat_async
nfs_stat64

View File

@ -131,6 +131,7 @@ struct nfs_context {
uint64_t readmax;
uint64_t writemax;
char *cwd;
int dircache_enabled;
struct nfsdir *dircache;
uint16_t mask;
@ -275,6 +276,8 @@ static int nfs_set_context_args(struct nfs_context *nfs, const char *arg, const
rpc_set_debug(nfs_get_rpc_context(nfs), atoi(val));
} else if (!strcmp(arg, "auto-traverse-mounts")) {
nfs->auto_traverse_mounts = atoi(val);
} else if (!strcmp(arg, "dircache")) {
nfs_set_dircache(nfs, atoi(val));
}
return 0;
}
@ -439,6 +442,7 @@ struct nfs_context *nfs_init_context(void)
nfs->cwd = strdup("/");
nfs->mask = 022;
nfs->auto_traverse_mounts = 1;
nfs->dircache_enabled = 1;
return nfs;
}
@ -4087,7 +4091,11 @@ struct nfsdirent *nfs_readdir(struct nfs_context *nfs _U_, struct nfsdir *nfsdir
*/
void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir)
{
nfs_dircache_add(nfs, nfsdir);
if (nfs->dircache_enabled) {
nfs_dircache_add(nfs, nfsdir);
} else {
nfs_free_nfsdir(nfsdir);
}
}
@ -5386,6 +5394,10 @@ void nfs_set_debug(struct nfs_context *nfs, int level) {
rpc_set_debug(nfs->rpc, level);
}
void nfs_set_dircache(struct nfs_context *nfs, int enabled) {
nfs->dircache_enabled = enabled;
}
void nfs_set_error(struct nfs_context *nfs, char *error_string, ...)
{
va_list ap;