From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/ntvfs/ntvfs_generic.c | 544 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 544 insertions(+) create mode 100644 source4/ntvfs/ntvfs_generic.c (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c new file mode 100644 index 0000000000..def448a671 --- /dev/null +++ b/source4/ntvfs/ntvfs_generic.c @@ -0,0 +1,544 @@ +/* + Unix SMB/CIFS implementation. + + NTVFS generic level mapping code + + Copyright (C) Andrew Tridgell 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + this implements mappings between info levels for NTVFS backend calls + + the idea is that each of these functions implements one of the NTVFS + backend calls in terms of the 'generic' call. All backends that use + these functions must supply the generic call, but can if it wants to + also implement other levels if the need arises + + this allows backend writers to only implement one varient of each + call unless they need fine grained control of the calls. +*/ + +#include "includes.h" + +/* + see if a filename ends in EXE COM DLL or SYM. This is needed for the DENY_DOS mapping for OpenX +*/ +static BOOL is_exe_file(const char *fname) +{ + char *p; + p = strrchr(fname, '.'); + if (!p) { + return False; + } + p++; + if (strcasecmp(p, "EXE") == 0 || + strcasecmp(p, "COM") == 0 || + strcasecmp(p, "DLL") == 0 || + strcasecmp(p, "SYM") == 0) { + return True; + } + return False; +} + + +/* + NTVFS open generic to any mapper +*/ +NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) +{ + NTSTATUS status; + union smb_open io2; + + if (io->generic.level == RAW_OPEN_GENERIC) { + return NT_STATUS_INVALID_LEVEL; + } + + switch (io->generic.level) { + case RAW_OPEN_OPENX: + ZERO_STRUCT(io2.generic.in); + io2.generic.level = RAW_OPEN_GENERIC; + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { + io2.generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; + } + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { + io2.generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + } + + switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { + case OPENX_MODE_ACCESS_READ: + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + break; + case OPENX_MODE_ACCESS_WRITE: + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + break; + case OPENX_MODE_ACCESS_RDWR: + case OPENX_MODE_ACCESS_FCB: + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; + break; + } + + switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { + case OPENX_MODE_DENY_READ: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_WRITE: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPENX_MODE_DENY_ALL: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPENX_MODE_DENY_NONE: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_DOS: + /* DENY_DOS is quite strange - it depends on the filename! */ + if (is_exe_file(io->openx.in.fname)) { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + } else { + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_READ) { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + } else { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + } + } + break; + case OPENX_MODE_DENY_FCB: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + } + + switch (io->openx.in.open_func) { + case (OPENX_OPEN_FUNC_FAIL): + io2.generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + case (OPENX_OPEN_FUNC_OPEN): + io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN; + break; + case (OPENX_OPEN_FUNC_TRUNC): + io2.generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; + break; + case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): + io2.generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): + io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + break; + case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): + io2.generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + break; + } + io2.generic.in.alloc_size = io->openx.in.size; + io2.generic.in.file_attr = io->openx.in.file_attrs; + io2.generic.in.fname = io->openx.in.fname; + + status = req->conn->ntvfs_ops->open(req, &io2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + ZERO_STRUCT(io->openx.out); + io->openx.out.fnum = io2.generic.out.fnum; + io->openx.out.attrib = io2.generic.out.attrib; + io->openx.out.write_time = nt_time_to_unix(&io2.generic.out.write_time); + io->openx.out.size = io2.generic.out.size; + + return NT_STATUS_OK; + + + case RAW_OPEN_OPEN: + ZERO_STRUCT(io2.generic.in); + io2.generic.level = RAW_OPEN_GENERIC; + io2.generic.in.file_attr = io->open.in.search_attrs; + io2.generic.in.fname = io->open.in.fname; + io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN; + DEBUG(9,("ntvfs_map_open(OPEN): mapping flags=0x%x\n", + io->open.in.flags)); + switch (io->open.in.flags & OPEN_FLAGS_MODE_MASK) { + case OPEN_FLAGS_OPEN_READ: + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io->open.out.rmode = DOS_OPEN_RDONLY; + break; + case OPEN_FLAGS_OPEN_WRITE: + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io->open.out.rmode = DOS_OPEN_WRONLY; + break; + case OPEN_FLAGS_OPEN_RDWR: + case 0xf: /* FCB mode */ + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; + io->open.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ + break; + default: + DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", + io->open.in.flags & OPEN_FLAGS_MODE_MASK)); + return NT_STATUS_INVALID_PARAMETER; + } + + switch(io->open.in.flags & OPEN_FLAGS_DENY_MASK) { + case OPEN_FLAGS_DENY_DOS: + /* DENY_DOS is quite strange - it depends on the filename! */ + /* REWRITE: is this necessary for OPEN? */ + if (is_exe_file(io->open.in.fname)) { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + } else { + if ((io->open.in.flags & OPEN_FLAGS_MODE_MASK) == + OPEN_FLAGS_OPEN_READ) { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + } else { + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + } + } + break; + case OPEN_FLAGS_DENY_ALL: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPEN_FLAGS_DENY_WRITE: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPEN_FLAGS_DENY_READ: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPEN_FLAGS_DENY_NONE: + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; + break; + case 0x70: /* FCB mode */ + io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + default: + DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", + io->open.in.flags & OPEN_FLAGS_DENY_MASK)); + return NT_STATUS_INVALID_PARAMETER; + } + DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", + io->open.in.flags, io2.generic.in.access_mask, io2.generic.in.share_access)); + + status = req->conn->ntvfs_ops->open(req, &io2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + ZERO_STRUCT(io->openx.out); + io->open.out.fnum = io2.generic.out.fnum; + io->open.out.attrib = io2.generic.out.attrib; + io->open.out.write_time = nt_time_to_unix(&io2.generic.out.write_time); + io->open.out.size = io2.generic.out.size; + io->open.out.rmode = DOS_OPEN_RDWR; + + return NT_STATUS_OK; + } + + return NT_STATUS_INVALID_LEVEL; +} + + +/* + NTVFS fsinfo generic to any mapper +*/ +NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) +{ + NTSTATUS status; + union smb_fsinfo fs2; + + if (fs->generic.level == RAW_QFS_GENERIC) { + return NT_STATUS_INVALID_LEVEL; + } + + /* ask the backend for the generic info */ + fs2.generic.level = RAW_QFS_GENERIC; + + status = req->conn->ntvfs_ops->fsinfo(req, &fs2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* and convert it to the required level */ + switch (fs->generic.level) { + case RAW_QFS_GENERIC: + return NT_STATUS_INVALID_LEVEL; + + case RAW_QFS_DSKATTR: { + /* map from generic to DSKATTR */ + unsigned bpunit = 64; + + /* we need to scale the sizes to fit */ + for (bpunit=64; bpunit<0x10000; bpunit *= 2) { + if (fs2.generic.out.blocks_total * (double)fs2.generic.out.block_size < bpunit * 512 * 65535.0) { + break; + } + } + + fs->dskattr.out.blocks_per_unit = bpunit; + fs->dskattr.out.block_size = 512; + fs->dskattr.out.units_total = + (fs2.generic.out.blocks_total * (double)fs2.generic.out.block_size) / (bpunit * 512); + fs->dskattr.out.units_free = + (fs2.generic.out.blocks_free * (double)fs2.generic.out.block_size) / (bpunit * 512); + + /* we must return a maximum of 2G to old DOS systems, or they get very confused */ + if (bpunit > 64 && req->smb->negotiate.protocol <= PROTOCOL_LANMAN2) { + fs->dskattr.out.blocks_per_unit = 64; + fs->dskattr.out.units_total = 0xFFFF; + fs->dskattr.out.units_free = 0xFFFF; + } + return NT_STATUS_OK; + } + + case RAW_QFS_ALLOCATION: + fs->allocation.out.fs_id = fs2.generic.out.fs_id; + fs->allocation.out.total_alloc_units = fs2.generic.out.blocks_total; + fs->allocation.out.avail_alloc_units = fs2.generic.out.blocks_free; + fs->allocation.out.sectors_per_unit = 1; + fs->allocation.out.bytes_per_sector = fs2.generic.out.block_size; + return NT_STATUS_OK; + + case RAW_QFS_VOLUME: + fs->volume.out.serial_number = fs2.generic.out.serial_number; + fs->volume.out.volume_name.s = fs2.generic.out.volume_name; + return NT_STATUS_OK; + + case RAW_QFS_VOLUME_INFO: + case RAW_QFS_VOLUME_INFORMATION: + fs->volume_info.out.create_time = fs2.generic.out.create_time; + fs->volume_info.out.serial_number = fs2.generic.out.serial_number; + fs->volume_info.out.volume_name.s = fs2.generic.out.volume_name; + return NT_STATUS_OK; + + case RAW_QFS_SIZE_INFO: + case RAW_QFS_SIZE_INFORMATION: + fs->size_info.out.total_alloc_units = fs2.generic.out.blocks_total; + fs->size_info.out.avail_alloc_units = fs2.generic.out.blocks_free; + fs->size_info.out.sectors_per_unit = 1; + fs->size_info.out.bytes_per_sector = fs2.generic.out.block_size; + return NT_STATUS_OK; + + case RAW_QFS_DEVICE_INFO: + case RAW_QFS_DEVICE_INFORMATION: + fs->device_info.out.device_type = fs2.generic.out.device_type; + fs->device_info.out.characteristics = fs2.generic.out.device_characteristics; + return NT_STATUS_OK; + + case RAW_QFS_ATTRIBUTE_INFO: + case RAW_QFS_ATTRIBUTE_INFORMATION: + fs->attribute_info.out.fs_attr = fs2.generic.out.fs_attr; + fs->attribute_info.out.max_file_component_length = fs2.generic.out.max_file_component_length; + fs->attribute_info.out.fs_type.s = fs2.generic.out.fs_type; + return NT_STATUS_OK; + + case RAW_QFS_QUOTA_INFORMATION: + ZERO_STRUCT(fs->quota_information.out.unknown); + fs->quota_information.out.quota_soft = fs2.generic.out.quota_soft; + fs->quota_information.out.quota_hard = fs2.generic.out.quota_hard; + fs->quota_information.out.quota_flags = fs2.generic.out.quota_flags; + return NT_STATUS_OK; + + case RAW_QFS_FULL_SIZE_INFORMATION: + fs->full_size_information.out.total_alloc_units = fs2.generic.out.blocks_total; + fs->full_size_information.out.call_avail_alloc_units = fs2.generic.out.blocks_free; + fs->full_size_information.out.actual_avail_alloc_units = fs2.generic.out.blocks_free; + fs->full_size_information.out.sectors_per_unit = 1; + fs->full_size_information.out.bytes_per_sector = fs2.generic.out.block_size; + return NT_STATUS_OK; + + case RAW_QFS_OBJECTID_INFORMATION: + fs->objectid_information.out.guid = fs2.generic.out.guid; + ZERO_STRUCT(fs->objectid_information.out.unknown); + return NT_STATUS_OK; + } + + + return NT_STATUS_INVALID_LEVEL; +} + + +/* + NTVFS fileinfo generic to any mapper +*/ +NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *info, union smb_fileinfo *info2) +{ + /* and convert it to the required level using results in info2 */ + switch (info->generic.level) { + case RAW_FILEINFO_GENERIC: + return NT_STATUS_INVALID_LEVEL; + case RAW_FILEINFO_GETATTR: + info->getattr.out.attrib = info2->generic.out.attrib & 0x3f; + info->getattr.out.size = info2->generic.out.size; + info->getattr.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + return NT_STATUS_OK; + + case RAW_FILEINFO_GETATTRE: + info->getattre.out.attrib = info2->generic.out.attrib; + info->getattre.out.size = info2->generic.out.size; + info->getattre.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->getattre.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); + info->getattre.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); + info->getattre.out.alloc_size = info2->generic.out.alloc_size; + return NT_STATUS_OK; + + case RAW_FILEINFO_NETWORK_OPEN_INFORMATION: + info->network_open_information.out.create_time = info2->generic.out.create_time; + info->network_open_information.out.access_time = info2->generic.out.access_time; + info->network_open_information.out.write_time = info2->generic.out.write_time; + info->network_open_information.out.change_time = info2->generic.out.change_time; + info->network_open_information.out.alloc_size = info2->generic.out.alloc_size; + info->network_open_information.out.size = info2->generic.out.size; + info->network_open_information.out.attrib = info2->generic.out.attrib; + return NT_STATUS_OK; + + case RAW_FILEINFO_ALL_INFO: + case RAW_FILEINFO_ALL_INFORMATION: + info->all_info.out.create_time = info2->generic.out.create_time; + info->all_info.out.access_time = info2->generic.out.access_time; + info->all_info.out.write_time = info2->generic.out.write_time; + info->all_info.out.change_time = info2->generic.out.change_time; + info->all_info.out.attrib = info2->generic.out.attrib; + info->all_info.out.alloc_size = info2->generic.out.alloc_size; + info->all_info.out.size = info2->generic.out.size; + info->all_info.out.nlink = info2->generic.out.nlink; + info->all_info.out.delete_pending = info2->generic.out.delete_pending; + info->all_info.out.directory = info2->generic.out.directory; + info->all_info.out.ea_size = info2->generic.out.ea_size; + info->all_info.out.fname.s = info2->generic.out.fname.s; + info->all_info.out.fname.private_length = info2->generic.out.fname.private_length; + return NT_STATUS_OK; + + case RAW_FILEINFO_BASIC_INFO: + case RAW_FILEINFO_BASIC_INFORMATION: + info->basic_info.out.create_time = info2->generic.out.create_time; + info->basic_info.out.access_time = info2->generic.out.access_time; + info->basic_info.out.write_time = info2->generic.out.write_time; + info->basic_info.out.change_time = info2->generic.out.change_time; + info->basic_info.out.attrib = info2->generic.out.attrib; + return NT_STATUS_OK; + + case RAW_FILEINFO_STANDARD: + info->standard.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); + info->standard.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); + info->standard.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->standard.out.size = info2->generic.out.size; + info->standard.out.alloc_size = info2->generic.out.alloc_size; + info->standard.out.attrib = info2->generic.out.attrib; + return NT_STATUS_OK; + + case RAW_FILEINFO_EA_SIZE: + info->ea_size.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); + info->ea_size.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); + info->ea_size.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->ea_size.out.size = info2->generic.out.size; + info->ea_size.out.alloc_size = info2->generic.out.alloc_size; + info->ea_size.out.attrib = info2->generic.out.attrib; + info->ea_size.out.ea_size = info2->generic.out.ea_size; + return NT_STATUS_OK; + + case RAW_FILEINFO_STANDARD_INFO: + case RAW_FILEINFO_STANDARD_INFORMATION: + info->standard_info.out.alloc_size = info2->generic.out.alloc_size; + info->standard_info.out.size = info2->generic.out.size; + info->standard_info.out.nlink = info2->generic.out.nlink; + info->standard_info.out.delete_pending = info2->generic.out.delete_pending; + info->standard_info.out.directory = info2->generic.out.directory; + return NT_STATUS_OK; + + case RAW_FILEINFO_INTERNAL_INFORMATION: + info->internal_information.out.device = info2->generic.out.device; + info->internal_information.out.inode = info2->generic.out.inode; + return NT_STATUS_OK; + + case RAW_FILEINFO_EA_INFO: + case RAW_FILEINFO_EA_INFORMATION: + info->ea_info.out.ea_size = info2->generic.out.ea_size; + return NT_STATUS_OK; + + case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION: + info->attribute_tag_information.out.attrib = info2->generic.out.attrib; + info->attribute_tag_information.out.reparse_tag = info2->generic.out.reparse_tag; + return NT_STATUS_OK; + + case RAW_FILEINFO_STREAM_INFO: + case RAW_FILEINFO_STREAM_INFORMATION: + /* setup a single data stream */ + info->stream_info.out.num_streams = info2->generic.out.num_streams; + info->stream_info.out.streams = talloc(req->mem_ctx, sizeof(info2->stream_info.out.streams[0])); + if (!info->stream_info.out.streams) { + return NT_STATUS_NO_MEMORY; + } + info->stream_info.out.streams[0].size = info2->generic.out.streams[0].size; + info->stream_info.out.streams[0].alloc_size = info2->generic.out.streams[0].alloc_size; + info->stream_info.out.streams[0].stream_name.s = info2->generic.out.streams[0].stream_name.s; + info->stream_info.out.streams[0].stream_name.private_length = info->generic.out.streams[0].stream_name.private_length; + return NT_STATUS_OK; + + case RAW_FILEINFO_NAME_INFO: + case RAW_FILEINFO_NAME_INFORMATION: + info->name_info.out.fname.s = info2->generic.out.fname.s; + info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; + return NT_STATUS_OK; + + case RAW_FILEINFO_ALT_NAME_INFO: + case RAW_FILEINFO_ALT_NAME_INFORMATION: + info->alt_name_info.out.fname.s = info2->generic.out.alt_fname.s; + info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length; + return NT_STATUS_OK; + } + + return NT_STATUS_INVALID_LEVEL; +} + +/* + NTVFS fileinfo generic to any mapper +*/ +NTSTATUS ntvfs_map_qfileinfo(struct request_context *req, union smb_fileinfo *info) +{ + NTSTATUS status; + union smb_fileinfo info2; + + if (info->generic.level == RAW_FILEINFO_GENERIC) { + return NT_STATUS_INVALID_LEVEL; + } + + /* ask the backend for the generic info */ + info2.generic.level = RAW_FILEINFO_GENERIC; + info2.generic.in.fnum = info->generic.in.fnum; + + status = req->conn->ntvfs_ops->qfileinfo(req, &info2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + return ntvfs_map_fileinfo(req, info, &info2); +} + +/* + NTVFS pathinfo generic to any mapper +*/ +NTSTATUS ntvfs_map_qpathinfo(struct request_context *req, union smb_fileinfo *info) +{ + NTSTATUS status; + union smb_fileinfo info2; + + if (info->generic.level == RAW_FILEINFO_GENERIC) { + return NT_STATUS_INVALID_LEVEL; + } + + /* ask the backend for the generic info */ + info2.generic.level = RAW_FILEINFO_GENERIC; + info2.generic.in.fname = info->generic.in.fname; + + status = req->conn->ntvfs_ops->qpathinfo(req, &info2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + return ntvfs_map_fileinfo(req, info, &info2); +} -- cgit From 0becf4d68329ca599f3e34ee97ca3f72d0e9425f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Sep 2003 04:37:33 +0000 Subject: thanks to ntfsd and some google searches I worked out what the unknown fields in level 261 and level 262 of directory search are, plus the names of the levels the unknown fields are a 64bit unique file id, and match the 64 bit number from the internal_information qfileinfo level (This used to be commit b69f54eb028a24144a2e813f059b08644118ab09) --- source4/ntvfs/ntvfs_generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index def448a671..08c8b88d30 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -453,8 +453,7 @@ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *inf return NT_STATUS_OK; case RAW_FILEINFO_INTERNAL_INFORMATION: - info->internal_information.out.device = info2->generic.out.device; - info->internal_information.out.inode = info2->generic.out.inode; + info->internal_information.out.file_id = info2->generic.out.file_id; return NT_STATUS_OK; case RAW_FILEINFO_EA_INFO: -- cgit From 42c6a2548a658a198f128cdce36b9fcf869c33c8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 2003 11:01:58 +0000 Subject: merged more updates from Jim Myers (This used to be commit 03bf30659640d684073f92d64da6e911edb65a73) --- source4/ntvfs/ntvfs_generic.c | 115 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 103 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 08c8b88d30..ea62f8c9a6 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -178,7 +178,8 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) break; case OPEN_FLAGS_OPEN_RDWR: case 0xf: /* FCB mode */ - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; + io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | + GENERIC_RIGHTS_FILE_WRITE; io->open.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ break; default: @@ -369,12 +370,13 @@ NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) */ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *info, union smb_fileinfo *info2) { + int i; /* and convert it to the required level using results in info2 */ switch (info->generic.level) { case RAW_FILEINFO_GENERIC: return NT_STATUS_INVALID_LEVEL; case RAW_FILEINFO_GETATTR: - info->getattr.out.attrib = info2->generic.out.attrib & 0x3f; + info->getattr.out.attrib = info2->generic.out.attrib & 0xff; info->getattr.out.size = info2->generic.out.size; info->getattr.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); return NT_STATUS_OK; @@ -468,29 +470,118 @@ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *inf case RAW_FILEINFO_STREAM_INFO: case RAW_FILEINFO_STREAM_INFORMATION: - /* setup a single data stream */ info->stream_info.out.num_streams = info2->generic.out.num_streams; - info->stream_info.out.streams = talloc(req->mem_ctx, sizeof(info2->stream_info.out.streams[0])); - if (!info->stream_info.out.streams) { - return NT_STATUS_NO_MEMORY; + if (info->stream_info.out.num_streams > 0) { + info->stream_info.out.streams = talloc(req->mem_ctx, + info->stream_info.out.num_streams * sizeof(struct stream_struct)); + if (!info->stream_info.out.streams) { + DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", + info->stream_info.out.num_streams)); + return NT_STATUS_NO_MEMORY; + } + for (i=0; i < info->stream_info.out.num_streams; i++) { + info->stream_info.out.streams[i] = info2->generic.out.streams[i]; + info->stream_info.out.streams[i].stream_name.s = + talloc_strdup(req->mem_ctx, info2->generic.out.streams[i].stream_name.s); + if (!info->stream_info.out.streams[i].stream_name.s) { + DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); + return NT_STATUS_NO_MEMORY; + } + } } - info->stream_info.out.streams[0].size = info2->generic.out.streams[0].size; - info->stream_info.out.streams[0].alloc_size = info2->generic.out.streams[0].alloc_size; - info->stream_info.out.streams[0].stream_name.s = info2->generic.out.streams[0].stream_name.s; - info->stream_info.out.streams[0].stream_name.private_length = info->generic.out.streams[0].stream_name.private_length; return NT_STATUS_OK; case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: - info->name_info.out.fname.s = info2->generic.out.fname.s; + info->name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.fname.s); info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_ALT_NAME_INFORMATION: - info->alt_name_info.out.fname.s = info2->generic.out.alt_fname.s; + info->alt_name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.alt_fname.s); info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length; return NT_STATUS_OK; + + case RAW_FILEINFO_POSITION_INFORMATION: + info->position_information.out.position = info2->generic.out.position; + return NT_STATUS_OK; + + case RAW_FILEINFO_ALL_EAS: + info->all_eas.out.num_eas = info2->generic.out.num_eas; + if (info->all_eas.out.num_eas > 0) { + info->all_eas.out.eas = talloc(req->mem_ctx, + info->all_eas.out.num_eas * sizeof(struct ea_struct)); + if (!info->all_eas.out.eas) { + DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", + info->all_eas.out.num_eas)); + return NT_STATUS_NO_MEMORY; + } + for (i = 0; i < info->all_eas.out.num_eas; i++) { + info->all_eas.out.eas[i] = info2->generic.out.eas[i]; + info->all_eas.out.eas[i].name.s = + talloc_strdup(req->mem_ctx, info2->generic.out.eas[i].name.s); + if (!info->all_eas.out.eas[i].name.s) { + DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); + return NT_STATUS_NO_MEMORY; + } + info->all_eas.out.eas[i].value.data = + talloc_memdup(req->mem_ctx, + info2->generic.out.eas[i].value.data, + info2->generic.out.eas[i].value.length); + if (!info->all_eas.out.eas[i].value.data) { + DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); + return NT_STATUS_NO_MEMORY; + } + } + } + return NT_STATUS_OK; + + case RAW_FILEINFO_IS_NAME_VALID: + return NT_STATUS_OK; + + case RAW_FILEINFO_COMPRESSION_INFO: + case RAW_FILEINFO_COMPRESSION_INFORMATION: + info->compression_info.out.compressed_size = info2->generic.out.compressed_size; + info->compression_info.out.format = info2->generic.out.format; + info->compression_info.out.unit_shift = info2->generic.out.unit_shift; + info->compression_info.out.chunk_shift = info2->generic.out.chunk_shift; + info->compression_info.out.cluster_shift = info2->generic.out.cluster_shift; + return NT_STATUS_OK; + + case RAW_FILEINFO_ACCESS_INFORMATION: + info->access_information.out.access_flags = info2->generic.out.access_flags; + return NT_STATUS_OK; + + case RAW_FILEINFO_MODE_INFORMATION: + info->mode_information.out.mode = info2->generic.out.mode; + return NT_STATUS_OK; + + case RAW_FILEINFO_ALIGNMENT_INFORMATION: + info->alignment_information.out.alignment_requirement = + info2->generic.out.alignment_requirement; + return NT_STATUS_OK; +#if 0 + case RAW_FILEINFO_UNIX_BASIC: + info->unix_basic_info.out.end_of_file = info2->generic.out.end_of_file; + info->unix_basic_info.out.num_bytes = info2->generic.out.size; + info->unix_basic_info.out.status_change_time = info2->generic.out.change_time; + info->unix_basic_info.out.access_time = info2->generic.out.access_time; + info->unix_basic_info.out.change_time = info2->generic.out.change_time; + info->unix_basic_info.out.uid = info2->generic.out.uid; + info->unix_basic_info.out.gid = info2->generic.out.gid; + info->unix_basic_info.out.file_type = info2->generic.out.file_type; + info->unix_basic_info.out.dev_major = info2->generic.out.device; + info->unix_basic_info.out.dev_minor = info2->generic.out.device; + info->unix_basic_info.out.unique_id = info2->generic.out.inode; + info->unix_basic_info.out.permissions = info2->generic.out.permissions; + info->unix_basic_info.out.nlink = info2->generic.out.nlink; + return NT_STATUS_OK; + + case RAW_FILEINFO_UNIX_LINK: + info->unix_link_info.out.link_dest = info2->generic.out.link_dest; + return NT_STATUS_OK; +#endif } return NT_STATUS_INVALID_LEVEL; -- cgit From 579c13da43d5b40ac6d6c1436399fbc1d8dfd054 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 May 2004 13:57:39 +0000 Subject: r873: converted samba4 to use real 64 bit integers instead of structures. This was suggested by metze recently. I checked on the build farm and all the machines we have support 64 bit ints, and support the LL suffix for 64 bit constants. I suspect some won't support strtoll() and related functions, so we will probably need replacements for those. (This used to be commit 9a9244a1c66654c12abe4379661cba83a73c4c21) --- source4/ntvfs/ntvfs_generic.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index ea62f8c9a6..116b716474 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -153,7 +153,7 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) ZERO_STRUCT(io->openx.out); io->openx.out.fnum = io2.generic.out.fnum; io->openx.out.attrib = io2.generic.out.attrib; - io->openx.out.write_time = nt_time_to_unix(&io2.generic.out.write_time); + io->openx.out.write_time = nt_time_to_unix(io2.generic.out.write_time); io->openx.out.size = io2.generic.out.size; return NT_STATUS_OK; @@ -235,7 +235,7 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) ZERO_STRUCT(io->openx.out); io->open.out.fnum = io2.generic.out.fnum; io->open.out.attrib = io2.generic.out.attrib; - io->open.out.write_time = nt_time_to_unix(&io2.generic.out.write_time); + io->open.out.write_time = nt_time_to_unix(io2.generic.out.write_time); io->open.out.size = io2.generic.out.size; io->open.out.rmode = DOS_OPEN_RDWR; @@ -378,15 +378,15 @@ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *inf case RAW_FILEINFO_GETATTR: info->getattr.out.attrib = info2->generic.out.attrib & 0xff; info->getattr.out.size = info2->generic.out.size; - info->getattr.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->getattr.out.write_time = nt_time_to_unix(info2->generic.out.write_time); return NT_STATUS_OK; case RAW_FILEINFO_GETATTRE: info->getattre.out.attrib = info2->generic.out.attrib; info->getattre.out.size = info2->generic.out.size; - info->getattre.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); - info->getattre.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); - info->getattre.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); + info->getattre.out.write_time = nt_time_to_unix(info2->generic.out.write_time); + info->getattre.out.create_time = nt_time_to_unix(info2->generic.out.create_time); + info->getattre.out.access_time = nt_time_to_unix(info2->generic.out.access_time); info->getattre.out.alloc_size = info2->generic.out.alloc_size; return NT_STATUS_OK; @@ -427,18 +427,18 @@ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *inf return NT_STATUS_OK; case RAW_FILEINFO_STANDARD: - info->standard.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); - info->standard.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); - info->standard.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->standard.out.create_time = nt_time_to_unix(info2->generic.out.create_time); + info->standard.out.access_time = nt_time_to_unix(info2->generic.out.access_time); + info->standard.out.write_time = nt_time_to_unix(info2->generic.out.write_time); info->standard.out.size = info2->generic.out.size; info->standard.out.alloc_size = info2->generic.out.alloc_size; info->standard.out.attrib = info2->generic.out.attrib; return NT_STATUS_OK; case RAW_FILEINFO_EA_SIZE: - info->ea_size.out.create_time = nt_time_to_unix(&info2->generic.out.create_time); - info->ea_size.out.access_time = nt_time_to_unix(&info2->generic.out.access_time); - info->ea_size.out.write_time = nt_time_to_unix(&info2->generic.out.write_time); + info->ea_size.out.create_time = nt_time_to_unix(info2->generic.out.create_time); + info->ea_size.out.access_time = nt_time_to_unix(info2->generic.out.access_time); + info->ea_size.out.write_time = nt_time_to_unix(info2->generic.out.write_time); info->ea_size.out.size = info2->generic.out.size; info->ea_size.out.alloc_size = info2->generic.out.alloc_size; info->ea_size.out.attrib = info2->generic.out.attrib; -- cgit From 770e3307ce3da928762e15a136c562df86a9c799 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 10:12:52 +0000 Subject: r962: convert 'unsigned' and 'unsigned int' to uint_t metze (This used to be commit 57151e80eb1090281401930c8fe25b20a8cf3a38) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 116b716474..0781558e8e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -273,7 +273,7 @@ NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) case RAW_QFS_DSKATTR: { /* map from generic to DSKATTR */ - unsigned bpunit = 64; + uint_t bpunit = 64; /* we need to scale the sizes to fit */ for (bpunit=64; bpunit<0x10000; bpunit *= 2) { -- cgit From 37fcf2236433bc5e74f19d2afac3d1d0055dcd01 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 27 Jun 2004 11:06:10 +0000 Subject: r1268: varient -> variant (This used to be commit de5984c95602ca67e8ac3139c3aa4330b74266e0) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 0781558e8e..d7d6f67a94 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -27,7 +27,7 @@ these functions must supply the generic call, but can if it wants to also implement other levels if the need arises - this allows backend writers to only implement one varient of each + this allows backend writers to only implement one variant of each call unless they need fine grained control of the calls. */ -- cgit From d4ae6ae74d712b74800e360590052d318d2fd101 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 07:41:15 +0000 Subject: r1277: rename struct server_context to smbsrv_ontext because I need server_context fot the generic server infastructure metze (This used to be commit 0712f9f30797e65362c99423c0cf158a2f539000) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index d7d6f67a94..0f5f0badcb 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -290,7 +290,7 @@ NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) (fs2.generic.out.blocks_free * (double)fs2.generic.out.block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ - if (bpunit > 64 && req->smb->negotiate.protocol <= PROTOCOL_LANMAN2) { + if (bpunit > 64 && req->smb_ctx->negotiate.protocol <= PROTOCOL_LANMAN2) { fs->dskattr.out.blocks_per_unit = 64; fs->dskattr.out.units_total = 0xFFFF; fs->dskattr.out.units_free = 0xFFFF; -- cgit From 4ddb2d347d86818a13d71d0eb2f0f8983c2cc41f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 08:27:36 +0000 Subject: r1279: rename struct tcon_context to smbsrv_tcon metze (This used to be commit 99473fab4b1ff87a795f3c08f4c521d9beb504c0) --- source4/ntvfs/ntvfs_generic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 0f5f0badcb..b2cf107b7d 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -145,7 +145,7 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) io2.generic.in.file_attr = io->openx.in.file_attrs; io2.generic.in.fname = io->openx.in.fname; - status = req->conn->ntvfs_ops->open(req, &io2); + status = req->tcon->ntvfs_ops->open(req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -227,7 +227,7 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", io->open.in.flags, io2.generic.in.access_mask, io2.generic.in.share_access)); - status = req->conn->ntvfs_ops->open(req, &io2); + status = req->tcon->ntvfs_ops->open(req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -261,7 +261,7 @@ NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) /* ask the backend for the generic info */ fs2.generic.level = RAW_QFS_GENERIC; - status = req->conn->ntvfs_ops->fsinfo(req, &fs2); + status = req->tcon->ntvfs_ops->fsinfo(req, &fs2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -603,7 +603,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct request_context *req, union smb_fileinfo *in info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fnum = info->generic.in.fnum; - status = req->conn->ntvfs_ops->qfileinfo(req, &info2); + status = req->tcon->ntvfs_ops->qfileinfo(req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -626,7 +626,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct request_context *req, union smb_fileinfo *in info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fname = info->generic.in.fname; - status = req->conn->ntvfs_ops->qpathinfo(req, &info2); + status = req->tcon->ntvfs_ops->qpathinfo(req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From 8bf537d119be3e1823ad41b8b8af0d163251b1c5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 08:39:00 +0000 Subject: r1280: rename struct request_context to smbsrv_request metze (This used to be commit a85d2db5826a84b812ea5162a11f54edd25f74e3) --- source4/ntvfs/ntvfs_generic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index b2cf107b7d..ba2ec344f4 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -57,7 +57,7 @@ static BOOL is_exe_file(const char *fname) /* NTVFS open generic to any mapper */ -NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) +NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io) { NTSTATUS status; union smb_open io2; @@ -249,7 +249,7 @@ NTSTATUS ntvfs_map_open(struct request_context *req, union smb_open *io) /* NTVFS fsinfo generic to any mapper */ -NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) +NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) { NTSTATUS status; union smb_fsinfo fs2; @@ -368,7 +368,7 @@ NTSTATUS ntvfs_map_fsinfo(struct request_context *req, union smb_fsinfo *fs) /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *info, union smb_fileinfo *info2) +NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, union smb_fileinfo *info2) { int i; /* and convert it to the required level using results in info2 */ @@ -590,7 +590,7 @@ NTSTATUS ntvfs_map_fileinfo(struct request_context *req, union smb_fileinfo *inf /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_qfileinfo(struct request_context *req, union smb_fileinfo *info) +NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info) { NTSTATUS status; union smb_fileinfo info2; @@ -613,7 +613,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct request_context *req, union smb_fileinfo *in /* NTVFS pathinfo generic to any mapper */ -NTSTATUS ntvfs_map_qpathinfo(struct request_context *req, union smb_fileinfo *info) +NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info) { NTSTATUS status; union smb_fileinfo info2; -- cgit From 118f3edd27f5adacc1da636ed05b33f04999584f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 Jun 2004 07:40:14 +0000 Subject: r1291: rename struct smbsrv_context to smbsrv_connection because this is the connection state per transport layer (tcp) connection I also moved the substructs directly into smbsrv_connection, because they don't need a struct name and we should allway pass the complete smbsrv_connection struct into functions metze (This used to be commit 60f823f201fcedf5473008e8453a6351e73a92c7) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index ba2ec344f4..36cbcabbd5 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -290,7 +290,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) (fs2.generic.out.blocks_free * (double)fs2.generic.out.block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ - if (bpunit > 64 && req->smb_ctx->negotiate.protocol <= PROTOCOL_LANMAN2) { + if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) { fs->dskattr.out.blocks_per_unit = 64; fs->dskattr.out.units_total = 0xFFFF; fs->dskattr.out.units_free = 0xFFFF; -- cgit From 893c62d38388b20c52cf3c45069d836c46f42bd3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Sep 2004 05:39:06 +0000 Subject: r2249: got rid of some more mem_ctx elements in structures (This used to be commit 21ef338cbbe96acc8594ffc550ef60c6a40fb951) --- source4/ntvfs/ntvfs_generic.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 36cbcabbd5..29f21b1863 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -472,7 +472,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_STREAM_INFORMATION: info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { - info->stream_info.out.streams = talloc(req->mem_ctx, + info->stream_info.out.streams = talloc(req, info->stream_info.out.num_streams * sizeof(struct stream_struct)); if (!info->stream_info.out.streams) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", @@ -482,7 +482,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info for (i=0; i < info->stream_info.out.num_streams; i++) { info->stream_info.out.streams[i] = info2->generic.out.streams[i]; info->stream_info.out.streams[i].stream_name.s = - talloc_strdup(req->mem_ctx, info2->generic.out.streams[i].stream_name.s); + talloc_strdup(req, info2->generic.out.streams[i].stream_name.s); if (!info->stream_info.out.streams[i].stream_name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; @@ -493,13 +493,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: - info->name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.fname.s); + info->name_info.out.fname.s = talloc_strdup(req, info2->generic.out.fname.s); info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_ALT_NAME_INFORMATION: - info->alt_name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.alt_fname.s); + info->alt_name_info.out.fname.s = talloc_strdup(req, info2->generic.out.alt_fname.s); info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length; return NT_STATUS_OK; @@ -510,7 +510,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc(req->mem_ctx, + info->all_eas.out.eas = talloc(req, info->all_eas.out.num_eas * sizeof(struct ea_struct)); if (!info->all_eas.out.eas) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", @@ -520,13 +520,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info for (i = 0; i < info->all_eas.out.num_eas; i++) { info->all_eas.out.eas[i] = info2->generic.out.eas[i]; info->all_eas.out.eas[i].name.s = - talloc_strdup(req->mem_ctx, info2->generic.out.eas[i].name.s); + talloc_strdup(req, info2->generic.out.eas[i].name.s); if (!info->all_eas.out.eas[i].name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } info->all_eas.out.eas[i].value.data = - talloc_memdup(req->mem_ctx, + talloc_memdup(req, info2->generic.out.eas[i].value.data, info2->generic.out.eas[i].value.length); if (!info->all_eas.out.eas[i].value.data) { -- cgit From a3cec511bbef2cc7768906f3af947ce2f900bde6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 23 Sep 2004 07:44:42 +0000 Subject: r2561: completely redid the ntvfs module chaining code, You can now do something like: ntvfs handler = nbench posix and the nbench pass-thru module will be called before the posix module. The chaining logic is now much saner, and less racy, with each level in the chain getting its own private pointer rather than relying on save/restore logic in the pass-thru module. The only pass-thru module we have at the moment is the nbench one (which records all traffic in a nbench compatibe format), but I plan on soon writing a "unixuid" pass-thru module that will implement the setegid()/setgroups()/seteuid() logic for standard posix uid handling. This separation of the posix backend from the uid handling should simplify the code, and make development easier. I also modified the nbench module so it can do multiple chaining, so if you want to you can do: ntvfs module = nbench nbench posix and it will save 2 copies of the log file in /tmp. This is really only useful for testing at the moment until we have more than one pass-thru module. (This used to be commit f84c0af35cb54c8fdc4933afefc18fa4c062aae4) --- source4/ntvfs/ntvfs_generic.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 29f21b1863..731e91f5c9 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -57,7 +57,8 @@ static BOOL is_exe_file(const char *fname) /* NTVFS open generic to any mapper */ -NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io) +NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, + const struct ntvfs_ops *ops) { NTSTATUS status; union smb_open io2; @@ -145,7 +146,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io) io2.generic.in.file_attr = io->openx.in.file_attrs; io2.generic.in.fname = io->openx.in.fname; - status = req->tcon->ntvfs_ops->open(req, &io2); + status = ops->open(req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -227,7 +228,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io) DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", io->open.in.flags, io2.generic.in.access_mask, io2.generic.in.share_access)); - status = req->tcon->ntvfs_ops->open(req, &io2); + status = ops->open(req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -249,7 +250,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io) /* NTVFS fsinfo generic to any mapper */ -NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) +NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, + const struct ntvfs_ops *ops) { NTSTATUS status; union smb_fsinfo fs2; @@ -261,7 +263,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) /* ask the backend for the generic info */ fs2.generic.level = RAW_QFS_GENERIC; - status = req->tcon->ntvfs_ops->fsinfo(req, &fs2); + status = ops->fsinfo(req, &fs2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -590,7 +592,8 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info) +NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info, + const struct ntvfs_ops *ops) { NTSTATUS status; union smb_fileinfo info2; @@ -603,7 +606,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fnum = info->generic.in.fnum; - status = req->tcon->ntvfs_ops->qfileinfo(req, &info2); + status = ops->qfileinfo(req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -613,7 +616,8 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf /* NTVFS pathinfo generic to any mapper */ -NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info) +NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info, + const struct ntvfs_ops *ops) { NTSTATUS status; union smb_fileinfo info2; @@ -626,7 +630,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fname = info->generic.in.fname; - status = req->tcon->ntvfs_ops->qpathinfo(req, &info2); + status = ops->qpathinfo(req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From dcad0f6fd492506efd9a69b4e32c7bbfa5da90e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 29 Sep 2004 13:17:09 +0000 Subject: r2751: this is a new ntvfs design which tries to solve: - the stacking of modules - finding the modules private data - hide the ntvfs details from the calling layer - I set NTVFS_INTERFACE_VERSION 0 till we are closer to release (because we need to solve some async problems with the module stacking) metze (This used to be commit 3ff03b5cb21bb79afdd3b1609be9635f6688a539) --- source4/ntvfs/ntvfs_generic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 731e91f5c9..9e1d653465 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -58,7 +58,7 @@ static BOOL is_exe_file(const char *fname) NTVFS open generic to any mapper */ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, - const struct ntvfs_ops *ops) + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_open io2; @@ -146,7 +146,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2.generic.in.file_attr = io->openx.in.file_attrs; io2.generic.in.fname = io->openx.in.fname; - status = ops->open(req, &io2); + status = ntvfs->ops->open(ntvfs, req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -228,7 +228,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", io->open.in.flags, io2.generic.in.access_mask, io2.generic.in.share_access)); - status = ops->open(req, &io2); + status = ntvfs->ops->open(ntvfs, req, &io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -251,7 +251,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, NTVFS fsinfo generic to any mapper */ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, - const struct ntvfs_ops *ops) + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fsinfo fs2; @@ -263,7 +263,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, /* ask the backend for the generic info */ fs2.generic.level = RAW_QFS_GENERIC; - status = ops->fsinfo(req, &fs2); + status = ntvfs->ops->fsinfo(ntvfs, req, &fs2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -593,7 +593,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info NTVFS fileinfo generic to any mapper */ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info, - const struct ntvfs_ops *ops) + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fileinfo info2; @@ -606,7 +606,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fnum = info->generic.in.fnum; - status = ops->qfileinfo(req, &info2); + status = ntvfs->ops->qfileinfo(ntvfs, req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -617,7 +617,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf NTVFS pathinfo generic to any mapper */ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info, - const struct ntvfs_ops *ops) + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fileinfo info2; @@ -630,7 +630,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf info2.generic.level = RAW_FILEINFO_GENERIC; info2.generic.in.fname = info->generic.in.fname; - status = ops->qpathinfo(req, &info2); + status = ntvfs->ops->qpathinfo(ntvfs, req, &info2); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From 20d17b80571f0d0265c99c1ccdc21910c2eed043 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Oct 2004 08:28:31 +0000 Subject: r3081: several updates to ntvfs and server side async request handling in preparation for the full share modes and ntcreatex code that I am working on. highlights include: - changed the way a backend determines if it is allowed to process a request asynchronously. The previous method of looking at the send_fn caused problems when an intermediate ntvfs module disabled it, and the caller then wanted to finished processing using this function. The new method is a REQ_CONTROL_MAY_ASYNC flag in req->control_flags, which is also a bit easier to read - fixed 2 bugs in the readbraw server code. One related to trying to answer a readbraw with smb signing (which can't work, and crashed our signing code), the second related to error handling, which attempted to send a normal SMB error packet, when readbraw must send a 0 read reply (as it has no header) - added several more ntvfs_generic.c generic mapping functions. This means that backends no longer need to implement such esoteric functions as SMBwriteunlock() if they don't want to. The backend can just request the mapping layer turn it into a write followed by an unlock. This makes the backends considerably simpler as they only need to implement one style of each function for lock, read, write, open etc, rather than the full host of functions that SMB provides. A backend can still choose to implement them individually, of course, and the CIFS backend does that. - simplified the generic structures to make them identical to the principal call for several common SMB calls (such as RAW_WRITE_GENERIC now being an alias for RAW_WRITE_WRITEX). - started rewriting the pvfs_open() code in preparation for the full ntcreatex semantics. - in pvfs_open and ipc_open, initially allocate the open file structure as a child of the request, so on error we don't need to clean up. Then when we are going to succeed the open steal the pointer into the long term backend context. This makes for much simpler error handling (and fixes some bugs) - use a destructor in the ipc backend to make sure that everthing is cleaned up on receive error conditions. - switched the ipc backend to using idtree for fnum allocation - in the ntvfs_generic mapping routines, use a allocated secondary structure not a stack structure to ensure the request pointer remains valid even if the backend replies async. (This used to be commit 3457c1836c09c82956697eb21627dfa2ed37682e) --- source4/ntvfs/ntvfs_generic.c | 483 +++++++++++++++++++++++++++++++++--------- 1 file changed, 385 insertions(+), 98 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 9e1d653465..b6f3d8e603 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -3,7 +3,7 @@ NTVFS generic level mapping code - Copyright (C) Andrew Tridgell 2003 + Copyright (C) Andrew Tridgell 2003-2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,8 @@ #include "includes.h" /* - see if a filename ends in EXE COM DLL or SYM. This is needed for the DENY_DOS mapping for OpenX + see if a filename ends in EXE COM DLL or SYM. This is needed for the + DENY_DOS mapping for OpenX */ static BOOL is_exe_file(const char *fname) { @@ -61,125 +62,133 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, struct ntvfs_module_context *ntvfs) { NTSTATUS status; - union smb_open io2; + union smb_open *io2; - if (io->generic.level == RAW_OPEN_GENERIC) { - return NT_STATUS_INVALID_LEVEL; + io2 = talloc_p(req, union smb_open); + if (io2 == NULL) { + return NT_STATUS_NO_MEMORY; } + /* must be synchronous, or we won't be called to do the + translation */ + req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + switch (io->generic.level) { + case RAW_OPEN_GENERIC: + return NT_STATUS_INVALID_LEVEL; + case RAW_OPEN_OPENX: - ZERO_STRUCT(io2.generic.in); - io2.generic.level = RAW_OPEN_GENERIC; + ZERO_STRUCT(io2->generic.in); + io2->generic.level = RAW_OPEN_GENERIC; if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { - io2.generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; } if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { - io2.generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; } switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; break; case OPENX_MODE_ACCESS_WRITE: - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; break; } switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { case OPENX_MODE_DENY_READ: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; break; case OPENX_MODE_DENY_WRITE: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; break; case OPENX_MODE_DENY_ALL: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; case OPENX_MODE_DENY_NONE: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; break; case OPENX_MODE_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ if (is_exe_file(io->openx.in.fname)) { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; } else { if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == OPENX_MODE_ACCESS_READ) { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; } else { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; } } break; case OPENX_MODE_DENY_FCB: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; } switch (io->openx.in.open_func) { case (OPENX_OPEN_FUNC_FAIL): - io2.generic.in.open_disposition = NTCREATEX_DISP_CREATE; + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; break; case (OPENX_OPEN_FUNC_OPEN): - io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN; + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; break; case (OPENX_OPEN_FUNC_TRUNC): - io2.generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; break; case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): - io2.generic.in.open_disposition = NTCREATEX_DISP_CREATE; + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; break; case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): - io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; break; case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): - io2.generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; break; } - io2.generic.in.alloc_size = io->openx.in.size; - io2.generic.in.file_attr = io->openx.in.file_attrs; - io2.generic.in.fname = io->openx.in.fname; + io2->generic.in.alloc_size = io->openx.in.size; + io2->generic.in.file_attr = io->openx.in.file_attrs; + io2->generic.in.fname = io->openx.in.fname; - status = ntvfs->ops->open(ntvfs, req, &io2); + status = ntvfs->ops->open(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { return status; } ZERO_STRUCT(io->openx.out); - io->openx.out.fnum = io2.generic.out.fnum; - io->openx.out.attrib = io2.generic.out.attrib; - io->openx.out.write_time = nt_time_to_unix(io2.generic.out.write_time); - io->openx.out.size = io2.generic.out.size; + io->openx.out.fnum = io2->generic.out.fnum; + io->openx.out.attrib = io2->generic.out.attrib; + io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openx.out.size = io2->generic.out.size; return NT_STATUS_OK; case RAW_OPEN_OPEN: - ZERO_STRUCT(io2.generic.in); - io2.generic.level = RAW_OPEN_GENERIC; - io2.generic.in.file_attr = io->open.in.search_attrs; - io2.generic.in.fname = io->open.in.fname; - io2.generic.in.open_disposition = NTCREATEX_DISP_OPEN; + ZERO_STRUCT(io2->generic.in); + io2->generic.level = RAW_OPEN_GENERIC; + io2->generic.in.file_attr = io->open.in.search_attrs; + io2->generic.in.fname = io->open.in.fname; + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; DEBUG(9,("ntvfs_map_open(OPEN): mapping flags=0x%x\n", io->open.in.flags)); switch (io->open.in.flags & OPEN_FLAGS_MODE_MASK) { case OPEN_FLAGS_OPEN_READ: - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; io->open.out.rmode = DOS_OPEN_RDONLY; break; case OPEN_FLAGS_OPEN_WRITE: - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; io->open.out.rmode = DOS_OPEN_WRONLY; break; case OPEN_FLAGS_OPEN_RDWR: case 0xf: /* FCB mode */ - io2.generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; io->open.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ break; @@ -194,31 +203,31 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, /* DENY_DOS is quite strange - it depends on the filename! */ /* REWRITE: is this necessary for OPEN? */ if (is_exe_file(io->open.in.fname)) { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; } else { if ((io->open.in.flags & OPEN_FLAGS_MODE_MASK) == OPEN_FLAGS_OPEN_READ) { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; } else { - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; } } break; case OPEN_FLAGS_DENY_ALL: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; case OPEN_FLAGS_DENY_WRITE: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; break; case OPEN_FLAGS_DENY_READ: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; break; case OPEN_FLAGS_DENY_NONE: - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; break; case 0x70: /* FCB mode */ - io2.generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; default: DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", @@ -226,18 +235,18 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, return NT_STATUS_INVALID_PARAMETER; } DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", - io->open.in.flags, io2.generic.in.access_mask, io2.generic.in.share_access)); + io->open.in.flags, io2->generic.in.access_mask, io2->generic.in.share_access)); - status = ntvfs->ops->open(ntvfs, req, &io2); + status = ntvfs->ops->open(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { return status; } ZERO_STRUCT(io->openx.out); - io->open.out.fnum = io2.generic.out.fnum; - io->open.out.attrib = io2.generic.out.attrib; - io->open.out.write_time = nt_time_to_unix(io2.generic.out.write_time); - io->open.out.size = io2.generic.out.size; + io->open.out.fnum = io2->generic.out.fnum; + io->open.out.attrib = io2->generic.out.attrib; + io->open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->open.out.size = io2->generic.out.size; io->open.out.rmode = DOS_OPEN_RDWR; return NT_STATUS_OK; @@ -254,16 +263,21 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, struct ntvfs_module_context *ntvfs) { NTSTATUS status; - union smb_fsinfo fs2; + union smb_fsinfo *fs2; + + fs2 = talloc_p(req, union smb_fsinfo); + if (fs2 == NULL) { + return NT_STATUS_NO_MEMORY; + } if (fs->generic.level == RAW_QFS_GENERIC) { return NT_STATUS_INVALID_LEVEL; } /* ask the backend for the generic info */ - fs2.generic.level = RAW_QFS_GENERIC; + fs2->generic.level = RAW_QFS_GENERIC; - status = ntvfs->ops->fsinfo(ntvfs, req, &fs2); + status = ntvfs->ops->fsinfo(ntvfs, req, fs2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -279,7 +293,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, /* we need to scale the sizes to fit */ for (bpunit=64; bpunit<0x10000; bpunit *= 2) { - if (fs2.generic.out.blocks_total * (double)fs2.generic.out.block_size < bpunit * 512 * 65535.0) { + if (fs2->generic.out.blocks_total * (double)fs2->generic.out.block_size < bpunit * 512 * 65535.0) { break; } } @@ -287,9 +301,9 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, fs->dskattr.out.blocks_per_unit = bpunit; fs->dskattr.out.block_size = 512; fs->dskattr.out.units_total = - (fs2.generic.out.blocks_total * (double)fs2.generic.out.block_size) / (bpunit * 512); + (fs2->generic.out.blocks_total * (double)fs2->generic.out.block_size) / (bpunit * 512); fs->dskattr.out.units_free = - (fs2.generic.out.blocks_free * (double)fs2.generic.out.block_size) / (bpunit * 512); + (fs2->generic.out.blocks_free * (double)fs2->generic.out.block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) { @@ -301,63 +315,63 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, } case RAW_QFS_ALLOCATION: - fs->allocation.out.fs_id = fs2.generic.out.fs_id; - fs->allocation.out.total_alloc_units = fs2.generic.out.blocks_total; - fs->allocation.out.avail_alloc_units = fs2.generic.out.blocks_free; + fs->allocation.out.fs_id = fs2->generic.out.fs_id; + fs->allocation.out.total_alloc_units = fs2->generic.out.blocks_total; + fs->allocation.out.avail_alloc_units = fs2->generic.out.blocks_free; fs->allocation.out.sectors_per_unit = 1; - fs->allocation.out.bytes_per_sector = fs2.generic.out.block_size; + fs->allocation.out.bytes_per_sector = fs2->generic.out.block_size; return NT_STATUS_OK; case RAW_QFS_VOLUME: - fs->volume.out.serial_number = fs2.generic.out.serial_number; - fs->volume.out.volume_name.s = fs2.generic.out.volume_name; + fs->volume.out.serial_number = fs2->generic.out.serial_number; + fs->volume.out.volume_name.s = fs2->generic.out.volume_name; return NT_STATUS_OK; case RAW_QFS_VOLUME_INFO: case RAW_QFS_VOLUME_INFORMATION: - fs->volume_info.out.create_time = fs2.generic.out.create_time; - fs->volume_info.out.serial_number = fs2.generic.out.serial_number; - fs->volume_info.out.volume_name.s = fs2.generic.out.volume_name; + fs->volume_info.out.create_time = fs2->generic.out.create_time; + fs->volume_info.out.serial_number = fs2->generic.out.serial_number; + fs->volume_info.out.volume_name.s = fs2->generic.out.volume_name; return NT_STATUS_OK; case RAW_QFS_SIZE_INFO: case RAW_QFS_SIZE_INFORMATION: - fs->size_info.out.total_alloc_units = fs2.generic.out.blocks_total; - fs->size_info.out.avail_alloc_units = fs2.generic.out.blocks_free; + fs->size_info.out.total_alloc_units = fs2->generic.out.blocks_total; + fs->size_info.out.avail_alloc_units = fs2->generic.out.blocks_free; fs->size_info.out.sectors_per_unit = 1; - fs->size_info.out.bytes_per_sector = fs2.generic.out.block_size; + fs->size_info.out.bytes_per_sector = fs2->generic.out.block_size; return NT_STATUS_OK; case RAW_QFS_DEVICE_INFO: case RAW_QFS_DEVICE_INFORMATION: - fs->device_info.out.device_type = fs2.generic.out.device_type; - fs->device_info.out.characteristics = fs2.generic.out.device_characteristics; + fs->device_info.out.device_type = fs2->generic.out.device_type; + fs->device_info.out.characteristics = fs2->generic.out.device_characteristics; return NT_STATUS_OK; case RAW_QFS_ATTRIBUTE_INFO: case RAW_QFS_ATTRIBUTE_INFORMATION: - fs->attribute_info.out.fs_attr = fs2.generic.out.fs_attr; - fs->attribute_info.out.max_file_component_length = fs2.generic.out.max_file_component_length; - fs->attribute_info.out.fs_type.s = fs2.generic.out.fs_type; + fs->attribute_info.out.fs_attr = fs2->generic.out.fs_attr; + fs->attribute_info.out.max_file_component_length = fs2->generic.out.max_file_component_length; + fs->attribute_info.out.fs_type.s = fs2->generic.out.fs_type; return NT_STATUS_OK; case RAW_QFS_QUOTA_INFORMATION: ZERO_STRUCT(fs->quota_information.out.unknown); - fs->quota_information.out.quota_soft = fs2.generic.out.quota_soft; - fs->quota_information.out.quota_hard = fs2.generic.out.quota_hard; - fs->quota_information.out.quota_flags = fs2.generic.out.quota_flags; + fs->quota_information.out.quota_soft = fs2->generic.out.quota_soft; + fs->quota_information.out.quota_hard = fs2->generic.out.quota_hard; + fs->quota_information.out.quota_flags = fs2->generic.out.quota_flags; return NT_STATUS_OK; case RAW_QFS_FULL_SIZE_INFORMATION: - fs->full_size_information.out.total_alloc_units = fs2.generic.out.blocks_total; - fs->full_size_information.out.call_avail_alloc_units = fs2.generic.out.blocks_free; - fs->full_size_information.out.actual_avail_alloc_units = fs2.generic.out.blocks_free; + fs->full_size_information.out.total_alloc_units = fs2->generic.out.blocks_total; + fs->full_size_information.out.call_avail_alloc_units = fs2->generic.out.blocks_free; + fs->full_size_information.out.actual_avail_alloc_units = fs2->generic.out.blocks_free; fs->full_size_information.out.sectors_per_unit = 1; - fs->full_size_information.out.bytes_per_sector = fs2.generic.out.block_size; + fs->full_size_information.out.bytes_per_sector = fs2->generic.out.block_size; return NT_STATUS_OK; case RAW_QFS_OBJECTID_INFORMATION: - fs->objectid_information.out.guid = fs2.generic.out.guid; + fs->objectid_information.out.guid = fs2->generic.out.guid; ZERO_STRUCT(fs->objectid_information.out.unknown); return NT_STATUS_OK; } @@ -370,7 +384,8 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, union smb_fileinfo *info2) +NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, + union smb_fileinfo *info2) { int i; /* and convert it to the required level using results in info2 */ @@ -596,21 +611,26 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf struct ntvfs_module_context *ntvfs) { NTSTATUS status; - union smb_fileinfo info2; + union smb_fileinfo *info2; + + info2 = talloc_p(req, union smb_fileinfo); + if (info2 == NULL) { + return NT_STATUS_NO_MEMORY; + } if (info->generic.level == RAW_FILEINFO_GENERIC) { return NT_STATUS_INVALID_LEVEL; } /* ask the backend for the generic info */ - info2.generic.level = RAW_FILEINFO_GENERIC; - info2.generic.in.fnum = info->generic.in.fnum; + info2->generic.level = RAW_FILEINFO_GENERIC; + info2->generic.in.fnum = info->generic.in.fnum; - status = ntvfs->ops->qfileinfo(ntvfs, req, &info2); + status = ntvfs->ops->qfileinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { return status; } - return ntvfs_map_fileinfo(req, info, &info2); + return ntvfs_map_fileinfo(req, info, info2); } /* @@ -620,19 +640,286 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf struct ntvfs_module_context *ntvfs) { NTSTATUS status; - union smb_fileinfo info2; + union smb_fileinfo *info2; + + info2 = talloc_p(req, union smb_fileinfo); + if (info2 == NULL) { + return NT_STATUS_NO_MEMORY; + } if (info->generic.level == RAW_FILEINFO_GENERIC) { return NT_STATUS_INVALID_LEVEL; } /* ask the backend for the generic info */ - info2.generic.level = RAW_FILEINFO_GENERIC; - info2.generic.in.fname = info->generic.in.fname; + info2->generic.level = RAW_FILEINFO_GENERIC; + info2->generic.in.fname = info->generic.in.fname; + + /* must be synchronous, or we won't be called to do the + translation */ + req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; - status = ntvfs->ops->qpathinfo(ntvfs, req, &info2); + status = ntvfs->ops->qpathinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { return status; } - return ntvfs_map_fileinfo(req, info, &info2); + return ntvfs_map_fileinfo(req, info, info2); +} + + +/* + NTVFS lock generic to any mapper +*/ +NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, + struct ntvfs_module_context *ntvfs) +{ + union smb_lock *lck2; + struct smb_lock_entry *locks; + + lck2 = talloc_p(req, union smb_lock); + if (lck2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + locks = talloc_array_p(lck2, struct smb_lock_entry, 1); + if (locks == NULL) { + return NT_STATUS_NO_MEMORY; + } + + switch (lck->generic.level) { + case RAW_LOCK_LOCKX: + return NT_STATUS_INVALID_LEVEL; + + case RAW_LOCK_LOCK: + lck2->generic.in.ulock_cnt = 0; + lck2->generic.in.lock_cnt = 1; + break; + + case RAW_LOCK_UNLOCK: + lck2->generic.in.ulock_cnt = 1; + lck2->generic.in.lock_cnt = 0; + break; + } + + lck2->generic.level = RAW_LOCK_GENERIC; + lck2->generic.in.fnum = lck->lock.in.fnum; + lck2->generic.in.mode = 0; + lck2->generic.in.timeout = 0; + lck2->generic.in.locks = locks; + locks->pid = req->smbpid; + locks->offset = lck->lock.in.offset; + locks->count = lck->lock.in.count; + + return ntvfs->ops->lock(ntvfs, req, lck2); +} + + +/* + NTVFS write generic to any mapper +*/ +NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, + struct ntvfs_module_context *ntvfs) +{ + union smb_write *wr2; + union smb_lock *lck; + union smb_close *cl; + NTSTATUS status; + + wr2 = talloc_p(req, union smb_write); + if (wr2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + wr2->generic.level = RAW_WRITE_GENERIC; + + /* we can't map asynchronously */ + req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + + switch (wr->generic.level) { + case RAW_WRITE_WRITEX: + status = NT_STATUS_INVALID_LEVEL; + break; + + case RAW_WRITE_WRITE: + wr2->generic.in.fnum = wr->write.in.fnum; + wr2->generic.in.offset = wr->write.in.offset; + wr2->generic.in.wmode = 0; + wr2->generic.in.remaining = wr->write.in.remaining; + wr2->generic.in.count = wr->write.in.count; + wr2->generic.in.data = wr->write.in.data; + status = ntvfs->ops->write(ntvfs, req, wr2); + wr->write.out.nwritten = wr2->generic.out.nwritten; + break; + + case RAW_WRITE_WRITEUNLOCK: + lck = talloc_p(wr2, union smb_lock); + if (lck == NULL) { + return NT_STATUS_NO_MEMORY; + } + + wr2->generic.in.fnum = wr->writeunlock.in.fnum; + wr2->generic.in.offset = wr->writeunlock.in.offset; + wr2->generic.in.wmode = 0; + wr2->generic.in.remaining = wr->writeunlock.in.remaining; + wr2->generic.in.count = wr->writeunlock.in.count; + wr2->generic.in.data = wr->writeunlock.in.data; + + lck->unlock.level = RAW_LOCK_UNLOCK; + lck->unlock.in.fnum = wr->writeunlock.in.fnum; + lck->unlock.in.count = wr->writeunlock.in.count; + lck->unlock.in.offset = wr->writeunlock.in.offset; + + status = ntvfs->ops->write(ntvfs, req, wr2); + + wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; + + if (NT_STATUS_IS_OK(status)) { + status = ntvfs->ops->lock(ntvfs, req, lck); + } + break; + + case RAW_WRITE_WRITECLOSE: + cl = talloc_p(wr2, union smb_close); + if (cl == NULL) { + return NT_STATUS_NO_MEMORY; + } + + wr2->generic.in.fnum = wr->writeclose.in.fnum; + wr2->generic.in.offset = wr->writeclose.in.offset; + wr2->generic.in.wmode = 0; + wr2->generic.in.remaining = 0; + wr2->generic.in.count = wr->writeclose.in.count; + wr2->generic.in.data = wr->writeclose.in.data; + + cl->close.level = RAW_CLOSE_CLOSE; + cl->close.in.fnum = wr->writeclose.in.fnum; + cl->close.in.write_time = wr->writeclose.in.mtime; + + status = ntvfs->ops->write(ntvfs, req, wr2); + wr->writeclose.out.nwritten = wr2->generic.out.nwritten; + + if (NT_STATUS_IS_OK(status)) { + status = ntvfs->ops->close(ntvfs, req, cl); + } + break; + + case RAW_WRITE_SPLWRITE: + wr2->generic.in.fnum = wr->splwrite.in.fnum; + wr2->generic.in.offset = 0; + wr2->generic.in.wmode = 0; + wr2->generic.in.remaining = 0; + wr2->generic.in.count = wr->splwrite.in.count; + wr2->generic.in.data = wr->splwrite.in.data; + status = ntvfs->ops->write(ntvfs, req, wr2); + break; + } + + + return status; +} + + +/* + NTVFS read generic to any mapper +*/ +NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, + struct ntvfs_module_context *ntvfs) +{ + union smb_read *rd2; + union smb_lock *lck; + NTSTATUS status; + + rd2 = talloc_p(req, union smb_read); + if (rd2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + rd2->generic.level = RAW_READ_GENERIC; + + /* we can't map asynchronously */ + req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + + switch (rd->generic.level) { + case RAW_READ_READX: + status = NT_STATUS_INVALID_LEVEL; + break; + + case RAW_READ_READ: + rd2->generic.in.fnum = rd->read.in.fnum; + rd2->generic.in.offset = rd->read.in.offset; + rd2->generic.in.mincnt = rd->read.in.count; + rd2->generic.in.maxcnt = rd->read.in.count; + rd2->generic.in.remaining = rd->read.in.remaining; + rd2->generic.out.data = rd->read.out.data; + status = ntvfs->ops->read(ntvfs, req, rd2); + rd->read.out.nread = rd2->generic.out.nread; + break; + + case RAW_READ_READBRAW: + rd2->generic.in.fnum = rd->readbraw.in.fnum; + rd2->generic.in.offset = rd->readbraw.in.offset; + rd2->generic.in.mincnt = rd->readbraw.in.mincnt; + rd2->generic.in.maxcnt = rd->readbraw.in.maxcnt; + rd2->generic.in.remaining = 0; + rd2->generic.out.data = rd->readbraw.out.data; + status = ntvfs->ops->read(ntvfs, req, rd2); + rd->readbraw.out.nread = rd2->generic.out.nread; + break; + + case RAW_READ_LOCKREAD: + lck = talloc_p(rd2, union smb_lock); + if (lck == NULL) { + return NT_STATUS_NO_MEMORY; + } + + rd2->generic.in.fnum = rd->lockread.in.fnum; + rd2->generic.in.offset = rd->lockread.in.offset; + rd2->generic.in.mincnt = rd->lockread.in.count; + rd2->generic.in.maxcnt = rd->lockread.in.count; + rd2->generic.in.remaining = rd->lockread.in.remaining; + rd2->generic.out.data = rd->lockread.out.data; + + lck->lock.level = RAW_LOCK_LOCK; + lck->lock.in.fnum = rd->lockread.in.fnum; + lck->lock.in.count = rd->lockread.in.count; + lck->lock.in.offset = rd->lockread.in.offset; + + status = ntvfs->ops->lock(ntvfs, req, lck); + + if (NT_STATUS_IS_OK(status)) { + status = ntvfs->ops->read(ntvfs, req, rd2); + rd->lockread.out.nread = rd2->generic.out.nread; + } + break; + } + + + return status; +} + + +/* + NTVFS close generic to any mapper +*/ +NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, + struct ntvfs_module_context *ntvfs) +{ + union smb_close *cl2; + + cl2 = talloc_p(req, union smb_close); + if (cl2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + switch (cl2->generic.level) { + case RAW_CLOSE_CLOSE: + return NT_STATUS_INVALID_LEVEL; + + case RAW_CLOSE_SPLCLOSE: + cl2->close.level = RAW_CLOSE_CLOSE; + cl2->close.in.fnum = cl->splclose.in.fnum; + break; + } + + return ntvfs->ops->close(ntvfs, req, cl2); } -- cgit From 2e4c8c01591496b5fb44f0d7e2ce082a9795c2f3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Oct 2004 11:10:51 +0000 Subject: r3083: fixed a couple of generic mapping errors found with RAW-* and cifs:mapgeneric (This used to be commit 76329798ff7f804bf4d7e6e9c1bb4c4dc7b9bb01) --- source4/ntvfs/ntvfs_generic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index b6f3d8e603..d4c163844f 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -773,7 +773,8 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; - if (NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_OK(status) && + lck->unlock.in.count != 0) { status = ntvfs->ops->lock(ntvfs, req, lck); } break; @@ -798,7 +799,8 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, status = ntvfs->ops->write(ntvfs, req, wr2); wr->writeclose.out.nwritten = wr2->generic.out.nwritten; - if (NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_OK(status) && + wr2->generic.in.count != 0) { status = ntvfs->ops->close(ntvfs, req, cl); } break; -- cgit From 82a56fae9954dcc12f7c531a44cc9344281acb85 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Oct 2004 12:24:31 +0000 Subject: r3087: fixed a typo (This used to be commit 3791b97694f052b0b7e170e07c21f7a5739d74dd) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index d4c163844f..0be4e5fd8e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -913,7 +913,7 @@ NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, return NT_STATUS_NO_MEMORY; } - switch (cl2->generic.level) { + switch (cl->generic.level) { case RAW_CLOSE_CLOSE: return NT_STATUS_INVALID_LEVEL; -- cgit From d33ae23165f4a5c07d41c9049ece4de5c0bb62f4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Oct 2004 06:36:14 +0000 Subject: r3107: slight tweak to the openx -> ntcreatex mapping routine. This mapping can never be perfect, as openx can do things that ntcreatex can't, but with this tweak we get close (the BASE-DENY1 test passes completely, for example) (This used to be commit 88112b9677b3c9ca97d349905c95516c6f29c8a7) --- source4/ntvfs/ntvfs_generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 0be4e5fd8e..ceb7900935 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -96,7 +96,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; break; } @@ -201,7 +201,6 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch(io->open.in.flags & OPEN_FLAGS_DENY_MASK) { case OPEN_FLAGS_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ - /* REWRITE: is this necessary for OPEN? */ if (is_exe_file(io->open.in.fname)) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; } else { -- cgit From 7fa912e708331e729d5e4ffad28646d294d4745a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 07:03:15 +0000 Subject: r3200: - improved the accuracy of openx emulation. We now nearly pass the openx portion of RAW-OPEN - fixed directory size reporting to make it consistent. we now pass the ntcreatex portion of RAW-OPEN (This used to be commit 6282e5811b8d4f1c17152d86875ac60d1323779d) --- source4/ntvfs/ntvfs_generic.c | 56 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index ceb7900935..452273cbdb 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -90,14 +90,20 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io->openx.out.access = OPENX_MODE_ACCESS_READ; break; case OPENX_MODE_ACCESS_WRITE: io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_WRITE; break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: + case OPENX_MODE_ACCESS_EXEC: io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_RDWR; break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; } switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { @@ -129,12 +135,11 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, case OPENX_MODE_DENY_FCB: io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; } switch (io->openx.in.open_func) { - case (OPENX_OPEN_FUNC_FAIL): - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; case (OPENX_OPEN_FUNC_OPEN): io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; break; @@ -150,8 +155,17 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; break; + default: + /* this one is very strange */ + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_EXEC) { + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + } + return NT_STATUS_INVALID_LOCK_SEQUENCE; } - io2->generic.in.alloc_size = io->openx.in.size; + + io2->generic.in.alloc_size = 0; io2->generic.in.file_attr = io->openx.in.file_attrs; io2->generic.in.fname = io->openx.in.fname; @@ -159,13 +173,35 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, if (!NT_STATUS_IS_OK(status)) { return status; } + + io->openx.out.fnum = io2->generic.out.fnum; + io->openx.out.attrib = io2->generic.out.attrib; + io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openx.out.size = io2->generic.out.size; + io->openx.out.ftype = 0; + io->openx.out.devstate = 0; + io->openx.out.action = io2->generic.out.create_action; + io->openx.out.unique_fid = 0; + io->openx.out.access_mask = io2->generic.in.access_mask; + io->openx.out.unknown = 0; - ZERO_STRUCT(io->openx.out); - io->openx.out.fnum = io2->generic.out.fnum; - io->openx.out.attrib = io2->generic.out.attrib; - io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); - io->openx.out.size = io2->generic.out.size; - + /* we need to extend the file to the requested size if + it was newly created */ + if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && + io->openx.in.size != 0) { + union smb_setfileinfo *sf; + sf = talloc_p(req, union smb_setfileinfo); + if (sf != NULL) { + sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sf->generic.file.fnum = io2->generic.out.fnum; + sf->end_of_file_info.in.size = io->openx.in.size; + status = ntvfs->ops->setfileinfo(ntvfs, req, sf); + if (NT_STATUS_IS_OK(status)) { + io->openx.out.size = io->openx.in.size; + } + } + } + return NT_STATUS_OK; -- cgit From 019719595778e0bd0a00781b33407554d1943985 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Oct 2004 21:48:53 +0000 Subject: r3336: use a struct ntvfs_async_state to be able to do async chaning of ntvfs modules the idea is that a passthru module can use ntvfs_async_state_push() before calling ntvfs_next_*() and in the _send function it calls ntvfs_async_state_pop() and then call the upper layer send_fn itself - ntvfs_nbench is now fully async - the ntvfs_map_*() functions and the trans(2) mapping functions are not converted yet metze (This used to be commit fde64c0dc142b53d128c8ba09af048dc58d8ef3a) --- source4/ntvfs/ntvfs_generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 452273cbdb..2639b5ae39 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -71,7 +71,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, /* must be synchronous, or we won't be called to do the translation */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (io->generic.level) { case RAW_OPEN_GENERIC: @@ -692,7 +692,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf /* must be synchronous, or we won't be called to do the translation */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->qpathinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { @@ -768,7 +768,7 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, wr2->generic.level = RAW_WRITE_GENERIC; /* we can't map asynchronously */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (wr->generic.level) { case RAW_WRITE_WRITEX: @@ -874,7 +874,7 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, rd2->generic.level = RAW_READ_GENERIC; /* we can't map asynchronously */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (rd->generic.level) { case RAW_READ_READX: -- cgit From 668ecaa325e827f2875295b121bbfc083702b77e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 10:02:24 +0000 Subject: r3427: split the openx logic out from the other open mapping code (This used to be commit 8d71ed9271a6ee43b9a3c28724b95714b5d2e56d) --- source4/ntvfs/ntvfs_generic.c | 263 ++++++++++++++++++++++-------------------- 1 file changed, 138 insertions(+), 125 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 2639b5ae39..da60615a44 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -55,6 +55,143 @@ static BOOL is_exe_file(const char *fname) } +/* + NTVFS openx to ntcreatex mapper +*/ +NTSTATUS ntvfs_map_open_openx(struct smbsrv_request *req, + union smb_open *io, + union smb_open *io2, + struct ntvfs_module_context *ntvfs) +{ + NTSTATUS status; + + ZERO_STRUCT(io2->generic.in); + io2->generic.level = RAW_OPEN_GENERIC; + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; + } + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + } + + switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { + case OPENX_MODE_ACCESS_READ: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io->openx.out.access = OPENX_MODE_ACCESS_READ; + break; + case OPENX_MODE_ACCESS_WRITE: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_WRITE; + break; + case OPENX_MODE_ACCESS_RDWR: + case OPENX_MODE_ACCESS_FCB: + case OPENX_MODE_ACCESS_EXEC: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_RDWR; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { + case OPENX_MODE_DENY_READ: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_WRITE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPENX_MODE_DENY_ALL: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPENX_MODE_DENY_NONE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_DOS: + /* DENY_DOS is quite strange - it depends on the filename! */ + if (is_exe_file(io->openx.in.fname)) { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + } else { + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_READ) { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + } else { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + } + } + break; + case OPENX_MODE_DENY_FCB: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (io->openx.in.open_func) { + case (OPENX_OPEN_FUNC_OPEN): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; + break; + case (OPENX_OPEN_FUNC_TRUNC): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; + break; + case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + break; + case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + break; + default: + /* this one is very strange */ + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_EXEC) { + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + } + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + io2->generic.in.alloc_size = 0; + io2->generic.in.file_attr = io->openx.in.file_attrs; + io2->generic.in.fname = io->openx.in.fname; + + status = ntvfs->ops->open(ntvfs, req, io2); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + io->openx.out.fnum = io2->generic.out.fnum; + io->openx.out.attrib = io2->generic.out.attrib; + io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openx.out.size = io2->generic.out.size; + io->openx.out.ftype = 0; + io->openx.out.devstate = 0; + io->openx.out.action = io2->generic.out.create_action; + io->openx.out.unique_fid = 0; + io->openx.out.access_mask = io2->generic.in.access_mask; + io->openx.out.unknown = 0; + + /* we need to extend the file to the requested size if + it was newly created */ + if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && + io->openx.in.size != 0) { + union smb_setfileinfo *sf; + sf = talloc_p(req, union smb_setfileinfo); + if (sf != NULL) { + sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sf->generic.file.fnum = io2->generic.out.fnum; + sf->end_of_file_info.in.size = io->openx.in.size; + status = ntvfs->ops->setfileinfo(ntvfs, req, sf); + if (NT_STATUS_IS_OK(status)) { + io->openx.out.size = io->openx.in.size; + } + } + } + + return NT_STATUS_OK; +} + /* NTVFS open generic to any mapper */ @@ -78,131 +215,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, return NT_STATUS_INVALID_LEVEL; case RAW_OPEN_OPENX: - ZERO_STRUCT(io2->generic.in); - io2->generic.level = RAW_OPEN_GENERIC; - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; - } - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; - } - - switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { - case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; - io->openx.out.access = OPENX_MODE_ACCESS_READ; - break; - case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_WRITE; - break; - case OPENX_MODE_ACCESS_RDWR: - case OPENX_MODE_ACCESS_FCB: - case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_RDWR; - break; - default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { - case OPENX_MODE_DENY_READ: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_WRITE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - break; - case OPENX_MODE_DENY_ALL: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - case OPENX_MODE_DENY_NONE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_DOS: - /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_file(io->openx.in.fname)) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - } else { - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_READ) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - } else { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - } - } - break; - case OPENX_MODE_DENY_FCB: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - switch (io->openx.in.open_func) { - case (OPENX_OPEN_FUNC_OPEN): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; - break; - case (OPENX_OPEN_FUNC_TRUNC): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; - break; - case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; - break; - case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; - break; - default: - /* this one is very strange */ - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_EXEC) { - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - } - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - io2->generic.in.alloc_size = 0; - io2->generic.in.file_attr = io->openx.in.file_attrs; - io2->generic.in.fname = io->openx.in.fname; - - status = ntvfs->ops->open(ntvfs, req, io2); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - io->openx.out.fnum = io2->generic.out.fnum; - io->openx.out.attrib = io2->generic.out.attrib; - io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); - io->openx.out.size = io2->generic.out.size; - io->openx.out.ftype = 0; - io->openx.out.devstate = 0; - io->openx.out.action = io2->generic.out.create_action; - io->openx.out.unique_fid = 0; - io->openx.out.access_mask = io2->generic.in.access_mask; - io->openx.out.unknown = 0; - - /* we need to extend the file to the requested size if - it was newly created */ - if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && - io->openx.in.size != 0) { - union smb_setfileinfo *sf; - sf = talloc_p(req, union smb_setfileinfo); - if (sf != NULL) { - sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.file.fnum = io2->generic.out.fnum; - sf->end_of_file_info.in.size = io->openx.in.size; - status = ntvfs->ops->setfileinfo(ntvfs, req, sf); - if (NT_STATUS_IS_OK(status)) { - io->openx.out.size = io->openx.in.size; - } - } - } - - return NT_STATUS_OK; + return ntvfs_map_open_openx(req, io, io2, ntvfs); case RAW_OPEN_OPEN: -- cgit From 8692564e350db4dfa4a9ef4c4cb014d76b284d3b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 04:17:30 +0000 Subject: r3458: more solaris portability fixes, the main one being that we can't use a structure element called "open" as its a macro on solaris. (This used to be commit 4e92e15c4e396b1d8cd211192888fea68c2cf0f9) --- source4/ntvfs/ntvfs_generic.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index da60615a44..835011437f 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -221,39 +221,39 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, case RAW_OPEN_OPEN: ZERO_STRUCT(io2->generic.in); io2->generic.level = RAW_OPEN_GENERIC; - io2->generic.in.file_attr = io->open.in.search_attrs; - io2->generic.in.fname = io->open.in.fname; + io2->generic.in.file_attr = io->openold.in.search_attrs; + io2->generic.in.fname = io->openold.in.fname; io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; DEBUG(9,("ntvfs_map_open(OPEN): mapping flags=0x%x\n", - io->open.in.flags)); - switch (io->open.in.flags & OPEN_FLAGS_MODE_MASK) { + io->openold.in.flags)); + switch (io->openold.in.flags & OPEN_FLAGS_MODE_MASK) { case OPEN_FLAGS_OPEN_READ: io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; - io->open.out.rmode = DOS_OPEN_RDONLY; + io->openold.out.rmode = DOS_OPEN_RDONLY; break; case OPEN_FLAGS_OPEN_WRITE: io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; - io->open.out.rmode = DOS_OPEN_WRONLY; + io->openold.out.rmode = DOS_OPEN_WRONLY; break; case OPEN_FLAGS_OPEN_RDWR: case 0xf: /* FCB mode */ io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; - io->open.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ + io->openold.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ break; default: DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", - io->open.in.flags & OPEN_FLAGS_MODE_MASK)); + io->openold.in.flags & OPEN_FLAGS_MODE_MASK)); return NT_STATUS_INVALID_PARAMETER; } - switch(io->open.in.flags & OPEN_FLAGS_DENY_MASK) { + switch(io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { case OPEN_FLAGS_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_file(io->open.in.fname)) { + if (is_exe_file(io->openold.in.fname)) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; } else { - if ((io->open.in.flags & OPEN_FLAGS_MODE_MASK) == + if ((io->openold.in.flags & OPEN_FLAGS_MODE_MASK) == OPEN_FLAGS_OPEN_READ) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; } else { @@ -279,11 +279,11 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, break; default: DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", - io->open.in.flags & OPEN_FLAGS_DENY_MASK)); + io->openold.in.flags & OPEN_FLAGS_DENY_MASK)); return NT_STATUS_INVALID_PARAMETER; } DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", - io->open.in.flags, io2->generic.in.access_mask, io2->generic.in.share_access)); + io->openold.in.flags, io2->generic.in.access_mask, io2->generic.in.share_access)); status = ntvfs->ops->open(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { @@ -291,11 +291,11 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, } ZERO_STRUCT(io->openx.out); - io->open.out.fnum = io2->generic.out.fnum; - io->open.out.attrib = io2->generic.out.attrib; - io->open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); - io->open.out.size = io2->generic.out.size; - io->open.out.rmode = DOS_OPEN_RDWR; + io->openold.out.fnum = io2->generic.out.fnum; + io->openold.out.attrib = io2->generic.out.attrib; + io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openold.out.size = io2->generic.out.size; + io->openold.out.rmode = DOS_OPEN_RDWR; return NT_STATUS_OK; } -- cgit From 2df2d1b67f9bf2907f452688b2c54b73052cfb49 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 04:51:57 +0000 Subject: r3461: another place where "open" was used as a structure element (This used to be commit 1087ea830e7aead86d54a1836512e88554afc919) --- source4/ntvfs/ntvfs_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 835011437f..8eaa3cf1b2 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -156,7 +156,7 @@ NTSTATUS ntvfs_map_open_openx(struct smbsrv_request *req, io2->generic.in.file_attr = io->openx.in.file_attrs; io2->generic.in.fname = io->openx.in.fname; - status = ntvfs->ops->open(ntvfs, req, io2); + status = ntvfs->ops->openfile(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -285,7 +285,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", io->openold.in.flags, io2->generic.in.access_mask, io2->generic.in.share_access)); - status = ntvfs->ops->open(ntvfs, req, io2); + status = ntvfs->ops->openfile(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From aa34fcebf8aa0660574a7c6976b33b3f37985e27 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 07:18:24 +0000 Subject: r3466: split out request.h, signing.h, and smb_server.h (This used to be commit 7c4e6ebf05790dd6e29896dd316db0fff613aa4e) --- source4/ntvfs/ntvfs_generic.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 8eaa3cf1b2..6e8caf787b 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -32,6 +32,8 @@ */ #include "includes.h" +#include "smb_server/smb_server.h" + /* see if a filename ends in EXE COM DLL or SYM. This is needed for the -- cgit From 00a1262f8932a2554a75756e34523fe83a56eb50 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Nov 2004 07:36:53 +0000 Subject: r3522: added async support to most of the ntvfs_map_*() functions, allowing functions like SMBopenx, SMBread and SMBwrite to be performed async (This used to be commit 9e80eb18ae8c4a4a8cdf2f32f0c869fbbc3832b4) --- source4/ntvfs/ntvfs_generic.c | 705 +++++++++++++++++++++++++----------------- 1 file changed, 429 insertions(+), 276 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 6e8caf787b..01a1a2dc60 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -34,6 +34,84 @@ #include "includes.h" #include "smb_server/smb_server.h" +/* a second stage function converts from the out parameters of the generic + call onto the out parameters of the specific call made */ +typedef NTSTATUS (*second_stage_t)(struct smbsrv_request *, + struct ntvfs_module_context *, + void *, void *, NTSTATUS); + +/* + this structure holds the async state for pending mapped async calls +*/ +struct ntvfs_map_async { + struct ntvfs_module_context *ntvfs; + void *io, *io2; + second_stage_t fn; +}; + +/* + this is a async wrapper, called from the backend when it has completed + a function that it has decided to reply to in an async fashion +*/ +static void ntvfs_map_async_send(struct smbsrv_request *req) +{ + struct ntvfs_map_async *m = req->async_states->private_data; + + ntvfs_async_state_pop(req); + + /* call the _finish function setup in ntvfs_map_async_setup() */ + req->async_states->status = m->fn(req, m->ntvfs, m->io, m->io2, req->async_states->status); + + /* call the send function from the next module up */ + req->async_states->send_fn(req); +} + +/* + prepare for calling a ntvfs backend with async support + io is the original call structure + io2 is the new call structure for the mapped call + fn is a second stage function for processing the out arguments +*/ +static NTSTATUS ntvfs_map_async_setup(struct smbsrv_request *req, + struct ntvfs_module_context *ntvfs, + void *io, void *io2, + second_stage_t fn) +{ + struct ntvfs_map_async *m; + m = talloc_p(req, struct ntvfs_map_async); + if (m == NULL) { + return NT_STATUS_NO_MEMORY; + } + m->ntvfs = ntvfs; + m->io = io; + m->io2 = io2; + m->fn = fn; + return ntvfs_async_state_push(req, m, ntvfs_map_async_send, ntvfs); +} + + +/* + called when first stage processing is complete. +*/ +static NTSTATUS ntvfs_map_async_finish(struct smbsrv_request *req, NTSTATUS status) +{ + struct ntvfs_map_async *m; + + /* if the backend has decided to reply in an async fashion then + we don't need to do any work here */ + if (req->async_states->state & NTVFS_ASYNC_STATE_ASYNC) { + return status; + } + + /* the backend is replying immediately. call the 2nd stage function after popping our local + async state */ + m = req->async_states->private_data; + + ntvfs_async_state_pop(req); + + return m->fn(req, m->ntvfs, m->io, m->io2, status); +} + /* see if a filename ends in EXE COM DLL or SYM. This is needed for the @@ -60,137 +138,65 @@ static BOOL is_exe_file(const char *fname) /* NTVFS openx to ntcreatex mapper */ -NTSTATUS ntvfs_map_open_openx(struct smbsrv_request *req, - union smb_open *io, - union smb_open *io2, - struct ntvfs_module_context *ntvfs) +static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, + struct ntvfs_module_context *ntvfs, + union smb_open *io, + union smb_open *io2, + NTSTATUS status) { - NTSTATUS status; - - ZERO_STRUCT(io2->generic.in); - io2->generic.level = RAW_OPEN_GENERIC; - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; - } - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; - } - - switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { - case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; - io->openx.out.access = OPENX_MODE_ACCESS_READ; - break; - case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_WRITE; - break; - case OPENX_MODE_ACCESS_RDWR: - case OPENX_MODE_ACCESS_FCB: - case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_RDWR; - break; - default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { - case OPENX_MODE_DENY_READ: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_WRITE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - break; - case OPENX_MODE_DENY_ALL: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - case OPENX_MODE_DENY_NONE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_DOS: - /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_file(io->openx.in.fname)) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - } else { - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_READ) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - } else { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - } - } - break; - case OPENX_MODE_DENY_FCB: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - switch (io->openx.in.open_func) { - case (OPENX_OPEN_FUNC_OPEN): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; - break; - case (OPENX_OPEN_FUNC_TRUNC): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; - break; - case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; - break; - case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; - break; - default: - /* this one is very strange */ - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_EXEC) { - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - } - return NT_STATUS_INVALID_LOCK_SEQUENCE; - } - - io2->generic.in.alloc_size = 0; - io2->generic.in.file_attr = io->openx.in.file_attrs; - io2->generic.in.fname = io->openx.in.fname; - - status = ntvfs->ops->openfile(ntvfs, req, io2); if (!NT_STATUS_IS_OK(status)) { return status; } - - io->openx.out.fnum = io2->generic.out.fnum; - io->openx.out.attrib = io2->generic.out.attrib; - io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); - io->openx.out.size = io2->generic.out.size; - io->openx.out.ftype = 0; - io->openx.out.devstate = 0; - io->openx.out.action = io2->generic.out.create_action; - io->openx.out.unique_fid = 0; - io->openx.out.access_mask = io2->generic.in.access_mask; - io->openx.out.unknown = 0; - - /* we need to extend the file to the requested size if - it was newly created */ - if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && - io->openx.in.size != 0) { - union smb_setfileinfo *sf; - sf = talloc_p(req, union smb_setfileinfo); - if (sf != NULL) { - sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.file.fnum = io2->generic.out.fnum; + + switch (io->generic.level) { + case RAW_OPEN_OPEN: + io->openold.out.fnum = io2->generic.out.fnum; + io->openold.out.attrib = io2->generic.out.attrib; + io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openold.out.size = io2->generic.out.size; + io->openold.out.rmode = DOS_OPEN_RDWR; + break; + + case RAW_OPEN_OPENX: + io->openx.out.fnum = io2->generic.out.fnum; + io->openx.out.attrib = io2->generic.out.attrib; + io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->openx.out.size = io2->generic.out.size; + io->openx.out.ftype = 0; + io->openx.out.devstate = 0; + io->openx.out.action = io2->generic.out.create_action; + io->openx.out.unique_fid = 0; + io->openx.out.access_mask = io2->generic.in.access_mask; + io->openx.out.unknown = 0; + + /* we need to extend the file to the requested size if + it was newly created */ + if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && + io->openx.in.size != 0) { + union smb_setfileinfo *sf; + uint_t state; + + /* doing this secondary request async is more + trouble than its worth */ + state = req->async_states->state; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + + sf = talloc_p(req, union smb_setfileinfo); + sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sf->generic.file.fnum = io2->generic.out.fnum; sf->end_of_file_info.in.size = io->openx.in.size; status = ntvfs->ops->setfileinfo(ntvfs, req, sf); if (NT_STATUS_IS_OK(status)) { io->openx.out.size = io->openx.in.size; } + req->async_states->state = state; } + break; + + default: + return NT_STATUS_INVALID_LEVEL; } - + return NT_STATUS_OK; } @@ -203,54 +209,141 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, NTSTATUS status; union smb_open *io2; - io2 = talloc_p(req, union smb_open); + io2 = talloc_zero_p(req, union smb_open); if (io2 == NULL) { return NT_STATUS_NO_MEMORY; } - /* must be synchronous, or we won't be called to do the - translation */ - req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + status = ntvfs_map_async_setup(req, ntvfs, io, io2, + (second_stage_t)ntvfs_map_open_finish); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + io2->generic.level = RAW_OPEN_GENERIC; + switch (io->generic.level) { - case RAW_OPEN_GENERIC: - return NT_STATUS_INVALID_LEVEL; - case RAW_OPEN_OPENX: - return ntvfs_map_open_openx(req, io, io2, ntvfs); - - + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; + } + if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + } + + switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { + case OPENX_MODE_ACCESS_READ: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io->openx.out.access = OPENX_MODE_ACCESS_READ; + break; + case OPENX_MODE_ACCESS_WRITE: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_WRITE; + break; + case OPENX_MODE_ACCESS_RDWR: + case OPENX_MODE_ACCESS_FCB: + case OPENX_MODE_ACCESS_EXEC: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; + io->openx.out.access = OPENX_MODE_ACCESS_RDWR; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { + case OPENX_MODE_DENY_READ: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_WRITE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPENX_MODE_DENY_ALL: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPENX_MODE_DENY_NONE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_DOS: + /* DENY_DOS is quite strange - it depends on the filename! */ + if (is_exe_file(io->openx.in.fname)) { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + } else { + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_READ) { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + } else { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + } + } + break; + case OPENX_MODE_DENY_FCB: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (io->openx.in.open_func) { + case (OPENX_OPEN_FUNC_OPEN): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; + break; + case (OPENX_OPEN_FUNC_TRUNC): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; + break; + case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + break; + case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + break; + default: + /* this one is very strange */ + if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == + OPENX_MODE_ACCESS_EXEC) { + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + } + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + io2->generic.in.alloc_size = 0; + io2->generic.in.file_attr = io->openx.in.file_attrs; + io2->generic.in.fname = io->openx.in.fname; + + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; + + case RAW_OPEN_OPEN: - ZERO_STRUCT(io2->generic.in); - io2->generic.level = RAW_OPEN_GENERIC; io2->generic.in.file_attr = io->openold.in.search_attrs; io2->generic.in.fname = io->openold.in.fname; io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; - DEBUG(9,("ntvfs_map_open(OPEN): mapping flags=0x%x\n", - io->openold.in.flags)); switch (io->openold.in.flags & OPEN_FLAGS_MODE_MASK) { - case OPEN_FLAGS_OPEN_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; - io->openold.out.rmode = DOS_OPEN_RDONLY; - break; - case OPEN_FLAGS_OPEN_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; - io->openold.out.rmode = DOS_OPEN_WRONLY; - break; - case OPEN_FLAGS_OPEN_RDWR: - case 0xf: /* FCB mode */ - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | - GENERIC_RIGHTS_FILE_WRITE; - io->openold.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ - break; - default: - DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", - io->openold.in.flags & OPEN_FLAGS_MODE_MASK)); - return NT_STATUS_INVALID_PARAMETER; + case OPEN_FLAGS_OPEN_READ: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io->openold.out.rmode = DOS_OPEN_RDONLY; + break; + case OPEN_FLAGS_OPEN_WRITE: + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io->openold.out.rmode = DOS_OPEN_WRONLY; + break; + case OPEN_FLAGS_OPEN_RDWR: + case 0xf: /* FCB mode */ + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | + GENERIC_RIGHTS_FILE_WRITE; + io->openold.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ + break; + default: + DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", + io->openold.in.flags & OPEN_FLAGS_MODE_MASK)); + return NT_STATUS_INVALID_PARAMETER; } - switch(io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { - case OPEN_FLAGS_DENY_DOS: + switch (io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { + case OPEN_FLAGS_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ if (is_exe_file(io->openold.in.fname)) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; @@ -263,46 +356,36 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, } } break; - case OPEN_FLAGS_DENY_ALL: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - case OPEN_FLAGS_DENY_WRITE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - break; - case OPEN_FLAGS_DENY_READ: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPEN_FLAGS_DENY_NONE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | - NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; - break; - case 0x70: /* FCB mode */ - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - default: - DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", - io->openold.in.flags & OPEN_FLAGS_DENY_MASK)); - return NT_STATUS_INVALID_PARAMETER; + case OPEN_FLAGS_DENY_ALL: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPEN_FLAGS_DENY_WRITE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPEN_FLAGS_DENY_READ: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPEN_FLAGS_DENY_NONE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; + break; + case 0x70: /* FCB mode */ + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + default: + DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", + io->openold.in.flags & OPEN_FLAGS_DENY_MASK)); + return NT_STATUS_INVALID_PARAMETER; } - DEBUG(9,("ntvfs_map_open(OPEN): mapped flags=0x%x to access_mask=0x%x and share_access=0x%x\n", - io->openold.in.flags, io2->generic.in.access_mask, io2->generic.in.share_access)); status = ntvfs->ops->openfile(ntvfs, req, io2); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - ZERO_STRUCT(io->openx.out); - io->openold.out.fnum = io2->generic.out.fnum; - io->openold.out.attrib = io2->generic.out.attrib; - io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); - io->openold.out.size = io2->generic.out.size; - io->openold.out.rmode = DOS_OPEN_RDWR; - - return NT_STATUS_OK; + break; + + default: + return NT_STATUS_INVALID_LEVEL; } - return NT_STATUS_INVALID_LEVEL; + return ntvfs_map_async_finish(req, status); } @@ -323,6 +406,10 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, if (fs->generic.level == RAW_QFS_GENERIC) { return NT_STATUS_INVALID_LEVEL; } + + /* this map function is only used by the simple backend, which + doesn't do async */ + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; /* ask the backend for the generic info */ fs2->generic.level = RAW_QFS_GENERIC; @@ -705,8 +792,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf info2->generic.level = RAW_FILEINFO_GENERIC; info2->generic.in.fname = info->generic.in.fname; - /* must be synchronous, or we won't be called to do the - translation */ + /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->qpathinfo(ntvfs, req, info2); @@ -767,112 +853,176 @@ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, /* NTVFS write generic to any mapper */ -NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, - struct ntvfs_module_context *ntvfs) +static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, + struct ntvfs_module_context *ntvfs, + union smb_write *wr, + union smb_write *wr2, + NTSTATUS status) + { - union smb_write *wr2; union smb_lock *lck; union smb_close *cl; - NTSTATUS status; + uint_t state; - wr2 = talloc_p(req, union smb_write); - if (wr2 == NULL) { - return NT_STATUS_NO_MEMORY; + if (NT_STATUS_IS_ERR(status)) { + return status; } - wr2->generic.level = RAW_WRITE_GENERIC; - - /* we can't map asynchronously */ - req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; - switch (wr->generic.level) { - case RAW_WRITE_WRITEX: - status = NT_STATUS_INVALID_LEVEL; - break; - case RAW_WRITE_WRITE: - wr2->generic.in.fnum = wr->write.in.fnum; - wr2->generic.in.offset = wr->write.in.offset; - wr2->generic.in.wmode = 0; - wr2->generic.in.remaining = wr->write.in.remaining; - wr2->generic.in.count = wr->write.in.count; - wr2->generic.in.data = wr->write.in.data; - status = ntvfs->ops->write(ntvfs, req, wr2); wr->write.out.nwritten = wr2->generic.out.nwritten; break; case RAW_WRITE_WRITEUNLOCK: + wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; + lck = talloc_p(wr2, union smb_lock); if (lck == NULL) { return NT_STATUS_NO_MEMORY; } - wr2->generic.in.fnum = wr->writeunlock.in.fnum; - wr2->generic.in.offset = wr->writeunlock.in.offset; - wr2->generic.in.wmode = 0; - wr2->generic.in.remaining = wr->writeunlock.in.remaining; - wr2->generic.in.count = wr->writeunlock.in.count; - wr2->generic.in.data = wr->writeunlock.in.data; - lck->unlock.level = RAW_LOCK_UNLOCK; lck->unlock.in.fnum = wr->writeunlock.in.fnum; lck->unlock.in.count = wr->writeunlock.in.count; lck->unlock.in.offset = wr->writeunlock.in.offset; - status = ntvfs->ops->write(ntvfs, req, wr2); - - wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; - - if (NT_STATUS_IS_OK(status) && - lck->unlock.in.count != 0) { + if (lck->unlock.in.count != 0) { + /* do the lock sync for now */ + state = req->async_states->state; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->lock(ntvfs, req, lck); + req->async_states->state = state; } break; case RAW_WRITE_WRITECLOSE: + wr->writeclose.out.nwritten = wr2->generic.out.nwritten; + cl = talloc_p(wr2, union smb_close); if (cl == NULL) { return NT_STATUS_NO_MEMORY; } - wr2->generic.in.fnum = wr->writeclose.in.fnum; - wr2->generic.in.offset = wr->writeclose.in.offset; - wr2->generic.in.wmode = 0; - wr2->generic.in.remaining = 0; - wr2->generic.in.count = wr->writeclose.in.count; - wr2->generic.in.data = wr->writeclose.in.data; - cl->close.level = RAW_CLOSE_CLOSE; cl->close.in.fnum = wr->writeclose.in.fnum; cl->close.in.write_time = wr->writeclose.in.mtime; - status = ntvfs->ops->write(ntvfs, req, wr2); - wr->writeclose.out.nwritten = wr2->generic.out.nwritten; - - if (NT_STATUS_IS_OK(status) && - wr2->generic.in.count != 0) { + if (wr2->generic.in.count != 0) { + /* do the close sync for now */ + state = req->async_states->state; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->close(ntvfs, req, cl); + req->async_states->state = state; } break; case RAW_WRITE_SPLWRITE: - wr2->generic.in.fnum = wr->splwrite.in.fnum; - wr2->generic.in.offset = 0; - wr2->generic.in.wmode = 0; - wr2->generic.in.remaining = 0; - wr2->generic.in.count = wr->splwrite.in.count; - wr2->generic.in.data = wr->splwrite.in.data; + break; + default: + return NT_STATUS_INVALID_LEVEL; + } + + return status; +} + + +/* + NTVFS write generic to any mapper +*/ +NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, + struct ntvfs_module_context *ntvfs) +{ + union smb_write *wr2; + NTSTATUS status; + + wr2 = talloc_p(req, union smb_write); + if (wr2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = ntvfs_map_async_setup(req, ntvfs, wr, wr2, + (second_stage_t)ntvfs_map_write_finish); + + wr2->writex.level = RAW_WRITE_GENERIC; + + switch (wr->generic.level) { + case RAW_WRITE_WRITEX: + status = NT_STATUS_INVALID_LEVEL; + break; + + case RAW_WRITE_WRITE: + wr2->writex.in.fnum = wr->write.in.fnum; + wr2->writex.in.offset = wr->write.in.offset; + wr2->writex.in.wmode = 0; + wr2->writex.in.remaining = wr->write.in.remaining; + wr2->writex.in.count = wr->write.in.count; + wr2->writex.in.data = wr->write.in.data; + status = ntvfs->ops->write(ntvfs, req, wr2); + break; + + case RAW_WRITE_WRITEUNLOCK: + wr2->writex.in.fnum = wr->writeunlock.in.fnum; + wr2->writex.in.offset = wr->writeunlock.in.offset; + wr2->writex.in.wmode = 0; + wr2->writex.in.remaining = wr->writeunlock.in.remaining; + wr2->writex.in.count = wr->writeunlock.in.count; + wr2->writex.in.data = wr->writeunlock.in.data; + status = ntvfs->ops->write(ntvfs, req, wr2); + break; + + case RAW_WRITE_WRITECLOSE: + wr2->writex.in.fnum = wr->writeclose.in.fnum; + wr2->writex.in.offset = wr->writeclose.in.offset; + wr2->writex.in.wmode = 0; + wr2->writex.in.remaining = 0; + wr2->writex.in.count = wr->writeclose.in.count; + wr2->writex.in.data = wr->writeclose.in.data; + status = ntvfs->ops->write(ntvfs, req, wr2); + break; + + case RAW_WRITE_SPLWRITE: + wr2->writex.in.fnum = wr->splwrite.in.fnum; + wr2->writex.in.offset = 0; + wr2->writex.in.wmode = 0; + wr2->writex.in.remaining = 0; + wr2->writex.in.count = wr->splwrite.in.count; + wr2->writex.in.data = wr->splwrite.in.data; status = ntvfs->ops->write(ntvfs, req, wr2); break; } + return ntvfs_map_async_finish(req, status); +} + + +/* + NTVFS read generic to any mapper - finish the out mapping +*/ +static NTSTATUS ntvfs_map_read_finish(struct smbsrv_request *req, + struct ntvfs_module_context *ntvfs, + union smb_read *rd, + union smb_read *rd2, + NTSTATUS status) +{ + switch (rd->generic.level) { + case RAW_READ_READ: + rd->read.out.nread = rd2->generic.out.nread; + break; + case RAW_READ_READBRAW: + rd->readbraw.out.nread = rd2->generic.out.nread; + break; + case RAW_READ_LOCKREAD: + rd->lockread.out.nread = rd2->generic.out.nread; + break; + default: + return NT_STATUS_INVALID_LEVEL; + } return status; } - /* - NTVFS read generic to any mapper + NTVFS read* to readx mapper */ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, struct ntvfs_module_context *ntvfs) @@ -880,16 +1030,20 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, union smb_read *rd2; union smb_lock *lck; NTSTATUS status; + uint_t state; rd2 = talloc_p(req, union smb_read); if (rd2 == NULL) { return NT_STATUS_NO_MEMORY; } - rd2->generic.level = RAW_READ_GENERIC; + status = ntvfs_map_async_setup(req, ntvfs, rd, rd2, + (second_stage_t)ntvfs_map_read_finish); + if (!NT_STATUS_IS_OK(status)) { + return status; + } - /* we can't map asynchronously */ - req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + rd2->readx.level = RAW_READ_READX; switch (rd->generic.level) { case RAW_READ_READX: @@ -897,56 +1051,55 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, break; case RAW_READ_READ: - rd2->generic.in.fnum = rd->read.in.fnum; - rd2->generic.in.offset = rd->read.in.offset; - rd2->generic.in.mincnt = rd->read.in.count; - rd2->generic.in.maxcnt = rd->read.in.count; - rd2->generic.in.remaining = rd->read.in.remaining; - rd2->generic.out.data = rd->read.out.data; + rd2->readx.in.fnum = rd->read.in.fnum; + rd2->readx.in.offset = rd->read.in.offset; + rd2->readx.in.mincnt = rd->read.in.count; + rd2->readx.in.maxcnt = rd->read.in.count; + rd2->readx.in.remaining = rd->read.in.remaining; + rd2->readx.out.data = rd->read.out.data; status = ntvfs->ops->read(ntvfs, req, rd2); - rd->read.out.nread = rd2->generic.out.nread; break; case RAW_READ_READBRAW: - rd2->generic.in.fnum = rd->readbraw.in.fnum; - rd2->generic.in.offset = rd->readbraw.in.offset; - rd2->generic.in.mincnt = rd->readbraw.in.mincnt; - rd2->generic.in.maxcnt = rd->readbraw.in.maxcnt; - rd2->generic.in.remaining = 0; - rd2->generic.out.data = rd->readbraw.out.data; + rd2->readx.in.fnum = rd->readbraw.in.fnum; + rd2->readx.in.offset = rd->readbraw.in.offset; + rd2->readx.in.mincnt = rd->readbraw.in.mincnt; + rd2->readx.in.maxcnt = rd->readbraw.in.maxcnt; + rd2->readx.in.remaining = 0; + rd2->readx.out.data = rd->readbraw.out.data; status = ntvfs->ops->read(ntvfs, req, rd2); - rd->readbraw.out.nread = rd2->generic.out.nread; break; case RAW_READ_LOCKREAD: + /* do the initial lock sync for now */ + state = req->async_states->state; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + lck = talloc_p(rd2, union smb_lock); if (lck == NULL) { return NT_STATUS_NO_MEMORY; } - - rd2->generic.in.fnum = rd->lockread.in.fnum; - rd2->generic.in.offset = rd->lockread.in.offset; - rd2->generic.in.mincnt = rd->lockread.in.count; - rd2->generic.in.maxcnt = rd->lockread.in.count; - rd2->generic.in.remaining = rd->lockread.in.remaining; - rd2->generic.out.data = rd->lockread.out.data; - lck->lock.level = RAW_LOCK_LOCK; lck->lock.in.fnum = rd->lockread.in.fnum; lck->lock.in.count = rd->lockread.in.count; lck->lock.in.offset = rd->lockread.in.offset; - status = ntvfs->ops->lock(ntvfs, req, lck); + req->async_states->state = state; + + rd2->readx.in.fnum = rd->lockread.in.fnum; + rd2->readx.in.offset = rd->lockread.in.offset; + rd2->readx.in.mincnt = rd->lockread.in.count; + rd2->readx.in.maxcnt = rd->lockread.in.count; + rd2->readx.in.remaining = rd->lockread.in.remaining; + rd2->readx.out.data = rd->lockread.out.data; if (NT_STATUS_IS_OK(status)) { status = ntvfs->ops->read(ntvfs, req, rd2); - rd->lockread.out.nread = rd2->generic.out.nread; } break; } - - return status; + return ntvfs_map_async_finish(req, status); } -- cgit From c870ae8b898d3bcc81ed9fd1afd505d78dea52cc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Nov 2004 11:28:38 +0000 Subject: r3528: added support for the SMBntcancel() operation, which cancels any outstanding async operation (triggering an immediate timeout). pvfs now passes the RAW-MUX test (This used to be commit 3423e2f41461d054067ef168b9b986f62cc8f77c) --- source4/ntvfs/ntvfs_generic.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 01a1a2dc60..885eb9719e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -942,6 +942,9 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, status = ntvfs_map_async_setup(req, ntvfs, wr, wr2, (second_stage_t)ntvfs_map_write_finish); + if (!NT_STATUS_IS_OK(status)) { + return status; + } wr2->writex.level = RAW_WRITE_GENERIC; -- cgit From 8fa7f264c62eca51868307796cdfd2dcc0abceff Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Nov 2004 12:12:09 +0000 Subject: r3530: make sure we match ntvfs_async_state_pop() with ntvfs_async_state_push() (This used to be commit 730ae0600e6c75a7048f7aaf3995604e8cdbba39) --- source4/ntvfs/ntvfs_generic.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 885eb9719e..274d5caa87 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -247,7 +247,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io->openx.out.access = OPENX_MODE_ACCESS_RDWR; break; default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; + status = NT_STATUS_INVALID_LOCK_SEQUENCE; + goto done; } switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { @@ -280,7 +281,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; + status = NT_STATUS_INVALID_LOCK_SEQUENCE; + goto done; } switch (io->openx.in.open_func) { @@ -306,7 +308,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; break; } - return NT_STATUS_INVALID_LOCK_SEQUENCE; + status = NT_STATUS_INVALID_LOCK_SEQUENCE; + goto done; } io2->generic.in.alloc_size = 0; @@ -339,7 +342,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, default: DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", io->openold.in.flags & OPEN_FLAGS_MODE_MASK)); - return NT_STATUS_INVALID_PARAMETER; + status = NT_STATUS_INVALID_PARAMETER; + goto done; } switch (io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { @@ -375,16 +379,19 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, default: DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", io->openold.in.flags & OPEN_FLAGS_DENY_MASK)); - return NT_STATUS_INVALID_PARAMETER; + status = NT_STATUS_INVALID_PARAMETER; + goto done; } status = ntvfs->ops->openfile(ntvfs, req, io2); break; default: - return NT_STATUS_INVALID_LEVEL; + status = NT_STATUS_INVALID_LEVEL; + break; } +done: return ntvfs_map_async_finish(req, status); } @@ -1080,7 +1087,8 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, lck = talloc_p(rd2, union smb_lock); if (lck == NULL) { - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto done; } lck->lock.level = RAW_LOCK_LOCK; lck->lock.in.fnum = rd->lockread.in.fnum; @@ -1102,6 +1110,7 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, break; } +done: return ntvfs_map_async_finish(req, status); } -- cgit From 39cd0639e9007bfd8b896b335aea50ace8631112 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Nov 2004 13:15:22 +0000 Subject: r3531: add support for RAW_OPEN_MKNEW, RAW_OPEN_CREATE and RAW_OPEN_CTEMP in pvfs (This used to be commit 1d2f0a55c1de01cbbf6552371584847223841bc3) --- source4/ntvfs/ntvfs_generic.c | 109 +++++++++++++++++++++++++++++++++++------- 1 file changed, 91 insertions(+), 18 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 274d5caa87..ed41b3d4d2 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -144,6 +144,11 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, union smb_open *io2, NTSTATUS status) { + time_t write_time = 0; + uint32_t set_size = 0; + union smb_setfileinfo *sf; + uint_t state; + if (!NT_STATUS_IS_OK(status)) { return status; } @@ -171,32 +176,56 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, /* we need to extend the file to the requested size if it was newly created */ - if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED && - io->openx.in.size != 0) { - union smb_setfileinfo *sf; - uint_t state; + if (io2->generic.out.create_action == NTCREATEX_ACTION_CREATED) { + set_size = io->openx.in.size; + } + break; - /* doing this secondary request async is more - trouble than its worth */ - state = req->async_states->state; - req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + case RAW_OPEN_MKNEW: + case RAW_OPEN_CREATE: + io->mknew.out.fnum = io2->generic.out.fnum; + write_time = io->mknew.in.write_time; + break; - sf = talloc_p(req, union smb_setfileinfo); - sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.file.fnum = io2->generic.out.fnum; - sf->end_of_file_info.in.size = io->openx.in.size; - status = ntvfs->ops->setfileinfo(ntvfs, req, sf); - if (NT_STATUS_IS_OK(status)) { - io->openx.out.size = io->openx.in.size; - } - req->async_states->state = state; - } + case RAW_OPEN_CTEMP: + io->ctemp.out.fnum = io2->generic.out.fnum; + io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + + strlen(io->ctemp.in.directory) + 1); + write_time = io->ctemp.in.write_time; break; default: return NT_STATUS_INVALID_LEVEL; } + /* doing a secondary request async is more trouble than its + worth */ + state = req->async_states->state; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + + if (write_time != 0) { + sf = talloc_p(req, union smb_setfileinfo); + sf->generic.level = RAW_SFILEINFO_STANDARD; + sf->generic.file.fnum = io2->generic.out.fnum; + sf->standard.in.create_time = 0; + sf->standard.in.write_time = write_time; + sf->standard.in.access_time = 0; + status = ntvfs->ops->setfileinfo(ntvfs, req, sf); + } + + if (set_size != 0) { + sf = talloc_p(req, union smb_setfileinfo); + sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sf->generic.file.fnum = io2->generic.out.fnum; + sf->end_of_file_info.in.size = io->openx.in.size; + status = ntvfs->ops->setfileinfo(ntvfs, req, sf); + if (NT_STATUS_IS_OK(status)) { + io->openx.out.size = io->openx.in.size; + } + } + + req->async_states->state = state; + return NT_STATUS_OK; } @@ -386,6 +415,50 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, status = ntvfs->ops->openfile(ntvfs, req, io2); break; + + case RAW_OPEN_MKNEW: + io2->generic.in.file_attr = io->mknew.in.attrib; + io2->generic.in.fname = io->mknew.in.fname; + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + io2->generic.in.access_mask = + GENERIC_RIGHTS_FILE_READ | + GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; + + case RAW_OPEN_CREATE: + io2->generic.in.file_attr = io->mknew.in.attrib; + io2->generic.in.fname = io->mknew.in.fname; + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io2->generic.in.access_mask = + GENERIC_RIGHTS_FILE_READ | + GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; + + case RAW_OPEN_CTEMP: + io2->generic.in.file_attr = io->ctemp.in.attrib; + io2->generic.in.file_attr = 0; + io2->generic.in.fname = + talloc_asprintf(io2, "%s\\SRV%s", + io->ctemp.in.directory, + generate_random_str_list(io2, 5, "0123456789")); + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + io2->generic.in.access_mask = + GENERIC_RIGHTS_FILE_READ | + GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; + default: status = NT_STATUS_INVALID_LEVEL; break; -- cgit From 439c1524fba3b58abe9e353f9ff2bd7f103f3d12 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 6 Nov 2004 07:58:45 +0000 Subject: r3573: added trans2open support to smbd and pvfs, and fine-tuned the open->generic ntvfs mapping code. (This used to be commit ed844192d7f7ed487290f719df65f256a5b0b9bc) --- source4/ntvfs/ntvfs_generic.c | 49 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index ed41b3d4d2..370463c41d 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -149,6 +149,13 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, union smb_setfileinfo *sf; uint_t state; + /* this is really strange, but matches w2k3 */ + if (io->generic.level == RAW_OPEN_T2OPEN && + io->t2open.in.open_func != OPENX_OPEN_FUNC_OPEN && + NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + return NT_STATUS_ACCESS_DENIED; + } + if (!NT_STATUS_IS_OK(status)) { return status; } @@ -159,7 +166,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->openold.out.attrib = io2->generic.out.attrib; io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openold.out.size = io2->generic.out.size; - io->openold.out.rmode = DOS_OPEN_RDWR; + io->openold.out.rmode = io->openold.in.flags; break; case RAW_OPEN_OPENX: @@ -181,6 +188,18 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, } break; + case RAW_OPEN_T2OPEN: + io->t2open.out.fnum = io2->openx.out.fnum; + io->t2open.out.attrib = io2->openx.out.attrib; + io->t2open.out.write_time = 0; + io->t2open.out.size = io2->openx.out.size; + io->t2open.out.access = io->t2open.in.open_mode; + io->t2open.out.ftype = io2->openx.out.ftype; + io->t2open.out.devstate = io2->openx.out.devstate; + io->t2open.out.action = io2->openx.out.action; + io->t2open.out.unknown = 0; + break; + case RAW_OPEN_MKNEW: case RAW_OPEN_CREATE: io->mknew.out.fnum = io2->generic.out.fnum; @@ -191,7 +210,6 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->ctemp.out.fnum = io2->generic.out.fnum; io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + strlen(io->ctemp.in.directory) + 1); - write_time = io->ctemp.in.write_time; break; default: @@ -217,7 +235,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, sf = talloc_p(req, union smb_setfileinfo); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; sf->generic.file.fnum = io2->generic.out.fnum; - sf->end_of_file_info.in.size = io->openx.in.size; + sf->end_of_file_info.in.size = set_size; status = ntvfs->ops->setfileinfo(ntvfs, req, sf); if (NT_STATUS_IS_OK(status)) { io->openx.out.size = io->openx.in.size; @@ -262,17 +280,17 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = STANDARD_RIGHTS_READ_ACCESS; io->openx.out.access = OPENX_MODE_ACCESS_READ; break; case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = STANDARD_RIGHTS_WRITE_ACCESS; io->openx.out.access = OPENX_MODE_ACCESS_WRITE; break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = STANDARD_RIGHTS_ALL_ACCESS; io->openx.out.access = OPENX_MODE_ACCESS_RDWR; break; default: @@ -402,8 +420,10 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; break; - case 0x70: /* FCB mode */ - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + case OPEN_FLAGS_DENY_MASK: + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; break; default: DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", @@ -415,6 +435,19 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, status = ntvfs->ops->openfile(ntvfs, req, io2); break; + case RAW_OPEN_T2OPEN: + io2->generic.level = RAW_OPEN_OPENX; + io2->openx.in.flags = io->t2open.in.flags; + io2->openx.in.open_mode = io->t2open.in.open_mode; + io2->openx.in.search_attrs = 0; + io2->openx.in.file_attrs = io->t2open.in.file_attrs; + io2->openx.in.write_time = io->t2open.in.write_time; + io2->openx.in.open_func = OPENX_OPEN_FUNC_OPEN; + io2->openx.in.size = io->t2open.in.size; + io2->openx.in.timeout = io->t2open.in.timeout; + io2->openx.in.fname = io->t2open.in.fname; + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; case RAW_OPEN_MKNEW: io2->generic.in.file_attr = io->mknew.in.attrib; -- cgit From a9158e0d47636e25ce374391cd9b02df3d27b390 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 6 Nov 2004 09:12:53 +0000 Subject: r3574: the RAW-OPEN test changes broke a couple of the other tests. This fixes most of them, although RAW-SEARCH still fails (due to an interaction with the new xattr code) (This used to be commit 09b4652b40c4cfca027765178bd5a0adbaa666c2) --- source4/ntvfs/ntvfs_generic.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 370463c41d..9ef2481d26 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -178,7 +178,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->openx.out.devstate = 0; io->openx.out.action = io2->generic.out.create_action; io->openx.out.unique_fid = 0; - io->openx.out.access_mask = io2->generic.in.access_mask; + io->openx.out.access_mask = STANDARD_RIGHTS_ALL_ACCESS; io->openx.out.unknown = 0; /* we need to extend the file to the requested size if @@ -280,17 +280,17 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = STANDARD_RIGHTS_READ_ACCESS; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; io->openx.out.access = OPENX_MODE_ACCESS_READ; break; case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = STANDARD_RIGHTS_WRITE_ACCESS; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; io->openx.out.access = OPENX_MODE_ACCESS_WRITE; break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = STANDARD_RIGHTS_ALL_ACCESS; + io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE | GENERIC_RIGHTS_FILE_READ; io->openx.out.access = OPENX_MODE_ACCESS_RDWR; break; default: @@ -309,12 +309,16 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; case OPENX_MODE_DENY_NONE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; break; case OPENX_MODE_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ if (is_exe_file(io->openx.in.fname)) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; } else { if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == OPENX_MODE_ACCESS_READ) { @@ -417,8 +421,9 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; break; case OPEN_FLAGS_DENY_NONE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE | - NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_DELETE; + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_READ; break; case OPEN_FLAGS_DENY_MASK: io2->generic.in.share_access = -- cgit From c077300a22806bab94d11a87c8ef96b6b541ada5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 8 Nov 2004 11:35:49 +0000 Subject: r3618: - this adds the special case for DENY_DOS semantics, as shown by the BASE-DENYDOS test. - pvfs now passes BASE-DENY1 and BASE-DENYDOS. (This used to be commit aa09df22ee729c02552638859236d9068e9748ae) --- source4/ntvfs/ntvfs_generic.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 9ef2481d26..a9bc8120c8 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -117,7 +117,7 @@ static NTSTATUS ntvfs_map_async_finish(struct smbsrv_request *req, NTSTATUS stat see if a filename ends in EXE COM DLL or SYM. This is needed for the DENY_DOS mapping for OpenX */ -static BOOL is_exe_file(const char *fname) +BOOL is_exe_filename(const char *fname) { char *p; p = strrchr(fname, '.'); @@ -315,7 +315,9 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, break; case OPENX_MODE_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_file(io->openx.in.fname)) { + io2->generic.in.create_options |= + NTCREATEX_OPTIONS_PRIVATE_DENY_DOS; + if (is_exe_filename(io->openx.in.fname)) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; @@ -329,6 +331,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, } break; case OPENX_MODE_DENY_FCB: + io2->generic.in.create_options |= + NTCREATEX_OPTIONS_PRIVATE_DENY_FCB; io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; default: @@ -400,7 +404,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { case OPEN_FLAGS_DENY_DOS: /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_file(io->openold.in.fname)) { + if (is_exe_filename(io->openold.in.fname)) { io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; } else { if ((io->openold.in.flags & OPEN_FLAGS_MODE_MASK) == -- cgit From fdc9f417d89fdf9dd6afbc22843d70585e195c9d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 Nov 2004 04:33:27 +0000 Subject: r4011: get rid of rpc_secdes.h and replace it with a single sane set of definitions for security access masks, in security.idl The previous definitions were inconsistently named, and contained many duplicate and misleading entries. I kept finding myself tripping up while using them. (This used to be commit 01c0fa722f80ceeb3f81f01987de95f365a2ed3d) --- source4/ntvfs/ntvfs_generic.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index a9bc8120c8..49de8944ff 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -33,6 +33,7 @@ #include "includes.h" #include "smb_server/smb_server.h" +#include "librpc/gen_ndr/ndr_security.h" /* a second stage function converts from the out parameters of the generic call onto the out parameters of the specific call made */ @@ -178,7 +179,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->openx.out.devstate = 0; io->openx.out.action = io2->generic.out.create_action; io->openx.out.unique_fid = 0; - io->openx.out.access_mask = STANDARD_RIGHTS_ALL_ACCESS; + io->openx.out.access_mask = SEC_STD_ALL; io->openx.out.unknown = 0; /* we need to extend the file to the requested size if @@ -280,17 +281,19 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; io->openx.out.access = OPENX_MODE_ACCESS_READ; break; case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = SEC_RIGHTS_FILE_WRITE; io->openx.out.access = OPENX_MODE_ACCESS_WRITE; break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE | GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = + SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; io->openx.out.access = OPENX_MODE_ACCESS_RDWR; break; default: @@ -381,17 +384,17 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; switch (io->openold.in.flags & OPEN_FLAGS_MODE_MASK) { case OPEN_FLAGS_OPEN_READ: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ; + io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; io->openold.out.rmode = DOS_OPEN_RDONLY; break; case OPEN_FLAGS_OPEN_WRITE: - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = SEC_RIGHTS_FILE_WRITE; io->openold.out.rmode = DOS_OPEN_WRONLY; break; case OPEN_FLAGS_OPEN_RDWR: case 0xf: /* FCB mode */ - io2->generic.in.access_mask = GENERIC_RIGHTS_FILE_READ | - GENERIC_RIGHTS_FILE_WRITE; + io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; io->openold.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ break; default: @@ -463,8 +466,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.fname = io->mknew.in.fname; io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; io2->generic.in.access_mask = - GENERIC_RIGHTS_FILE_READ | - GENERIC_RIGHTS_FILE_WRITE; + SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; @@ -476,8 +479,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.fname = io->mknew.in.fname; io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; io2->generic.in.access_mask = - GENERIC_RIGHTS_FILE_READ | - GENERIC_RIGHTS_FILE_WRITE; + SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; @@ -493,8 +496,8 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, generate_random_str_list(io2, 5, "0123456789")); io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; io2->generic.in.access_mask = - GENERIC_RIGHTS_FILE_READ | - GENERIC_RIGHTS_FILE_WRITE; + SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; -- cgit From fbd8c61ff7a7c41d16c400ddb87ad290f4af167d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 2004 10:48:21 +0000 Subject: r4173: - new t2open code, that can cope with "create with EAs". Many thanks to kukks on #samba-technical for the sniffs that allowed me to work this out - much simpler ntvfs open generic mapping code - added t2open create with EA torture test to RAW-OPEN test (This used to be commit a56d95ad89b4f32a05974c4fe9a816d67aa369e3) --- source4/ntvfs/ntvfs_generic.c | 332 +++++++++++++++++++----------------------- 1 file changed, 147 insertions(+), 185 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 49de8944ff..407bd38f74 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -150,13 +150,6 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, union smb_setfileinfo *sf; uint_t state; - /* this is really strange, but matches w2k3 */ - if (io->generic.level == RAW_OPEN_T2OPEN && - io->t2open.in.open_func != OPENX_OPEN_FUNC_OPEN && - NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - return NT_STATUS_ACCESS_DENIED; - } - if (!NT_STATUS_IS_OK(status)) { return status; } @@ -167,7 +160,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->openold.out.attrib = io2->generic.out.attrib; io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openold.out.size = io2->generic.out.size; - io->openold.out.rmode = io->openold.in.flags; + io->openold.out.rmode = io->openold.in.open_mode; break; case RAW_OPEN_OPENX: @@ -175,6 +168,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->openx.out.attrib = io2->generic.out.attrib; io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openx.out.size = io2->generic.out.size; + io->openx.out.access = (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK); io->openx.out.ftype = 0; io->openx.out.devstate = 0; io->openx.out.action = io2->generic.out.create_action; @@ -190,15 +184,15 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, break; case RAW_OPEN_T2OPEN: - io->t2open.out.fnum = io2->openx.out.fnum; - io->t2open.out.attrib = io2->openx.out.attrib; - io->t2open.out.write_time = 0; - io->t2open.out.size = io2->openx.out.size; - io->t2open.out.access = io->t2open.in.open_mode; - io->t2open.out.ftype = io2->openx.out.ftype; - io->t2open.out.devstate = io2->openx.out.devstate; - io->t2open.out.action = io2->openx.out.action; - io->t2open.out.unknown = 0; + io->t2open.out.fnum = io2->generic.out.fnum; + io->t2open.out.attrib = io2->generic.out.attrib; + io->t2open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); + io->t2open.out.size = io2->generic.out.size; + io->t2open.out.access = io->t2open.in.open_mode; + io->t2open.out.ftype = 0; + io->t2open.out.devstate = 0; + io->t2open.out.action = io2->generic.out.create_action; + io->t2open.out.file_id = 0; break; case RAW_OPEN_MKNEW: @@ -248,6 +242,106 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, return NT_STATUS_OK; } +/* + the core of the mapping between openx style parameters and ntcreatex + parameters +*/ +static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, + uint16_t open_func, const char *fname, + union smb_open *io2) +{ + if (flags & OPENX_FLAGS_REQUEST_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; + } + if (flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { + io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + } + + switch (open_mode & OPENX_MODE_ACCESS_MASK) { + case OPENX_MODE_ACCESS_READ: + io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; + break; + case OPENX_MODE_ACCESS_WRITE: + io2->generic.in.access_mask = SEC_RIGHTS_FILE_WRITE; + break; + case OPENX_MODE_ACCESS_RDWR: + case OPENX_MODE_ACCESS_FCB: + case OPENX_MODE_ACCESS_EXEC: + io2->generic.in.access_mask = + SEC_RIGHTS_FILE_READ | + SEC_RIGHTS_FILE_WRITE; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (open_mode & OPENX_MODE_DENY_MASK) { + case OPENX_MODE_DENY_READ: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_WRITE: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + break; + case OPENX_MODE_DENY_ALL: + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + case OPENX_MODE_DENY_NONE: + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; + break; + case OPENX_MODE_DENY_DOS: + /* DENY_DOS is quite strange - it depends on the filename! */ + io2->generic.in.create_options |= + NTCREATEX_OPTIONS_PRIVATE_DENY_DOS; + if (is_exe_filename(fname)) { + io2->generic.in.share_access = + NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE; + } else { + if ((open_mode & OPENX_MODE_ACCESS_MASK) == OPENX_MODE_ACCESS_READ) { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; + } else { + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + } + } + break; + case OPENX_MODE_DENY_FCB: + io2->generic.in.create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB; + io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + break; + default: + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + switch (open_func) { + case (OPENX_OPEN_FUNC_OPEN): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; + break; + case (OPENX_OPEN_FUNC_TRUNC): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; + break; + case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + break; + case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): + io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + break; + default: + /* this one is very strange */ + if ((open_mode & OPENX_MODE_ACCESS_MASK) == OPENX_MODE_ACCESS_EXEC) { + io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; + break; + } + return NT_STATUS_INVALID_LOCK_SEQUENCE; + } + + return NT_STATUS_OK; +} + /* NTVFS open generic to any mapper */ @@ -272,105 +366,15 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, switch (io->generic.level) { case RAW_OPEN_OPENX: - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK; - } - if (io->openx.in.flags & OPENX_FLAGS_REQUEST_BATCH_OPLOCK) { - io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; - } - - switch (io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) { - case OPENX_MODE_ACCESS_READ: - io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; - io->openx.out.access = OPENX_MODE_ACCESS_READ; - break; - case OPENX_MODE_ACCESS_WRITE: - io2->generic.in.access_mask = SEC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_WRITE; - break; - case OPENX_MODE_ACCESS_RDWR: - case OPENX_MODE_ACCESS_FCB: - case OPENX_MODE_ACCESS_EXEC: - io2->generic.in.access_mask = - SEC_RIGHTS_FILE_READ | - SEC_RIGHTS_FILE_WRITE; - io->openx.out.access = OPENX_MODE_ACCESS_RDWR; - break; - default: - status = NT_STATUS_INVALID_LOCK_SEQUENCE; - goto done; - } - - switch (io->openx.in.open_mode & OPENX_MODE_DENY_MASK) { - case OPENX_MODE_DENY_READ: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_WRITE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - break; - case OPENX_MODE_DENY_ALL: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - case OPENX_MODE_DENY_NONE: - io2->generic.in.share_access = - NTCREATEX_SHARE_ACCESS_READ | - NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPENX_MODE_DENY_DOS: - /* DENY_DOS is quite strange - it depends on the filename! */ - io2->generic.in.create_options |= - NTCREATEX_OPTIONS_PRIVATE_DENY_DOS; - if (is_exe_filename(io->openx.in.fname)) { - io2->generic.in.share_access = - NTCREATEX_SHARE_ACCESS_READ | - NTCREATEX_SHARE_ACCESS_WRITE; - } else { - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_READ) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - } else { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - } - } - break; - case OPENX_MODE_DENY_FCB: - io2->generic.in.create_options |= - NTCREATEX_OPTIONS_PRIVATE_DENY_FCB; - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - default: - status = NT_STATUS_INVALID_LOCK_SEQUENCE; - goto done; - } - - switch (io->openx.in.open_func) { - case (OPENX_OPEN_FUNC_OPEN): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; - break; - case (OPENX_OPEN_FUNC_TRUNC): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE; - break; - case (OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - case (OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN_IF; - break; - case (OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE): - io2->generic.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; - break; - default: - /* this one is very strange */ - if ((io->openx.in.open_mode & OPENX_MODE_ACCESS_MASK) == - OPENX_MODE_ACCESS_EXEC) { - io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; - break; - } - status = NT_STATUS_INVALID_LOCK_SEQUENCE; + status = map_openx_open(io->openx.in.flags, + io->openx.in.open_mode, + io->openx.in.open_func, + io->openx.in.fname, + io2); + if (!NT_STATUS_IS_OK(status)) { goto done; } - io2->generic.in.alloc_size = 0; io2->generic.in.file_attr = io->openx.in.file_attrs; io2->generic.in.fname = io->openx.in.fname; @@ -379,85 +383,44 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, case RAW_OPEN_OPEN: + status = map_openx_open(0, + io->openold.in.open_mode, + OPENX_OPEN_FUNC_OPEN, + io->openold.in.fname, + io2); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + io2->generic.in.file_attr = io->openold.in.search_attrs; io2->generic.in.fname = io->openold.in.fname; - io2->generic.in.open_disposition = NTCREATEX_DISP_OPEN; - switch (io->openold.in.flags & OPEN_FLAGS_MODE_MASK) { - case OPEN_FLAGS_OPEN_READ: - io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; - io->openold.out.rmode = DOS_OPEN_RDONLY; - break; - case OPEN_FLAGS_OPEN_WRITE: - io2->generic.in.access_mask = SEC_RIGHTS_FILE_WRITE; - io->openold.out.rmode = DOS_OPEN_WRONLY; - break; - case OPEN_FLAGS_OPEN_RDWR: - case 0xf: /* FCB mode */ - io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ | - SEC_RIGHTS_FILE_WRITE; - io->openold.out.rmode = DOS_OPEN_RDWR; /* assume we got r/w */ - break; - default: - DEBUG(2,("ntvfs_map_open(OPEN): invalid mode 0x%x\n", - io->openold.in.flags & OPEN_FLAGS_MODE_MASK)); - status = NT_STATUS_INVALID_PARAMETER; + + status = ntvfs->ops->openfile(ntvfs, req, io2); + break; + + case RAW_OPEN_T2OPEN: + io2->generic.level = RAW_OPEN_NTTRANS_CREATE; + + if (io->t2open.in.open_func == 0) { + status = NT_STATUS_OBJECT_NAME_COLLISION; goto done; } - - switch (io->openold.in.flags & OPEN_FLAGS_DENY_MASK) { - case OPEN_FLAGS_DENY_DOS: - /* DENY_DOS is quite strange - it depends on the filename! */ - if (is_exe_filename(io->openold.in.fname)) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - } else { - if ((io->openold.in.flags & OPEN_FLAGS_MODE_MASK) == - OPEN_FLAGS_OPEN_READ) { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - } else { - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - } - } - break; - case OPEN_FLAGS_DENY_ALL: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; - break; - case OPEN_FLAGS_DENY_WRITE: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ; - break; - case OPEN_FLAGS_DENY_READ: - io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_WRITE; - break; - case OPEN_FLAGS_DENY_NONE: - io2->generic.in.share_access = - NTCREATEX_SHARE_ACCESS_WRITE | - NTCREATEX_SHARE_ACCESS_READ; - break; - case OPEN_FLAGS_DENY_MASK: - io2->generic.in.share_access = - NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE; - break; - default: - DEBUG(2,("ntvfs_map_open(OPEN): invalid DENY 0x%x\n", - io->openold.in.flags & OPEN_FLAGS_DENY_MASK)); - status = NT_STATUS_INVALID_PARAMETER; + + status = map_openx_open(io->t2open.in.flags, + io->t2open.in.open_mode, + io->t2open.in.open_func, + io->t2open.in.fname, + io2); + if (!NT_STATUS_IS_OK(status)) { goto done; } - status = ntvfs->ops->openfile(ntvfs, req, io2); - break; + io2->generic.in.file_attr = io->t2open.in.file_attrs; + io2->generic.in.fname = io->t2open.in.fname; + io2->generic.in.ea_list = talloc_p(io2, struct smb_ea_list); + io2->generic.in.ea_list->num_eas = io->t2open.in.num_eas; + io2->generic.in.ea_list->eas = io->t2open.in.eas; - case RAW_OPEN_T2OPEN: - io2->generic.level = RAW_OPEN_OPENX; - io2->openx.in.flags = io->t2open.in.flags; - io2->openx.in.open_mode = io->t2open.in.open_mode; - io2->openx.in.search_attrs = 0; - io2->openx.in.file_attrs = io->t2open.in.file_attrs; - io2->openx.in.write_time = io->t2open.in.write_time; - io2->openx.in.open_func = OPENX_OPEN_FUNC_OPEN; - io2->openx.in.size = io->t2open.in.size; - io2->openx.in.timeout = io->t2open.in.timeout; - io2->openx.in.fname = io->t2open.in.fname; status = ntvfs->ops->openfile(ntvfs, req, io2); break; @@ -508,7 +471,6 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, status = NT_STATUS_INVALID_LEVEL; break; } - done: return ntvfs_map_async_finish(req, status); } -- cgit From ddc10d4d37984246a6547e34a32d629c689c40d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:06:58 +0000 Subject: r4549: got rid of a lot more uses of plain talloc(), instead using talloc_size() or talloc_array_p() where appropriate. also fixed a memory leak in pvfs_copy_file() (failed to free a memory context) (This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503) --- source4/ntvfs/ntvfs_generic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 407bd38f74..051e92b19c 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -713,8 +713,10 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_STREAM_INFORMATION: info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { - info->stream_info.out.streams = talloc(req, - info->stream_info.out.num_streams * sizeof(struct stream_struct)); + info->stream_info.out.streams = + talloc_array_p(req, + struct stream_struct, + info->stream_info.out.num_streams); if (!info->stream_info.out.streams) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", info->stream_info.out.num_streams)); @@ -751,8 +753,9 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc(req, - info->all_eas.out.num_eas * sizeof(struct ea_struct)); + info->all_eas.out.eas = talloc_array_p(req, + struct ea_struct, + info->all_eas.out.num_eas); if (!info->all_eas.out.eas) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", info->all_eas.out.num_eas)); -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/ntvfs/ntvfs_generic.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 051e92b19c..9b6c75e5c6 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -79,7 +79,7 @@ static NTSTATUS ntvfs_map_async_setup(struct smbsrv_request *req, second_stage_t fn) { struct ntvfs_map_async *m; - m = talloc_p(req, struct ntvfs_map_async); + m = talloc(req, struct ntvfs_map_async); if (m == NULL) { return NT_STATUS_NO_MEMORY; } @@ -217,7 +217,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; if (write_time != 0) { - sf = talloc_p(req, union smb_setfileinfo); + sf = talloc(req, union smb_setfileinfo); sf->generic.level = RAW_SFILEINFO_STANDARD; sf->generic.file.fnum = io2->generic.out.fnum; sf->standard.in.create_time = 0; @@ -227,7 +227,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, } if (set_size != 0) { - sf = talloc_p(req, union smb_setfileinfo); + sf = talloc(req, union smb_setfileinfo); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; sf->generic.file.fnum = io2->generic.out.fnum; sf->end_of_file_info.in.size = set_size; @@ -351,7 +351,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, NTSTATUS status; union smb_open *io2; - io2 = talloc_zero_p(req, union smb_open); + io2 = talloc_zero(req, union smb_open); if (io2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -417,7 +417,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.file_attr = io->t2open.in.file_attrs; io2->generic.in.fname = io->t2open.in.fname; - io2->generic.in.ea_list = talloc_p(io2, struct smb_ea_list); + io2->generic.in.ea_list = talloc(io2, struct smb_ea_list); io2->generic.in.ea_list->num_eas = io->t2open.in.num_eas; io2->generic.in.ea_list->eas = io->t2open.in.eas; @@ -485,7 +485,7 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, NTSTATUS status; union smb_fsinfo *fs2; - fs2 = talloc_p(req, union smb_fsinfo); + fs2 = talloc(req, union smb_fsinfo); if (fs2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -714,7 +714,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { info->stream_info.out.streams = - talloc_array_p(req, + talloc_array(req, struct stream_struct, info->stream_info.out.num_streams); if (!info->stream_info.out.streams) { @@ -753,7 +753,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc_array_p(req, + info->all_eas.out.eas = talloc_array(req, struct ea_struct, info->all_eas.out.num_eas); if (!info->all_eas.out.eas) { @@ -840,7 +840,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf NTSTATUS status; union smb_fileinfo *info2; - info2 = talloc_p(req, union smb_fileinfo); + info2 = talloc(req, union smb_fileinfo); if (info2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -869,7 +869,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf NTSTATUS status; union smb_fileinfo *info2; - info2 = talloc_p(req, union smb_fileinfo); + info2 = talloc(req, union smb_fileinfo); if (info2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -902,12 +902,12 @@ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, union smb_lock *lck2; struct smb_lock_entry *locks; - lck2 = talloc_p(req, union smb_lock); + lck2 = talloc(req, union smb_lock); if (lck2 == NULL) { return NT_STATUS_NO_MEMORY; } - locks = talloc_array_p(lck2, struct smb_lock_entry, 1); + locks = talloc_array(lck2, struct smb_lock_entry, 1); if (locks == NULL) { return NT_STATUS_NO_MEMORY; } @@ -966,7 +966,7 @@ static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, case RAW_WRITE_WRITEUNLOCK: wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; - lck = talloc_p(wr2, union smb_lock); + lck = talloc(wr2, union smb_lock); if (lck == NULL) { return NT_STATUS_NO_MEMORY; } @@ -988,7 +988,7 @@ static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, case RAW_WRITE_WRITECLOSE: wr->writeclose.out.nwritten = wr2->generic.out.nwritten; - cl = talloc_p(wr2, union smb_close); + cl = talloc(wr2, union smb_close); if (cl == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1025,7 +1025,7 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, union smb_write *wr2; NTSTATUS status; - wr2 = talloc_p(req, union smb_write); + wr2 = talloc(req, union smb_write); if (wr2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1125,7 +1125,7 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, NTSTATUS status; uint_t state; - rd2 = talloc_p(req, union smb_read); + rd2 = talloc(req, union smb_read); if (rd2 == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1168,7 +1168,7 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, state = req->async_states->state; req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; - lck = talloc_p(rd2, union smb_lock); + lck = talloc(rd2, union smb_lock); if (lck == NULL) { status = NT_STATUS_NO_MEMORY; goto done; @@ -1206,7 +1206,7 @@ NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, { union smb_close *cl2; - cl2 = talloc_p(req, union smb_close); + cl2 = talloc(req, union smb_close); if (cl2 == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From 74942e1a11501dd75085b29f16ac66cd2185fe2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 01:57:53 +0000 Subject: r8107: now that we properly separate DOS and NT status codes all the places that relied on the mapping need to be fixed. The first thing is to get all the torture tests working against w2k3 again with nt status codes enabled. The 2nd step will be to make them pass with nt status disabled. This starts on the first task, fixing the assumption that NT_STATUS_INVALID_LOCK_SEQUENCE is a valid substitute for ERRDOS:ERRbadaccess (This used to be commit 87cdd117081193d215c5a9e3603438e058ad777b) --- source4/ntvfs/ntvfs_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 9b6c75e5c6..024a48bf7a 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -272,7 +272,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, SEC_RIGHTS_FILE_WRITE; break; default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; + return NT_STATUS_DOS(ERRDOS, ERRbadaccess); } switch (open_mode & OPENX_MODE_DENY_MASK) { @@ -311,7 +311,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; break; default: - return NT_STATUS_INVALID_LOCK_SEQUENCE; + return NT_STATUS_DOS(ERRDOS, ERRbadaccess); } switch (open_func) { @@ -336,7 +336,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, io2->generic.in.open_disposition = NTCREATEX_DISP_CREATE; break; } - return NT_STATUS_INVALID_LOCK_SEQUENCE; + return NT_STATUS_DOS(ERRDOS, ERRbadaccess); } return NT_STATUS_OK; -- cgit From 5fd875ae74b86d7ea532714d47aa74eb2f009ec9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 10 Sep 2005 02:21:44 +0000 Subject: r10138: Fix the mapping table (as tested in smbtorture). EXEC_ACCESS should map to SEC_RIGHTS_FILE_READ, not READ|WRITE. Jeremy. (This used to be commit 26f63973e6207e3b5c3123f1326027ceac38966f) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 024a48bf7a..8d2809cf6b 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -259,6 +259,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, switch (open_mode & OPENX_MODE_ACCESS_MASK) { case OPENX_MODE_ACCESS_READ: + case OPENX_MODE_ACCESS_EXEC: io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ; break; case OPENX_MODE_ACCESS_WRITE: @@ -266,7 +267,6 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, break; case OPENX_MODE_ACCESS_RDWR: case OPENX_MODE_ACCESS_FCB: - case OPENX_MODE_ACCESS_EXEC: io2->generic.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; -- cgit From 0a3c167f6bcf08b2204ca49831ca49eef73dcbf4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 22:51:30 +0000 Subject: r12528: Add seperate proto headers for ntvfs, tdr, smb_server and nbt_server. (This used to be commit 87f665a1d5ba74289974bf9d8f9441c162e6f1b1) --- source4/ntvfs/ntvfs_generic.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 8d2809cf6b..dc638ade5f 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -34,6 +34,7 @@ #include "includes.h" #include "smb_server/smb_server.h" #include "librpc/gen_ndr/ndr_security.h" +#include "ntvfs/ntvfs.h" /* a second stage function converts from the out parameters of the generic call onto the out parameters of the specific call made */ -- cgit From 69f7c004fefc4f4e85843bd171fe066167703bb8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 10:53:52 +0000 Subject: r12838: make the ntvfs function public metze (This used to be commit 41a564fdba5969fc7e518439520764fd56cfa280) --- source4/ntvfs/ntvfs_generic.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index dc638ade5f..b30508b1d7 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -346,8 +346,8 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, /* NTVFS open generic to any mapper */ -NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_open *io2; @@ -480,8 +480,8 @@ done: /* NTVFS fsinfo generic to any mapper */ -NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fsinfo *fs2; @@ -609,8 +609,8 @@ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, - union smb_fileinfo *info2) +_PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, + union smb_fileinfo *info2) { int i; /* and convert it to the required level using results in info2 */ @@ -835,8 +835,8 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info /* NTVFS fileinfo generic to any mapper */ -NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info, + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fileinfo *info2; @@ -864,8 +864,8 @@ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *inf /* NTVFS pathinfo generic to any mapper */ -NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info, + struct ntvfs_module_context *ntvfs) { NTSTATUS status; union smb_fileinfo *info2; @@ -897,8 +897,8 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf /* NTVFS lock generic to any mapper */ -NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, + struct ntvfs_module_context *ntvfs) { union smb_lock *lck2; struct smb_lock_entry *locks; @@ -1020,8 +1020,8 @@ static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, /* NTVFS write generic to any mapper */ -NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, + struct ntvfs_module_context *ntvfs) { union smb_write *wr2; NTSTATUS status; @@ -1118,8 +1118,8 @@ static NTSTATUS ntvfs_map_read_finish(struct smbsrv_request *req, /* NTVFS read* to readx mapper */ -NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, + struct ntvfs_module_context *ntvfs) { union smb_read *rd2; union smb_lock *lck; @@ -1202,8 +1202,8 @@ done: /* NTVFS close generic to any mapper */ -NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, + struct ntvfs_module_context *ntvfs) { union smb_close *cl2; -- cgit From fd9a6d5e4679ba4d1480dcbff23fb49504573715 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 22 Feb 2006 11:11:16 +0000 Subject: r13623: - make sure ntvfs_map_qfileinfo isn't used for async replies - add some comments metze (This used to be commit e1611b622184b48d2cef1eff2646a09f9e691f9b) --- source4/ntvfs/ntvfs_generic.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index b30508b1d7..e5224aafcd 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -495,8 +495,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo return NT_STATUS_INVALID_LEVEL; } - /* this map function is only used by the simple backend, which - doesn't do async */ + /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; /* ask the backend for the generic info */ @@ -854,6 +853,9 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_file info2->generic.level = RAW_FILEINFO_GENERIC; info2->generic.in.fnum = info->generic.in.fnum; + /* only used by the simple backend, which doesn't do async */ + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; + status = ntvfs->ops->qfileinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { return status; @@ -937,6 +939,11 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck locks->offset = lck->lock.in.offset; locks->count = lck->lock.in.count; + /* + * we don't need to call ntvfs_map_async_setup() here, + * as lock() doesn't have any output fields + */ + return ntvfs->ops->lock(ntvfs, req, lck2); } @@ -1222,5 +1229,10 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *c break; } + /* + * we don't need to call ntvfs_map_async_setup() here, + * as close() doesn't have any output fields + */ + return ntvfs->ops->close(ntvfs, req, cl2); } -- cgit From 86497db6113c4ec3210d671c3fcf957d1026098c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 14:31:17 +0000 Subject: r14157: - pass a struct ntvfs_request to the ntvfs layer (for now we just do #define ntvfs_request smbsrv_request, but it's the first step...) - rename ntvfs_openfile() -> ntvfs_open() - fix the talloc hierachie in some places in the ntvfs_map_*() code metze (This used to be commit ed9ed1f48f602354810937c0b0de850b44322191) --- source4/ntvfs/ntvfs_generic.c | 122 +++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 54 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e5224aafcd..5133f63268 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -38,8 +38,8 @@ /* a second stage function converts from the out parameters of the generic call onto the out parameters of the specific call made */ -typedef NTSTATUS (*second_stage_t)(struct smbsrv_request *, - struct ntvfs_module_context *, +typedef NTSTATUS (*second_stage_t)(struct ntvfs_module_context *, + struct ntvfs_request *, void *, void *, NTSTATUS); /* @@ -55,14 +55,14 @@ struct ntvfs_map_async { this is a async wrapper, called from the backend when it has completed a function that it has decided to reply to in an async fashion */ -static void ntvfs_map_async_send(struct smbsrv_request *req) +static void ntvfs_map_async_send(struct ntvfs_request *req) { struct ntvfs_map_async *m = req->async_states->private_data; ntvfs_async_state_pop(req); /* call the _finish function setup in ntvfs_map_async_setup() */ - req->async_states->status = m->fn(req, m->ntvfs, m->io, m->io2, req->async_states->status); + req->async_states->status = m->fn(m->ntvfs, req, m->io, m->io2, req->async_states->status); /* call the send function from the next module up */ req->async_states->send_fn(req); @@ -74,8 +74,8 @@ static void ntvfs_map_async_send(struct smbsrv_request *req) io2 is the new call structure for the mapped call fn is a second stage function for processing the out arguments */ -static NTSTATUS ntvfs_map_async_setup(struct smbsrv_request *req, - struct ntvfs_module_context *ntvfs, +static NTSTATUS ntvfs_map_async_setup(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, void *io, void *io2, second_stage_t fn) { @@ -88,14 +88,13 @@ static NTSTATUS ntvfs_map_async_setup(struct smbsrv_request *req, m->io = io; m->io2 = io2; m->fn = fn; - return ntvfs_async_state_push(req, m, ntvfs_map_async_send, ntvfs); + return ntvfs_async_state_push(ntvfs, req, m, ntvfs_map_async_send); } - /* called when first stage processing is complete. */ -static NTSTATUS ntvfs_map_async_finish(struct smbsrv_request *req, NTSTATUS status) +static NTSTATUS ntvfs_map_async_finish(struct ntvfs_request *req, NTSTATUS status) { struct ntvfs_map_async *m; @@ -111,10 +110,9 @@ static NTSTATUS ntvfs_map_async_finish(struct smbsrv_request *req, NTSTATUS stat ntvfs_async_state_pop(req); - return m->fn(req, m->ntvfs, m->io, m->io2, status); + return m->fn(m->ntvfs, req, m->io, m->io2, status); } - /* see if a filename ends in EXE COM DLL or SYM. This is needed for the DENY_DOS mapping for OpenX @@ -140,8 +138,8 @@ BOOL is_exe_filename(const char *fname) /* NTVFS openx to ntcreatex mapper */ -static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, - struct ntvfs_module_context *ntvfs, +static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_open *io, union smb_open *io2, NTSTATUS status) @@ -206,6 +204,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, io->ctemp.out.fnum = io2->generic.out.fnum; io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + strlen(io->ctemp.in.directory) + 1); + NT_STATUS_HAVE_NO_MEMORY(io->ctemp.out.name); break; default: @@ -218,9 +217,10 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; if (write_time != 0) { - sf = talloc(req, union smb_setfileinfo); - sf->generic.level = RAW_SFILEINFO_STANDARD; - sf->generic.file.fnum = io2->generic.out.fnum; + sf = talloc(req, union smb_setfileinfo); + NT_STATUS_HAVE_NO_MEMORY(sf); + sf->generic.level = RAW_SFILEINFO_STANDARD; + sf->generic.file.fnum = io2->generic.out.fnum; sf->standard.in.create_time = 0; sf->standard.in.write_time = write_time; sf->standard.in.access_time = 0; @@ -229,6 +229,7 @@ static NTSTATUS ntvfs_map_open_finish(struct smbsrv_request *req, if (set_size != 0) { sf = talloc(req, union smb_setfileinfo); + NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; sf->generic.file.fnum = io2->generic.out.fnum; sf->end_of_file_info.in.size = set_size; @@ -346,8 +347,9 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, /* NTVFS open generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_open *io) { NTSTATUS status; union smb_open *io2; @@ -357,7 +359,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, return NT_STATUS_NO_MEMORY; } - status = ntvfs_map_async_setup(req, ntvfs, io, io2, + status = ntvfs_map_async_setup(ntvfs, req, + io, io2, (second_stage_t)ntvfs_map_open_finish); if (!NT_STATUS_IS_OK(status)) { return status; @@ -379,7 +382,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.file_attr = io->openx.in.file_attrs; io2->generic.in.fname = io->openx.in.fname; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; @@ -396,7 +399,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.file_attr = io->openold.in.search_attrs; io2->generic.in.fname = io->openold.in.fname; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; case RAW_OPEN_T2OPEN: @@ -422,7 +425,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.ea_list->num_eas = io->t2open.in.num_eas; io2->generic.in.ea_list->eas = io->t2open.in.eas; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; case RAW_OPEN_MKNEW: @@ -435,7 +438,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; case RAW_OPEN_CREATE: @@ -448,7 +451,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; case RAW_OPEN_CTEMP: @@ -465,7 +468,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - status = ntvfs->ops->openfile(ntvfs, req, io2); + status = ntvfs->ops->open(ntvfs, req, io2); break; default: @@ -480,8 +483,9 @@ done: /* NTVFS fsinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_fsinfo *fs) { NTSTATUS status; union smb_fsinfo *fs2; @@ -608,7 +612,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct smbsrv_request *req, union smb_fsinfo /* NTVFS fileinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info, +_PUBLIC_ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx, + union smb_fileinfo *info, union smb_fileinfo *info2) { int i; @@ -714,7 +719,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { info->stream_info.out.streams = - talloc_array(req, + talloc_array(mem_ctx, struct stream_struct, info->stream_info.out.num_streams); if (!info->stream_info.out.streams) { @@ -725,7 +730,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei for (i=0; i < info->stream_info.out.num_streams; i++) { info->stream_info.out.streams[i] = info2->generic.out.streams[i]; info->stream_info.out.streams[i].stream_name.s = - talloc_strdup(req, info2->generic.out.streams[i].stream_name.s); + talloc_strdup(info->stream_info.out.streams, + info2->generic.out.streams[i].stream_name.s); if (!info->stream_info.out.streams[i].stream_name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; @@ -736,13 +742,15 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: - info->name_info.out.fname.s = talloc_strdup(req, info2->generic.out.fname.s); + info->name_info.out.fname.s = talloc_strdup(mem_ctx, info2->generic.out.fname.s); + NT_STATUS_HAVE_NO_MEMORY(info->name_info.out.fname.s); info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_ALT_NAME_INFORMATION: - info->alt_name_info.out.fname.s = talloc_strdup(req, info2->generic.out.alt_fname.s); + info->alt_name_info.out.fname.s = talloc_strdup(mem_ctx, info2->generic.out.alt_fname.s); + NT_STATUS_HAVE_NO_MEMORY(info->alt_name_info.out.fname.s); info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length; return NT_STATUS_OK; @@ -753,7 +761,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc_array(req, + info->all_eas.out.eas = talloc_array(mem_ctx, struct ea_struct, info->all_eas.out.num_eas); if (!info->all_eas.out.eas) { @@ -764,13 +772,14 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei for (i = 0; i < info->all_eas.out.num_eas; i++) { info->all_eas.out.eas[i] = info2->generic.out.eas[i]; info->all_eas.out.eas[i].name.s = - talloc_strdup(req, info2->generic.out.eas[i].name.s); + talloc_strdup(info->all_eas.out.eas, + info2->generic.out.eas[i].name.s); if (!info->all_eas.out.eas[i].name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } info->all_eas.out.eas[i].value.data = - talloc_memdup(req, + talloc_memdup(info->all_eas.out.eas, info2->generic.out.eas[i].value.data, info2->generic.out.eas[i].value.length); if (!info->all_eas.out.eas[i].value.data) { @@ -834,8 +843,9 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_filei /* NTVFS fileinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_fileinfo *info) { NTSTATUS status; union smb_fileinfo *info2; @@ -866,8 +876,9 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct smbsrv_request *req, union smb_file /* NTVFS pathinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_fileinfo *info) { NTSTATUS status; union smb_fileinfo *info2; @@ -899,8 +910,9 @@ _PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_file /* NTVFS lock generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_lock *lck) { union smb_lock *lck2; struct smb_lock_entry *locks; @@ -951,12 +963,11 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct smbsrv_request *req, union smb_lock *lck /* NTVFS write generic to any mapper */ -static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, - struct ntvfs_module_context *ntvfs, +static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_write *wr, union smb_write *wr2, NTSTATUS status) - { union smb_lock *lck; union smb_close *cl; @@ -1027,8 +1038,9 @@ static NTSTATUS ntvfs_map_write_finish(struct smbsrv_request *req, /* NTVFS write generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_write *wr) { union smb_write *wr2; NTSTATUS status; @@ -1038,7 +1050,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *w return NT_STATUS_NO_MEMORY; } - status = ntvfs_map_async_setup(req, ntvfs, wr, wr2, + status = ntvfs_map_async_setup(ntvfs, req, wr, wr2, (second_stage_t)ntvfs_map_write_finish); if (!NT_STATUS_IS_OK(status)) { return status; @@ -1099,8 +1111,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *w /* NTVFS read generic to any mapper - finish the out mapping */ -static NTSTATUS ntvfs_map_read_finish(struct smbsrv_request *req, - struct ntvfs_module_context *ntvfs, +static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_read *rd, union smb_read *rd2, NTSTATUS status) @@ -1125,8 +1137,9 @@ static NTSTATUS ntvfs_map_read_finish(struct smbsrv_request *req, /* NTVFS read* to readx mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_read *rd) { union smb_read *rd2; union smb_lock *lck; @@ -1138,7 +1151,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, return NT_STATUS_NO_MEMORY; } - status = ntvfs_map_async_setup(req, ntvfs, rd, rd2, + status = ntvfs_map_async_setup(ntvfs, req, rd, rd2, (second_stage_t)ntvfs_map_read_finish); if (!NT_STATUS_IS_OK(status)) { return status; @@ -1209,8 +1222,9 @@ done: /* NTVFS close generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_close(struct smbsrv_request *req, union smb_close *cl, - struct ntvfs_module_context *ntvfs) +_PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_close *cl) { union smb_close *cl2; -- cgit From 307e43bb5628e8b53a930c2928279af994281ba5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 20:49:20 +0000 Subject: r14173: change smb interface structures to always use a union smb_file, to abtract - const char *path fot qpathinfo and setpathinfo - uint16_t fnum for SMB - smb2_handle handle for SMB2 the idea is to later add a struct ntvfs_handle *ntvfs so that the ntvfs subsystem don't need to know the difference between SMB and SMB2 metze (This used to be commit 2ef3f5970901b5accdb50f0d0115b5d46b0c788f) --- source4/ntvfs/ntvfs_generic.c | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 5133f63268..e373c7a28e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -155,7 +155,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, switch (io->generic.level) { case RAW_OPEN_OPEN: - io->openold.out.fnum = io2->generic.out.fnum; + io->openold.file.fnum = io2->generic.file.fnum; io->openold.out.attrib = io2->generic.out.attrib; io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openold.out.size = io2->generic.out.size; @@ -163,7 +163,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_OPENX: - io->openx.out.fnum = io2->generic.out.fnum; + io->openx.file.fnum = io2->generic.file.fnum; io->openx.out.attrib = io2->generic.out.attrib; io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openx.out.size = io2->generic.out.size; @@ -183,7 +183,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_T2OPEN: - io->t2open.out.fnum = io2->generic.out.fnum; + io->t2open.file.fnum = io2->generic.file.fnum; io->t2open.out.attrib = io2->generic.out.attrib; io->t2open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->t2open.out.size = io2->generic.out.size; @@ -196,14 +196,14 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_MKNEW: case RAW_OPEN_CREATE: - io->mknew.out.fnum = io2->generic.out.fnum; + io->mknew.file.fnum = io2->generic.file.fnum; write_time = io->mknew.in.write_time; break; case RAW_OPEN_CTEMP: - io->ctemp.out.fnum = io2->generic.out.fnum; - io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + - strlen(io->ctemp.in.directory) + 1); + io->ctemp.file.fnum = io2->generic.file.fnum; + io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + + strlen(io->ctemp.in.directory) + 1); NT_STATUS_HAVE_NO_MEMORY(io->ctemp.out.name); break; @@ -220,7 +220,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_STANDARD; - sf->generic.file.fnum = io2->generic.out.fnum; + sf->generic.file.fnum = io2->generic.file.fnum; sf->standard.in.create_time = 0; sf->standard.in.write_time = write_time; sf->standard.in.access_time = 0; @@ -231,7 +231,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.file.fnum = io2->generic.out.fnum; + sf->generic.file.fnum = io2->generic.file.fnum; sf->end_of_file_info.in.size = set_size; status = ntvfs->ops->setfileinfo(ntvfs, req, sf); if (NT_STATUS_IS_OK(status)) { @@ -861,7 +861,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; - info2->generic.in.fnum = info->generic.in.fnum; + info2->generic.file.fnum = info->generic.file.fnum; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; @@ -894,7 +894,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; - info2->generic.in.fname = info->generic.in.fname; + info2->generic.file.path = info->generic.file.path; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; @@ -943,7 +943,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, } lck2->generic.level = RAW_LOCK_GENERIC; - lck2->generic.in.fnum = lck->lock.in.fnum; + lck2->generic.file.fnum = lck->lock.file.fnum; lck2->generic.in.mode = 0; lck2->generic.in.timeout = 0; lck2->generic.in.locks = locks; @@ -991,7 +991,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, } lck->unlock.level = RAW_LOCK_UNLOCK; - lck->unlock.in.fnum = wr->writeunlock.in.fnum; + lck->unlock.file.fnum = wr->writeunlock.file.fnum; lck->unlock.in.count = wr->writeunlock.in.count; lck->unlock.in.offset = wr->writeunlock.in.offset; @@ -1013,7 +1013,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, } cl->close.level = RAW_CLOSE_CLOSE; - cl->close.in.fnum = wr->writeclose.in.fnum; + cl->close.file.fnum = wr->writeclose.file.fnum; cl->close.in.write_time = wr->writeclose.in.mtime; if (wr2->generic.in.count != 0) { @@ -1064,7 +1064,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITE: - wr2->writex.in.fnum = wr->write.in.fnum; + wr2->writex.file.fnum = wr->write.file.fnum; wr2->writex.in.offset = wr->write.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->write.in.remaining; @@ -1074,7 +1074,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITEUNLOCK: - wr2->writex.in.fnum = wr->writeunlock.in.fnum; + wr2->writex.file.fnum = wr->writeunlock.file.fnum; wr2->writex.in.offset = wr->writeunlock.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->writeunlock.in.remaining; @@ -1084,7 +1084,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITECLOSE: - wr2->writex.in.fnum = wr->writeclose.in.fnum; + wr2->writex.file.fnum = wr->writeclose.file.fnum; wr2->writex.in.offset = wr->writeclose.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1094,7 +1094,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_SPLWRITE: - wr2->writex.in.fnum = wr->splwrite.in.fnum; + wr2->writex.file.fnum = wr->splwrite.file.fnum; wr2->writex.in.offset = 0; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1165,7 +1165,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READ: - rd2->readx.in.fnum = rd->read.in.fnum; + rd2->readx.file.fnum = rd->read.file.fnum; rd2->readx.in.offset = rd->read.in.offset; rd2->readx.in.mincnt = rd->read.in.count; rd2->readx.in.maxcnt = rd->read.in.count; @@ -1175,7 +1175,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READBRAW: - rd2->readx.in.fnum = rd->readbraw.in.fnum; + rd2->readx.file.fnum = rd->readbraw.file.fnum; rd2->readx.in.offset = rd->readbraw.in.offset; rd2->readx.in.mincnt = rd->readbraw.in.mincnt; rd2->readx.in.maxcnt = rd->readbraw.in.maxcnt; @@ -1195,13 +1195,13 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, goto done; } lck->lock.level = RAW_LOCK_LOCK; - lck->lock.in.fnum = rd->lockread.in.fnum; + lck->lock.file.fnum = rd->lockread.file.fnum; lck->lock.in.count = rd->lockread.in.count; lck->lock.in.offset = rd->lockread.in.offset; status = ntvfs->ops->lock(ntvfs, req, lck); req->async_states->state = state; - rd2->readx.in.fnum = rd->lockread.in.fnum; + rd2->readx.file.fnum = rd->lockread.file.fnum; rd2->readx.in.offset = rd->lockread.in.offset; rd2->readx.in.mincnt = rd->lockread.in.count; rd2->readx.in.maxcnt = rd->lockread.in.count; @@ -1238,8 +1238,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; case RAW_CLOSE_SPLCLOSE: - cl2->close.level = RAW_CLOSE_CLOSE; - cl2->close.in.fnum = cl->splclose.in.fnum; + cl2->close.level = RAW_CLOSE_CLOSE; + cl2->close.file.fnum = cl->splclose.file.fnum; break; } -- cgit From 7f0c7702f6b9db216fcd6c29165b2a11ea1f24a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 11 Mar 2006 12:58:36 +0000 Subject: r14208: removed use of req->flags2 inside the ntvfs layer. This should help metze on his quest to unify the ntvfs strucures for the smb and smb2 servers. The only place we needed flags2 inside ntvfs was for the FLAGS2_READ_PERMIT_EXECUTE bit, which only affects readx, so I added a readx.in.read_for_execute flag instead. (This used to be commit b78abbbce60ab0009da19a72dd769800c44298a2) --- source4/ntvfs/ntvfs_generic.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e373c7a28e..e4bc963882 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1158,6 +1158,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, } rd2->readx.level = RAW_READ_READX; + rd2->readx.in.read_for_execute = False; switch (rd->generic.level) { case RAW_READ_READX: -- cgit From a1b295ed4823ce8d06f830b8db9a5d965c934b54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 22:48:25 +0000 Subject: r14256: - rename smb_file -> smb_handle - move it into the in/out substructs again - allow file.path only on smb_fileinfo/smb_setfileinfo metze (This used to be commit be6d5298a2cdb7e7c61d70471bad445645af5963) --- source4/ntvfs/ntvfs_generic.c | 68 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e4bc963882..51b03606fb 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -155,7 +155,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, switch (io->generic.level) { case RAW_OPEN_OPEN: - io->openold.file.fnum = io2->generic.file.fnum; + io->openold.out.file.fnum = io2->generic.out.file.fnum; io->openold.out.attrib = io2->generic.out.attrib; io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openold.out.size = io2->generic.out.size; @@ -163,7 +163,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_OPENX: - io->openx.file.fnum = io2->generic.file.fnum; + io->openx.out.file.fnum = io2->generic.out.file.fnum; io->openx.out.attrib = io2->generic.out.attrib; io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openx.out.size = io2->generic.out.size; @@ -183,7 +183,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_T2OPEN: - io->t2open.file.fnum = io2->generic.file.fnum; + io->t2open.out.file.fnum = io2->generic.out.file.fnum; io->t2open.out.attrib = io2->generic.out.attrib; io->t2open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->t2open.out.size = io2->generic.out.size; @@ -196,14 +196,14 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_MKNEW: case RAW_OPEN_CREATE: - io->mknew.file.fnum = io2->generic.file.fnum; - write_time = io->mknew.in.write_time; + io->mknew.out.file.fnum = io2->generic.out.file.fnum; + write_time = io->mknew.in.write_time; break; case RAW_OPEN_CTEMP: - io->ctemp.file.fnum = io2->generic.file.fnum; - io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + - strlen(io->ctemp.in.directory) + 1); + io->ctemp.out.file.fnum = io2->generic.out.file.fnum; + io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + + strlen(io->ctemp.in.directory) + 1); NT_STATUS_HAVE_NO_MEMORY(io->ctemp.out.name); break; @@ -220,7 +220,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_STANDARD; - sf->generic.file.fnum = io2->generic.file.fnum; + sf->generic.in.file.fnum = io2->generic.out.file.fnum; sf->standard.in.create_time = 0; sf->standard.in.write_time = write_time; sf->standard.in.access_time = 0; @@ -231,7 +231,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.file.fnum = io2->generic.file.fnum; + sf->generic.in.file.fnum = io2->generic.out.file.fnum; sf->end_of_file_info.in.size = set_size; status = ntvfs->ops->setfileinfo(ntvfs, req, sf); if (NT_STATUS_IS_OK(status)) { @@ -861,7 +861,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; - info2->generic.file.fnum = info->generic.file.fnum; + info2->generic.in.file.fnum = info->generic.in.file.fnum; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; @@ -893,8 +893,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, } /* ask the backend for the generic info */ - info2->generic.level = RAW_FILEINFO_GENERIC; - info2->generic.file.path = info->generic.file.path; + info2->generic.level = RAW_FILEINFO_GENERIC; + info2->generic.in.file.path = info->generic.in.file.path; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; @@ -943,7 +943,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, } lck2->generic.level = RAW_LOCK_GENERIC; - lck2->generic.file.fnum = lck->lock.file.fnum; + lck2->generic.in.file.fnum = lck->lock.in.file.fnum; lck2->generic.in.mode = 0; lck2->generic.in.timeout = 0; lck2->generic.in.locks = locks; @@ -990,10 +990,10 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - lck->unlock.level = RAW_LOCK_UNLOCK; - lck->unlock.file.fnum = wr->writeunlock.file.fnum; - lck->unlock.in.count = wr->writeunlock.in.count; - lck->unlock.in.offset = wr->writeunlock.in.offset; + lck->unlock.level = RAW_LOCK_UNLOCK; + lck->unlock.in.file.fnum= wr->writeunlock.in.file.fnum; + lck->unlock.in.count = wr->writeunlock.in.count; + lck->unlock.in.offset = wr->writeunlock.in.offset; if (lck->unlock.in.count != 0) { /* do the lock sync for now */ @@ -1012,9 +1012,9 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - cl->close.level = RAW_CLOSE_CLOSE; - cl->close.file.fnum = wr->writeclose.file.fnum; - cl->close.in.write_time = wr->writeclose.in.mtime; + cl->close.level = RAW_CLOSE_CLOSE; + cl->close.in.file.fnum = wr->writeclose.in.file.fnum; + cl->close.in.write_time = wr->writeclose.in.mtime; if (wr2->generic.in.count != 0) { /* do the close sync for now */ @@ -1064,7 +1064,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITE: - wr2->writex.file.fnum = wr->write.file.fnum; + wr2->writex.in.file.fnum = wr->write.in.file.fnum; wr2->writex.in.offset = wr->write.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->write.in.remaining; @@ -1074,7 +1074,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITEUNLOCK: - wr2->writex.file.fnum = wr->writeunlock.file.fnum; + wr2->writex.in.file.fnum = wr->writeunlock.in.file.fnum; wr2->writex.in.offset = wr->writeunlock.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->writeunlock.in.remaining; @@ -1084,7 +1084,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITECLOSE: - wr2->writex.file.fnum = wr->writeclose.file.fnum; + wr2->writex.in.file.fnum = wr->writeclose.in.file.fnum; wr2->writex.in.offset = wr->writeclose.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1094,7 +1094,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_SPLWRITE: - wr2->writex.file.fnum = wr->splwrite.file.fnum; + wr2->writex.in.file.fnum = wr->splwrite.in.file.fnum; wr2->writex.in.offset = 0; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1166,7 +1166,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READ: - rd2->readx.file.fnum = rd->read.file.fnum; + rd2->readx.in.file.fnum = rd->read.in.file.fnum; rd2->readx.in.offset = rd->read.in.offset; rd2->readx.in.mincnt = rd->read.in.count; rd2->readx.in.maxcnt = rd->read.in.count; @@ -1176,7 +1176,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READBRAW: - rd2->readx.file.fnum = rd->readbraw.file.fnum; + rd2->readx.in.file.fnum = rd->readbraw.in.file.fnum; rd2->readx.in.offset = rd->readbraw.in.offset; rd2->readx.in.mincnt = rd->readbraw.in.mincnt; rd2->readx.in.maxcnt = rd->readbraw.in.maxcnt; @@ -1195,14 +1195,14 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, status = NT_STATUS_NO_MEMORY; goto done; } - lck->lock.level = RAW_LOCK_LOCK; - lck->lock.file.fnum = rd->lockread.file.fnum; - lck->lock.in.count = rd->lockread.in.count; - lck->lock.in.offset = rd->lockread.in.offset; + lck->lock.level = RAW_LOCK_LOCK; + lck->lock.in.file.fnum = rd->lockread.in.file.fnum; + lck->lock.in.count = rd->lockread.in.count; + lck->lock.in.offset = rd->lockread.in.offset; status = ntvfs->ops->lock(ntvfs, req, lck); req->async_states->state = state; - rd2->readx.file.fnum = rd->lockread.file.fnum; + rd2->readx.in.file.fnum = rd->lockread.in.file.fnum; rd2->readx.in.offset = rd->lockread.in.offset; rd2->readx.in.mincnt = rd->lockread.in.count; rd2->readx.in.maxcnt = rd->lockread.in.count; @@ -1239,8 +1239,8 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; case RAW_CLOSE_SPLCLOSE: - cl2->close.level = RAW_CLOSE_CLOSE; - cl2->close.file.fnum = cl->splclose.file.fnum; + cl2->close.level = RAW_CLOSE_CLOSE; + cl2->close.in.file.fnum = cl->splclose.in.file.fnum; break; } -- cgit From d3087451c4ec25171ba956fe2cd4e1d0f64f7edc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Mar 2006 18:54:19 +0000 Subject: r14487: split smbsrv_request into two parts, one will be moved to ntvfs_request but I don't to get the commit to large, to I'll do this tomorrow... metze (This used to be commit 10e627032d7d04f1ebf6efed248c426614f5aa6f) --- source4/ntvfs/ntvfs_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 51b03606fb..f74092eda0 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -534,7 +534,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, (fs2->generic.out.blocks_free * (double)fs2->generic.out.block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ - if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) { + if (bpunit > 64 && req->ctx->protocol <= PROTOCOL_LANMAN2) { fs->dskattr.out.blocks_per_unit = 64; fs->dskattr.out.units_total = 0xFFFF; fs->dskattr.out.units_free = 0xFFFF; -- cgit From ad06a8bd651e3a8b598c92a356ac1ce4117ae72e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 26 Mar 2006 01:23:40 +0000 Subject: r14736: - the ntvfs subsystem should not know about smb_server.h - the process module subsystem should not know about smb_server.h - the smb_server module should not know about process models metze (This used to be commit bac95bb8f4ad35a31ee666f5916ff9b2f292d964) --- source4/ntvfs/ntvfs_generic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index f74092eda0..fdc186c710 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -32,7 +32,6 @@ */ #include "includes.h" -#include "smb_server/smb_server.h" #include "librpc/gen_ndr/ndr_security.h" #include "ntvfs/ntvfs.h" -- cgit From e002300f238dd0937dd9f768e366c006945e8baa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 17:34:49 +0000 Subject: r15328: Move some functions around, remove dependencies. Remove some autogenerated headers (which had prototypes now autogenerated by pidl) Remove ndr_security.h from a few places - it's no longer necessary (This used to be commit c19c2b51d3e1ad347120b06a22bda5ec586c22e8) --- source4/ntvfs/ntvfs_generic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index fdc186c710..b04a3af21e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -32,7 +32,6 @@ */ #include "includes.h" -#include "librpc/gen_ndr/ndr_security.h" #include "ntvfs/ntvfs.h" /* a second stage function converts from the out parameters of the generic -- cgit From 9ef33f5f5c786b83311ca088357fb2f0aa72fc9e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 08:15:22 +0000 Subject: r15734: This is a major change to the NTVFS subsystem: - to use a struct ntvfs_handle instead of a uint16_t fnum. (to make it independend from the frontend protocol) - the allocation of handles now is provided by the frontend (smbsrv_*) via callbacks and not by each backend module - this also makes sure that file handles are only passed to the ntvfs subsystem when the tcon and session matches, so modules can rely on this and need to check this. - this allows multiple modules in the ntvfs module chain to allocate file handles. This can be used for virtual files like "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"... - also this will make SMB2 with 128 bit file handles possible metze (This used to be commit 287fc1c22d670f6e568014b420f7f4cb31dc7958) --- source4/ntvfs/ntvfs_generic.c | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index b04a3af21e..5058225ceb 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -153,7 +153,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, switch (io->generic.level) { case RAW_OPEN_OPEN: - io->openold.out.file.fnum = io2->generic.out.file.fnum; + io->openold.out.file.ntvfs = io2->generic.out.file.ntvfs; io->openold.out.attrib = io2->generic.out.attrib; io->openold.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openold.out.size = io2->generic.out.size; @@ -161,7 +161,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_OPENX: - io->openx.out.file.fnum = io2->generic.out.file.fnum; + io->openx.out.file.ntvfs = io2->generic.out.file.ntvfs; io->openx.out.attrib = io2->generic.out.attrib; io->openx.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->openx.out.size = io2->generic.out.size; @@ -181,7 +181,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_T2OPEN: - io->t2open.out.file.fnum = io2->generic.out.file.fnum; + io->t2open.out.file.ntvfs = io2->generic.out.file.ntvfs; io->t2open.out.attrib = io2->generic.out.attrib; io->t2open.out.write_time = nt_time_to_unix(io2->generic.out.write_time); io->t2open.out.size = io2->generic.out.size; @@ -194,12 +194,12 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_MKNEW: case RAW_OPEN_CREATE: - io->mknew.out.file.fnum = io2->generic.out.file.fnum; + io->mknew.out.file.ntvfs= io2->generic.out.file.ntvfs; write_time = io->mknew.in.write_time; break; case RAW_OPEN_CTEMP: - io->ctemp.out.file.fnum = io2->generic.out.file.fnum; + io->ctemp.out.file.ntvfs= io2->generic.out.file.ntvfs; io->ctemp.out.name = talloc_strdup(req, io2->generic.in.fname + strlen(io->ctemp.in.directory) + 1); NT_STATUS_HAVE_NO_MEMORY(io->ctemp.out.name); @@ -218,7 +218,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_STANDARD; - sf->generic.in.file.fnum = io2->generic.out.file.fnum; + sf->generic.in.file.ntvfs = io2->generic.out.file.ntvfs; sf->standard.in.create_time = 0; sf->standard.in.write_time = write_time; sf->standard.in.access_time = 0; @@ -229,7 +229,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, sf = talloc(req, union smb_setfileinfo); NT_STATUS_HAVE_NO_MEMORY(sf); sf->generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; - sf->generic.in.file.fnum = io2->generic.out.file.fnum; + sf->generic.in.file.ntvfs = io2->generic.out.file.ntvfs; sf->end_of_file_info.in.size = set_size; status = ntvfs->ops->setfileinfo(ntvfs, req, sf); if (NT_STATUS_IS_OK(status)) { @@ -859,7 +859,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; - info2->generic.in.file.fnum = info->generic.in.file.fnum; + info2->generic.in.file.ntvfs= info->generic.in.file.ntvfs; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; @@ -941,7 +941,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, } lck2->generic.level = RAW_LOCK_GENERIC; - lck2->generic.in.file.fnum = lck->lock.in.file.fnum; + lck2->generic.in.file.ntvfs= lck->lock.in.file.ntvfs; lck2->generic.in.mode = 0; lck2->generic.in.timeout = 0; lck2->generic.in.locks = locks; @@ -988,10 +988,10 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - lck->unlock.level = RAW_LOCK_UNLOCK; - lck->unlock.in.file.fnum= wr->writeunlock.in.file.fnum; - lck->unlock.in.count = wr->writeunlock.in.count; - lck->unlock.in.offset = wr->writeunlock.in.offset; + lck->unlock.level = RAW_LOCK_UNLOCK; + lck->unlock.in.file.ntvfs = wr->writeunlock.in.file.ntvfs; + lck->unlock.in.count = wr->writeunlock.in.count; + lck->unlock.in.offset = wr->writeunlock.in.offset; if (lck->unlock.in.count != 0) { /* do the lock sync for now */ @@ -1011,7 +1011,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, } cl->close.level = RAW_CLOSE_CLOSE; - cl->close.in.file.fnum = wr->writeclose.in.file.fnum; + cl->close.in.file.ntvfs = wr->writeclose.in.file.ntvfs; cl->close.in.write_time = wr->writeclose.in.mtime; if (wr2->generic.in.count != 0) { @@ -1062,7 +1062,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITE: - wr2->writex.in.file.fnum = wr->write.in.file.fnum; + wr2->writex.in.file.ntvfs= wr->write.in.file.ntvfs; wr2->writex.in.offset = wr->write.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->write.in.remaining; @@ -1072,7 +1072,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITEUNLOCK: - wr2->writex.in.file.fnum = wr->writeunlock.in.file.fnum; + wr2->writex.in.file.ntvfs= wr->writeunlock.in.file.ntvfs; wr2->writex.in.offset = wr->writeunlock.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = wr->writeunlock.in.remaining; @@ -1082,7 +1082,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_WRITECLOSE: - wr2->writex.in.file.fnum = wr->writeclose.in.file.fnum; + wr2->writex.in.file.ntvfs= wr->writeclose.in.file.ntvfs; wr2->writex.in.offset = wr->writeclose.in.offset; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1092,7 +1092,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, break; case RAW_WRITE_SPLWRITE: - wr2->writex.in.file.fnum = wr->splwrite.in.file.fnum; + wr2->writex.in.file.ntvfs= wr->splwrite.in.file.ntvfs; wr2->writex.in.offset = 0; wr2->writex.in.wmode = 0; wr2->writex.in.remaining = 0; @@ -1164,7 +1164,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READ: - rd2->readx.in.file.fnum = rd->read.in.file.fnum; + rd2->readx.in.file.ntvfs= rd->read.in.file.ntvfs; rd2->readx.in.offset = rd->read.in.offset; rd2->readx.in.mincnt = rd->read.in.count; rd2->readx.in.maxcnt = rd->read.in.count; @@ -1174,7 +1174,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_READBRAW: - rd2->readx.in.file.fnum = rd->readbraw.in.file.fnum; + rd2->readx.in.file.ntvfs= rd->readbraw.in.file.ntvfs; rd2->readx.in.offset = rd->readbraw.in.offset; rd2->readx.in.mincnt = rd->readbraw.in.mincnt; rd2->readx.in.maxcnt = rd->readbraw.in.maxcnt; @@ -1194,13 +1194,13 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, goto done; } lck->lock.level = RAW_LOCK_LOCK; - lck->lock.in.file.fnum = rd->lockread.in.file.fnum; + lck->lock.in.file.ntvfs = rd->lockread.in.file.ntvfs; lck->lock.in.count = rd->lockread.in.count; lck->lock.in.offset = rd->lockread.in.offset; status = ntvfs->ops->lock(ntvfs, req, lck); req->async_states->state = state; - rd2->readx.in.file.fnum = rd->lockread.in.file.fnum; + rd2->readx.in.file.ntvfs= rd->lockread.in.file.ntvfs; rd2->readx.in.offset = rd->lockread.in.offset; rd2->readx.in.mincnt = rd->lockread.in.count; rd2->readx.in.maxcnt = rd->lockread.in.count; @@ -1238,7 +1238,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, case RAW_CLOSE_SPLCLOSE: cl2->close.level = RAW_CLOSE_CLOSE; - cl2->close.in.file.fnum = cl->splclose.in.file.fnum; + cl2->close.in.file.ntvfs= cl->splclose.in.file.ntvfs; break; } -- cgit From 35d6a53ff7b7b906d9a42bad5b7647a2abc6a3f6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 16:10:22 +0000 Subject: r15750: don't clear after setting metze (This used to be commit 0e23d2a45a4507051bb3453387b82e7a9f4433ea) --- source4/ntvfs/ntvfs_generic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 5058225ceb..a4cc0ff396 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -454,7 +454,6 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, case RAW_OPEN_CTEMP: io2->generic.in.file_attr = io->ctemp.in.attrib; - io2->generic.in.file_attr = 0; io2->generic.in.fname = talloc_asprintf(io2, "%s\\SRV%s", io->ctemp.in.directory, -- cgit From 6af051409a0a1bcda9e2673bab1652690ab88fea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 16:53:44 +0000 Subject: r15752: - add generic mapping for RAW_OPEN_SMB2 metze (This used to be commit d26144f9575f1e53bfb837024d964a3324d38728) --- source4/ntvfs/ntvfs_generic.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index a4cc0ff396..8b80e9db80 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -205,6 +205,22 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(io->ctemp.out.name); break; + case RAW_OPEN_SMB2: + io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs; + io->smb2.out.oplock_flags = 0; + io->smb2.out.create_action = io2->generic.out.create_action; + io->smb2.out.create_time = io2->generic.out.create_time; + io->smb2.out.access_time = io2->generic.out.access_time; + io->smb2.out.write_time = io2->generic.out.write_time; + io->smb2.out.change_time = io2->generic.out.change_time; + io->smb2.out.alloc_size = io2->generic.out.alloc_size; + io->smb2.out.size = io2->generic.out.size; + /*io->smb2.out.file_attr = io2->generic.out.attrib; would this be correct? */ + io->smb2.out.file_attr = 0; + io->smb2.out._pad = 0; + io->smb2.out.blob = data_blob(NULL, 0); + break; + default: return NT_STATUS_INVALID_LEVEL; } @@ -467,6 +483,22 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, NTCREATEX_SHARE_ACCESS_WRITE; status = ntvfs->ops->open(ntvfs, req, io2); break; + case RAW_OPEN_SMB2: + io2->generic.in.flags = 0; + io2->generic.in.root_fid = 0; + io2->generic.in.access_mask = io->smb2.in.access_mask; + io2->generic.in.alloc_size = 0; + io2->generic.in.file_attr = io->smb2.in.file_attr; + io2->generic.in.share_access = io->smb2.in.share_access; + io2->generic.in.open_disposition= io->smb2.in.open_disposition; + io2->generic.in.create_options = io->smb2.in.create_options; + io2->generic.in.impersonation = io->smb2.in.impersonation; + io2->generic.in.security_flags = 0; + io2->generic.in.fname = io->smb2.in.fname; + io2->generic.in.sec_desc = NULL; + io2->generic.in.ea_list = NULL; + status = ntvfs->ops->open(ntvfs, req, io2); + break; default: status = NT_STATUS_INVALID_LEVEL; -- cgit From 183fb2bd4b51fbf6d5660b84804b6f79bf9db36f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 17:20:34 +0000 Subject: r15754: - implement SMB2 Close - add RAW_CLOSE_SMB2 generic mapping metze (This used to be commit 41bc3cfc822bfc2fe4413f93a180fc4507005282) --- source4/ntvfs/ntvfs_generic.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 8b80e9db80..89481e5038 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1268,8 +1268,15 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; case RAW_CLOSE_SPLCLOSE: - cl2->close.level = RAW_CLOSE_CLOSE; - cl2->close.in.file.ntvfs= cl->splclose.in.file.ntvfs; + cl2->generic.level = RAW_CLOSE_CLOSE; + cl2->generic.in.file.ntvfs = cl->splclose.in.file.ntvfs; + break; + + case RAW_CLOSE_SMB2: + cl2->generic.level = RAW_CLOSE_CLOSE; + cl2->generic.in.file.ntvfs = cl->smb2.in.file.ntvfs; + /* SMB2 Close has output parameter, but we just zero them */ + ZERO_STRUCT(cl->smb2.out); break; } -- cgit From 772c4928404bc26e5cc7cfdcba1f931ee0d0de82 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 18:56:08 +0000 Subject: r15757: - add RAW_WRITE_SMB2 => generic mapping - implement SMB2 Write metze (This used to be commit 5ab6f304f8b91c0362fd57429cc24126b241bd51) --- source4/ntvfs/ntvfs_generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 89481e5038..119fef2c6d 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1056,6 +1056,14 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, case RAW_WRITE_SPLWRITE: break; + + case RAW_WRITE_SMB2: + wr->smb2.out._pad = 0; + wr->smb2.out.nwritten = wr2->generic.out.nwritten; + wr->smb2.out.unknown1 = 0; + wr->smb2.out._bug = 0; + break; + default: return NT_STATUS_INVALID_LEVEL; } @@ -1131,6 +1139,15 @@ _PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, wr2->writex.in.data = wr->splwrite.in.data; status = ntvfs->ops->write(ntvfs, req, wr2); break; + + case RAW_WRITE_SMB2: + wr2->writex.in.file.ntvfs= wr->smb2.in.file.ntvfs; + wr2->writex.in.offset = wr->smb2.in.offset; + wr2->writex.in.wmode = 0; + wr2->writex.in.remaining = 0; + wr2->writex.in.count = wr->smb2.in.data.length; + wr2->writex.in.data = wr->smb2.in.data.data; + status = ntvfs->ops->write(ntvfs, req, wr2); } return ntvfs_map_async_finish(req, status); -- cgit From e23cc70a72e6582e91bcfdaf1d6ed2191e7e23a6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 19:03:06 +0000 Subject: r15760: - add RAW_READ_SMB2 => generic mapping - Implement SMB2 Read metze (This used to be commit d0ac0c5af44ba5aa8b18106c2ac26c0d194e59b4) --- source4/ntvfs/ntvfs_generic.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 119fef2c6d..922093a0a9 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1165,13 +1165,16 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, { switch (rd->generic.level) { case RAW_READ_READ: - rd->read.out.nread = rd2->generic.out.nread; + rd->read.out.nread = rd2->generic.out.nread; break; case RAW_READ_READBRAW: - rd->readbraw.out.nread = rd2->generic.out.nread; + rd->readbraw.out.nread = rd2->generic.out.nread; break; case RAW_READ_LOCKREAD: - rd->lockread.out.nread = rd2->generic.out.nread; + rd->lockread.out.nread = rd2->generic.out.nread; + break; + case RAW_READ_SMB2: + rd->smb2.out.data.length= rd2->generic.out.nread; break; default: return NT_STATUS_INVALID_LEVEL; @@ -1259,6 +1262,22 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, status = ntvfs->ops->read(ntvfs, req, rd2); } break; + + case RAW_READ_SMB2: + if (rd->smb2.in.length > UINT16_MAX) { + DEBUG(0,("%s: mapping SMB2 => generic length to large %u!\n", + __FUNCTION__, rd->smb2.in.length)); + status = NT_STATUS_FOOBAR; + goto done; + } + rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs; + rd2->readx.in.offset = rd->smb2.in.offset; + rd2->readx.in.mincnt = rd->smb2.in.length; + rd2->readx.in.maxcnt = rd->smb2.in.length; + rd2->readx.in.remaining = 0; + rd2->readx.out.data = rd->smb2.out.data.data; + status = ntvfs->ops->read(ntvfs, req, rd2); + break; } done: -- cgit From d9bdfb0a0720907151b71086be289a0f6ec2bb98 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 May 2006 17:21:38 +0000 Subject: r15814: add SMB2 Lock interface structure metze (This used to be commit 8f1850ef65dc8c860912639d787d82399d015f13) --- source4/ntvfs/ntvfs_generic.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 922093a0a9..3283ee673d 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -969,6 +969,9 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, lck2->generic.in.ulock_cnt = 1; lck2->generic.in.lock_cnt = 0; break; + + case RAW_LOCK_SMB2: + return NT_STATUS_INVALID_LEVEL; } lck2->generic.level = RAW_LOCK_GENERIC; -- cgit From d63dd113ae2c7f4f6d64def00a488548e805bc7e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Jun 2006 22:16:58 +0000 Subject: r16699: the layout of SMB2 Read and Write is identical... so we know that the 9th bytes is just uninitialized padding metze (This used to be commit f97a21b970ed23973cced2c67b5bc9ecd7afee88) --- source4/ntvfs/ntvfs_generic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 3283ee673d..5987ff4ba6 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1064,7 +1064,6 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, wr->smb2.out._pad = 0; wr->smb2.out.nwritten = wr2->generic.out.nwritten; wr->smb2.out.unknown1 = 0; - wr->smb2.out._bug = 0; break; default: -- cgit From 30ae843cbf9cd57c052941d3e58785ae5c854624 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 1 Jul 2006 14:04:28 +0000 Subject: r16730: that is correct... metze (This used to be commit 9c3992a27948f01803650c446914aa24be2a8d7a) --- source4/ntvfs/ntvfs_generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 5987ff4ba6..8c48e52b5c 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -215,8 +215,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, io->smb2.out.change_time = io2->generic.out.change_time; io->smb2.out.alloc_size = io2->generic.out.alloc_size; io->smb2.out.size = io2->generic.out.size; - /*io->smb2.out.file_attr = io2->generic.out.attrib; would this be correct? */ - io->smb2.out.file_attr = 0; + io->smb2.out.file_attr = io2->generic.out.attrib; io->smb2.out._pad = 0; io->smb2.out.blob = data_blob(NULL, 0); break; -- cgit From 1b45214f3186e3be045d09083c27017e67017cdd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 8 Jul 2006 07:37:05 +0000 Subject: r16868: init some uninitialized values (found by valgrind) metze (This used to be commit 1bb60b5be48fab7d84594283f58d2bc04c474b0c) --- source4/ntvfs/ntvfs_generic.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 8c48e52b5c..e0e69b25e1 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1176,6 +1176,7 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, break; case RAW_READ_SMB2: rd->smb2.out.data.length= rd2->generic.out.nread; + rd->smb2.out.unknown1 = 0; break; default: return NT_STATUS_INVALID_LEVEL; @@ -1307,11 +1308,13 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, case RAW_CLOSE_SPLCLOSE: cl2->generic.level = RAW_CLOSE_CLOSE; cl2->generic.in.file.ntvfs = cl->splclose.in.file.ntvfs; + cl2->generic.in.write_time = 0; break; case RAW_CLOSE_SMB2: cl2->generic.level = RAW_CLOSE_CLOSE; cl2->generic.in.file.ntvfs = cl->smb2.in.file.ntvfs; + cl2->generic.in.write_time = 0; /* SMB2 Close has output parameter, but we just zero them */ ZERO_STRUCT(cl->smb2.out); break; -- cgit From e1248154d6c42cd6780ce5e065a5877e983a7c9d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 17 Jul 2006 11:17:32 +0000 Subject: r17088: add ntvfs mapping function for notify metze (This used to be commit 7daf432d58ecebd10a28acd3ddbded9cb16536d0) --- source4/ntvfs/ntvfs_generic.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e0e69b25e1..aff05b70a8 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1327,3 +1327,67 @@ _PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, return ntvfs->ops->close(ntvfs, req, cl2); } + +/* + NTVFS notify generic to any mapper +*/ +static NTSTATUS ntvfs_map_notify_finish(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_notify *nt, + union smb_notify *nt2, + NTSTATUS status) +{ + NT_STATUS_NOT_OK_RETURN(status); + + switch (nt->nttrans.level) { + case RAW_NOTIFY_SMB2: + if (nt2->nttrans.out.num_changes == 0) { + return STATUS_NOTIFY_ENUM_DIR; + } + nt->smb2.out.num_changes = nt2->nttrans.out.num_changes; + nt->smb2.out.changes = talloc_steal(req, nt2->nttrans.out.changes); + break; + + default: + return NT_STATUS_INVALID_LEVEL; + } + + return status; +} + + +/* + NTVFS notify generic to any mapper +*/ +_PUBLIC_ NTSTATUS ntvfs_map_notify(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_notify *nt) +{ + union smb_notify *nt2; + NTSTATUS status; + + nt2 = talloc(req, union smb_notify); + NT_STATUS_HAVE_NO_MEMORY(nt2); + + status = ntvfs_map_async_setup(ntvfs, req, nt, nt2, + (second_stage_t)ntvfs_map_notify_finish); + NT_STATUS_NOT_OK_RETURN(status); + + nt2->nttrans.level = RAW_NOTIFY_NTTRANS; + + switch (nt->nttrans.level) { + case RAW_NOTIFY_NTTRANS: + status = NT_STATUS_INVALID_LEVEL; + break; + + case RAW_NOTIFY_SMB2: + nt2->nttrans.in.file.ntvfs = nt->smb2.in.file.ntvfs; + nt2->nttrans.in.buffer_size = nt->smb2.in.buffer_size; + nt2->nttrans.in.completion_filter = nt->smb2.in.completion_filter; + nt2->nttrans.in.recursive = nt->smb2.in.recursive; + status = ntvfs->ops->notify(ntvfs, req, nt2); + break; + } + + return ntvfs_map_async_finish(req, status); +} -- cgit From 921f73c7e58eac1900eb7ec9f7276cd3afaf0480 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 23 Sep 2006 02:19:15 +0000 Subject: r18835: expand IO limits on SMB2. Samba4 now tops out at 16.7MB IOs. (This used to be commit 1e34e4d5a1fd3d74080424140e4ab276b6042d12) --- source4/ntvfs/ntvfs_generic.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index aff05b70a8..aa6edcdf42 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1266,12 +1266,6 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, break; case RAW_READ_SMB2: - if (rd->smb2.in.length > UINT16_MAX) { - DEBUG(0,("%s: mapping SMB2 => generic length to large %u!\n", - __FUNCTION__, rd->smb2.in.length)); - status = NT_STATUS_FOOBAR; - goto done; - } rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs; rd2->readx.in.offset = rd->smb2.in.offset; rd2->readx.in.mincnt = rd->smb2.in.length; -- cgit From bd93b41d17361b0ee8aa050c8b7b85622846699d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 14 May 2007 13:47:03 +0000 Subject: r22849: map smb2 lock to the generic level metze (This used to be commit fbbb144f8e5271a543c0b47b0105eccd357477ba) --- source4/ntvfs/ntvfs_generic.c | 55 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index aa6edcdf42..05fb0df47b 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -33,6 +33,8 @@ #include "includes.h" #include "ntvfs/ntvfs.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" /* a second stage function converts from the out parameters of the generic call onto the out parameters of the specific call made */ @@ -960,27 +962,60 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; case RAW_LOCK_LOCK: + lck2->generic.level = RAW_LOCK_GENERIC; + lck2->generic.in.file.ntvfs= lck->lock.in.file.ntvfs; + lck2->generic.in.mode = 0; + lck2->generic.in.timeout = 0; lck2->generic.in.ulock_cnt = 0; lck2->generic.in.lock_cnt = 1; + lck2->generic.in.locks = locks; + locks->pid = req->smbpid; + locks->offset = lck->lock.in.offset; + locks->count = lck->lock.in.count; break; case RAW_LOCK_UNLOCK: + lck2->generic.level = RAW_LOCK_GENERIC; + lck2->generic.in.file.ntvfs= lck->unlock.in.file.ntvfs; + lck2->generic.in.mode = 0; + lck2->generic.in.timeout = 0; lck2->generic.in.ulock_cnt = 1; lck2->generic.in.lock_cnt = 0; + lck2->generic.in.locks = locks; + locks->pid = req->smbpid; + locks->offset = lck->unlock.in.offset; + locks->count = lck->unlock.in.count; break; case RAW_LOCK_SMB2: - return NT_STATUS_INVALID_LEVEL; - } + if (lck->smb2.in.unknown1 != 1) { + return NT_STATUS_INVALID_PARAMETER; + } + + lck2->generic.level = RAW_LOCK_GENERIC; + lck2->generic.in.file.ntvfs= lck->smb2.in.file.ntvfs; + if (lck->smb2.in.flags & SMB2_LOCK_FLAG_EXCLUSIV) { + lck2->generic.in.mode = 0; + } else { + lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; + } + lck2->generic.in.timeout = 0; + if (lck->smb2.in.flags & SMB2_LOCK_FLAG_UNLOCK) { + lck2->generic.in.ulock_cnt = 1; + lck2->generic.in.lock_cnt = 0; + } else { + lck2->generic.in.ulock_cnt = 0; + lck2->generic.in.lock_cnt = 1; + } + lck2->generic.in.locks = locks; + locks->pid = 0; + locks->offset = lck->smb2.in.offset; + locks->count = lck->smb2.in.count; - lck2->generic.level = RAW_LOCK_GENERIC; - lck2->generic.in.file.ntvfs= lck->lock.in.file.ntvfs; - lck2->generic.in.mode = 0; - lck2->generic.in.timeout = 0; - lck2->generic.in.locks = locks; - locks->pid = req->smbpid; - locks->offset = lck->lock.in.offset; - locks->count = lck->lock.in.count; + /* initialize output value */ + lck->smb2.out.unknown1 = 0; + break; + } /* * we don't need to call ntvfs_map_async_setup() here, -- cgit From 37f8c04d900df00dd984dfd6be33b367b145a3ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 14 May 2007 17:58:28 +0000 Subject: r22865: handle pending locks in smb2 metze (This used to be commit 8329fa689521b12e4ce2ac094b3e322fa4ed4bb8) --- source4/ntvfs/ntvfs_generic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 05fb0df47b..aa3009d86e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -999,7 +999,11 @@ _PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, } else { lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; } - lck2->generic.in.timeout = 0; + if (lck->smb2.in.flags & SMB2_LOCK_FLAG_NO_PENDING) { + lck2->generic.in.timeout = 0; + } else { + lck2->generic.in.timeout = UINT32_MAX; + } if (lck->smb2.in.flags & SMB2_LOCK_FLAG_UNLOCK) { lck2->generic.in.ulock_cnt = 1; lck2->generic.in.lock_cnt = 0; -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/ntvfs/ntvfs_generic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index aa3009d86e..8ed99ce3f1 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* this implements mappings between info levels for NTVFS backend calls -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/ntvfs/ntvfs_generic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 8ed99ce3f1..7708f4fc80 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -116,21 +116,21 @@ static NTSTATUS ntvfs_map_async_finish(struct ntvfs_request *req, NTSTATUS statu see if a filename ends in EXE COM DLL or SYM. This is needed for the DENY_DOS mapping for OpenX */ -BOOL is_exe_filename(const char *fname) +bool is_exe_filename(const char *fname) { char *p; p = strrchr(fname, '.'); if (!p) { - return False; + return false; } p++; if (strcasecmp(p, "EXE") == 0 || strcasecmp(p, "COM") == 0 || strcasecmp(p, "DLL") == 0 || strcasecmp(p, "SYM") == 0) { - return True; + return true; } - return False; + return false; } @@ -1247,7 +1247,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, } rd2->readx.level = RAW_READ_READX; - rd2->readx.in.read_for_execute = False; + rd2->readx.in.read_for_execute = false; switch (rd->generic.level) { case RAW_READ_READX: -- cgit From 158bd784fc235cc34287971ee04107742dc40cca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 17:36:41 +1100 Subject: missed another spot in the SMB2 create conversion (This used to be commit df82b0aa6990b59cde20893cb690a8a260526178) --- source4/ntvfs/ntvfs_generic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 7708f4fc80..5092e732b4 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -208,7 +208,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_SMB2: io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs; - io->smb2.out.oplock_flags = 0; + io->smb2.out.oplock_level = 0; io->smb2.out.create_action = io2->generic.out.create_action; io->smb2.out.create_time = io2->generic.out.create_time; io->smb2.out.access_time = io2->generic.out.access_time; @@ -217,7 +217,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, io->smb2.out.alloc_size = io2->generic.out.alloc_size; io->smb2.out.size = io2->generic.out.size; io->smb2.out.file_attr = io2->generic.out.attrib; - io->smb2.out._pad = 0; + io->smb2.out.reserved2 = 0; io->smb2.out.blob = data_blob(NULL, 0); break; @@ -486,13 +486,13 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, case RAW_OPEN_SMB2: io2->generic.in.flags = 0; io2->generic.in.root_fid = 0; - io2->generic.in.access_mask = io->smb2.in.access_mask; + io2->generic.in.access_mask = io->smb2.in.desired_access; io2->generic.in.alloc_size = 0; - io2->generic.in.file_attr = io->smb2.in.file_attr; + io2->generic.in.file_attr = io->smb2.in.file_attributes; io2->generic.in.share_access = io->smb2.in.share_access; - io2->generic.in.open_disposition= io->smb2.in.open_disposition; + io2->generic.in.open_disposition= io->smb2.in.create_disposition; io2->generic.in.create_options = io->smb2.in.create_options; - io2->generic.in.impersonation = io->smb2.in.impersonation; + io2->generic.in.impersonation = io->smb2.in.impersonation_level; io2->generic.in.security_flags = 0; io2->generic.in.fname = io->smb2.in.fname; io2->generic.in.sec_desc = NULL; -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/ntvfs/ntvfs_generic.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 5092e732b4..e1a86c07c0 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -361,7 +361,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode, /* NTVFS open generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { @@ -512,7 +512,7 @@ done: /* NTVFS fsinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { @@ -641,7 +641,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, /* NTVFS fileinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx, +NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx, union smb_fileinfo *info, union smb_fileinfo *info2) { @@ -872,7 +872,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx, /* NTVFS fileinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { @@ -905,7 +905,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, /* NTVFS pathinfo generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { @@ -939,7 +939,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, /* NTVFS lock generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *lck) { @@ -1114,7 +1114,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, /* NTVFS write generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { @@ -1226,7 +1226,7 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, /* NTVFS read* to readx mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { @@ -1322,7 +1322,7 @@ done: /* NTVFS close generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *cl) { @@ -1391,7 +1391,7 @@ static NTSTATUS ntvfs_map_notify_finish(struct ntvfs_module_context *ntvfs, /* NTVFS notify generic to any mapper */ -_PUBLIC_ NTSTATUS ntvfs_map_notify(struct ntvfs_module_context *ntvfs, +NTSTATUS ntvfs_map_notify(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_notify *nt) { -- cgit From 275f32ae2df333c089343dd20fc4efee1bed2b7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 Apr 2008 11:31:17 +0200 Subject: fill in unknown fields in SMB2 READ call (This used to be commit 9b686c138037f613da15168d0722786e00f023e5) --- source4/ntvfs/ntvfs_generic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e1a86c07c0..fee3269eaf 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1214,7 +1214,8 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, break; case RAW_READ_SMB2: rd->smb2.out.data.length= rd2->generic.out.nread; - rd->smb2.out.unknown1 = 0; + rd->smb2.out.remaining = 0; + rd->smb2.out.reserved = 0; break; default: return NT_STATUS_INVALID_LEVEL; -- cgit From baad7a7e56e2b0f24885e01672cd9bdc6667a6a8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 17 Apr 2008 03:54:26 +0200 Subject: ntvfs_generic: map SMB2 oplock levels to the generic ones metze (This used to be commit 9013748273378f88bfc66d3583814f0fee67c40f) --- source4/ntvfs/ntvfs_generic.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index fee3269eaf..5d4bbf388c 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -208,7 +208,21 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_SMB2: io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs; - io->smb2.out.oplock_level = 0; + switch (io2->generic.out.oplock_level) { + case OPLOCK_BATCH: + io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_BATCH; + break; + case OPLOCK_EXCLUSIVE: + io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_EXCLUSIVE; + break; + case OPLOCK_LEVEL_II: + io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_II; + break; + default: + io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_NONE; + break; + } + io->smb2.out.reserved = 0; io->smb2.out.create_action = io2->generic.out.create_action; io->smb2.out.create_time = io2->generic.out.create_time; io->smb2.out.access_time = io2->generic.out.access_time; @@ -484,7 +498,18 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, status = ntvfs->ops->open(ntvfs, req, io2); break; case RAW_OPEN_SMB2: - io2->generic.in.flags = 0; + switch (io->smb2.in.oplock_level) { + case SMB2_OPLOCK_LEVEL_BATCH: + io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK | + NTCREATEX_FLAGS_REQUEST_OPLOCK; + break; + case SMB2_OPLOCK_LEVEL_EXCLUSIVE: + io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_OPLOCK; + break; + default: + io2->generic.in.flags = 0; + break; + } io2->generic.in.root_fid = 0; io2->generic.in.access_mask = io->smb2.in.desired_access; io2->generic.in.alloc_size = 0; -- cgit From b2f2c1486e9c6bd6fdba3dc321f9df0d29d7def2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 19 Apr 2008 00:14:52 +0200 Subject: ntvfs_generic: fix mapping the granted oplocks for SMB2 metze (This used to be commit 60c4a4fc1afe88716ac63d3ea430e07fea7b9991) --- source4/ntvfs/ntvfs_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 5d4bbf388c..debcfc3f8a 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -209,13 +209,13 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, case RAW_OPEN_SMB2: io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs; switch (io2->generic.out.oplock_level) { - case OPLOCK_BATCH: + case BATCH_OPLOCK_RETURN: io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_BATCH; break; - case OPLOCK_EXCLUSIVE: + case EXCLUSIVE_OPLOCK_RETURN: io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_EXCLUSIVE; break; - case OPLOCK_LEVEL_II: + case LEVEL_II_OPLOCK_RETURN: io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_II; break; default: -- cgit From 39d23027218c02dc3055d8a0cc28dcc169e8b064 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Apr 2008 22:32:25 +0200 Subject: ntvfs_generic: map RAW_LOCK_SMB2_BREAK to RAW_LOCK_GENERIC metze (This used to be commit b781bb733c9a563457f87c94abe8c91b426c07ee) --- source4/ntvfs/ntvfs_generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index debcfc3f8a..3653ad82c1 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1043,6 +1043,23 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, /* initialize output value */ lck->smb2.out.unknown1 = 0; break; + + case RAW_LOCK_SMB2_BREAK: + lck2->generic.level = RAW_LOCK_GENERIC; + lck2->generic.in.file.ntvfs = lck->smb2_break.in.file.ntvfs; + lck2->generic.in.mode = LOCKING_ANDX_OPLOCK_RELEASE | + ((lck->smb2_break.in.oplock_level << 8) & 0xFF00); + lck2->generic.in.timeout = 0; + lck2->generic.in.ulock_cnt = 0; + lck2->generic.in.lock_cnt = 0; + lck2->generic.in.locks = NULL; + + /* initialize output value */ + lck->smb2_break.out.oplock_level= lck->smb2_break.in.oplock_level; + lck->smb2_break.out.reserved = lck->smb2_break.in.reserved; + lck->smb2_break.out.reserved2 = lck->smb2_break.in.reserved2; + lck->smb2_break.out.file = lck->smb2_break.in.file; + break; } /* -- cgit From 4d39976dddf2adf6a0d659050c3a21a6e0ff8ab2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 May 2008 22:12:20 +1000 Subject: fixed SMB2 locking - SMB2 locking is different in several ways from SMB locking. To fix it properly we will need a new generic mapping structure for locking, but for now do a best effort mapping - added locking to gentest_smb2 (This used to be commit ea6d9cf602302adafe0f9d5f5f90a9b26d1ead6f) --- source4/ntvfs/ntvfs_generic.c | 62 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 22 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 3653ad82c1..a706e621c9 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1011,38 +1011,56 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, locks->count = lck->unlock.in.count; break; - case RAW_LOCK_SMB2: - if (lck->smb2.in.unknown1 != 1) { + case RAW_LOCK_SMB2: { + /* this is only approximate! We need to change the + generic structure to fix this properly */ + int i; + if (lck->smb2.in.lock_count < 1) { return NT_STATUS_INVALID_PARAMETER; } lck2->generic.level = RAW_LOCK_GENERIC; lck2->generic.in.file.ntvfs= lck->smb2.in.file.ntvfs; - if (lck->smb2.in.flags & SMB2_LOCK_FLAG_EXCLUSIV) { - lck2->generic.in.mode = 0; - } else { - lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; + lck2->generic.in.timeout = UINT32_MAX; + lck2->generic.in.mode = 0; + lck2->generic.in.lock_cnt = 0; + lck2->generic.in.ulock_cnt = 0; + lck2->generic.in.locks = talloc_zero_array(lck2, struct smb_lock_entry, + lck->smb2.in.lock_count); + if (lck2->generic.in.locks == NULL) { + return NT_STATUS_NO_MEMORY; } - if (lck->smb2.in.flags & SMB2_LOCK_FLAG_NO_PENDING) { - lck2->generic.in.timeout = 0; - } else { - lck2->generic.in.timeout = UINT32_MAX; + for (i=0;ismb2.in.lock_count;i++) { + if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { + int j = lck2->generic.in.ulock_cnt; + lck2->generic.in.ulock_cnt++; + lck2->generic.in.locks[j].pid = 0; + lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; + lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; + lck2->generic.in.locks[j].pid = 0; + } } - if (lck->smb2.in.flags & SMB2_LOCK_FLAG_UNLOCK) { - lck2->generic.in.ulock_cnt = 1; - lck2->generic.in.lock_cnt = 0; - } else { - lck2->generic.in.ulock_cnt = 0; - lck2->generic.in.lock_cnt = 1; + for (i=0;ismb2.in.lock_count;i++) { + if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { + int j = lck2->generic.in.ulock_cnt + + lck2->generic.in.lock_cnt; + lck2->generic.in.lock_cnt++; + lck2->generic.in.locks[j].pid = 0; + lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; + lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; + lck2->generic.in.locks[j].pid = 0; + if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { + lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; + } + if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) { + lck2->generic.in.timeout = 0; + } + } } - lck2->generic.in.locks = locks; - locks->pid = 0; - locks->offset = lck->smb2.in.offset; - locks->count = lck->smb2.in.count; - /* initialize output value */ - lck->smb2.out.unknown1 = 0; + lck->smb2.out.reserved = 0; break; + } case RAW_LOCK_SMB2_BREAK: lck2->generic.level = RAW_LOCK_GENERIC; -- cgit From 2e0f61a18ab002a90faa06477fa258e36b8a5fc0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 May 2008 23:07:16 +1000 Subject: SMB2 read returns NT_STATUS_END_OF_FILE on read past end of file (This used to be commit 1590494daf5abe43e43402e7602f92267bcda34b) --- source4/ntvfs/ntvfs_generic.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index a706e621c9..62a1427405 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1276,6 +1276,11 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, rd->smb2.out.data.length= rd2->generic.out.nread; rd->smb2.out.remaining = 0; rd->smb2.out.reserved = 0; + if (NT_STATUS_IS_OK(status) && + rd->smb2.out.data.length == 0 && + rd->smb2.in.length != 0) { + status = NT_STATUS_END_OF_FILE; + } break; default: return NT_STATUS_INVALID_LEVEL; -- cgit From 2ad2bdda89c07c0b8ce754c3b0cd4664eefc697d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 May 2008 15:02:43 +1000 Subject: stricter checks for valid inputs in SMB2 open and lock (This used to be commit a7b5689a73adde59de28770aa3949660441291ea) --- source4/ntvfs/ntvfs_generic.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 62a1427405..9b4f235cde 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -522,6 +522,12 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, io2->generic.in.fname = io->smb2.in.fname; io2->generic.in.sec_desc = NULL; io2->generic.in.ea_list = NULL; + + /* we use a couple of bits of the create options internally */ + if (io2->generic.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) { + return NT_STATUS_INVALID_PARAMETER; + } + status = ntvfs->ops->open(ntvfs, req, io2); break; @@ -1031,6 +1037,9 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } for (i=0;ismb2.in.lock_count;i++) { + if (lck->smb2.in.locks[i].flags & ~SMB2_LOCK_FLAG_ALL_MASK) { + return NT_STATUS_INVALID_PARAMETER; + } if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { int j = lck2->generic.in.ulock_cnt; lck2->generic.in.ulock_cnt++; @@ -1277,10 +1286,15 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, rd->smb2.out.remaining = 0; rd->smb2.out.reserved = 0; if (NT_STATUS_IS_OK(status) && - rd->smb2.out.data.length == 0 && - rd->smb2.in.length != 0) { + rd->smb2.out.data.length == 0) { status = NT_STATUS_END_OF_FILE; } + /* SMB2 does honor the min_count field, SMB does not */ + if (NT_STATUS_IS_OK(status) && + rd->smb2.in.min_count > rd->smb2.out.data.length) { + rd->smb2.out.data.length = 0; + status = NT_STATUS_END_OF_FILE; + } break; default: return NT_STATUS_INVALID_LEVEL; -- cgit From 506849f6008386dad5baa287e7e81a73af031622 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 May 2008 12:42:43 +1000 Subject: check invalid create options in the right order (This used to be commit 73dbfb9b4148dbfdc30518c08db4658d189f4160) --- source4/ntvfs/ntvfs_generic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 9b4f235cde..c5b88da3d1 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -523,9 +523,16 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, io2->generic.in.sec_desc = NULL; io2->generic.in.ea_list = NULL; + /* we need to check these bits before we check the private mask */ + if (io2->generic.in.create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) { + status = NT_STATUS_NOT_SUPPORTED; + break; + } + /* we use a couple of bits of the create options internally */ if (io2->generic.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) { - return NT_STATUS_INVALID_PARAMETER; + status = NT_STATUS_INVALID_PARAMETER; + break; } status = ntvfs->ops->open(ntvfs, req, io2); -- cgit From 848e7c5830a869d86d7fe236acc1e6a1949252d3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 May 2008 16:02:10 +1000 Subject: it seems that lock flags are only validated when UNLOCK is set (This used to be commit d1bde5830cd56042236d72598e5cfe9c7abc4c47) --- source4/ntvfs/ntvfs_generic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index c5b88da3d1..e449e61b34 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1044,11 +1044,12 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } for (i=0;ismb2.in.lock_count;i++) { - if (lck->smb2.in.locks[i].flags & ~SMB2_LOCK_FLAG_ALL_MASK) { - return NT_STATUS_INVALID_PARAMETER; - } if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { int j = lck2->generic.in.ulock_cnt; + if (lck->smb2.in.locks[i].flags & + (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) { + return NT_STATUS_INVALID_PARAMETER; + } lck2->generic.in.ulock_cnt++; lck2->generic.in.locks[j].pid = 0; lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; -- cgit From cb36437db2d75e7facc91cf0089f2caa20bf0ca0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 May 2008 16:43:36 +1000 Subject: added support for the output fields of SMB2 close (This used to be commit 2633bc749792c224acc73a2e4ca723404331c19c) --- source4/ntvfs/ntvfs_generic.c | 63 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index e449e61b34..a1c89e7df4 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1407,6 +1407,36 @@ done: } +/* + NTVFS close generic to any mapper +*/ +static NTSTATUS ntvfs_map_close_finish(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + union smb_close *cl, + union smb_close *cl2, + NTSTATUS status) +{ + NT_STATUS_NOT_OK_RETURN(status); + + switch (cl->generic.level) { + case RAW_CLOSE_SMB2: + cl->smb2.out.flags = cl2->generic.out.flags; + cl->smb2.out._pad = 0; + cl->smb2.out.create_time = cl2->generic.out.create_time; + cl->smb2.out.access_time = cl2->generic.out.access_time; + cl->smb2.out.write_time = cl2->generic.out.write_time; + cl->smb2.out.change_time = cl2->generic.out.change_time; + cl->smb2.out.alloc_size = cl2->generic.out.alloc_size; + cl->smb2.out.size = cl2->generic.out.size; + cl->smb2.out.file_attr = cl2->generic.out.file_attr; + break; + default: + break; + } + + return status; +} + /* NTVFS close generic to any mapper */ @@ -1415,6 +1445,7 @@ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, union smb_close *cl) { union smb_close *cl2; + NTSTATUS status; cl2 = talloc(req, union smb_close); if (cl2 == NULL) { @@ -1422,30 +1453,38 @@ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs, } switch (cl->generic.level) { - case RAW_CLOSE_CLOSE: + case RAW_CLOSE_GENERIC: return NT_STATUS_INVALID_LEVEL; + case RAW_CLOSE_CLOSE: + cl2->generic.level = RAW_CLOSE_GENERIC; + cl2->generic.in.file = cl->close.in.file; + cl2->generic.in.write_time = cl->close.in.write_time; + cl2->generic.in.flags = 0; + break; + case RAW_CLOSE_SPLCLOSE: - cl2->generic.level = RAW_CLOSE_CLOSE; - cl2->generic.in.file.ntvfs = cl->splclose.in.file.ntvfs; + cl2->generic.level = RAW_CLOSE_GENERIC; + cl2->generic.in.file = cl->splclose.in.file; cl2->generic.in.write_time = 0; + cl2->generic.in.flags = 0; break; case RAW_CLOSE_SMB2: - cl2->generic.level = RAW_CLOSE_CLOSE; - cl2->generic.in.file.ntvfs = cl->smb2.in.file.ntvfs; + cl2->generic.level = RAW_CLOSE_GENERIC; + cl2->generic.in.file = cl->smb2.in.file; cl2->generic.in.write_time = 0; - /* SMB2 Close has output parameter, but we just zero them */ - ZERO_STRUCT(cl->smb2.out); + cl2->generic.in.flags = cl->smb2.in.flags; break; } - /* - * we don't need to call ntvfs_map_async_setup() here, - * as close() doesn't have any output fields - */ + status = ntvfs_map_async_setup(ntvfs, req, cl, cl2, + (second_stage_t)ntvfs_map_close_finish); + NT_STATUS_NOT_OK_RETURN(status); + + status = ntvfs->ops->close(ntvfs, req, cl2); - return ntvfs->ops->close(ntvfs, req, cl2); + return ntvfs_map_async_finish(req, status); } /* -- cgit From beac55a88fd28b6003ba163f32539a7bdc2df1a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 May 2008 17:22:02 +1000 Subject: enforce lock ordering in SMB2 (This used to be commit 3bec932a89006521ba74bde7943b8cd5b4a660d8) --- source4/ntvfs/ntvfs_generic.c | 56 ++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index a1c89e7df4..3d92c0be33 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1027,7 +1027,7 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, case RAW_LOCK_SMB2: { /* this is only approximate! We need to change the generic structure to fix this properly */ - int i; + int i, j; if (lck->smb2.in.lock_count < 1) { return NT_STATUS_INVALID_PARAMETER; } @@ -1044,34 +1044,36 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } for (i=0;ismb2.in.lock_count;i++) { - if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { - int j = lck2->generic.in.ulock_cnt; - if (lck->smb2.in.locks[i].flags & - (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) { - return NT_STATUS_INVALID_PARAMETER; - } - lck2->generic.in.ulock_cnt++; - lck2->generic.in.locks[j].pid = 0; - lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; - lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; - lck2->generic.in.locks[j].pid = 0; + if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { + break; + } + j = lck2->generic.in.ulock_cnt; + if (lck->smb2.in.locks[i].flags & + (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) { + return NT_STATUS_INVALID_PARAMETER; } + lck2->generic.in.ulock_cnt++; + lck2->generic.in.locks[j].pid = 0; + lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; + lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; + lck2->generic.in.locks[j].pid = 0; } - for (i=0;ismb2.in.lock_count;i++) { - if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { - int j = lck2->generic.in.ulock_cnt + - lck2->generic.in.lock_cnt; - lck2->generic.in.lock_cnt++; - lck2->generic.in.locks[j].pid = 0; - lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; - lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; - lck2->generic.in.locks[j].pid = 0; - if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { - lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; - } - if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) { - lck2->generic.in.timeout = 0; - } + for (;ismb2.in.lock_count;i++) { + if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { + /* w2008 requires unlocks to come first */ + return NT_STATUS_INVALID_PARAMETER; + } + j = lck2->generic.in.ulock_cnt + lck2->generic.in.lock_cnt; + lck2->generic.in.lock_cnt++; + lck2->generic.in.locks[j].pid = 0; + lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; + lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; + lck2->generic.in.locks[j].pid = 0; + if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { + lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; + } + if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) { + lck2->generic.in.timeout = 0; } } /* initialize output value */ -- cgit From 8daeee5c5d7d5851677089cceaf26a0e32675a96 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 May 2008 18:20:23 +1000 Subject: ensure that we honor SMB2 read min_count properly (This used to be commit 318038d6f670efffa96d8b0db63f46b3752e1cd3) --- source4/ntvfs/ntvfs_generic.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 3d92c0be33..06d89a717b 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1295,16 +1295,6 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, rd->smb2.out.data.length= rd2->generic.out.nread; rd->smb2.out.remaining = 0; rd->smb2.out.reserved = 0; - if (NT_STATUS_IS_OK(status) && - rd->smb2.out.data.length == 0) { - status = NT_STATUS_END_OF_FILE; - } - /* SMB2 does honor the min_count field, SMB does not */ - if (NT_STATUS_IS_OK(status) && - rd->smb2.in.min_count > rd->smb2.out.data.length) { - rd->smb2.out.data.length = 0; - status = NT_STATUS_END_OF_FILE; - } break; default: return NT_STATUS_INVALID_LEVEL; @@ -1396,7 +1386,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, case RAW_READ_SMB2: rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs; rd2->readx.in.offset = rd->smb2.in.offset; - rd2->readx.in.mincnt = rd->smb2.in.length; + rd2->readx.in.mincnt = rd->smb2.in.min_count; rd2->readx.in.maxcnt = rd->smb2.in.length; rd2->readx.in.remaining = 0; rd2->readx.out.data = rd->smb2.out.data.data; -- cgit From 6b707263058ec69f12a6235890005a226c8671de Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 May 2008 16:28:37 +1000 Subject: implement the documented SMB2 create blobs in the server Not all of them are honoured yet, but they are all parsed and the ones that have SMB equivalents are honoured (This used to be commit 9fc70e2ed6a54f6d9a0530f4d37c0f8acadb6778) --- source4/ntvfs/ntvfs_generic.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 06d89a717b..9227295696 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -207,6 +207,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, break; case RAW_OPEN_SMB2: + ZERO_STRUCT(io->smb2.out); io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs; switch (io2->generic.out.oplock_level) { case BATCH_OPLOCK_RETURN: @@ -232,7 +233,6 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, io->smb2.out.size = io2->generic.out.size; io->smb2.out.file_attr = io2->generic.out.attrib; io->smb2.out.reserved2 = 0; - io->smb2.out.blob = data_blob(NULL, 0); break; default: @@ -512,7 +512,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, } io2->generic.in.root_fid = 0; io2->generic.in.access_mask = io->smb2.in.desired_access; - io2->generic.in.alloc_size = 0; + io2->generic.in.alloc_size = io->smb2.in.alloc_size; io2->generic.in.file_attr = io->smb2.in.file_attributes; io2->generic.in.share_access = io->smb2.in.share_access; io2->generic.in.open_disposition= io->smb2.in.create_disposition; @@ -520,8 +520,14 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, io2->generic.in.impersonation = io->smb2.in.impersonation_level; io2->generic.in.security_flags = 0; io2->generic.in.fname = io->smb2.in.fname; - io2->generic.in.sec_desc = NULL; - io2->generic.in.ea_list = NULL; + io2->generic.in.sec_desc = io->smb2.in.sec_desc; + io2->generic.in.ea_list = &io->smb2.in.eas; + + /* we don't support timewarp yet */ + if (io->smb2.in.timewarp != 0) { + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + break; + } /* we need to check these bits before we check the private mask */ if (io2->generic.in.create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) { -- cgit From c86dc11be6e626fa81f025d7ec78226fb4249cdc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 May 2008 19:16:26 +1000 Subject: added support for returning the maximal access MXAC tag in SMB2 create (This used to be commit 4eb49335d5f0319f9aa47ded5215a2977d3336bf) --- source4/ntvfs/ntvfs_generic.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 9227295696..d705758475 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -233,6 +233,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, io->smb2.out.size = io2->generic.out.size; io->smb2.out.file_attr = io2->generic.out.attrib; io->smb2.out.reserved2 = 0; + io->smb2.out.maximal_access = io2->generic.out.maximal_access; break; default: @@ -522,6 +523,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, io2->generic.in.fname = io->smb2.in.fname; io2->generic.in.sec_desc = io->smb2.in.sec_desc; io2->generic.in.ea_list = &io->smb2.in.eas; + io2->generic.in.query_maximal_access = io->smb2.in.query_maximal_access; /* we don't support timewarp yet */ if (io->smb2.in.timewarp != 0) { -- cgit From 8da3217d1b6b8b7a7b977c1722bc6ad39df49762 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 2 Jun 2008 11:04:13 +1000 Subject: smbpid is 32 bit, and update SMB2 locking per MS-SMB2 The UNLOCK bit is only used from the first lock structure (This used to be commit 9483b7c137b61d3029a1e1e7d8d8d0723b541129) --- source4/ntvfs/ntvfs_generic.c | 45 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index d705758475..a3a8fcb1f4 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -986,8 +986,8 @@ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, NTVFS lock generic to any mapper */ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, - union smb_lock *lck) + struct ntvfs_request *req, + union smb_lock *lck) { union smb_lock *lck2; struct smb_lock_entry *locks; @@ -1035,7 +1035,8 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, case RAW_LOCK_SMB2: { /* this is only approximate! We need to change the generic structure to fix this properly */ - int i, j; + int i; + bool isunlock; if (lck->smb2.in.lock_count < 1) { return NT_STATUS_INVALID_PARAMETER; } @@ -1051,32 +1052,24 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, if (lck2->generic.in.locks == NULL) { return NT_STATUS_NO_MEMORY; } - for (i=0;ismb2.in.lock_count;i++) { - if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { - break; - } - j = lck2->generic.in.ulock_cnt; - if (lck->smb2.in.locks[i].flags & - (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) { - return NT_STATUS_INVALID_PARAMETER; - } - lck2->generic.in.ulock_cnt++; - lck2->generic.in.locks[j].pid = 0; - lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; - lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; - lck2->generic.in.locks[j].pid = 0; + /* only the first lock gives the UNLOCK bit - see + MS-SMB2 3.3.5.14 */ + if (lck->smb2.in.locks[0].flags & SMB2_LOCK_FLAG_UNLOCK) { + lck2->generic.in.ulock_cnt = lck->smb2.in.lock_count; + isunlock = true; + } else { + lck2->generic.in.lock_cnt = lck->smb2.in.lock_count; + isunlock = false; } - for (;ismb2.in.lock_count;i++) { - if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { - /* w2008 requires unlocks to come first */ + for (i=0;ismb2.in.lock_count;i++) { + if (isunlock && + (lck->smb2.in.locks[i].flags & + (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE))) { return NT_STATUS_INVALID_PARAMETER; } - j = lck2->generic.in.ulock_cnt + lck2->generic.in.lock_cnt; - lck2->generic.in.lock_cnt++; - lck2->generic.in.locks[j].pid = 0; - lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; - lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; - lck2->generic.in.locks[j].pid = 0; + lck2->generic.in.locks[i].pid = req->smbpid; + lck2->generic.in.locks[i].offset = lck->smb2.in.locks[i].offset; + lck2->generic.in.locks[i].count = lck->smb2.in.locks[i].length; if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; } -- cgit From 538f624fe02b9420fe44a5c32e0d0fcf6fcf1359 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 3 Jun 2008 09:36:02 +1000 Subject: it is not valid to set a UNLOCK flag on a lock request (This used to be commit 63f315572969e7fc52bdc7c0b38eaaee736d5e2a) --- source4/ntvfs/ntvfs_generic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index a3a8fcb1f4..4f3a7e2198 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1067,9 +1067,13 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE))) { return NT_STATUS_INVALID_PARAMETER; } - lck2->generic.in.locks[i].pid = req->smbpid; + if (!isunlock && + (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { + return NT_STATUS_INVALID_PARAMETER; + } + lck2->generic.in.locks[i].pid = req->smbpid; lck2->generic.in.locks[i].offset = lck->smb2.in.locks[i].offset; - lck2->generic.in.locks[i].count = lck->smb2.in.locks[i].length; + lck2->generic.in.locks[i].count = lck->smb2.in.locks[i].length; if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; } -- cgit From 548ed8d9586bbf9504bec5064a14893f5827b0e4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Aug 2008 09:52:45 +0200 Subject: ntvfs_generic: fix handling of create_options for SMB2 metze (This used to be commit cbd585d2a1e179615eba773cb07385524369c686) --- source4/ntvfs/ntvfs_generic.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/ntvfs_generic.c') diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 4f3a7e2198..c34bb7125e 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -532,16 +532,14 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, } /* we need to check these bits before we check the private mask */ - if (io2->generic.in.create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) { + if (io2->generic.in.create_options & SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK) { status = NT_STATUS_NOT_SUPPORTED; break; } - /* we use a couple of bits of the create options internally */ - if (io2->generic.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) { - status = NT_STATUS_INVALID_PARAMETER; - break; - } + /* TODO: find out why only SMB2 ignores these */ + io2->generic.in.create_options &= ~NTCREATEX_OPTIONS_SYNC_ALERT; + io2->generic.in.create_options &= ~NTCREATEX_OPTIONS_ASYNC_ALERT; status = ntvfs->ops->open(ntvfs, req, io2); break; -- cgit