aboutsummaryrefslogtreecommitdiffstats
path: root/example/fusexmp.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-11-16 13:00:24 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-11-16 13:00:24 +0000
commitb3f9972a859e95cf836c0044c82fcf312afc566e (patch)
tree8eaad737402f56ae53f6ed57e2b0878830e652eb /example/fusexmp.c
parent666aea72dfafcf8e93d9c781d1d8d3e644bd6949 (diff)
downloadlibfuse-b3f9972a859e95cf836c0044c82fcf312afc566e.tar.gz
merge FreeBSD stuff
Diffstat (limited to 'example/fusexmp.c')
-rw-r--r--example/fusexmp.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/example/fusexmp.c b/example/fusexmp.c
index 5a2e9a0..26b2be2 100644
--- a/example/fusexmp.c
+++ b/example/fusexmp.c
@@ -29,7 +29,7 @@ static int xmp_getattr(const char *path, struct stat *stbuf)
int res;
res = lstat(path, stbuf);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -40,7 +40,7 @@ static int xmp_access(const char *path, int mask)
int res;
res = access(path, mask);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -51,7 +51,7 @@ static int xmp_readlink(const char *path, char *buf, size_t size)
int res;
res = readlink(path, buf, size - 1);
- if(res == -1)
+ if (res == -1)
return -errno;
buf[res] = '\0';
@@ -69,10 +69,10 @@ static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
(void) fi;
dp = opendir(path);
- if(dp == NULL)
+ if (dp == NULL)
return -errno;
- while((de = readdir(dp)) != NULL) {
+ while ((de = readdir(dp)) != NULL) {
struct stat st;
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
@@ -89,8 +89,17 @@ static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
int res;
- res = mknod(path, mode, rdev);
- if(res == -1)
+ /* On Linux this could just be 'mknod(path, mode, rdev)' but this
+ is more portable */
+ if (S_ISREG(mode)) {
+ res = open(path, O_CREAT | O_EXCL | O_WRONLY, mode);
+ if (res >= 0)
+ res = close(res);
+ } else if (S_ISFIFO(mode))
+ res = mkfifo(path, mode);
+ else
+ res = mknod(path, mode, rdev);
+ if (res == -1)
return -errno;
return 0;
@@ -101,7 +110,7 @@ static int xmp_mkdir(const char *path, mode_t mode)
int res;
res = mkdir(path, mode);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -112,7 +121,7 @@ static int xmp_unlink(const char *path)
int res;
res = unlink(path);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -123,7 +132,7 @@ static int xmp_rmdir(const char *path)
int res;
res = rmdir(path);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -134,7 +143,7 @@ static int xmp_symlink(const char *from, const char *to)
int res;
res = symlink(from, to);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -145,7 +154,7 @@ static int xmp_rename(const char *from, const char *to)
int res;
res = rename(from, to);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -156,7 +165,7 @@ static int xmp_link(const char *from, const char *to)
int res;
res = link(from, to);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -167,7 +176,7 @@ static int xmp_chmod(const char *path, mode_t mode)
int res;
res = chmod(path, mode);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -178,7 +187,7 @@ static int xmp_chown(const char *path, uid_t uid, gid_t gid)
int res;
res = lchown(path, uid, gid);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -189,7 +198,7 @@ static int xmp_truncate(const char *path, off_t size)
int res;
res = truncate(path, size);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -200,7 +209,7 @@ static int xmp_utime(const char *path, struct utimbuf *buf)
int res;
res = utime(path, buf);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -212,7 +221,7 @@ static int xmp_open(const char *path, struct fuse_file_info *fi)
int res;
res = open(path, fi->flags);
- if(res == -1)
+ if (res == -1)
return -errno;
close(res);
@@ -227,11 +236,11 @@ static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
(void) fi;
fd = open(path, O_RDONLY);
- if(fd == -1)
+ if (fd == -1)
return -errno;
res = pread(fd, buf, size, offset);
- if(res == -1)
+ if (res == -1)
res = -errno;
close(fd);
@@ -246,11 +255,11 @@ static int xmp_write(const char *path, const char *buf, size_t size,
(void) fi;
fd = open(path, O_WRONLY);
- if(fd == -1)
+ if (fd == -1)
return -errno;
res = pwrite(fd, buf, size, offset);
- if(res == -1)
+ if (res == -1)
res = -errno;
close(fd);
@@ -262,7 +271,7 @@ static int xmp_statfs(const char *path, struct statvfs *stbuf)
int res;
res = statvfs(path, stbuf);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
@@ -296,7 +305,7 @@ static int xmp_setxattr(const char *path, const char *name, const char *value,
size_t size, int flags)
{
int res = lsetxattr(path, name, value, size, flags);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
}
@@ -305,7 +314,7 @@ static int xmp_getxattr(const char *path, const char *name, char *value,
size_t size)
{
int res = lgetxattr(path, name, value, size);
- if(res == -1)
+ if (res == -1)
return -errno;
return res;
}
@@ -313,7 +322,7 @@ static int xmp_getxattr(const char *path, const char *name, char *value,
static int xmp_listxattr(const char *path, char *list, size_t size)
{
int res = llistxattr(path, list, size);
- if(res == -1)
+ if (res == -1)
return -errno;
return res;
}
@@ -321,7 +330,7 @@ static int xmp_listxattr(const char *path, char *list, size_t size)
static int xmp_removexattr(const char *path, const char *name)
{
int res = lremovexattr(path, name);
- if(res == -1)
+ if (res == -1)
return -errno;
return 0;
}