From af0a9eb52955cfae570bfdc01821f56385c860cf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Jul 2006 08:00:24 +0000 Subject: r16834: split the level's of smb_search_first/smb_search_next and the levels of smb_search_data metze (This used to be commit 78c201db8a47a71908698c4dda2add4cf85694d9) --- source4/ntvfs/nbench/vfs_nbench.c | 4 +- source4/ntvfs/posix/pvfs_search.c | 116 +++++++++++++++++++++++++------------- source4/ntvfs/simple/vfs_simple.c | 12 +++- 3 files changed, 90 insertions(+), 42 deletions(-) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index f7834a9751..34cf8d9565 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -819,13 +819,13 @@ static void nbench_search_first_send(struct ntvfs_request *req) union smb_search_first *io = req->async_states->private_data; switch (io->generic.level) { - case RAW_SEARCH_BOTH_DIRECTORY_INFO: + case RAW_SEARCH_TRANS2: if (NT_STATUS_IS_ERR(req->async_states->status)) { ZERO_STRUCT(io->t2ffirst.out); } nbench_log(req, "FIND_FIRST \"%s\" %d %d %d %s\n", io->t2ffirst.in.pattern, - io->generic.level, + io->t2ffirst.data_level, io->t2ffirst.in.max_count, io->t2ffirst.out.count, get_nt_error_c_code(req->async_states->status)); diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index 4d218fbe9c..794d223060 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -68,7 +68,7 @@ static void pvfs_search_setup_timer(struct pvfs_search_state *search) fill in a single search result for a given info level */ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, - enum smb_search_level level, + enum smb_search_data_level level, const char *unix_path, const char *fname, struct pvfs_search_state *search, @@ -90,9 +90,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, } switch (level) { - case RAW_SEARCH_SEARCH: - case RAW_SEARCH_FFIRST: - case RAW_SEARCH_FUNIQUE: + case RAW_SEARCH_DATA_SEARCH: shortname = pvfs_short_name(pvfs, name, name); file->search.attrib = name->dos.attrib; file->search.write_time = nt_time_to_unix(name->dos.write_time); @@ -107,7 +105,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->search.id.client_cookie = 0; return NT_STATUS_OK; - case RAW_SEARCH_STANDARD: + case RAW_SEARCH_DATA_STANDARD: file->standard.resume_key = dir_index; file->standard.create_time = nt_time_to_unix(name->dos.create_time); file->standard.access_time = nt_time_to_unix(name->dos.access_time); @@ -118,7 +116,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->standard.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_EA_SIZE: + case RAW_SEARCH_DATA_EA_SIZE: file->ea_size.resume_key = dir_index; file->ea_size.create_time = nt_time_to_unix(name->dos.create_time); file->ea_size.access_time = nt_time_to_unix(name->dos.access_time); @@ -130,7 +128,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->ea_size.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_EA_LIST: + case RAW_SEARCH_DATA_EA_LIST: file->ea_list.resume_key = dir_index; file->ea_list.create_time = nt_time_to_unix(name->dos.create_time); file->ea_list.access_time = nt_time_to_unix(name->dos.access_time); @@ -144,7 +142,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, search->ea_names, &file->ea_list.eas); - case RAW_SEARCH_DIRECTORY_INFO: + case RAW_SEARCH_DATA_DIRECTORY_INFO: file->directory_info.file_index = dir_index; file->directory_info.create_time = name->dos.create_time; file->directory_info.access_time = name->dos.access_time; @@ -156,7 +154,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->directory_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_FULL_DIRECTORY_INFO: + case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO: file->full_directory_info.file_index = dir_index; file->full_directory_info.create_time = name->dos.create_time; file->full_directory_info.access_time = name->dos.access_time; @@ -169,12 +167,12 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->full_directory_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_NAME_INFO: + case RAW_SEARCH_DATA_NAME_INFO: file->name_info.file_index = dir_index; file->name_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_BOTH_DIRECTORY_INFO: + case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO: file->both_directory_info.file_index = dir_index; file->both_directory_info.create_time = name->dos.create_time; file->both_directory_info.access_time = name->dos.access_time; @@ -188,7 +186,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->both_directory_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_ID_FULL_DIRECTORY_INFO: + case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO: file->id_full_directory_info.file_index = dir_index; file->id_full_directory_info.create_time = name->dos.create_time; file->id_full_directory_info.access_time = name->dos.access_time; @@ -202,7 +200,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->id_full_directory_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_ID_BOTH_DIRECTORY_INFO: + case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO: file->id_both_directory_info.file_index = dir_index; file->id_both_directory_info.create_time = name->dos.create_time; file->id_both_directory_info.access_time = name->dos.access_time; @@ -217,7 +215,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->id_both_directory_info.name.s = fname; return NT_STATUS_OK; - case RAW_SEARCH_GENERIC: + case RAW_SEARCH_DATA_GENERIC: break; } @@ -231,7 +229,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, static NTSTATUS pvfs_search_fill(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx, uint_t max_count, struct pvfs_search_state *search, - enum smb_search_level level, + enum smb_search_data_level level, uint_t *reply_count, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) @@ -378,7 +376,7 @@ static NTSTATUS pvfs_search_first_old(struct ntvfs_module_context *ntvfs, talloc_set_destructor(search, pvfs_search_destructor); - status = pvfs_search_fill(pvfs, req, io->search_first.in.max_count, search, io->generic.level, + status = pvfs_search_fill(pvfs, req, io->search_first.in.max_count, search, io->generic.data_level, &reply_count, search_private, callback); if (!NT_STATUS_IS_OK(status)) { return status; @@ -422,7 +420,7 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs, search->last_used = time(NULL); dir = search->dir; - status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.level, + status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.data_level, &reply_count, search_private, callback); if (!NT_STATUS_IS_OK(status)) { return status; @@ -441,10 +439,10 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs, /* list files in a directory matching a wildcard pattern */ -NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, union smb_search_first *io, - void *search_private, - BOOL (*callback)(void *, union smb_search_data *)) +static NTSTATUS pvfs_search_first_trans2(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_first *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) { struct pvfs_dir *dir; struct pvfs_state *pvfs = ntvfs->private_data; @@ -456,10 +454,6 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs, struct pvfs_filename *name; int id; - if (io->generic.level >= RAW_SEARCH_SEARCH) { - return pvfs_search_first_old(ntvfs, req, io, search_private, callback); - } - search_attrib = io->t2ffirst.in.search_attrib; pattern = io->t2ffirst.in.pattern; max_count = io->t2ffirst.in.max_count; @@ -512,7 +506,7 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs, DLIST_ADD(pvfs->search.list, search); talloc_set_destructor(search, pvfs_search_destructor); - status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.level, + status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.data_level, &reply_count, search_private, callback); if (!NT_STATUS_IS_OK(status)) { return status; @@ -541,10 +535,10 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs, } /* continue a search */ -NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, union smb_search_next *io, - void *search_private, - BOOL (*callback)(void *, union smb_search_data *)) +static NTSTATUS pvfs_search_next_trans2(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_next *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) { struct pvfs_state *pvfs = ntvfs->private_data; struct pvfs_search_state *search; @@ -553,10 +547,6 @@ NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, uint16_t handle; NTSTATUS status; - if (io->generic.level >= RAW_SEARCH_SEARCH) { - return pvfs_search_next_old(ntvfs, req, io, search_private, callback); - } - handle = io->t2fnext.in.handle; search = idr_find(pvfs->search.idtree, handle); @@ -586,7 +576,7 @@ NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, search->num_ea_names = io->t2fnext.in.num_names; search->ea_names = io->t2fnext.in.ea_names; - status = pvfs_search_fill(pvfs, req, io->t2fnext.in.max_count, search, io->generic.level, + status = pvfs_search_fill(pvfs, req, io->t2fnext.in.max_count, search, io->generic.data_level, &reply_count, search_private, callback); if (!NT_STATUS_IS_OK(status)) { return status; @@ -605,18 +595,68 @@ NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; } +/* + list files in a directory matching a wildcard pattern +*/ +NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_first *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) +{ + switch (io->generic.level) { + case RAW_SEARCH_SEARCH: + case RAW_SEARCH_FFIRST: + case RAW_SEARCH_FUNIQUE: + return pvfs_search_first_old(ntvfs, req, io, search_private, callback); + + case RAW_SEARCH_TRANS2: + return pvfs_search_first_trans2(ntvfs, req, io, search_private, callback); + } + + return NT_STATUS_INVALID_LEVEL; +} + +/* continue a search */ +NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_search_next *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) +{ + switch (io->generic.level) { + case RAW_SEARCH_SEARCH: + case RAW_SEARCH_FFIRST: + return pvfs_search_next_old(ntvfs, req, io, search_private, callback); + + case RAW_SEARCH_FUNIQUE: + return NT_STATUS_INVALID_LEVEL; + + case RAW_SEARCH_TRANS2: + return pvfs_search_next_trans2(ntvfs, req, io, search_private, callback); + } + + return NT_STATUS_INVALID_LEVEL; +} + + /* close a search */ NTSTATUS pvfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { struct pvfs_state *pvfs = ntvfs->private_data; struct pvfs_search_state *search; - uint16_t handle; + uint16_t handle = 0; - if (io->generic.level == RAW_FINDCLOSE_FCLOSE) { + switch (io->generic.level) { + case RAW_FINDCLOSE_GENERIC: + return NT_STATUS_INVALID_LEVEL; + + case RAW_FINDCLOSE_FCLOSE: handle = io->fclose.in.id.handle; - } else { + break; + + case RAW_FINDCLOSE_FINDCLOSE: handle = io->findclose.in.handle; + break; } search = idr_find(pvfs->search.idtree, handle); diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 9e5d4ae922..beffe2b546 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -838,7 +838,11 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, union smb_search_data file; uint_t max_count; - if (io->generic.level != RAW_SEARCH_BOTH_DIRECTORY_INFO) { + if (io->generic.level != RAW_SEARCH_TRANS2) { + return NT_STATUS_NOT_SUPPORTED; + } + + if (io->generic.data_level != RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO) { return NT_STATUS_NOT_SUPPORTED; } @@ -908,7 +912,11 @@ static NTSTATUS svfs_search_next(struct ntvfs_module_context *ntvfs, union smb_search_data file; uint_t max_count; - if (io->generic.level != RAW_SEARCH_BOTH_DIRECTORY_INFO) { + if (io->generic.level != RAW_SEARCH_TRANS2) { + return NT_STATUS_NOT_SUPPORTED; + } + + if (io->generic.data_level != RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO) { return NT_STATUS_NOT_SUPPORTED; } -- cgit