summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/dosmode.c2
-rw-r--r--source3/smbd/fileio.c3
-rw-r--r--source3/smbd/open.c9
3 files changed, 13 insertions, 1 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 2c6dcd00c6..cf95348583 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -911,6 +911,8 @@ NTSTATUS file_set_sparse(connection_struct *conn,
FILE_NOTIFY_CHANGE_ATTRIBUTES,
fsp->fsp_name->base_name);
+ fsp->is_sparse = sparse;
+
return NT_STATUS_OK;
}
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index aec6554436..da40013bc5 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -128,7 +128,8 @@ static ssize_t real_write_file(struct smb_request *req,
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;
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 80756d6641..32a08b5967 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2221,6 +2221,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
}
}
+ /* 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.