diff options
author | Ralph Boehme <slow@samba.org> | 2016-12-08 20:42:54 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2017-03-07 08:28:14 +0100 |
commit | abfcab1bb9dbc9865c1d2d65f20aa7db59aa4387 (patch) | |
tree | 8a3a5fbd9e3ac51c7a29b194e3e2aa08ab4efe3d | |
parent | 61147afcc19221f3cf075bf06c5dfdfdb72de504 (diff) | |
download | samba-abfcab1bb9dbc9865c1d2d65f20aa7db59aa4387.tar.gz |
vfs_fruit: refactor fruit_ftruncate and use new adouble API
Use struct fio to denote a fsp handle is for a stream we care about.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
(cherry picked from commit cc88132854ed47510e056ed451ed376770ee301e)
-rw-r--r-- | source3/modules/vfs_fruit.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 0d6db26d842..4a636ab40e8 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -4679,6 +4679,8 @@ static int fruit_ftruncate_rsrc_adouble(struct vfs_handle_struct *handle, ad = ad_fget(talloc_tos(), handle, fsp, ADOUBLE_RSRC); if (ad == NULL) { + DBG_DEBUG("ad_get [%s] failed [%s]\n", + fsp_str_dbg(fsp), strerror(errno)); return -1; } @@ -4686,6 +4688,7 @@ static int fruit_ftruncate_rsrc_adouble(struct vfs_handle_struct *handle, rc = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset + ad_off); if (rc != 0) { + TALLOC_FREE(ad); return -1; } @@ -4693,14 +4696,13 @@ static int fruit_ftruncate_rsrc_adouble(struct vfs_handle_struct *handle, rc = ad_fset(ad, fsp); if (rc != 0) { - DBG_ERR("ad_write [%s] failed [%s]\n", + DBG_ERR("ad_fset [%s] failed [%s]\n", fsp_str_dbg(fsp), strerror(errno)); + TALLOC_FREE(ad); return -1; } - DBG_DEBUG("Path [%s] offset [%jd]\n", - fsp_str_dbg(fsp), (intmax_t)offset); - + TALLOC_FREE(ad); return 0; } @@ -4719,13 +4721,10 @@ static int fruit_ftruncate_rsrc(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset) { + struct fio *fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp); int ret; - struct fruit_config_data *config; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return -1); - switch (config->rsrc) { + switch (fio->config->rsrc) { case FRUIT_RSRC_XATTR: ret = fruit_ftruncate_rsrc_xattr(handle, fsp, offset); break; @@ -4739,7 +4738,7 @@ static int fruit_ftruncate_rsrc(struct vfs_handle_struct *handle, break; default: - DBG_ERR("Unexpected rsrc config [%d]\n", config->rsrc); + DBG_ERR("Unexpected rsrc config [%d]\n", fio->config->rsrc); return -1; } @@ -4747,33 +4746,45 @@ static int fruit_ftruncate_rsrc(struct vfs_handle_struct *handle, return ret; } +static int fruit_ftruncate_meta(struct vfs_handle_struct *handle, + struct files_struct *fsp, + off_t offset) +{ + if (offset > 60) { + DBG_WARNING("ftruncate %s to %jd", + fsp_str_dbg(fsp), (intmax_t)offset); + /* OS X returns NT_STATUS_ALLOTTED_SPACE_EXCEEDED */ + errno = EOVERFLOW; + return -1; + } + + /* OS X returns success but does nothing */ + DBG_INFO("ignoring ftruncate %s to %jd\n", + fsp_str_dbg(fsp), (intmax_t)offset); + return 0; +} + static int fruit_ftruncate(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset) { - DBG_DEBUG("fruit_ftruncate called for file %s offset %.0f\n", - fsp_str_dbg(fsp), (double)offset); + struct fio *fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp); + int ret; - if (is_afpinfo_stream(fsp->fsp_name)) { - if (offset > 60) { - DBG_WARNING("ftruncate %s to %jd", - fsp_str_dbg(fsp), (intmax_t)offset); - /* OS X returns NT_STATUS_ALLOTTED_SPACE_EXCEEDED */ - errno = EOVERFLOW; - return -1; - } + DBG_DEBUG("Path [%s] offset [%zd]\n", fsp_str_dbg(fsp), offset); - DBG_WARNING("ignoring ftruncate %s to %jd", - fsp_str_dbg(fsp), (intmax_t)offset); - /* OS X returns success but does nothing */ - return 0; + if (fio == NULL) { + return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); } - if (is_afpresource_stream(fsp->fsp_name)) { - return fruit_ftruncate_rsrc(handle, fsp, offset); + if (fio->type == ADOUBLE_META) { + ret = fruit_ftruncate_meta(handle, fsp, offset); + } else { + ret = fruit_ftruncate_rsrc(handle, fsp, offset); } - return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); + DBG_DEBUG("Path [%s] result [%d]\n", fsp_str_dbg(fsp), ret); + return ret; } static NTSTATUS fruit_create_file(vfs_handle_struct *handle, |