1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

vfs: add and use fget_ea_dos_attribute()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-11-03 07:57:03 +01:00
parent 0f5a28d6c1
commit d466ba6d61
3 changed files with 40 additions and 1 deletions

View File

@ -1894,7 +1894,7 @@ static NTSTATUS vfswrap_fget_dos_attributes(struct vfs_handle_struct *handle,
*dosmode |= FILE_ATTRIBUTE_OFFLINE;
}
return get_ea_dos_attribute(handle->conn, fsp->fsp_name, dosmode);
return fget_ea_dos_attribute(fsp, dosmode);
}
static NTSTATUS vfswrap_set_dos_attributes(struct vfs_handle_struct *handle,

View File

@ -436,6 +436,43 @@ NTSTATUS get_ea_dos_attribute(connection_struct *conn,
return NT_STATUS_OK;
}
NTSTATUS fget_ea_dos_attribute(struct files_struct *fsp,
uint32_t *pattr)
{
DATA_BLOB blob;
ssize_t sizeret;
fstring attrstr;
NTSTATUS status;
if (!lp_store_dos_attributes(SNUM(fsp->conn))) {
return NT_STATUS_NOT_IMPLEMENTED;
}
/* Don't reset pattr to zero as we may already have filename-based attributes we
need to preserve. */
sizeret = SMB_VFS_FGETXATTR(fsp->base_fsp ? fsp->base_fsp : fsp,
SAMBA_XATTR_DOS_ATTRIB,
attrstr,
sizeof(attrstr));
if (sizeret == -1) {
DBG_INFO("Cannot get attribute "
"from EA on file %s: Error = %s\n",
fsp_str_dbg(fsp), strerror(errno));
return map_nt_error_from_unix(errno);
}
blob.data = (uint8_t *)attrstr;
blob.length = sizeret;
status = parse_dos_attribute_blob(fsp->fsp_name, blob, pattr);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
return NT_STATUS_OK;
}
/****************************************************************************
Set DOS attributes in an EA.
Also sets the create time.

View File

@ -290,6 +290,8 @@ bool set_sticky_write_time_fsp(struct files_struct *fsp,
NTSTATUS get_ea_dos_attribute(connection_struct *conn,
struct smb_filename *smb_fname,
uint32_t *pattr);
NTSTATUS fget_ea_dos_attribute(struct files_struct *fsp,
uint32_t *pattr);
NTSTATUS set_ea_dos_attribute(connection_struct *conn,
const struct smb_filename *smb_fname,
uint32_t dosmode);