summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c37
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c8
2 files changed, 44 insertions, 1 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 2430f9becb..6f1fb1c87f 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -539,6 +539,39 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs,
}
/*
+ special handling for t2open
+*/
+static NTSTATUS pvfs_open_t2open(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_open *io)
+{
+ struct pvfs_state *pvfs = ntvfs->private_data;
+ struct pvfs_filename *name;
+ NTSTATUS status;
+
+ status = pvfs_resolve_name(pvfs, req, io->t2open.in.fname,
+ PVFS_RESOLVE_NO_WILDCARD, &name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (io->t2open.in.open_func & OPENX_OPEN_FUNC_CREATE) {
+ if (!name->exists) return NT_STATUS_ACCESS_DENIED;
+ }
+ if (io->t2open.in.open_func & OPENX_OPEN_FUNC_TRUNC) {
+ if (name->exists) return NT_STATUS_ACCESS_DENIED;
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+ if ((io->t2open.in.open_func & 0xF) == OPENX_OPEN_FUNC_FAIL) {
+ if (!name->exists) return NT_STATUS_ACCESS_DENIED;
+ return NT_STATUS_OBJECT_NAME_COLLISION;
+ }
+
+ talloc_free(name);
+
+ return ntvfs_map_open(req, io, ntvfs);
+}
+
+/*
open a file
*/
NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
@@ -555,6 +588,10 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
uint32_t share_access;
uint32_t access_mask;
+ if (io->generic.level == RAW_OPEN_T2OPEN) {
+ return pvfs_open_t2open(ntvfs, req, io);
+ }
+
/* use the generic mapping code to avoid implementing all the
different open calls. This won't allow openx to work
perfectly as the mapping code has no way of knowing if two
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index e570743aba..22997be94d 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -188,10 +188,16 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
/* possibly change the file size */
if (newstats.st.st_size != f->name->st.st_size) {
+ int ret;
if (f->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
- if (ftruncate(f->fd, newstats.st.st_size) == -1) {
+ if (f->access_mask & SA_RIGHT_FILE_WRITE_APPEND) {
+ ret = ftruncate(f->fd, newstats.st.st_size);
+ } else {
+ ret = truncate(f->name->full_name, newstats.st.st_size);
+ }
+ if (ret == -1) {
return pvfs_map_errno(pvfs, errno);
}
}