diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2005-08-23 15:39:43 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2005-08-23 15:39:43 +0000 |
commit | b0c52c59f710b4619949adfc359dabfca005fe0d (patch) | |
tree | ded91b7758b4c99506cdaa112446df40c8bab514 /example | |
parent | 9724d546a61d031eb0fa2ae5f64e26b7f77c781b (diff) |
fix
Diffstat (limited to 'example')
-rw-r--r-- | example/fusexmp_fh.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/example/fusexmp_fh.c b/example/fusexmp_fh.c index 432ff6f..a1d2283 100644 --- a/example/fusexmp_fh.c +++ b/example/fusexmp_fh.c @@ -217,6 +217,28 @@ static int xmp_open(const char *path, struct fuse_file_info *fi) return 0; } +static int xmp_create(const char *path, mode_t mode, struct fuse_file_info *fi) +{ + int fd; + struct stat stbuf; + + fd = open(path, fi->flags | O_NOFOLLOW, mode); + if(fd == -1) + return -errno; + + if (fstat(fd, &stbuf) == -1) { + close(fd); + return -EIO; + } + if (!S_ISREG(stbuf.st_mode)) { + close(fd); + return -EISDIR; + } + + fi->fh = fd; + return 0; +} + static int xmp_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { @@ -338,6 +360,7 @@ static struct fuse_operations xmp_oper = { .statfs = xmp_statfs, .release = xmp_release, .fsync = xmp_fsync, + .create = xmp_create, #ifdef HAVE_SETXATTR .setxattr = xmp_setxattr, .getxattr = xmp_getxattr, |