#include "svfs.h"
#include "system/time.h"
#include "dlinklist.h"
-#include "smb_server/smb_server.h"
#include "ntvfs/ntvfs.h"
#include "ntvfs/simple/proto.h"
#define O_DIRECTORY 0
#endif
-#define CHECK_READ_ONLY(req) do { if (lp_readonly(req->tcon->service)) return NT_STATUS_ACCESS_DENIED; } while (0)
+#define CHECK_READ_ONLY(req) do { if (lp_readonly(ntvfs->ctx->config.snum)) return NT_STATUS_ACCESS_DENIED; } while (0)
/*
connect to a share - used when a tree_connect operation comes
struct ntvfs_request *req, const char *sharename)
{
struct stat st;
- struct smbsrv_tcon *tcon = req->tcon;
struct svfs_private *private;
+ int snum = ntvfs->ctx->config.snum;
private = talloc(ntvfs, struct svfs_private);
private->next_search_handle = 0;
- private->connectpath = talloc_strdup(private, lp_pathname(tcon->service));
+ private->connectpath = talloc_strdup(private, lp_pathname(snum));
private->open_files = NULL;
private->search = NULL;
return NT_STATUS_BAD_NETWORK_NAME;
}
- tcon->fs_type = talloc_strdup(tcon, "NTFS");
- tcon->dev_type = talloc_strdup(tcon, "A:");
+ ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
+ NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
+ ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
+ NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
ntvfs->private_data = private;
The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
*/
static NTSTATUS svfs_unlink(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_unlink *unl)
+ struct ntvfs_request *req,
+ union smb_unlink *unl)
{
char *unix_path;
CHECK_READ_ONLY(req);
- unix_path = svfs_unix_path(ntvfs, req, unl->in.pattern);
+ unix_path = svfs_unix_path(ntvfs, req, unl->unlink.in.pattern);
/* ignoring wildcards ... */
if (unlink(unix_path) == -1) {
check if a directory exists
*/
static NTSTATUS svfs_chkpath(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_chkpath *cp)
+ struct ntvfs_request *req,
+ union smb_chkpath *cp)
{
char *unix_path;
struct stat st;
- unix_path = svfs_unix_path(ntvfs, req, cp->in.path);
+ unix_path = svfs_unix_path(ntvfs, req, cp->chkpath.in.path);
if (stat(unix_path, &st) == -1) {
return map_nt_error_from_unix(errno);
char *unix_path;
struct stat st;
- DEBUG(19,("svfs_qpathinfo: file %s level 0x%x\n", info->generic.in.fname, info->generic.level));
+ DEBUG(19,("svfs_qpathinfo: file %s level 0x%x\n", info->generic.in.file.path, info->generic.level));
if (info->generic.level != RAW_FILEINFO_GENERIC) {
return ntvfs_map_qpathinfo(ntvfs, req, info);
}
- unix_path = svfs_unix_path(ntvfs, req, info->generic.in.fname);
+ unix_path = svfs_unix_path(ntvfs, req, info->generic.in.file.path);
DEBUG(19,("svfs_qpathinfo: file %s\n", unix_path));
if (stat(unix_path, &st) == -1) {
DEBUG(19,("svfs_qpathinfo: file %s errno=%d\n", unix_path, errno));
return ntvfs_map_qfileinfo(ntvfs, req, info);
}
- f = find_fd(private, info->generic.in.fnum);
+ f = find_fd(private, info->generic.in.file.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
- if (fstat(info->generic.in.fnum, &st) == -1) {
+ if (fstat(info->generic.in.file.fnum, &st) == -1) {
return map_nt_error_from_unix(errno);
}
int fd, flags;
struct svfs_file *f;
int create_flags, rdwr_flags;
+ BOOL readonly;
if (io->generic.level != RAW_OPEN_GENERIC) {
return ntvfs_map_open(ntvfs, req, io);
}
- if (lp_readonly(req->tcon->service)) {
+ readonly = lp_readonly(ntvfs->ctx->config.snum);
+ if (readonly) {
create_flags = 0;
rdwr_flags = O_RDONLY;
} else {
if (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) {
flags = O_RDONLY | O_DIRECTORY;
- if (lp_readonly(req->tcon->service)) {
+ if (readonly) {
goto do_open;
}
switch (io->generic.in.open_disposition) {
return map_nt_error_from_unix(errno);
}
- f = talloc(req->tcon, struct svfs_file);
+ f = talloc(ntvfs, struct svfs_file);
+ NT_STATUS_HAVE_NO_MEMORY(f);
f->fd = fd;
- f->name = talloc_strdup(req->tcon, unix_path);
+ f->name = talloc_strdup(f, unix_path);
+ NT_STATUS_HAVE_NO_MEMORY(f->name);
DLIST_ADD(private->open_files, f);
unix_to_nt_time(&io->generic.out.access_time, st.st_atime);
unix_to_nt_time(&io->generic.out.write_time, st.st_mtime);
unix_to_nt_time(&io->generic.out.change_time, st.st_mtime);
- io->generic.out.fnum = fd;
+ io->generic.out.file.fnum = fd;
io->generic.out.alloc_size = st.st_size;
io->generic.out.size = st.st_size;
io->generic.out.attrib = svfs_unix_to_dos_attrib(st.st_mode);
return NT_STATUS_NOT_SUPPORTED;
}
- ret = pread(rd->readx.in.fnum,
+ ret = pread(rd->readx.in.file.fnum,
rd->readx.out.data,
rd->readx.in.maxcnt,
rd->readx.in.offset);
CHECK_READ_ONLY(req);
- ret = pwrite(wr->writex.in.fnum,
+ ret = pwrite(wr->writex.in.file.fnum,
wr->writex.in.data,
wr->writex.in.count,
wr->writex.in.offset);
seek in a file
*/
static NTSTATUS svfs_seek(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_seek *io)
+ struct ntvfs_request *req,
+ union smb_seek *io)
{
return NT_STATUS_NOT_SUPPORTED;
}
flush a file
*/
static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_flush *io)
+ struct ntvfs_request *req,
+ union smb_flush *io)
{
- fsync(io->in.fnum);
+ fsync(io->flush.in.file.fnum);
return NT_STATUS_OK;
}
close a file
*/
static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_close *io)
+ struct ntvfs_request *req,
+ union smb_close *io)
{
struct svfs_private *private = ntvfs->private_data;
struct svfs_file *f;
return NT_STATUS_INVALID_LEVEL;
}
- f = find_fd(private, io->close.in.fnum);
+ f = find_fd(private, io->close.in.file.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
- if (close(io->close.in.fnum) == -1) {
+ if (close(io->close.in.file.fnum) == -1) {
return map_nt_error_from_unix(errno);
}
switch (info->generic.level) {
case RAW_SFILEINFO_END_OF_FILE_INFO:
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
- if (ftruncate(info->end_of_file_info.file.fnum,
+ if (ftruncate(info->end_of_file_info.in.file.fnum,
info->end_of_file_info.in.size) == -1) {
return map_nt_error_from_unix(errno);
}
case RAW_SFILEINFO_SETATTRE:
unix_times.actime = info->setattre.in.access_time;
unix_times.modtime = info->setattre.in.write_time;
- fd = info->setattre.file.fnum;
+ fd = info->setattre.in.file.fnum;
if (unix_times.actime == 0 && unix_times.modtime == 0) {
break;
fs->generic.out.quota_soft = 0;
fs->generic.out.quota_hard = 0;
fs->generic.out.quota_flags = 0;
- fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service));
- fs->generic.out.fs_type = req->tcon->fs_type;
+ fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(ntvfs->ctx->config.snum));
+ fs->generic.out.fs_type = ntvfs->ctx->fs_type;
return NT_STATUS_OK;
}