<member>fchmod</member>
<member>fchown</member>
<member>fdopendir</member>
+ <member>fget_compression</member>
<member>fget_dos_attributes</member>
<member>fget_nt_acl_at</member>
<member>fgetxattr</member>
<member>fsync_send</member>
<member>ftruncate</member>
<member>get_alloc_size</member>
- <member>get_compression</member>
<member>get_dfs_referrals</member>
<member>get_dos_attributes</member>
<member>get_dos_attributes_recv</member>
return NT_STATUS_OK;
}
-static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
+static NTSTATUS skel_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
return NT_STATUS_INVALID_DEVICE_REQUEST;
.offload_read_recv_fn = skel_offload_read_recv,
.offload_write_send_fn = skel_offload_write_send,
.offload_write_recv_fn = skel_offload_write_recv,
- .get_compression_fn = skel_get_compression,
+ .fget_compression_fn = skel_fget_compression,
.set_compression_fn = skel_set_compression,
.streaminfo_fn = skel_streaminfo,
return NT_STATUS_OK;
}
-static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
+static NTSTATUS skel_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
- return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
+ return SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
_compression_fmt);
}
.offload_read_recv_fn = skel_offload_read_recv,
.offload_write_send_fn = skel_offload_write_send,
.offload_write_recv_fn = skel_offload_write_recv,
- .get_compression_fn = skel_get_compression,
+ .fget_compression_fn = skel_fget_compression,
.set_compression_fn = skel_set_compression,
.streaminfo_fn = skel_streaminfo,
* Version 44 - Add 'have_proc_fds' flag to struct files_struct.
* Version 44 - Add dirfsp arg to SMB_VFS_READDIR()
* Version 44 - Remove SMB_VFS_GET_DOS_ATTRIBUTES()
+ * Version 44 - Replace SMB_VFS_GET_COMPRESSION() with SMB_VFS_FGET_COMPRESSION()
*/
#define SMB_VFS_INTERFACE_VERSION 44
NTSTATUS (*offload_write_recv_fn)(struct vfs_handle_struct *handle,
struct tevent_req *req,
off_t *copied);
- NTSTATUS (*get_compression_fn)(struct vfs_handle_struct *handle,
+ NTSTATUS (*fget_compression_fn)(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt);
NTSTATUS (*set_compression_fn)(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
NTSTATUS smb_vfs_call_offload_write_recv(struct vfs_handle_struct *handle,
struct tevent_req *req,
off_t *copied);
-NTSTATUS smb_vfs_call_get_compression(struct vfs_handle_struct *handle,
+NTSTATUS smb_vfs_call_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt);
NTSTATUS smb_vfs_call_set_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
NTSTATUS vfs_not_implemented_offload_write_recv(struct vfs_handle_struct *handle,
struct tevent_req *req,
off_t *copied);
-NTSTATUS vfs_not_implemented_get_compression(struct vfs_handle_struct *handle,
+NTSTATUS vfs_not_implemented_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt);
NTSTATUS vfs_not_implemented_set_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
#define SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(handle, req, copied) \
smb_vfs_call_offload_write_recv((handle)->next, (req), (copied))
-#define SMB_VFS_GET_COMPRESSION(conn, mem_ctx, fsp, smb_fname, _compression_fmt) \
- smb_vfs_call_get_compression((conn)->vfs_handles, (mem_ctx), (fsp), (smb_fname), (_compression_fmt))
-#define SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname, _compression_fmt) \
- smb_vfs_call_get_compression((handle)->next, (mem_ctx), (fsp), (smb_fname), (_compression_fmt))
+#define SMB_VFS_FGET_COMPRESSION(conn, mem_ctx, fsp, _compression_fmt) \
+ smb_vfs_call_fget_compression((conn)->vfs_handles, (mem_ctx), (fsp), (_compression_fmt))
+#define SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp, _compression_fmt) \
+ smb_vfs_call_fget_compression((handle)->next, (mem_ctx), (fsp), (_compression_fmt))
#define SMB_VFS_SET_COMPRESSION(conn, mem_ctx, fsp, compression_fmt) \
smb_vfs_call_set_compression((conn)->vfs_handles, (mem_ctx), (fsp), (compression_fmt))
return NT_STATUS_OK;
}
-/*
- * caller must pass a non-null fsp or smb_fname. If fsp is null, then
- * fall back to opening the corresponding file to issue the ioctl.
- */
-static NTSTATUS btrfs_get_compression(struct vfs_handle_struct *handle,
- TALLOC_CTX *mem_ctx,
- struct files_struct *fsp,
- struct smb_filename *smb_fname,
- uint16_t *_compression_fmt)
+static NTSTATUS btrfs_fget_compression(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *fsp,
+ uint16_t *_compression_fmt)
{
+ char buf[PATH_MAX];
+ const char *p = NULL;
int ret;
long flags = 0;
- int fd;
- bool opened = false;
+ int fd = -1;
NTSTATUS status;
- DIR *dir = NULL;
-
- if ((fsp != NULL) && (fsp_get_io_fd(fsp) != -1)) {
- fd = fsp_get_io_fd(fsp);
- } else if (smb_fname != NULL) {
- if (S_ISDIR(smb_fname->st.st_ex_mode)) {
- dir = opendir(smb_fname->base_name);
- if (dir == NULL) {
- return NT_STATUS_UNSUCCESSFUL;
- }
- opened = true;
- fd = dirfd(dir);
- if (fd < 0) {
- status = NT_STATUS_UNSUCCESSFUL;
- goto err_close;
- }
+
+ if (!fsp->fsp_flags.is_pathref) {
+ ret = ioctl(fd, FS_IOC_GETFLAGS, &flags);
+ if (ret < 0) {
+ DBG_WARNING("FS_IOC_GETFLAGS failed: %s, fd %lld\n",
+ strerror(errno), (long long)fd);
+ return map_nt_error_from_unix(errno);
+ }
+ if (flags & FS_COMPR_FL) {
+ *_compression_fmt = COMPRESSION_FORMAT_LZNT1;
} else {
- fd = open(smb_fname->base_name, O_RDONLY);
- if (fd < 0) {
- return NT_STATUS_UNSUCCESSFUL;
- }
- opened = true;
+ *_compression_fmt = COMPRESSION_FORMAT_NONE;
}
- } else {
- return NT_STATUS_INVALID_PARAMETER;
+ return NT_STATUS_OK;
+ }
+
+ if (!fsp->fsp_flags.have_proc_fds) {
+ return NT_STATUS_NOT_IMPLEMENTED;
+ }
+
+ fd = fsp_get_pathref_fd(fsp);
+
+ p = sys_proc_fd_path(fd, buf, sizeof(buf));
+ if (p == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ fd = open(p, O_RDONLY);
+ if (fd == -1) {
+ DBG_ERR("/proc open of %s failed: %s\n", p, strerror(errno));
+ return map_nt_error_from_unix(errno);
}
ret = ioctl(fd, FS_IOC_GETFLAGS, &flags);
*_compression_fmt = COMPRESSION_FORMAT_NONE;
}
status = NT_STATUS_OK;
+
err_close:
- if (opened) {
- if (dir != NULL) {
- closedir(dir);
- } else {
- close(fd);
- }
+ if (fd != -1) {
+ close(fd);
}
return status;
.offload_read_recv_fn = btrfs_offload_read_recv,
.offload_write_send_fn = btrfs_offload_write_send,
.offload_write_recv_fn = btrfs_offload_write_recv,
- .get_compression_fn = btrfs_get_compression,
+ .fget_compression_fn = btrfs_fget_compression,
.set_compression_fn = btrfs_set_compression,
.snap_check_path_fn = btrfs_snap_check_path,
.snap_create_fn = btrfs_snap_create,
return result;
}
-static NTSTATUS catia_get_compression(vfs_handle_struct *handle,
+static NTSTATUS catia_fget_compression(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
NTSTATUS result;
struct catia_cache *cc = NULL;
int ret;
- struct smb_filename *mapped_smb_fname = NULL;
- char *mapped_name = NULL;
-
- if (fsp != NULL) {
- ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
- if (ret != 0) {
- return map_nt_error_from_unix(errno);
- }
- mapped_smb_fname = fsp->fsp_name;
- } else {
- result = catia_string_replace_allocate(handle->conn,
- smb_fname->base_name,
- &mapped_name,
- vfs_translate_to_unix);
- if (!NT_STATUS_IS_OK(result)) {
- return result;
- }
-
- mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
- mapped_name,
- NULL,
- &smb_fname->st,
- smb_fname->twrp,
- smb_fname->flags);
- if (mapped_smb_fname == NULL) {
- TALLOC_FREE(mapped_name);
- return NT_STATUS_NO_MEMORY;
- }
- TALLOC_FREE(mapped_name);
+ ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
+ if (ret != 0) {
+ return map_nt_error_from_unix(errno);
}
- result = SMB_VFS_NEXT_GET_COMPRESSION(handle,
+ result = SMB_VFS_NEXT_FGET_COMPRESSION(handle,
mem_ctx,
fsp,
- mapped_smb_fname,
_compression_fmt);
- if (fsp != NULL) {
- CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
- } else {
- TALLOC_FREE(mapped_smb_fname);
- }
+ CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
return result;
}
.set_dos_attributes_fn = catia_set_dos_attributes,
.fset_dos_attributes_fn = catia_fset_dos_attributes,
.fget_dos_attributes_fn = catia_fget_dos_attributes,
- .get_compression_fn = catia_get_compression,
+ .fget_compression_fn = catia_fget_compression,
.set_compression_fn = catia_set_compression,
.create_dfs_pathat_fn = catia_create_dfs_pathat,
.read_dfs_pathat_fn = catia_read_dfs_pathat,
return NT_STATUS_OK;
}
-static NTSTATUS vfswrap_get_compression(struct vfs_handle_struct *handle,
+static NTSTATUS vfswrap_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
return NT_STATUS_INVALID_DEVICE_REQUEST;
.offload_read_recv_fn = vfswrap_offload_read_recv,
.offload_write_send_fn = vfswrap_offload_write_send,
.offload_write_recv_fn = vfswrap_offload_write_recv,
- .get_compression_fn = vfswrap_get_compression,
+ .fget_compression_fn = vfswrap_fget_compression,
.set_compression_fn = vfswrap_set_compression,
/* NT ACL operations. */
SMB_VFS_OP_OFFLOAD_READ_RECV,
SMB_VFS_OP_OFFLOAD_WRITE_SEND,
SMB_VFS_OP_OFFLOAD_WRITE_RECV,
- SMB_VFS_OP_GET_COMPRESSION,
+ SMB_VFS_OP_FGET_COMPRESSION,
SMB_VFS_OP_SET_COMPRESSION,
SMB_VFS_OP_SNAP_CHECK_PATH,
SMB_VFS_OP_SNAP_CREATE,
{ SMB_VFS_OP_OFFLOAD_READ_RECV, "offload_read_recv" },
{ SMB_VFS_OP_OFFLOAD_WRITE_SEND, "offload_write_send" },
{ SMB_VFS_OP_OFFLOAD_WRITE_RECV, "offload_write_recv" },
- { SMB_VFS_OP_GET_COMPRESSION, "get_compression" },
+ { SMB_VFS_OP_FGET_COMPRESSION, "fget_compression" },
{ SMB_VFS_OP_SET_COMPRESSION, "set_compression" },
{ SMB_VFS_OP_SNAP_CHECK_PATH, "snap_check_path" },
{ SMB_VFS_OP_SNAP_CREATE, "snap_create" },
return result;
}
-static NTSTATUS smb_full_audit_get_compression(vfs_handle_struct *handle,
+static NTSTATUS smb_full_audit_fget_compression(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
NTSTATUS result;
- result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
+ result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
_compression_fmt);
- do_log(SMB_VFS_OP_GET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
+ do_log(SMB_VFS_OP_FGET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
"%s",
- (fsp ? fsp_str_do_log(fsp) :
- smb_fname_str_do_log(handle->conn, smb_fname)));
+ fsp_str_do_log(fsp));
return result;
}
.offload_read_recv_fn = smb_full_audit_offload_read_recv,
.offload_write_send_fn = smb_full_audit_offload_write_send,
.offload_write_recv_fn = smb_full_audit_offload_write_recv,
- .get_compression_fn = smb_full_audit_get_compression,
+ .fget_compression_fn = smb_full_audit_fget_compression,
.set_compression_fn = smb_full_audit_set_compression,
.snap_check_path_fn = smb_full_audit_snap_check_path,
.snap_create_fn = smb_full_audit_snap_create,
return NT_STATUS_OK;
}
-NTSTATUS vfs_not_implemented_get_compression(struct vfs_handle_struct *handle,
+NTSTATUS vfs_not_implemented_fget_compression(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
return NT_STATUS_INVALID_DEVICE_REQUEST;
.offload_read_recv_fn = vfs_not_implemented_offload_read_recv,
.offload_write_send_fn = vfs_not_implemented_offload_write_send,
.offload_write_recv_fn = vfs_not_implemented_offload_write_recv,
- .get_compression_fn = vfs_not_implemented_get_compression,
+ .fget_compression_fn = vfs_not_implemented_fget_compression,
.set_compression_fn = vfs_not_implemented_set_compression,
.streaminfo_fn = vfs_not_implemented_streaminfo,
return NT_STATUS_OK;
}
-static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
+static NTSTATUS smb_time_audit_fget_compression(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
NTSTATUS result;
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
+ result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
_compression_fmt);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
- if (fsp != NULL) {
- smb_time_audit_log_fsp("get_compression",
- timediff, fsp);
- } else {
- smb_time_audit_log_smb_fname("get_compression",
- timediff, smb_fname);
- }
+ smb_time_audit_log_fsp("get_compression",
+ timediff, fsp);
}
return result;
.offload_read_recv_fn = smb_time_audit_offload_read_recv,
.offload_write_send_fn = smb_time_audit_offload_write_send,
.offload_write_recv_fn = smb_time_audit_offload_write_recv,
- .get_compression_fn = smb_time_audit_get_compression,
+ .fget_compression_fn = smb_time_audit_fget_compression,
.set_compression_fn = smb_time_audit_set_compression,
.snap_check_path_fn = smb_time_audit_snap_check_path,
.snap_create_fn = smb_time_audit_snap_create,
goto err_out;
}
- status = SMB_VFS_GET_COMPRESSION(conn, tmp_ctx, fsp, smb_fname,
+ status = SMB_VFS_FGET_COMPRESSION(conn, tmp_ctx, fsp,
&compression_fmt);
if (!NT_STATUS_IS_OK(status)) {
goto err_ctx_free;
ZERO_STRUCT(cmpr_state);
if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) {
- status = SMB_VFS_GET_COMPRESSION(fsp->conn,
+ status = SMB_VFS_FGET_COMPRESSION(fsp->conn,
mem_ctx,
fsp,
- NULL,
&cmpr_state.format);
if (!NT_STATUS_IS_OK(status)) {
return status;
return NT_STATUS_OK;
}
-NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,
+NTSTATUS smb_vfs_call_fget_compression(vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx,
struct files_struct *fsp,
- struct smb_filename *smb_fname,
uint16_t *_compression_fmt)
{
- VFS_FIND(get_compression);
- return handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname,
+ VFS_FIND(fget_compression);
+ return handle->fns->fget_compression_fn(handle, mem_ctx, fsp,
_compression_fmt);
}