summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_resolve.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_resolve.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_resolve.c')
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 66e7a5d103..5c535c9880 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -116,11 +116,13 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename *
}
if (!de) {
- closedir(dir);
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ if (i < num_components-1) {
+ closedir(dir);
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+ } else {
+ components[i] = talloc_strdup(name, de->d_name);
}
-
- components[i] = talloc_strdup(name, de->d_name);
test_name = talloc_asprintf(name, "%s/%s", partial_name, components[i]);
talloc_free(partial_name);
partial_name = test_name;
@@ -137,6 +139,10 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename *
talloc_free(name->full_name);
name->full_name = partial_name;
+ if (name->exists) {
+ return pvfs_fill_dos_info(pvfs, name);
+ }
+
return NT_STATUS_OK;
}
@@ -154,7 +160,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
{
char *ret, *p;
- name->original_name = cifs_name;
+ name->original_name = talloc_strdup(name, cifs_name);
name->stream_name = NULL;
name->has_wildcard = False;
@@ -252,7 +258,7 @@ NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
/* if we can stat() the full name now then we are done */
if (stat((*name)->full_name, &(*name)->st) == 0) {
(*name)->exists = True;
- return NT_STATUS_OK;
+ return pvfs_fill_dos_info(pvfs, *name);
}
/* the filesystem might be case insensitive, in which
@@ -280,12 +286,14 @@ NTSTATUS pvfs_resolve_partial(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
const char *unix_dir, const char *fname,
struct pvfs_filename **name)
{
+ NTSTATUS status;
+
*name = talloc_p(mem_ctx, struct pvfs_filename);
if (*name == NULL) {
return NT_STATUS_NO_MEMORY;
}
- (*name)->full_name = talloc_asprintf(mem_ctx, "%s/%s", unix_dir, fname);
+ (*name)->full_name = talloc_asprintf(*name, "%s/%s", unix_dir, fname);
if ((*name)->full_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -296,8 +304,28 @@ NTSTATUS pvfs_resolve_partial(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
(*name)->exists = True;
(*name)->has_wildcard = False;
- (*name)->original_name = fname;
+ (*name)->original_name = talloc_strdup(*name, fname);
(*name)->stream_name = NULL;
- return NT_STATUS_OK;
+ status = pvfs_fill_dos_info(pvfs, *name);
+
+ return status;
+}
+
+
+/*
+ fill in the pvfs_filename info for an open file, given the current
+ info for a (possibly) non-open file. This is used by places that need
+ to update the pvfs_filename stat information, and by pvfs_open()
+*/
+NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
+ struct pvfs_filename *name)
+{
+ if (fstat(fd, &name->st) == -1) {
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ name->exists = True;
+
+ return pvfs_fill_dos_info(pvfs, name);
}