aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2004-02-20 16:38:45 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2004-02-20 16:38:45 +0000
commitc40748abd7f911b3c622600bd23b8517bd8f09c4 (patch)
tree3921bd77bcb57f36365cff93fb2bbe54af19b1d1 /lib/fuse.c
parentb59586199b5c53fa7002e9e1e6accc08a515f420 (diff)
downloadlibfuse-c40748abd7f911b3c622600bd23b8517bd8f09c4.tar.gz
fix
Diffstat (limited to 'lib/fuse.c')
-rw-r--r--lib/fuse.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/fuse.c b/lib/fuse.c
index 2e6950d..9d0783d 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -1106,6 +1106,9 @@ struct fuse_cmd *__fuse_read_cmd(struct fuse *f)
void fuse_loop(struct fuse *f)
{
+ if(f == NULL)
+ return;
+
while(1) {
struct fuse_cmd *cmd;
@@ -1133,6 +1136,35 @@ struct fuse_context *fuse_get_context(struct fuse *f)
return &f->context;
}
+static int check_version(struct fuse *f)
+{
+ int res;
+ FILE *vf = fopen(FUSE_VERSION_FILE, "r");
+ if(vf == NULL) {
+ fprintf(stderr, "fuse: kernel interface too old, need >= %i.%i\n",
+ FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
+ return -1;
+ }
+ res = fscanf(vf, "%i.%i", &f->majorver, &f->minorver);
+ fclose(vf);
+ if(res != 2) {
+ fprintf(stderr, "fuse: error reading %s\n", FUSE_VERSION_FILE);
+ return -1;
+ }
+ if(f->majorver != FUSE_KERNEL_VERSION) {
+ fprintf(stderr, "fuse: bad kernel interface major version: needs %i\n",
+ FUSE_KERNEL_VERSION);
+ return -1;
+ }
+ if(f->minorver < FUSE_KERNEL_MINOR_VERSION) {
+ fprintf(stderr, "fuse: kernel interface too old: need >= %i.%i",
+ FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
+ return -1;
+ }
+
+ return 0;
+}
+
struct fuse *fuse_new(int fd, int flags, const struct fuse_operations *op)
{
struct fuse *f;
@@ -1140,6 +1172,11 @@ struct fuse *fuse_new(int fd, int flags, const struct fuse_operations *op)
f = (struct fuse *) calloc(1, sizeof(struct fuse));
+ if(check_version(f) == -1) {
+ free(f);
+ return NULL;
+ }
+
f->flags = flags;
f->fd = fd;
f->ctr = 0;