2 Unix SMB/CIFS implementation.
4 POSIX NTVFS backend - read
6 Copyright (C) Andrew Tridgell 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "include/includes.h"
24 #include "vfs_posix.h"
29 NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs,
30 struct smbsrv_request *req, union smb_read *rd)
32 struct pvfs_state *pvfs = ntvfs->private_data;
38 if (rd->generic.level != RAW_READ_READX) {
39 return ntvfs_map_read(req, rd, ntvfs);
42 f = pvfs_find_fd(pvfs, req, rd->readx.in.fnum);
44 return NT_STATUS_INVALID_HANDLE;
47 if (f->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
48 return NT_STATUS_FILE_IS_A_DIRECTORY;
51 if (!(f->access_mask & SA_RIGHT_FILE_READ_DATA)) {
52 return NT_STATUS_ACCESS_VIOLATION;
55 maxcnt = rd->readx.in.maxcnt;
56 if (maxcnt > UINT16_MAX) {
60 status = pvfs_check_lock(pvfs, f, req->smbpid,
64 if (!NT_STATUS_IS_OK(status)) {
73 return pvfs_map_errno(pvfs, errno);
76 f->position = f->seek_offset = rd->readx.in.offset + ret;
78 rd->readx.out.nread = ret;
79 rd->readx.out.remaining = 0xFFFF;
80 rd->readx.out.compaction_mode = 0;