summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_qfileinfo.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-20 07:28:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:52 -0500
commit8a1c3ddd947039bf3b62efd94d3429359b593e15 (patch)
tree624a515f2654edd6854e7567173d9ce083eb925d /source4/ntvfs/posix/pvfs_qfileinfo.c
parent421c0d2a187481c74ebee0937be9ba0a47752fa6 (diff)
downloadsamba-8a1c3ddd947039bf3b62efd94d3429359b593e15.tar.gz
samba-8a1c3ddd947039bf3b62efd94d3429359b593e15.tar.bz2
samba-8a1c3ddd947039bf3b62efd94d3429359b593e15.zip
r2436: the second big lump of posix vfs code.
this is still just a skeleton, and many of the functions are just based on the simple vfs backend, they are there to allow me to run smbtorture tests against the real parts of the posix backend. (This used to be commit f2fa7fe565e89360dba3bb5434d3a6a36f398348)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_qfileinfo.c')
-rw-r--r--source4/ntvfs/posix/pvfs_qfileinfo.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
new file mode 100644
index 0000000000..691ba91532
--- /dev/null
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -0,0 +1,129 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ POSIX NTVFS backend - read
+
+ Copyright (C) Andrew Tridgell 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
+ 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.
+*/
+
+#include "include/includes.h"
+#include "vfs_posix.h"
+
+
+/*
+ approximately map a struct pvfs_filename to a generic fileinfo struct
+*/
+static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
+ struct pvfs_filename *name, union smb_fileinfo *info)
+{
+ info->generic.out.create_time = name->dos.create_time;
+ info->generic.out.access_time = name->dos.access_time;
+ info->generic.out.write_time = name->dos.write_time;
+ info->generic.out.change_time = name->dos.change_time;
+
+ info->generic.out.alloc_size = name->dos.alloc_size;
+ info->generic.out.size = name->st.st_size;
+ info->generic.out.attrib = name->dos.attrib;
+ info->generic.out.nlink = name->dos.nlink;
+ info->generic.out.directory = (name->dos.attrib&FILE_ATTRIBUTE_DIRECTORY)?1:0;
+ info->generic.out.file_id = name->dos.file_id;
+
+ /* REWRITE: TODO stuff in here */
+ info->generic.out.delete_pending = 0;
+ info->generic.out.ea_size = 0;
+ info->generic.out.num_eas = 0;
+ info->generic.out.fname.s = name->original_name;
+ info->generic.out.alt_fname.s = pvfs_short_name(pvfs, name);
+ info->generic.out.compressed_size = name->st.st_size;
+ info->generic.out.format = 0;
+ info->generic.out.unit_shift = 0;
+ info->generic.out.chunk_shift = 0;
+ info->generic.out.cluster_shift = 0;
+
+ info->generic.out.access_flags = 0;
+ info->generic.out.position = 0;
+ info->generic.out.mode = 0;
+ info->generic.out.alignment_requirement = 0;
+ info->generic.out.reparse_tag = 0;
+
+ /* setup a single data stream */
+ info->generic.out.num_streams = 1;
+ info->generic.out.streams = talloc_array_p(mem_ctx,
+ struct stream_struct,
+ info->generic.out.num_streams);
+ if (!info->generic.out.streams) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ info->generic.out.streams[0].size = name->st.st_size;
+ info->generic.out.streams[0].alloc_size = name->st.st_size;
+ info->generic.out.streams[0].stream_name.s = talloc_strdup(mem_ctx, "::$DATA");
+
+ return NT_STATUS_OK;
+}
+
+/*
+ return info on a pathname
+*/
+NTSTATUS pvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
+{
+ struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ struct pvfs_filename *name;
+ NTSTATUS status;
+
+ if (info->generic.level != RAW_FILEINFO_GENERIC) {
+ return ntvfs_map_qpathinfo(req, info);
+ }
+
+ /* resolve the cifs name to a posix name */
+ status = pvfs_resolve_name(pvfs, req, info->generic.in.fname, PVFS_RESOLVE_NO_WILDCARD, &name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (!name->exists) {
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ return pvfs_map_fileinfo(pvfs, req, name, info);
+}
+
+/*
+ query info on a open file
+*/
+NTSTATUS pvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
+{
+ struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ struct pvfs_file *f;
+ NTSTATUS status;
+
+ if (info->generic.level != RAW_FILEINFO_GENERIC) {
+ return ntvfs_map_qfileinfo(req, info);
+ }
+
+ f = pvfs_find_fd(pvfs, info->generic.in.fnum);
+ if (!f) {
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ /* update the file information */
+ status = pvfs_resolve_name_fd(pvfs, f->fd, f->name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return pvfs_map_fileinfo(pvfs, req, f->name, info);
+}