summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-08 05:39:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:34 -0500
commit893c62d38388b20c52cf3c45069d836c46f42bd3 (patch)
treeb11304934190db80fd453089a88ff18ec4728bba /source4/ntvfs
parent8293df91bcec574fb4a2b290cc11dd83353264ae (diff)
downloadsamba-893c62d38388b20c52cf3c45069d836c46f42bd3.tar.gz
samba-893c62d38388b20c52cf3c45069d836c46f42bd3.tar.bz2
samba-893c62d38388b20c52cf3c45069d836c46f42bd3.zip
r2249: got rid of some more mem_ctx elements in structures
(This used to be commit 21ef338cbbe96acc8594ffc550ef60c6a40fb951)
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c42
-rw-r--r--source4/ntvfs/ipc/ipc_rap.c10
-rw-r--r--source4/ntvfs/ipc/rap_server.c6
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c8
-rw-r--r--source4/ntvfs/nbench/vfs_nbench.c2
-rw-r--r--source4/ntvfs/ntvfs_generic.c14
-rw-r--r--source4/ntvfs/posix/vfs_posix.c42
-rw-r--r--source4/ntvfs/print/vfs_print.c2
-rw-r--r--source4/ntvfs/simple/svfs_util.c4
-rw-r--r--source4/ntvfs/simple/vfs_simple.c43
10 files changed, 94 insertions, 79 deletions
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 9020ba2bba..078075a11f 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -113,7 +113,7 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename)
return NT_STATUS_INVALID_PARAMETER;
}
- private = talloc(req->tcon->mem_ctx, sizeof(struct cvfs_private));
+ private = talloc(req->tcon, sizeof(struct cvfs_private));
if (!private) {
return NT_STATUS_NO_MEMORY;
}
@@ -136,18 +136,18 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename)
private->tree->session->pid = SVAL(req->in.hdr, HDR_PID);
private->tcon = req->tcon;
- tcon->fs_type = talloc_strdup(tcon->mem_ctx, "NTFS");
- tcon->dev_type = talloc_strdup(tcon->mem_ctx, "A:");
+ tcon->fs_type = talloc_strdup(tcon, "NTFS");
+ tcon->dev_type = talloc_strdup(tcon, "A:");
map_calls = lp_parm_string(req->tcon->service, "cifs", "map calls");
if (map_calls) {
- private->map_calls = talloc_strdup(tcon->mem_ctx, map_calls);
+ private->map_calls = talloc_strdup(tcon, map_calls);
}
/* if we are mapping trans2, then we need to give a trans2
pointer in the operations structure */
if (private->map_calls && in_list("trans2", private->map_calls, True)) {
- struct ntvfs_ops *ops = talloc_memdup(tcon->mem_ctx,tcon->ntvfs_ops,sizeof(*ops));
+ struct ntvfs_ops *ops = talloc_memdup(tcon, tcon->ntvfs_ops,sizeof(*ops));
static NTSTATUS cvfs_trans2(struct smbsrv_request *,struct smb_trans2 *);
if (!ops) {
return NT_STATUS_NO_MEMORY;
@@ -203,7 +203,7 @@ static void async_simple(struct smbcli_request *c_req)
if (!c_req) return NT_STATUS_UNSUCCESSFUL; \
{ \
struct async_info *async; \
- async = talloc(req->mem_ctx, sizeof(*async)); \
+ async = talloc_p(req, struct async_info); \
if (!async) return NT_STATUS_NO_MEMORY; \
async->parms = io; \
async->req = req; \
@@ -243,7 +243,7 @@ static void async_ioctl(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_ioctl_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_ioctl_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -258,7 +258,7 @@ static NTSTATUS cvfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
/* see if the front end will allow us to perform this
function asynchronously. */
if (!req->async.send_fn) {
- return smb_raw_ioctl(private->tree, req->mem_ctx, io);
+ return smb_raw_ioctl(private->tree, req, io);
}
c_req = smb_raw_ioctl_send(private->tree, io);
@@ -290,7 +290,7 @@ static void async_qpathinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_pathinfo_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_pathinfo_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -303,7 +303,7 @@ static NTSTATUS cvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *i
struct smbcli_request *c_req;
if (!req->async.send_fn) {
- return smb_raw_pathinfo(private->tree, req->mem_ctx, info);
+ return smb_raw_pathinfo(private->tree, req, info);
}
c_req = smb_raw_pathinfo_send(private->tree, info);
@@ -318,7 +318,7 @@ static void async_qfileinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_fileinfo_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_fileinfo_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -331,7 +331,7 @@ static NTSTATUS cvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *i
struct smbcli_request *c_req;
if (!req->async.send_fn) {
- return smb_raw_fileinfo(private->tree, req->mem_ctx, info);
+ return smb_raw_fileinfo(private->tree, req, info);
}
c_req = smb_raw_fileinfo_send(private->tree, info);
@@ -365,7 +365,7 @@ static void async_open(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_open_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_open_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -383,7 +383,7 @@ static NTSTATUS cvfs_open(struct smbsrv_request *req, union smb_open *io)
}
if (!req->async.send_fn) {
- return smb_raw_open(private->tree, req->mem_ctx, io);
+ return smb_raw_open(private->tree, req, io);
}
c_req = smb_raw_open_send(private->tree, io);
@@ -587,7 +587,7 @@ static void async_fsinfo(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_fsinfo_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_fsinfo_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -600,10 +600,10 @@ static NTSTATUS cvfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
struct smbcli_request *c_req;
if (!req->async.send_fn) {
- return smb_raw_fsinfo(private->tree, req->mem_ctx, fs);
+ return smb_raw_fsinfo(private->tree, req, fs);
}
- c_req = smb_raw_fsinfo_send(private->tree, req->mem_ctx, fs);
+ c_req = smb_raw_fsinfo_send(private->tree, req, fs);
ASYNC_RECV_TAIL(fs, async_fsinfo);
}
@@ -625,7 +625,7 @@ static NTSTATUS cvfs_search_first(struct smbsrv_request *req, union smb_search_f
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- return smb_raw_search_first(private->tree, req->mem_ctx, io, search_private, callback);
+ return smb_raw_search_first(private->tree, req, io, search_private, callback);
}
/* continue a search */
@@ -635,7 +635,7 @@ static NTSTATUS cvfs_search_next(struct smbsrv_request *req, union smb_search_ne
{
struct cvfs_private *private = req->tcon->ntvfs_private;
- return smb_raw_search_next(private->tree, req->mem_ctx, io, search_private, callback);
+ return smb_raw_search_next(private->tree, req, io, search_private, callback);
}
/* close a search */
@@ -653,7 +653,7 @@ static void async_trans2(struct smbcli_request *c_req)
{
struct async_info *async = c_req->async.private;
struct smbsrv_request *req = async->req;
- req->async.status = smb_raw_trans2_recv(c_req, req->mem_ctx, async->parms);
+ req->async.status = smb_raw_trans2_recv(c_req, req, async->parms);
req->async.send_fn(req);
}
@@ -664,7 +664,7 @@ static NTSTATUS cvfs_trans2(struct smbsrv_request *req, struct smb_trans2 *trans
struct smbcli_request *c_req;
if (!req->async.send_fn) {
- return smb_raw_trans2(private->tree, req->mem_ctx, trans2);
+ return smb_raw_trans2(private->tree, req, trans2);
}
c_req = smb_raw_trans2_send(private->tree, trans2);
diff --git a/source4/ntvfs/ipc/ipc_rap.c b/source4/ntvfs/ipc/ipc_rap.c
index 347ff39d97..32b2fa2181 100644
--- a/source4/ntvfs/ipc/ipc_rap.c
+++ b/source4/ntvfs/ipc/ipc_rap.c
@@ -395,7 +395,7 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans)
struct ndr_push *final_param;
struct ndr_push *final_data;
- call = new_rap_srv_call(req->mem_ctx, trans);
+ call = new_rap_srv_call(req, trans);
if (call == NULL)
return NT_STATUS_NO_MEMORY;
@@ -406,8 +406,8 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans)
NDR_CHECK(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
&call->datadesc));
- call->ndr_push_param = ndr_push_init_ctx(req->mem_ctx);
- call->ndr_push_data = ndr_push_init_ctx(req->mem_ctx);
+ call->ndr_push_param = ndr_push_init_ctx(req);
+ call->ndr_push_data = ndr_push_init_ctx(req);
if ((call->ndr_push_param == NULL) || (call->ndr_push_data == NULL))
return NT_STATUS_NO_MEMORY;
@@ -432,8 +432,8 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans)
result_param = ndr_push_blob(call->ndr_push_param);
result_data = ndr_push_blob(call->ndr_push_data);
- final_param = ndr_push_init_ctx(req->mem_ctx);
- final_data = ndr_push_init_ctx(req->mem_ctx);
+ final_param = ndr_push_init_ctx(req);
+ final_data = ndr_push_init_ctx(req);
if ((final_param == NULL) || (final_data == NULL))
return NT_STATUS_NO_MEMORY;
diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c
index 4a7b2dd91b..4ab1915c81 100644
--- a/source4/ntvfs/ipc/rap_server.c
+++ b/source4/ntvfs/ipc/rap_server.c
@@ -29,18 +29,18 @@ NTSTATUS rap_netshareenum(struct smbsrv_request *req,
{
r->out.status = 0;
r->out.available = 2;
- r->out.info = talloc_array_p(req->mem_ctx,
+ r->out.info = talloc_array_p(req,
union rap_shareenum_info, 2);
strncpy(r->out.info[0].info1.name, "C$", 12);
r->out.info[0].info1.pad = 0;
r->out.info[0].info1.type = 0;
- r->out.info[0].info1.comment = talloc_strdup(req->mem_ctx, "Bla");
+ r->out.info[0].info1.comment = talloc_strdup(req, "Bla");
strncpy(r->out.info[1].info1.name, "IPC$", 12);
r->out.info[1].info1.pad = 0;
r->out.info[1].info1.type = 1;
- r->out.info[1].info1.comment = talloc_strdup(req->mem_ctx, "Blub");
+ r->out.info[1].info1.comment = talloc_strdup(req, "Blub");
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 2e44b00c6b..053222460c 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -110,11 +110,11 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename)
struct smbsrv_tcon *tcon = req->tcon;
struct ipc_private *private;
- tcon->fs_type = talloc_strdup(tcon->mem_ctx, "IPC");
- tcon->dev_type = talloc_strdup(tcon->mem_ctx, "IPC");
+ tcon->fs_type = talloc_strdup(tcon, "IPC");
+ tcon->dev_type = talloc_strdup(tcon, "IPC");
/* prepare the private state for this connection */
- private = talloc(tcon->mem_ctx, sizeof(struct ipc_private));
+ private = talloc_p(tcon, struct ipc_private);
if (!private) {
return NT_STATUS_NO_MEMORY;
}
@@ -604,7 +604,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *tr
return NT_STATUS_INVALID_HANDLE;
}
- trans->out.data = data_blob_talloc(req->mem_ctx, NULL, trans->in.max_data);
+ trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data);
if (!trans->out.data.data) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c
index e4e5af4171..549d1d893f 100644
--- a/source4/ntvfs/nbench/vfs_nbench.c
+++ b/source4/ntvfs/nbench/vfs_nbench.c
@@ -100,7 +100,7 @@ static NTSTATUS nbench_connect(struct smbsrv_request *req, const char *sharename
NTSTATUS status;
char *logname = NULL;
- private = talloc_p(req->tcon->mem_ctx, struct nbench_private);
+ private = talloc_p(req->tcon, struct nbench_private);
if (!private) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 36cbcabbd5..29f21b1863 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -472,7 +472,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
case RAW_FILEINFO_STREAM_INFORMATION:
info->stream_info.out.num_streams = info2->generic.out.num_streams;
if (info->stream_info.out.num_streams > 0) {
- info->stream_info.out.streams = talloc(req->mem_ctx,
+ info->stream_info.out.streams = talloc(req,
info->stream_info.out.num_streams * sizeof(struct stream_struct));
if (!info->stream_info.out.streams) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n",
@@ -482,7 +482,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
for (i=0; i < info->stream_info.out.num_streams; i++) {
info->stream_info.out.streams[i] = info2->generic.out.streams[i];
info->stream_info.out.streams[i].stream_name.s =
- talloc_strdup(req->mem_ctx, info2->generic.out.streams[i].stream_name.s);
+ talloc_strdup(req, info2->generic.out.streams[i].stream_name.s);
if (!info->stream_info.out.streams[i].stream_name.s) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n"));
return NT_STATUS_NO_MEMORY;
@@ -493,13 +493,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
case RAW_FILEINFO_NAME_INFO:
case RAW_FILEINFO_NAME_INFORMATION:
- info->name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.fname.s);
+ info->name_info.out.fname.s = talloc_strdup(req, info2->generic.out.fname.s);
info->name_info.out.fname.private_length = info2->generic.out.fname.private_length;
return NT_STATUS_OK;
case RAW_FILEINFO_ALT_NAME_INFO:
case RAW_FILEINFO_ALT_NAME_INFORMATION:
- info->alt_name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.alt_fname.s);
+ info->alt_name_info.out.fname.s = talloc_strdup(req, info2->generic.out.alt_fname.s);
info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length;
return NT_STATUS_OK;
@@ -510,7 +510,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
case RAW_FILEINFO_ALL_EAS:
info->all_eas.out.num_eas = info2->generic.out.num_eas;
if (info->all_eas.out.num_eas > 0) {
- info->all_eas.out.eas = talloc(req->mem_ctx,
+ info->all_eas.out.eas = talloc(req,
info->all_eas.out.num_eas * sizeof(struct ea_struct));
if (!info->all_eas.out.eas) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n",
@@ -520,13 +520,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info
for (i = 0; i < info->all_eas.out.num_eas; i++) {
info->all_eas.out.eas[i] = info2->generic.out.eas[i];
info->all_eas.out.eas[i].name.s =
- talloc_strdup(req->mem_ctx, info2->generic.out.eas[i].name.s);
+ talloc_strdup(req, info2->generic.out.eas[i].name.s);
if (!info->all_eas.out.eas[i].name.s) {
DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n"));
return NT_STATUS_NO_MEMORY;
}
info->all_eas.out.eas[i].value.data =
- talloc_memdup(req->mem_ctx,
+ talloc_memdup(req,
info2->generic.out.eas[i].value.data,
info2->generic.out.eas[i].value.length);
if (!info->all_eas.out.eas[i].value.data) {
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 93cfbd74a9..8269f9bba7 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -1,8 +1,9 @@
/*
Unix SMB/CIFS implementation.
+
POSIX NTVFS backend
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) Stefan (metze) Metzmacher 2004
+
+ 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
@@ -24,6 +25,8 @@
*/
#include "include/includes.h"
+#include "vfs_posix.h"
+
/*
connect to a share - used when a tree_connect operation comes
@@ -33,16 +36,31 @@
*/
static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
{
- DEBUG(0, ("Connection to share [%s] ACCESS DENIED!\n", sharename));
- DEBUGADD(0,("This is because your using the 'ntvfs handler = default'.\n"));
- DEBUGADD(0,("This backend is not functional at the moment.\n"));
- DEBUGADD(0,("Please use one of the following backends:\n"));
- DEBUGADD(0,("cifs - a proxy to another cifs-server\n"));
- DEBUGADD(0,("simple - a very, very simple posix backend\n"));
- DEBUGADD(0,(" all file acess is done as user 'root'\n"));
- DEBUGADD(0,(" Please don't use this a sensitive data!!!\n"));
-
- return NT_STATUS_DEVICE_CONFIGURATION_ERROR;
+ struct smbsrv_tcon *tcon = req->tcon;
+ struct pvfs_state *pvfs;
+ struct stat st;
+
+ DEBUG(0,("WARNING: the posix vfs handler is incomplete - you probably want \"ntvfs handler = simple\"\n"));
+
+ pvfs = talloc_named(tcon, sizeof(struct pvfs_state), "pvfs_connect(%s)", sharename);
+ if (pvfs == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ pvfs->base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service));
+
+ /* the directory must exist. Note that we deliberately don't
+ check that it is readable */
+ if (stat(pvfs->base_directory, &st) != 0 || !S_ISDIR(st.st_mode)) {
+ DEBUG(0,("pvfs_connect: '%s' is not a directory, when connecting to [%s]\n",
+ pvfs->base_directory, sharename));
+ return NT_STATUS_BAD_NETWORK_NAME;
+ }
+
+ tcon->fs_type = talloc_strdup(tcon, "NTFS");
+ tcon->dev_type = talloc_strdup(tcon, "A:");
+
+ return NT_STATUS_OK;
}
/*
diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c
index fa5835843a..4b50e3e6e5 100644
--- a/source4/ntvfs/print/vfs_print.c
+++ b/source4/ntvfs/print/vfs_print.c
@@ -64,7 +64,7 @@ static NTSTATUS print_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) {
/* a request for the print job id of an open print job */
- io->ioctl.out.blob = data_blob_talloc(req->mem_ctx, NULL, 32);
+ io->ioctl.out.blob = data_blob_talloc(req, NULL, 32);
data_blob_clear(&io->ioctl.out.blob);
diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c
index 14ffc6d19c..04165cadd9 100644
--- a/source4/ntvfs/simple/svfs_util.c
+++ b/source4/ntvfs/simple/svfs_util.c
@@ -35,9 +35,9 @@ char *svfs_unix_path(struct smbsrv_request *req, const char *name)
char *ret;
if (*name != '\\') {
- ret = talloc_asprintf(req->mem_ctx, "%s/%s", private->connectpath, name);
+ ret = talloc_asprintf(req, "%s/%s", private->connectpath, name);
} else {
- ret = talloc_asprintf(req->mem_ctx, "%s%s", private->connectpath, name);
+ ret = talloc_asprintf(req, "%s%s", private->connectpath, name);
}
all_string_sub(ret, "\\", "/", 0);
diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c
index 007095f44a..8bce111e9c 100644
--- a/source4/ntvfs/simple/vfs_simple.c
+++ b/source4/ntvfs/simple/vfs_simple.c
@@ -67,12 +67,12 @@ static NTSTATUS svfs_connect(struct smbsrv_request *req, const char *sharename)
struct smbsrv_tcon *tcon = req->tcon;
struct svfs_private *private;
- tcon->ntvfs_private = talloc_p(tcon->mem_ctx, struct svfs_private);
+ tcon->ntvfs_private = talloc_p(tcon, struct svfs_private);
private = tcon->ntvfs_private;
private->next_search_handle = 0;
- private->connectpath = talloc_strdup(tcon->mem_ctx, lp_pathname(tcon->service));
+ private->connectpath = talloc_strdup(tcon, lp_pathname(tcon->service));
private->open_files = NULL;
/* the directory must exist */
@@ -82,8 +82,8 @@ static NTSTATUS svfs_connect(struct smbsrv_request *req, const char *sharename)
return NT_STATUS_BAD_NETWORK_NAME;
}
- tcon->fs_type = talloc_strdup(tcon->mem_ctx, "NTFS");
- tcon->dev_type = talloc_strdup(tcon->mem_ctx, "A:");
+ tcon->fs_type = talloc_strdup(tcon, "NTFS");
+ tcon->dev_type = talloc_strdup(tcon, "A:");
DEBUG(0,("WARNING: ntvfs simple: connect to share [%s] with ROOT privileges!!!\n",sharename));
@@ -183,7 +183,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo
asprintf(&pattern, "%s:*", unix_path);
if (pattern) {
- dir = svfs_list_unix(req->mem_ctx, req, pattern);
+ dir = svfs_list_unix(req, req, pattern);
}
unix_to_nt_time(&info->generic.out.create_time, st->st_ctime);
@@ -201,8 +201,8 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo
info->generic.out.delete_pending = 0;
info->generic.out.ea_size = 0;
info->generic.out.num_eas = 0;
- info->generic.out.fname.s = talloc_strdup(req->mem_ctx, short_name);
- info->generic.out.alt_fname.s = talloc_strdup(req->mem_ctx, short_name);
+ info->generic.out.fname.s = talloc_strdup(req, short_name);
+ info->generic.out.alt_fname.s = talloc_strdup(req, short_name);
info->generic.out.ex_attrib = 0;
info->generic.out.compressed_size = 0;
info->generic.out.format = 0;
@@ -218,7 +218,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo
info->generic.out.num_streams = 0;
/* setup a single data stream */
info->generic.out.num_streams = 1 + (dir?dir->count:0);
- info->generic.out.streams = talloc_array_p(req->mem_ctx,
+ info->generic.out.streams = talloc_array_p(req,
struct stream_struct,
info->generic.out.num_streams);
if (!info->generic.out.streams) {
@@ -226,7 +226,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo
}
info->generic.out.streams[0].size = st->st_size;
info->generic.out.streams[0].alloc_size = st->st_size;
- info->generic.out.streams[0].stream_name.s = talloc_strdup(req->mem_ctx,"::$DATA");
+ info->generic.out.streams[0].stream_name.s = talloc_strdup(req,"::$DATA");
for (i=0;dir && i<dir->count;i++) {
s = strchr(dir->files[i].name, ':');
@@ -376,9 +376,9 @@ do_open:
return map_nt_error_from_unix(errno);
}
- f = talloc_p(req->tcon->mem_ctx, struct svfs_file);
+ f = talloc_p(req->tcon, struct svfs_file);
f->fd = fd;
- f->name = talloc_strdup(req->tcon->mem_ctx, unix_path);
+ f->name = talloc_strdup(req->tcon, unix_path);
DLIST_ADD(private->open_files, f);
@@ -690,7 +690,7 @@ static NTSTATUS svfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
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->mem_ctx, lp_servicename(req->tcon->service));
+ fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service));
fs->generic.out.fs_type = req->tcon->fs_type;
return NT_STATUS_OK;
@@ -720,8 +720,8 @@ static NTSTATUS svfs_fsattr(struct smbsrv_request *req, union smb_fsattr *fs)
FILE_PERSISTENT_ACLS;
fs->generic.out.max_file_component_length = 255;
fs->generic.out.serial_number = 1;
- fs->generic.out.fs_type = talloc_strdup(req->mem_ctx, "NTFS");
- fs->generic.out.volume_name = talloc_strdup(req->mem_ctx,
+ fs->generic.out.fs_type = talloc_strdup(req, "NTFS");
+ fs->generic.out.volume_name = talloc_strdup(req,
lp_servicename(req->tcon->service));
return NT_STATUS_OK;
@@ -755,22 +755,19 @@ static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_f
return NT_STATUS_NOT_SUPPORTED;
}
- mem_ctx = talloc_init("svfs_search");
-
- search = talloc_zero(mem_ctx, sizeof(struct search_state));
+ search = talloc_zero(private, sizeof(struct search_state));
if (!search) {
return NT_STATUS_NO_MEMORY;
}
max_count = io->t2ffirst.in.max_count;
- dir = svfs_list(mem_ctx, req, io->t2ffirst.in.pattern);
+ dir = svfs_list(private, req, io->t2ffirst.in.pattern);
if (!dir) {
talloc_free(mem_ctx);
return NT_STATUS_FOOBAR;
}
- search->mem_ctx = mem_ctx;
search->handle = private->next_search_handle;
search->dir = dir;
@@ -803,7 +800,7 @@ static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_f
/* work out if we are going to keep the search state */
if ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
- talloc_free(search->mem_ctx);
+ talloc_free(search);
} else {
private->next_search_handle++;
DLIST_ADD(private->search, search);
@@ -893,7 +890,7 @@ found:
if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
DLIST_REMOVE(private->search, search);
- talloc_free(search->mem_ctx);
+ talloc_free(search);
}
return NT_STATUS_OK;
@@ -915,7 +912,7 @@ static NTSTATUS svfs_search_close(struct smbsrv_request *req, union smb_search_c
}
DLIST_REMOVE(private->search, search);
- talloc_free(search->mem_ctx);
+ talloc_free(search);
return NT_STATUS_OK;
}
@@ -970,7 +967,7 @@ NTSTATUS ntvfs_simple_init(void)
ops.trans = svfs_trans;
/* register ourselves with the NTVFS subsystem. We register
- under names 'simple'
+ under names 'simple'
*/
ops.name = "simple";
ret = register_backend("ntvfs", &ops);