ntvfs/posix/pvfs_shortname.o \
ntvfs/posix/pvfs_lock.o \
ntvfs/posix/pvfs_wait.o \
+ ntvfs/posix/pvfs_seek.o \
ntvfs/common/opendb.o \
ntvfs/common/brlock.o
# End MODULE ntvfs_posix
f->locking_key = data_blob(NULL, 0);
f->create_options = io->generic.in.create_options;
f->share_access = io->generic.in.share_access;
+ f->seek_offset = 0;
+ f->position = 0;
DLIST_ADD(pvfs->open_files, f);
f->create_options = io->generic.in.create_options;
f->share_access = io->generic.in.share_access;
f->access_mask = io->generic.in.access_mask;
+ f->seek_offset = 0;
+ f->position = 0;
DLIST_ADD(pvfs->open_files, f);
f->create_options = io->generic.in.create_options;
f->share_access = io->generic.in.share_access;
f->access_mask = io->generic.in.access_mask;
+ f->seek_offset = 0;
+ f->position = 0;
DLIST_ADD(pvfs->open_files, f);
return status;
}
- return pvfs_map_fileinfo(pvfs, req, f->name, info);
+ status = pvfs_map_fileinfo(pvfs, req, f->name, info);
+
+ info->generic.out.position = f->position;
+
+ return status;
}
return pvfs_map_errno(pvfs, errno);
}
+ f->position = f->seek_offset = rd->readx.in.offset + ret;
+
rd->readx.out.nread = ret;
rd->readx.out.remaining = 0; /* should fill this in? */
rd->readx.out.compaction_mode = 0;
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ POSIX NTVFS backend - seek
+
+ 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"
+
+/*
+ seek in a file
+*/
+NTSTATUS pvfs_seek(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, struct smb_seek *io)
+{
+ struct pvfs_state *pvfs = ntvfs->private_data;
+ struct pvfs_file *f;
+ NTSTATUS status;
+
+ f = pvfs_find_fd(pvfs, req, io->in.fnum);
+ if (!f) {
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ status = NT_STATUS_OK;
+
+ switch (io->in.mode) {
+ case SEEK_MODE_START:
+ f->seek_offset = io->in.offset;
+ break;
+
+ case SEEK_MODE_CURRENT:
+ f->seek_offset += io->in.offset;
+ break;
+
+ case SEEK_MODE_END:
+ status = pvfs_resolve_name_fd(pvfs, f->fd, f->name);
+ f->seek_offset = f->name->st.st_size + io->in.offset;
+ break;
+ }
+
+ io->out.offset = f->seek_offset;
+
+ return status;
+}
+
create_options &= ~NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
}
return pvfs_change_create_options(pvfs, req, f, create_options);
+
+ case RAW_SFILEINFO_POSITION_INFORMATION:
+ f->position = info->position_information.in.position;
+ break;
}
return NT_STATUS_OK;
}
+
+
+/*
+ set info on a pathname
+*/
+NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, union smb_setfileinfo *info)
+{
+ struct pvfs_state *pvfs = ntvfs->private_data;
+ struct pvfs_filename *name;
+ NTSTATUS status;
+ struct utimbuf unix_times;
+
+ /* resolve the cifs name to a posix name */
+ status = pvfs_resolve_name(pvfs, req, info->generic.file.fname,
+ PVFS_RESOLVE_NO_WILDCARD, &name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (!name->exists) {
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ switch (info->generic.level) {
+ case RAW_SFILEINFO_END_OF_FILE_INFO:
+ case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
+ if (truncate(name->full_name,
+ info->end_of_file_info.in.size) == -1) {
+ return pvfs_map_errno(pvfs, errno);
+ }
+ break;
+
+ case RAW_SFILEINFO_SETATTRE:
+ unix_times.actime = info->setattre.in.access_time;
+ unix_times.modtime = info->setattre.in.write_time;
+
+ if (unix_times.actime == 0 && unix_times.modtime == 0) {
+ break;
+ }
+
+ /* set modify time = to access time if modify time was 0 */
+ if (unix_times.actime != 0 && unix_times.modtime == 0) {
+ unix_times.modtime = unix_times.actime;
+ }
+
+ /* Set the date on this file */
+ if (utime(name->full_name, &unix_times) == -1) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+ break;
+
+ case RAW_SFILEINFO_DISPOSITION_INFO:
+ case RAW_SFILEINFO_DISPOSITION_INFORMATION:
+ return NT_STATUS_INVALID_PARAMETER;
+
+ case RAW_SFILEINFO_POSITION_INFORMATION:
+ return NT_STATUS_OK;
+ }
+
+ return NT_STATUS_INVALID_LEVEL;
+}
+
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
+
+ f->seek_offset = wr->writex.in.offset + ret;
wr->writex.out.nwritten = ret;
wr->writex.out.remaining = 0; /* should fill this in? */
return NT_STATUS_NOT_SUPPORTED;
}
-/*
- seek in a file
-*/
-static NTSTATUS pvfs_seek(struct ntvfs_module_context *ntvfs,
- struct smbsrv_request *req, struct smb_seek *io)
-{
- DEBUG(0,("pvfs_seek not implemented\n"));
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- set info on a pathname
-*/
-static NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
- struct smbsrv_request *req, union smb_setfileinfo *st)
-{
- DEBUG(0,("pvfs_setpathinfo not implemented\n"));
- return NT_STATUS_NOT_SUPPORTED;
-}
-
/*
return print queue info
*/
uint32_t create_options;
uint32_t share_access;
uint32_t access_mask;
+
+ /* yes, we need 2 independent positions ... */
+ uint64_t seek_offset;
+ uint64_t position;
};