}
static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
- enum vfs_fallocate_mode mode, off_t offset, off_t len)
+ uint32_t mode, off_t offset, off_t len)
{
errno = ENOSYS;
return -1;
}
static int skel_fallocate(vfs_handle_struct *handle, files_struct *fsp,
- enum vfs_fallocate_mode mode, off_t offset, off_t len)
+ uint32_t mode, off_t offset, off_t len)
{
return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
}
int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
bool fake_dir_create_times);
int sys_posix_fallocate(int fd, off_t offset, off_t len);
-int sys_fallocate(int fd, enum vfs_fallocate_mode mode, off_t offset, off_t len);
+int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len);
void kernel_flock(int fd, uint32 share_mode, uint32 access_mask);
DIR *sys_fdopendir(int fd);
int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
/* Version 32 - Add in and out create context blobs to create_file */
/* Version 32 - Remove unnecessary SMB_VFS_DISK_FREE() small_query parameter */
/* Bump to version 33 - Samba 4.3 will ship with that. */
+/* Version 33 - change fallocate mode flags param from enum->uint32_t */
#define SMB_VFS_INTERFACE_VERSION 33
vfs_translate_to_windows
};
-enum vfs_fallocate_mode {
- VFS_FALLOCATE_EXTEND_SIZE = 0,
- VFS_FALLOCATE_KEEP_SIZE = 1
+enum vfs_fallocate_flags {
+ VFS_FALLOCATE_FL_KEEP_SIZE = 0x0001,
};
/*
int (*ftruncate_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset);
int (*fallocate_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len);
bool (*lock_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, off_t offset, off_t count, int type);
int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
struct files_struct *fsp, off_t offset);
int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
- off_t offset,
- off_t len);
+ struct files_struct *fsp,
+ uint32_t mode,
+ off_t offset,
+ off_t len);
bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp, int op, off_t offset,
off_t count, int type);
#include <linux/falloc.h>
#endif
-int sys_fallocate(int fd, enum vfs_fallocate_mode mode, off_t offset, off_t len)
+int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len)
{
#if defined(HAVE_LINUX_FALLOCATE)
- int lmode;
- switch (mode) {
- case VFS_FALLOCATE_EXTEND_SIZE:
- lmode = 0;
- break;
- case VFS_FALLOCATE_KEEP_SIZE:
- lmode = FALLOC_FL_KEEP_SIZE;
- break;
- default:
+ int lmode = 0;
+
+ if (mode & VFS_FALLOCATE_FL_KEEP_SIZE) {
+ lmode |= FALLOC_FL_KEEP_SIZE;
+ mode &= ~VFS_FALLOCATE_FL_KEEP_SIZE;
+ }
+
+ if (mode != 0) {
+ DEBUG(2, ("unmapped fallocate flags: %lx\n",
+ (unsigned long)mode));
errno = EINVAL;
return -1;
}
emulation is being done by the libc (like on AIX with JFS1). In that
case we do our own emulation. fallocate implementations can
return ENOTSUP or EINVAL in cases like that. */
- ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
- pst->st_ex_size, space_to_write);
+ ret = SMB_VFS_FALLOCATE(fsp, 0, pst->st_ex_size, space_to_write);
if (ret == -1 && errno == ENOSPC) {
return -1;
}
emulation is being done by the libc (like on AIX with JFS1). In that
case we do our own emulation. fallocate implementations can
return ENOTSUP or EINVAL in cases like that. */
- ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
- pst->st_ex_size, space_to_write);
+ ret = SMB_VFS_FALLOCATE(fsp, 0, pst->st_ex_size, space_to_write);
if (ret == -1 && errno == ENOSPC) {
return -1;
}
static int vfswrap_fallocate(vfs_handle_struct *handle,
files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len)
{
int result;
START_PROFILE(syscall_fallocate);
- if (mode == VFS_FALLOCATE_EXTEND_SIZE) {
+ if (mode == 0) {
result = sys_posix_fallocate(fsp->fh->fd, offset, len);
/*
* posix_fallocate returns 0 on success, errno on error
errno = result;
result = -1;
}
- } else if (mode == VFS_FALLOCATE_KEEP_SIZE) {
- result = sys_fallocate(fsp->fh->fd, mode, offset, len);
} else {
- errno = EINVAL;
- result = -1;
+ /* sys_fallocate handles filtering of unsupported mode flags */
+ result = sys_fallocate(fsp->fh->fd, mode, offset, len);
}
END_PROFILE(syscall_fallocate);
return result;
static int fruit_fallocate(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len)
{
}
static int smb_full_audit_fallocate(vfs_handle_struct *handle, files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len)
{
static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset, off_t len)
{
+ /* TODO: add support using glfs_fallocate() and glfs_zerofill() */
errno = ENOTSUP;
return -1;
}
}
static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
- struct files_struct *fsp, enum vfs_fallocate_mode mode,
+ struct files_struct *fsp, uint32_t mode,
off_t offset, off_t len)
{
int ret;
return -1;
}
- if (mode == VFS_FALLOCATE_KEEP_SIZE) {
- DEBUG(10, ("Unsupported VFS_FALLOCATE_KEEP_SIZE\n"));
+ if (mode != 0) {
+ DEBUG(10, ("unmapped fallocate flags: %lx\n",
+ (unsigned long)mode));
errno = ENOTSUP;
return -1;
}
static int streams_xattr_fallocate(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len)
{
static int smb_time_audit_fallocate(vfs_handle_struct *handle,
files_struct *fsp,
- enum vfs_fallocate_mode mode,
+ uint32_t mode,
off_t offset,
off_t len)
{
if (lp_strict_allocate(SNUM(fsp->conn))) {
/* See if we have a syscall that will allocate beyond
end-of-file without changing EOF. */
- ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
+ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
+ 0, len);
} else {
ret = 0;
}
* emulation is being done by the libc (like on AIX with JFS1). In that
* case we do our own emulation. fallocate implementations can
* return ENOTSUP or EINVAL in cases like that. */
- ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
- offset, num_to_write);
+ ret = SMB_VFS_FALLOCATE(fsp, 0, offset, num_to_write);
if (ret == -1 && errno == ENOSPC) {
goto out;
}
}
int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
- enum vfs_fallocate_mode mode,
- off_t offset,
- off_t len)
+ struct files_struct *fsp,
+ uint32_t mode,
+ off_t offset,
+ off_t len)
{
VFS_FIND(fallocate);
return handle->fns->fallocate_fn(handle, fsp, mode, offset, len);