diff --git a/include/ntfs-3g/param.h b/include/ntfs-3g/param.h index a4c5656b..ebc8a0ae 100644 --- a/include/ntfs-3g/param.h +++ b/include/ntfs-3g/param.h @@ -119,6 +119,9 @@ enum { * having access control in the file system leads to fewer requests * to the file system and fewer context switches. * + * Irrespective of the selected mode, cacheing is always used + * in read-only mounts + * * Possible values for high level : * 1 : no cache, kernel control (recommended) * 4 : no cache, file system control @@ -126,8 +129,8 @@ enum { * 7 : no cache, kernel control for ACLs * * Possible values for low level : - * 2 : no cache, kernel control (recommended) - * 3 : use kernel/fuse cache, kernel control + * 2 : no cache, kernel control + * 3 : use kernel/fuse cache, kernel control (recommended) * 5 : no cache, file system control * 6 : kernel/fuse cache, file system control (OpenIndiana only) * 8 : no cache, kernel control for ACLs @@ -138,6 +141,7 @@ enum { * of 6 is added in the mount report. */ +#define TIMEOUT_RO 600 /* Attribute time out for read-only mounts */ #if defined(__sun) && defined(__SVR4) /* * Access control by kernel is not implemented on OpenIndiana, @@ -153,7 +157,7 @@ enum { * Also ACL checks by recent kernels do not prove satisfactory. */ #define HPERMSCONFIG 1 -#define LPERMSCONFIG 2 +#define LPERMSCONFIG 3 #endif /* defined(__sun) && defined(__SVR4) */ #endif /* defined _NTFS_PARAM_H */ diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index d005e683..04fbef65 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -129,12 +129,12 @@ #endif #if !CACHEING -#define ATTR_TIMEOUT 0.0 -#define ENTRY_TIMEOUT 0.0 +#define ATTR_TIMEOUT (ctx->ro ? TIMEOUT_RO : 0.0) +#define ENTRY_TIMEOUT (ctx->ro ? TIMEOUT_RO : 0.0) #else #if defined(__sun) && defined (__SVR4) -#define ATTR_TIMEOUT 10.0 -#define ENTRY_TIMEOUT 10.0 +#define ATTR_TIMEOUT (ctx->ro ? TIMEOUT_RO : 10.0) +#define ENTRY_TIMEOUT (ctx->ro ? TIMEOUT_RO : 10.0) #else /* defined(__sun) && defined (__SVR4) */ /* * FUSE cacheing is only usable with basic permissions @@ -144,11 +144,13 @@ #warning "Fuse cacheing is only usable with basic permissions checked by kernel" #endif #if KERNELACLS -#define ATTR_TIMEOUT 10.0 -#define ENTRY_TIMEOUT 10.0 +#define ATTR_TIMEOUT (ctx->ro ? TIMEOUT_RO : 10.0) +#define ENTRY_TIMEOUT (ctx->ro ? TIMEOUT_RO : 10.0) #else /* KERNELACLS */ -#define ATTR_TIMEOUT (ctx->vol->secure_flags & (1 << SECURITY_DEFAULT) ? 10.0 : 0.0) -#define ENTRY_TIMEOUT (ctx->vol->secure_flags & (1 << SECURITY_DEFAULT) ? 10.0 : 0.0) +#define ATTR_TIMEOUT (ctx->ro ? TIMEOUT_RO : \ + (ctx->vol->secure_flags & (1 << SECURITY_DEFAULT) ? 10.0 : 0.0)) +#define ENTRY_TIMEOUT (ctx->ro ? TIMEOUT_RO : \ + (ctx->vol->secure_flags & (1 << SECURITY_DEFAULT) ? 10.0 : 0.0)) #endif /* KERNELACLS */ #endif /* defined(__sun) && defined (__SVR4) */ #endif /* !CACHEING */ diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index b5d425e4..eb91797e 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -4054,13 +4054,28 @@ static struct fuse *mount_fuse(char *parsed_options) if (fuse_opt_add_arg(&args, "") == -1) goto err; + if (ctx->ro) { + char buf[128]; + int len; + + len = snprintf(buf, sizeof(buf), "-ouse_ino,kernel_cache" + ",attr_timeout=%d,entry_timeout=%d", + (int)TIMEOUT_RO, (int)TIMEOUT_RO); + if ((len < 0) + || (len >= (int)sizeof(buf)) + || (fuse_opt_add_arg(&args, buf) == -1)) + goto err; + } else { #if !CACHEING - if (fuse_opt_add_arg(&args, "-ouse_ino,kernel_cache,attr_timeout=0") == -1) - goto err; + if (fuse_opt_add_arg(&args, "-ouse_ino,kernel_cache" + ",attr_timeout=0") == -1) + goto err; #else - if (fuse_opt_add_arg(&args, "-ouse_ino,kernel_cache,attr_timeout=1") == -1) - goto err; + if (fuse_opt_add_arg(&args, "-ouse_ino,kernel_cache" + ",attr_timeout=1") == -1) + goto err; #endif + } if (ctx->debug) if (fuse_opt_add_arg(&args, "-odebug") == -1) goto err;