{
if (ino != 2)
fuse_reply_err(req, EISDIR);
- else if ((fi->flags & 3) != O_RDONLY)
+ else if ((fi->flags & O_ACCMODE) != O_RDONLY)
fuse_reply_err(req, EACCES);
else
fuse_reply_open(req, fi);
timeout, so we just send a big value */
#define NO_TIMEOUT 500000
-/* We cannot check directly if e.g. O_RDONLY is set, since this is not
- * an individual bit (cf. open(2)) */
-#define ACCESS_MASK (O_RDONLY | O_WRONLY | O_RDWR)
-
#define MAX_STR_LEN 128
#define FILE_INO 2
#define FILE_NAME "current_time"
if (ino == FUSE_ROOT_ID)
fuse_reply_err(req, EISDIR);
- else if ((fi->flags & ACCESS_MASK) != O_RDONLY)
+ else if ((fi->flags & O_ACCMODE) != O_RDONLY)
fuse_reply_err(req, EACCES);
else if (ino == FILE_INO)
fuse_reply_open(req, fi);
timeout, so we just send a big value */
#define NO_TIMEOUT 500000
-/* We cannot check directly if e.g. O_RDONLY is set, since this is not
- * an individual bit (cf. open(2)) */
-#define ACCESS_MASK (O_RDONLY | O_WRONLY | O_RDWR)
-
#define MAX_STR_LEN 128
#define FILE_INO 2
#define FILE_NAME "current_time"
if (ino == FUSE_ROOT_ID)
fuse_reply_err(req, EISDIR);
- else if ((fi->flags & ACCESS_MASK) != O_RDONLY)
+ else if ((fi->flags & O_ACCMODE) != O_RDONLY)
fuse_reply_err(req, EACCES);
else if (ino == FILE_INO)
fuse_reply_open(req, fi);
if (idx < 0)
return -ENOENT;
- if ((fi->flags & 3) != O_RDONLY)
+ if ((fi->flags & O_ACCMODE) != O_RDONLY)
return -EACCES;
if (fsel_open_mask & (1 << idx))
return -EBUSY;
*/
#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
+/**
+ * Fsync flags
+ *
+ * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata
+ */
+#define FUSE_FSYNC_FDATASYNC (1 << 0)
+
enum fuse_opcode {
FUSE_LOOKUP = 1,
FUSE_FORGET = 2, /* no reply */
dirent->ino = stbuf->st_ino;
dirent->off = off;
dirent->namelen = namelen;
- dirent->type = (stbuf->st_mode & 0170000) >> 12;
+ dirent->type = (stbuf->st_mode & S_IFMT) >> 12;
strncpy(dirent->name, name, namelen);
memset(dirent->name + namelen, 0, entlen_padded - entlen);
dirent->ino = e->attr.st_ino;
dirent->off = off;
dirent->namelen = namelen;
- dirent->type = (e->attr.st_mode & 0170000) >> 12;
+ dirent->type = (e->attr.st_mode & S_IFMT) >> 12;
strncpy(dirent->name, name, namelen);
memset(dirent->name + namelen, 0, entlen_padded - entlen);
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
- fi.writepage = (arg->write_flags & 1) != 0;
+ fi.writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
if (req->se->conn.proto_minor < 9) {
param = ((char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
- fi.writepage = arg->write_flags & 1;
+ fi.writepage = arg->write_flags & FUSE_WRITE_CACHE;
if (se->conn.proto_minor < 9) {
bufv.buf[0].mem = ((char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE;
{
struct fuse_fsync_in *arg = (struct fuse_fsync_in *) inarg;
struct fuse_file_info fi;
+ int datasync = arg->fsync_flags & FUSE_FSYNC_FDATASYNC;
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
if (req->se->op.fsync)
- req->se->op.fsync(req, nodeid, arg->fsync_flags & 1, &fi);
+ req->se->op.fsync(req, nodeid, datasync, &fi);
else
fuse_reply_err(req, ENOSYS);
}
{
struct fuse_fsync_in *arg = (struct fuse_fsync_in *) inarg;
struct fuse_file_info fi;
+ int datasync = arg->fsync_flags & FUSE_FSYNC_FDATASYNC;
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
if (req->se->op.fsyncdir)
- req->se->op.fsyncdir(req, nodeid, arg->fsync_flags & 1, &fi);
+ req->se->op.fsyncdir(req, nodeid, datasync, &fi);
else
fuse_reply_err(req, ENOSYS);
}
PERROR("lstat");
return -1;
}
- if ((stbuf.st_mode & 07777) != mode) {
- ERROR("mode 0%o instead of 0%o", stbuf.st_mode & 07777, mode);
+ if ((stbuf.st_mode & ALLPERMS) != mode) {
+ ERROR("mode 0%o instead of 0%o", stbuf.st_mode & ALLPERMS,
+ mode);
return -1;
}
return 0;
PERROR("fstat");
return -1;
}
- if ((stbuf.st_mode & 07777) != mode) {
- ERROR("mode 0%o instead of 0%o", stbuf.st_mode & 07777, mode);
+ if ((stbuf.st_mode & ALLPERMS) != mode) {
+ ERROR("mode 0%o instead of 0%o", stbuf.st_mode & ALLPERMS,
+ mode);
return -1;
}
return 0;
err += check_mode(testfile, mode);
err += check_nlink(testfile, 1);
err += check_size(testfile, currlen);
- if (exist && !(flags & O_TRUNC) && (mode & 0400))
+ if (exist && !(flags & O_TRUNC) && (mode & S_IRUSR))
err += check_data(testfile, testdata2, 0, testdata2len);
res = write(fd, data, datalen);
err += check_size(testfile, currlen);
- if (mode & 0400) {
+ if (mode & S_IRUSR) {
err += check_data(testfile, data, 0, datalen);
if (exist && !(flags & O_TRUNC) &&
testdata2len > datalen)