bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
bool delete_on_close;
bool posix_open;
+ bool is_sparse;
struct smb_filename *fsp_name;
struct vfs_fsp_data *vfs_extension;
START_PROFILE(syscall_ftruncate);
- if (lp_strict_allocate(SNUM(fsp->conn))) {
+ if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) {
result = strict_allocate_ftruncate(handle, fsp, len);
END_PROFILE(syscall_ftruncate);
return result;
FILE_NOTIFY_CHANGE_ATTRIBUTES,
fsp->fsp_name->base_name);
+ fsp->is_sparse = sparse;
+
return NT_STATUS_OK;
}
ret = vfs_write_data(req, fsp, data, n);
} else {
fsp->fh->pos = pos;
- if (pos && lp_strict_allocate(SNUM(fsp->conn))) {
+ if (pos && lp_strict_allocate(SNUM(fsp->conn) &&
+ !fsp->is_sparse)) {
if (vfs_fill_sparse(fsp, pos) == -1) {
return -1;
}
}
}
+ /* Determine sparse flag. */
+ if (posix_open) {
+ /* POSIX opens are sparse by default. */
+ fsp->is_sparse = true;
+ } else {
+ fsp->is_sparse = (file_existed &&
+ (existing_dos_attributes & FILE_ATTRIBUTE_SPARSE));
+ }
+
/*
* Take care of inherited ACLs on created files - if default ACL not
* selected.