summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_search.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-10 07:24:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:08 -0500
commit89efea81d9d67ebed159321e8ea496eee54c2deb (patch)
tree9ffc195a05eab698b1697015410f15546e48e266 /source4/ntvfs/posix/pvfs_search.c
parentc74d5b9204c004f30494645f04d34306667990c8 (diff)
downloadsamba-89efea81d9d67ebed159321e8ea496eee54c2deb.tar.gz
samba-89efea81d9d67ebed159321e8ea496eee54c2deb.tar.bz2
samba-89efea81d9d67ebed159321e8ea496eee54c2deb.zip
r18319: fixed the directory search resume code on IRIX
The problem was twofold: 1) irix returns 64 bit numbers in telldir(). The protocol uses a 32 bit resume key. We now cope with this properly using the code in pvfs_list_seek_ofs(). 2) irix returns 0xFFFFFFFF from telldir() for the last entry in the directory. When added to DIR_OFFSET_BASE this became DIR_OFFSET_DOTDOT which meant an infinite loop! (This used to be commit 8cce9740ed0da9f08d6821beb4acaa9d28d149c2)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_search.c')
-rw-r--r--source4/ntvfs/posix/pvfs_search.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c
index bfe0780958..6224e15304 100644
--- a/source4/ntvfs/posix/pvfs_search.c
+++ b/source4/ntvfs/posix/pvfs_search.c
@@ -75,12 +75,15 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs,
const char *unix_path,
const char *fname,
struct pvfs_search_state *search,
- uint32_t dir_index,
+ off_t dir_offset,
union smb_search_data *file)
{
struct pvfs_filename *name;
NTSTATUS status;
const char *shortname;
+ uint32_t dir_index = (uint32_t)dir_offset; /* truncated - see the code
+ in pvfs_list_seek_ofs() for
+ how we cope with this */
status = pvfs_resolve_partial(pvfs, file, unix_path, fname, &name);
if (!NT_STATUS_IS_OK(status)) {
@@ -249,7 +252,7 @@ static NTSTATUS pvfs_search_fill(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
while ((*reply_count) < max_count) {
union smb_search_data *file;
const char *name;
- uint_t ofs = search->current_index;
+ off_t ofs = search->current_index;
name = pvfs_list_next(dir, &search->current_index);
if (name == NULL) break;
@@ -419,10 +422,15 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs,
return NT_STATUS_INVALID_HANDLE;
}
- search->current_index = io->search_next.in.id.server_cookie;
- search->last_used = time(NULL);
dir = search->dir;
+ status = pvfs_list_seek_ofs(dir, io->search_next.in.id.server_cookie,
+ &search->current_index);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ search->last_used = time(NULL);
+
status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.data_level,
&reply_count, search_private, callback);
if (!NT_STATUS_IS_OK(status)) {
@@ -557,23 +565,24 @@ static NTSTATUS pvfs_search_next_trans2(struct ntvfs_module_context *ntvfs,
/* we didn't find the search handle */
return NT_STATUS_INVALID_HANDLE;
}
-
+
dir = search->dir;
+
+ status = NT_STATUS_OK;
/* work out what type of continuation is being used */
if (io->t2fnext.in.last_name && *io->t2fnext.in.last_name) {
status = pvfs_list_seek(dir, io->t2fnext.in.last_name, &search->current_index);
- if (!NT_STATUS_IS_OK(status)) {
- if (io->t2fnext.in.resume_key) {
- search->current_index = io->t2fnext.in.resume_key;
- } else {
- return status;
- }
+ if (!NT_STATUS_IS_OK(status) && io->t2fnext.in.resume_key) {
+ status = pvfs_list_seek_ofs(dir, io->t2fnext.in.resume_key,
+ &search->current_index);
}
- } else if (io->t2fnext.in.flags & FLAG_TRANS2_FIND_CONTINUE) {
- /* plain continue - nothing to do */
- } else {
- search->current_index = io->t2fnext.in.resume_key;
+ } else if (!(io->t2fnext.in.flags & FLAG_TRANS2_FIND_CONTINUE)) {
+ status = pvfs_list_seek_ofs(dir, io->t2fnext.in.resume_key,
+ &search->current_index);
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
search->num_ea_names = io->t2fnext.in.num_names;