summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-02 15:59:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:27 -0500
commit289bc557ebbad8c3ad8b24a37eb48a5d4de43ee2 (patch)
tree35fc180cd49c3cbbba193d46ec7c8bfd0ce9d3f6 /source4/ntvfs
parent3716deee4cd487a040db5616b76d500c9bf051be (diff)
downloadsamba-289bc557ebbad8c3ad8b24a37eb48a5d4de43ee2.tar.gz
samba-289bc557ebbad8c3ad8b24a37eb48a5d4de43ee2.tar.bz2
samba-289bc557ebbad8c3ad8b24a37eb48a5d4de43ee2.zip
r6580: fixed the bug that caused the truncation of the main file on a stream
open with openx and the 'truncate if exists' flag (This used to be commit aa82b105d5871b3ca693a0757bb48cc589d88824)
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c26
-rw-r--r--source4/ntvfs/posix/xattr_system.c2
2 files changed, 21 insertions, 7 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index e68670f7cc..4a2c8ea247 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -856,7 +856,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
uint32_t create_options;
uint32_t share_access;
uint32_t access_mask;
- BOOL stream_existed;
+ BOOL stream_existed, stream_truncate=False;
/* use the generic mapping code to avoid implementing all the
different open calls. */
@@ -892,13 +892,16 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
return NT_STATUS_INVALID_PARAMETER;
}
+ flags = 0;
+
switch (io->generic.in.open_disposition) {
case NTCREATEX_DISP_SUPERSEDE:
- flags = O_TRUNC;
- break;
-
case NTCREATEX_DISP_OVERWRITE_IF:
- flags = O_TRUNC;
+ if (name->stream_name == NULL) {
+ flags = O_TRUNC;
+ } else {
+ stream_truncate = True;
+ }
break;
case NTCREATEX_DISP_OPEN:
@@ -912,7 +915,11 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
if (!name->stream_exists) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- flags = O_TRUNC;
+ if (name->stream_name == NULL) {
+ flags = O_TRUNC;
+ } else {
+ stream_truncate = True;
+ }
break;
case NTCREATEX_DISP_CREATE:
@@ -1075,6 +1082,13 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
talloc_free(lck);
return status;
}
+ if (stream_truncate) {
+ status = pvfs_stream_truncate(pvfs, f->handle->name, fd, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(lck);
+ return status;
+ }
+ }
}
/* re-resolve the open fd */
diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c
index 3b8becf6fe..4101b69ed7 100644
--- a/source4/ntvfs/posix/xattr_system.c
+++ b/source4/ntvfs/posix/xattr_system.c
@@ -37,7 +37,7 @@ NTSTATUS pull_xattr_blob_system(struct pvfs_state *pvfs,
#if HAVE_XATTR_SUPPORT
int ret;
- *blob = data_blob_talloc(mem_ctx, NULL, estimated_size);
+ *blob = data_blob_talloc(mem_ctx, NULL, estimated_size+16);
if (blob->data == NULL) {
return NT_STATUS_NO_MEMORY;
}