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"
28 approximately map a struct pvfs_filename to a generic fileinfo struct
30 static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
31 struct pvfs_filename *name, union smb_fileinfo *info)
33 info->generic.out.create_time = name->dos.create_time;
34 info->generic.out.access_time = name->dos.access_time;
35 info->generic.out.write_time = name->dos.write_time;
36 info->generic.out.change_time = name->dos.change_time;
38 info->generic.out.alloc_size = name->dos.alloc_size;
39 info->generic.out.size = name->st.st_size;
40 info->generic.out.attrib = name->dos.attrib;
41 info->generic.out.nlink = name->dos.nlink;
42 info->generic.out.directory = (name->dos.attrib&FILE_ATTRIBUTE_DIRECTORY)?1:0;
43 info->generic.out.file_id = name->dos.file_id;
45 /* REWRITE: TODO stuff in here */
46 info->generic.out.delete_pending = 0;
47 info->generic.out.ea_size = 0;
48 info->generic.out.num_eas = 0;
49 info->generic.out.fname.s = name->original_name;
50 info->generic.out.alt_fname.s = pvfs_short_name(pvfs, name);
51 info->generic.out.compressed_size = name->st.st_size;
52 info->generic.out.format = 0;
53 info->generic.out.unit_shift = 0;
54 info->generic.out.chunk_shift = 0;
55 info->generic.out.cluster_shift = 0;
57 info->generic.out.access_flags = 0;
58 info->generic.out.position = 0;
59 info->generic.out.mode = 0;
60 info->generic.out.alignment_requirement = 0;
61 info->generic.out.reparse_tag = 0;
63 /* setup a single data stream */
64 info->generic.out.num_streams = 1;
65 info->generic.out.streams = talloc_array_p(mem_ctx,
67 info->generic.out.num_streams);
68 if (!info->generic.out.streams) {
69 return NT_STATUS_NO_MEMORY;
71 info->generic.out.streams[0].size = name->st.st_size;
72 info->generic.out.streams[0].alloc_size = name->st.st_size;
73 info->generic.out.streams[0].stream_name.s = talloc_strdup(mem_ctx, "::$DATA");
79 return info on a pathname
81 NTSTATUS pvfs_qpathinfo(struct ntvfs_module_context *ntvfs,
82 struct smbsrv_request *req, union smb_fileinfo *info)
84 struct pvfs_state *pvfs = ntvfs->private_data;
85 struct pvfs_filename *name;
88 if (info->generic.level != RAW_FILEINFO_GENERIC) {
89 return ntvfs_map_qpathinfo(req, info, ntvfs);
92 /* resolve the cifs name to a posix name */
93 status = pvfs_resolve_name(pvfs, req, info->generic.in.fname, PVFS_RESOLVE_NO_WILDCARD, &name);
94 if (!NT_STATUS_IS_OK(status)) {
99 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
102 return pvfs_map_fileinfo(pvfs, req, name, info);
106 query info on a open file
108 NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
109 struct smbsrv_request *req, union smb_fileinfo *info)
111 struct pvfs_state *pvfs = ntvfs->private_data;
115 if (info->generic.level != RAW_FILEINFO_GENERIC) {
116 return ntvfs_map_qfileinfo(req, info, ntvfs);
119 f = pvfs_find_fd(pvfs, req, info->generic.in.fnum);
121 return NT_STATUS_INVALID_HANDLE;
124 /* update the file information */
125 status = pvfs_resolve_name_fd(pvfs, f->fd, f->name);
126 if (!NT_STATUS_IS_OK(status)) {
130 return pvfs_map_fileinfo(pvfs, req, f->name, info);