aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--cache.c12
-rw-r--r--opts.c18
-rw-r--r--opts.h2
-rw-r--r--sshfs.c17
5 files changed, 40 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 59bb2e5..27a4b2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-02-17 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Parse 'max_read' mount option and if smaller than 65536 forward
+ to FUSE
+
2005-02-16 Miklos Szeredi <miklos@szeredi.hu>
* Added simple readahead (big performance gain in case of
diff --git a/cache.c b/cache.c
index 034121d..b3ccd60 100644
--- a/cache.c
+++ b/cache.c
@@ -486,21 +486,11 @@ static struct opt cache_opts[] = {
static int get_timeout(int sel, unsigned *timeoutp)
{
- char *end;
struct opt *o = &cache_opts[sel];
- unsigned val;
if (!o->present)
return 0;
- if (!o->value || !o->value[0]) {
- fprintf(stderr, "Missing value for '%s' option\n", o->optname);
+ if (opt_get_unsigned(o, timeoutp) == -1)
return -1;
- }
- val = strtoul(o->value, &end, 10);
- if (end[0]) {
- fprintf(stderr, "Invalid value for '%s' option\n", o->optname);
- return -1;
- }
- *timeoutp = val;
return 1;
}
diff --git a/opts.c b/opts.c
index 4027d18..373e5b6 100644
--- a/opts.c
+++ b/opts.c
@@ -7,6 +7,7 @@
*/
#include "opts.h"
+#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
@@ -102,3 +103,20 @@ void process_options(int *argcp, char *argv[], struct opt opts[],
}
*argcp = newargctr;
}
+
+int opt_get_unsigned(const struct opt *o, unsigned *valp)
+{
+ char *end;
+ unsigned val;
+ if (!o->value || !o->value[0]) {
+ fprintf(stderr, "Missing value for '%s' option\n", o->optname);
+ return -1;
+ }
+ val = strtoul(o->value, &end, 0);
+ if (end[0]) {
+ fprintf(stderr, "Invalid value for '%s' option\n", o->optname);
+ return -1;
+ }
+ *valp = val;
+ return 0;
+}
diff --git a/opts.h b/opts.h
index b5c8729..86e2f24 100644
--- a/opts.h
+++ b/opts.h
@@ -14,3 +14,5 @@ struct opt {
void process_options(int *argcp, char *argv[], struct opt opts[],
int case_sensitive);
+
+int opt_get_unsigned(const struct opt *o, unsigned *valp);
diff --git a/sshfs.c b/sshfs.c
index ae88cf8..4cda622 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -187,6 +187,7 @@ enum {
SOPT_SSHCMD,
SOPT_SYNC_WRITE,
SOPT_SYNC_READ,
+ SOPT_MAX_READ,
SOPT_LAST /* Last entry in this list! */
};
@@ -195,6 +196,7 @@ static struct opt sshfs_opts[] = {
[SOPT_SSHCMD] = { .optname = "ssh_command" },
[SOPT_SYNC_WRITE] = { .optname = "sshfs_sync" },
[SOPT_SYNC_READ] = { .optname = "no_readahead" },
+ [SOPT_MAX_READ] = { .optname = "max_read" },
[SOPT_LAST] = { .optname = NULL }
};
@@ -1308,8 +1310,8 @@ static struct read_chunk *search_read_chunk(struct sshfs_file *sf, size_t size,
off_t offset)
{
struct read_chunk *ch = sf->readahead;
- if (ch && ch->size == size && ch->offset == offset) {
- sf->readahead = NULL;
+ if (ch && ch->offset == offset && ch->size == size) {
+ ch->refs++;
return ch;
} else
return NULL;
@@ -1485,6 +1487,7 @@ int main(int argc, char *argv[])
char *fsname;
int res;
int argctr;
+ unsigned max_read = 65536;
int newargc = 0;
char **newargv = (char **) malloc((argc + 10) * sizeof(char *));
newargv[newargc++] = argv[0];
@@ -1545,6 +1548,14 @@ int main(int argc, char *argv[])
sync_write = 1;
if (sshfs_opts[SOPT_SYNC_READ].present)
sync_read = 1;
+ if (sshfs_opts[SOPT_MAX_READ].present) {
+ unsigned val;
+ if (opt_get_unsigned(&sshfs_opts[SOPT_MAX_READ], &val) == -1)
+ exit(1);
+
+ if (val < max_read)
+ max_read = val;
+ }
if (sshfs_opts[SOPT_DIRECTPORT].present)
res = connect_to(host, sshfs_opts[SOPT_DIRECTPORT].value);
else {
@@ -1567,7 +1578,7 @@ int main(int argc, char *argv[])
if (res == -1)
exit(1);
- newargv[newargc++] = "-omax_read=65536";
+ newargv[newargc++] = g_strdup_printf("-omax_read=%u", max_read);
newargv[newargc++] = g_strdup_printf("-ofsname=sshfs#%s", fsname);
g_free(fsname);
newargv[newargc] = NULL;