changed ObLookupObject to use Parse member if nonnull

svn path=/trunk/; revision=181
This commit is contained in:
Rex Jolliff 1999-01-20 00:19:46 +00:00
parent a1fca3d3ae
commit 5998255e83

View file

@ -432,8 +432,12 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
InsertTailList(&parent->head,&Object->Entry); InsertTailList(&parent->head,&Object->Entry);
} }
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object, NTSTATUS
PWSTR* UnparsedSection, ULONG Attributes) ObLookupObject(HANDLE rootdir,
PWSTR string,
PVOID* Object,
PWSTR* UnparsedSection,
ULONG Attributes)
/* /*
* FUNCTION: Lookup an object within the system namespc * FUNCTION: Lookup an object within the system namespc
* ARGUMENTS: * ARGUMENTS:
@ -443,112 +447,120 @@ NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
* On failure NULL * On failure NULL
*/ */
{ {
PWSTR current; PWSTR current;
PWSTR next; PWSTR next;
PDIRECTORY_OBJECT current_dir = NULL; PDIRECTORY_OBJECT current_dir = NULL;
NTSTATUS Status; NTSTATUS Status;
DPRINT("ObLookupObject(rootdir %x, string %x, string %w, Object %x, " DPRINT("ObLookupObject(rootdir %x, string %x, string %w, Object %x, "
"UnparsedSection %x)\n",rootdir,string,string,Object, "UnparsedSection %x)\n",rootdir,string,string,Object,
UnparsedSection); UnparsedSection);
*UnparsedSection = NULL;
*Object = NULL;
*UnparsedSection = NULL; if (rootdir == NULL)
*Object = NULL; {
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
if (rootdir==NULL) }
{ else
current_dir = HEADER_TO_BODY(&(namespc_root.hdr)); {
} ObReferenceObjectByHandle(rootdir,
else DIRECTORY_TRAVERSE,
{ NULL,
ObReferenceObjectByHandle(rootdir,DIRECTORY_TRAVERSE,NULL, UserMode,
UserMode,(PVOID*)&current_dir,NULL); (PVOID*)&current_dir,
NULL);
} }
/* /*
* Bit of a hack this * Bit of a hack this
*/ */
if (string[0]==0) if (string[0] == 0)
{ {
*Object=current_dir; *Object = current_dir;
return(STATUS_SUCCESS); return STATUS_SUCCESS;
} }
if (string[0]!='\\') if (string[0] != '\\')
{ {
DbgPrint("(%s:%d) Non absolute pathname passed to %s\n",__FILE__, DbgPrint("Non absolute pathname passed\n");
__LINE__,__FUNCTION__); return STATUS_UNSUCCESSFUL;
return(STATUS_UNSUCCESSFUL); }
}
next = &string[0]; next = string;
current = next+1; current = next + 1;
while (next!=NULL && while (next != NULL &&
BODY_TO_HEADER(current_dir)->ObjectType==ObDirectoryType) BODY_TO_HEADER(current_dir)->ObjectType == ObDirectoryType)
{ {
*next = '\\'; *next = '\\';
current = next+1; current = next + 1;
next = wcschr(next+1,'\\'); next = wcschr(next + 1,'\\');
if (next!=NULL) if (next != NULL)
{ {
*next=0; *next = 0;
} }
DPRINT("current %w current[5] %x next %x ",current,current[5],next); DPRINT("current %w current[5] %x next %x ", current, current[5], next);
if (next!=NULL) if (next != NULL)
{ {
DPRINT("(next+1) %w",next+1); DPRINT("(next+1) %w", next + 1);
} }
DPRINT("\n",0); DPRINT("\n",0);
current_dir=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current, current_dir = (PDIRECTORY_OBJECT)ObDirLookup(current_dir,
Attributes); current,
if (current_dir==NULL) Attributes);
{ if (current_dir == NULL)
DbgPrint("(%s:%d) Path component %w not found\n",__FILE__, {
__LINE__,current); DbgPrint("Path component %w not found\n", current);
return(STATUS_UNSUCCESSFUL); return STATUS_UNSUCCESSFUL;
} }
if (BODY_TO_HEADER(current_dir)->ObjectType==IoSymbolicLinkType) if (BODY_TO_HEADER(current_dir)->ObjectType == IoSymbolicLinkType)
{ {
current_dir = IoOpenSymlink(current_dir); current_dir = IoOpenSymlink(current_dir);
} }
} }
DPRINT("next %x\n",next); DPRINT("next %x\n",next);
DPRINT("current %x current %w\n",current,current); DPRINT("current %x current %w\n",current,current);
if (next==NULL) if (next == NULL)
{ {
if (current_dir==NULL) if (current_dir == NULL)
{ {
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;
} }
else else
{ {
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
} }
} }
else else
{ {
CHECKPOINT; CHECKPOINT;
*next = '\\'; *next = '\\';
*UnparsedSection = next; *UnparsedSection = next;
if (BODY_TO_HEADER(current_dir)->ObjectType == IoDeviceType) if (BODY_TO_HEADER(current_dir)->ObjectType == IoDeviceType)
{ {
Status = STATUS_FS_QUERY_REQUIRED; Status = STATUS_FS_QUERY_REQUIRED;
} }
else else if (BODY_TO_HEADER(current_dir)->ObjectType->Parse != NULL)
{ {
Status = STATUS_UNSUCCESSFUL; current_dir = BODY_TO_HEADER(current_dir)->ObjectType->
} Parse(current_dir,
} UnparsedSection);
CHECKPOINT; Status = (current_dir != NULL) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
*Object = current_dir; }
DPRINT("(%s:%d) current_dir %x\n",__FILE__,__LINE__,current_dir); else
{
return(Status); Status = STATUS_UNSUCCESSFUL;
}
}
CHECKPOINT;
*Object = current_dir;
DPRINT("current_dir %x\n", current_dir);
return Status;
} }