summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-23 07:44:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:06 -0500
commita3cec511bbef2cc7768906f3af947ce2f900bde6 (patch)
tree16c0df54ed092084abd2265acc01a111cdb4c4b3 /source4/ntvfs/posix
parent5821c39553f1d9899f6bcfb703876de767ccebf4 (diff)
downloadsamba-a3cec511bbef2cc7768906f3af947ce2f900bde6.tar.gz
samba-a3cec511bbef2cc7768906f3af947ce2f900bde6.tar.bz2
samba-a3cec511bbef2cc7768906f3af947ce2f900bde6.zip
r2561: completely redid the ntvfs module chaining code, You can now do something like:
ntvfs handler = nbench posix and the nbench pass-thru module will be called before the posix module. The chaining logic is now much saner, and less racy, with each level in the chain getting its own private pointer rather than relying on save/restore logic in the pass-thru module. The only pass-thru module we have at the moment is the nbench one (which records all traffic in a nbench compatibe format), but I plan on soon writing a "unixuid" pass-thru module that will implement the setegid()/setgroups()/seteuid() logic for standard posix uid handling. This separation of the posix backend from the uid handling should simplify the code, and make development easier. I also modified the nbench module so it can do multiple chaining, so if you want to you can do: ntvfs module = nbench nbench posix and it will save 2 copies of the log file in /tmp. This is really only useful for testing at the moment until we have more than one pass-thru module. (This used to be commit f84c0af35cb54c8fdc4933afefc18fa4c062aae4)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_fsinfo.c4
-rw-r--r--source4/ntvfs/posix/pvfs_mkdir.c4
-rw-r--r--source4/ntvfs/posix/pvfs_open.c6
-rw-r--r--source4/ntvfs/posix/pvfs_qfileinfo.c8
-rw-r--r--source4/ntvfs/posix/pvfs_read.c2
-rw-r--r--source4/ntvfs/posix/pvfs_rename.c2
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c14
-rw-r--r--source4/ntvfs/posix/pvfs_search.c10
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c2
-rw-r--r--source4/ntvfs/posix/pvfs_unlink.c2
-rw-r--r--source4/ntvfs/posix/pvfs_write.c2
-rw-r--r--source4/ntvfs/posix/vfs_posix.c10
-rw-r--r--source4/ntvfs/posix/vfs_posix.h2
13 files changed, 42 insertions, 26 deletions
diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c
index 826e331b84..f1c42e8920 100644
--- a/source4/ntvfs/posix/pvfs_fsinfo.c
+++ b/source4/ntvfs/posix/pvfs_fsinfo.c
@@ -29,11 +29,11 @@
*/
NTSTATUS pvfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct stat st;
if (fs->generic.level != RAW_QFS_GENERIC) {
- return ntvfs_map_fsinfo(req, fs);
+ return ntvfs_map_fsinfo(req, fs, pvfs->ops);
}
if (sys_fsusage(pvfs->base_directory,
diff --git a/source4/ntvfs/posix/pvfs_mkdir.c b/source4/ntvfs/posix/pvfs_mkdir.c
index 4881326ecb..de51d2e8fd 100644
--- a/source4/ntvfs/posix/pvfs_mkdir.c
+++ b/source4/ntvfs/posix/pvfs_mkdir.c
@@ -28,7 +28,7 @@
*/
NTSTATUS pvfs_mkdir(struct smbsrv_request *req, union smb_mkdir *md)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
NTSTATUS status;
struct pvfs_filename *name;
@@ -62,7 +62,7 @@ NTSTATUS pvfs_mkdir(struct smbsrv_request *req, union smb_mkdir *md)
*/
NTSTATUS pvfs_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
NTSTATUS status;
struct pvfs_filename *name;
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 26fd444984..1c6ecc1eb2 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -45,14 +45,14 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs, uint16_t fnum)
*/
NTSTATUS pvfs_open(struct smbsrv_request *req, union smb_open *io)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
int fd, flags;
struct pvfs_filename *name;
struct pvfs_file *f;
NTSTATUS status;
if (io->generic.level != RAW_OPEN_GENERIC) {
- return ntvfs_map_open(req, io);
+ return ntvfs_map_open(req, io, pvfs->ops);
}
/* resolve the cifs name to a posix name */
@@ -155,7 +155,7 @@ do_open:
*/
NTSTATUS pvfs_close(struct smbsrv_request *req, union smb_close *io)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_file *f;
if (io->generic.level != RAW_CLOSE_CLOSE) {
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
index 691ba91532..649036b09a 100644
--- a/source4/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -80,12 +80,12 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
*/
NTSTATUS pvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_filename *name;
NTSTATUS status;
if (info->generic.level != RAW_FILEINFO_GENERIC) {
- return ntvfs_map_qpathinfo(req, info);
+ return ntvfs_map_qpathinfo(req, info, pvfs->ops);
}
/* resolve the cifs name to a posix name */
@@ -106,12 +106,12 @@ NTSTATUS pvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
*/
NTSTATUS pvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_file *f;
NTSTATUS status;
if (info->generic.level != RAW_FILEINFO_GENERIC) {
- return ntvfs_map_qfileinfo(req, info);
+ return ntvfs_map_qfileinfo(req, info, pvfs->ops);
}
f = pvfs_find_fd(pvfs, info->generic.in.fnum);
diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c
index d30645e76d..cbb0317638 100644
--- a/source4/ntvfs/posix/pvfs_read.c
+++ b/source4/ntvfs/posix/pvfs_read.c
@@ -28,7 +28,7 @@
*/
NTSTATUS pvfs_read(struct smbsrv_request *req, union smb_read *rd)
{
- struct pvfs_private *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
ssize_t ret;
struct pvfs_file *f;
diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c
index 40b84f7628..a58a1e9c6e 100644
--- a/source4/ntvfs/posix/pvfs_rename.c
+++ b/source4/ntvfs/posix/pvfs_rename.c
@@ -28,7 +28,7 @@
*/
NTSTATUS pvfs_rename(struct smbsrv_request *req, union smb_rename *ren)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
NTSTATUS status;
struct pvfs_filename *name1, *name2;
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 5c535c9880..dfd6744eff 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -164,10 +164,18 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
name->stream_name = NULL;
name->has_wildcard = False;
- if (*cifs_name == '\\') {
+ while (*cifs_name == '\\') {
cifs_name++;
}
+ if (*cifs_name == 0) {
+ name->full_name = talloc_asprintf(name, "%s/.", pvfs->base_directory);
+ if (name->full_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ return NT_STATUS_OK;
+ }
+
ret = talloc_asprintf(name, "%s/%s", pvfs->base_directory, cifs_name);
if (ret == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -175,6 +183,10 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
p = ret + strlen(pvfs->base_directory) + 1;
+ if (p[strlen(cifs_name)-1] == '\\') {
+ p[strlen(cifs_name)-1] = 0;
+ }
+
/* now do an in-place conversion of '\' to '/', checking
for legal characters */
for (;*p;p++) {
diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c
index 1d1d973d3f..414b010263 100644
--- a/source4/ntvfs/posix/pvfs_search.c
+++ b/source4/ntvfs/posix/pvfs_search.c
@@ -255,7 +255,7 @@ static NTSTATUS pvfs_search_first_old(struct smbsrv_request *req, union smb_sear
BOOL (*callback)(void *, union smb_search_data *))
{
struct pvfs_dir *dir;
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_search_state *search;
uint_t reply_count;
uint16_t search_attrib;
@@ -331,7 +331,7 @@ static NTSTATUS pvfs_search_next_old(struct smbsrv_request *req, union smb_searc
void *search_private,
BOOL (*callback)(void *, union smb_search_data *))
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_search_state *search;
struct pvfs_dir *dir;
uint_t reply_count, max_count;
@@ -379,7 +379,7 @@ NTSTATUS pvfs_search_first(struct smbsrv_request *req, union smb_search_first *i
BOOL (*callback)(void *, union smb_search_data *))
{
struct pvfs_dir *dir;
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_search_state *search;
uint_t reply_count;
uint16_t search_attrib, max_count;
@@ -470,7 +470,7 @@ NTSTATUS pvfs_search_next(struct smbsrv_request *req, union smb_search_next *io,
void *search_private,
BOOL (*callback)(void *, union smb_search_data *))
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_search_state *search;
struct pvfs_dir *dir;
uint_t reply_count;
@@ -547,7 +547,7 @@ found:
/* close a search */
NTSTATUS pvfs_search_close(struct smbsrv_request *req, union smb_search_close *io)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_search_state *search;
uint16_t handle;
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index a271b43d38..c2c58415be 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -29,7 +29,7 @@
NTSTATUS pvfs_setfileinfo(struct smbsrv_request *req,
union smb_setfileinfo *info)
{
- struct pvfs_private *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_private, pvfs, req);
struct utimbuf unix_times;
struct pvfs_file *f;
diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c
index 98151d4e75..9e0353c041 100644
--- a/source4/ntvfs/posix/pvfs_unlink.c
+++ b/source4/ntvfs/posix/pvfs_unlink.c
@@ -63,7 +63,7 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
*/
NTSTATUS pvfs_unlink(struct smbsrv_request *req, struct smb_unlink *unl)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_dir *dir;
NTSTATUS status;
uint32_t i, total_deleted=0;
diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c
index 4194ced431..ac9d23b88f 100644
--- a/source4/ntvfs/posix/pvfs_write.c
+++ b/source4/ntvfs/posix/pvfs_write.c
@@ -29,7 +29,7 @@
*/
NTSTATUS pvfs_write(struct smbsrv_request *req, union smb_write *wr)
{
- struct pvfs_private *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
ssize_t ret;
struct pvfs_file *f;
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 84a5647075..9bd060c639 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -50,7 +50,7 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
directory exists (tho it doesn't need to be accessible by the user,
that comes later)
*/
-static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
+static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename, int depth)
{
struct smbsrv_tcon *tcon = req->tcon;
struct pvfs_state *pvfs;
@@ -71,6 +71,7 @@ static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
pvfs->tcon = tcon;
pvfs->base_directory = base_directory;
+ pvfs->ops = ntvfs_backend_byname("posix", NTVFS_DISK);
/* the directory must exist. Note that we deliberately don't
check that it is readable */
@@ -82,7 +83,8 @@ static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
tcon->fs_type = talloc_strdup(tcon, "NTFS");
tcon->dev_type = talloc_strdup(tcon, "A:");
- tcon->ntvfs_private = pvfs;
+
+ ntvfs_set_private(tcon, depth, pvfs);
pvfs_setup_options(pvfs);
@@ -92,7 +94,7 @@ static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
/*
disconnect from a share
*/
-static NTSTATUS pvfs_disconnect(struct smbsrv_tcon *tcon)
+static NTSTATUS pvfs_disconnect(struct smbsrv_tcon *tcon, int depth)
{
return NT_STATUS_OK;
}
@@ -110,7 +112,7 @@ static NTSTATUS pvfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
*/
static NTSTATUS pvfs_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp)
{
- struct pvfs_state *pvfs = req->tcon->ntvfs_private;
+ NTVFS_GET_PRIVATE(pvfs_state, pvfs, req);
struct pvfs_filename *name;
NTSTATUS status;
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index 8b7ddfad88..bfb1fbf7ca 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -49,6 +49,8 @@ struct pvfs_state {
} search;
struct pvfs_file *open_files;
+
+ const struct ntvfs_ops *ops;
};