Removed KEEP_WRONG_DIRENT_RECLEN support.
Fixed endian issue. Changed due to new inode code. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10052 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8f60d4cdba
commit
04c79aa160
@ -1,12 +1,12 @@
|
|||||||
/* Query - query parsing and evaluation
|
/* Query - query parsing and evaluation
|
||||||
**
|
*
|
||||||
** Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de
|
* The pattern matching is roughly based on code originally written
|
||||||
** The pattern matching is roughly based on code originally written
|
* by J. Kercheval, and on code written by Kenneth Almquist, though
|
||||||
** by J. Kercheval, and on code written by Kenneth Almquist, though
|
* it shares no code.
|
||||||
** it shares no code.
|
*
|
||||||
**
|
* Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de.
|
||||||
** This file may be used under the terms of the OpenBeOS License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
@ -798,8 +798,9 @@ status_t
|
|||||||
Equation::Match(Inode *inode, const char *attributeName, int32 type, const uint8 *key, size_t size)
|
Equation::Match(Inode *inode, const char *attributeName, int32 type, const uint8 *key, size_t size)
|
||||||
{
|
{
|
||||||
// get a pointer to the attribute in question
|
// get a pointer to the attribute in question
|
||||||
|
NodeGetter nodeGetter(inode->GetVolume());
|
||||||
union value value;
|
union value value;
|
||||||
uint8 *buffer;
|
uint8 *buffer = (uint8 *)&value;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
|
|
||||||
// first, check if we are matching for a live query and use that value
|
// first, check if we are matching for a live query and use that value
|
||||||
@ -813,11 +814,13 @@ Equation::Match(Inode *inode, const char *attributeName, int32 type, const uint8
|
|||||||
buffer = const_cast<uint8 *>(key);
|
buffer = const_cast<uint8 *>(key);
|
||||||
} else if (!strcmp(fAttribute, "name")) {
|
} else if (!strcmp(fAttribute, "name")) {
|
||||||
// we need to lock before accessing Inode::Name()
|
// we need to lock before accessing Inode::Name()
|
||||||
|
nodeGetter.SetToNode(inode);
|
||||||
|
|
||||||
inode->SmallDataLock().Lock();
|
inode->SmallDataLock().Lock();
|
||||||
locked = true;
|
locked = true;
|
||||||
|
|
||||||
// if not, check for "fake" attributes, "name", "size", "last_modified",
|
// if not, check for "fake" attributes, "name", "size", "last_modified",
|
||||||
buffer = (uint8 *)inode->Name();
|
buffer = (uint8 *)inode->Name(nodeGetter.Node());
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
inode->SmallDataLock().Unlock();
|
inode->SmallDataLock().Unlock();
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@ -825,19 +828,28 @@ Equation::Match(Inode *inode, const char *attributeName, int32 type, const uint8
|
|||||||
|
|
||||||
type = B_STRING_TYPE;
|
type = B_STRING_TYPE;
|
||||||
size = strlen((const char *)buffer);
|
size = strlen((const char *)buffer);
|
||||||
} else if (!strcmp(fAttribute,"size")) {
|
} else if (!strcmp(fAttribute, "size")) {
|
||||||
buffer = (uint8 *)&inode->Node()->data.size;
|
#ifdef BFS_NATIVE_ENDIAN
|
||||||
|
buffer = (uint8 *)&inode->Node().data.size;
|
||||||
|
#else
|
||||||
|
value.Int64 = inode->Size();
|
||||||
|
#endif
|
||||||
type = B_INT64_TYPE;
|
type = B_INT64_TYPE;
|
||||||
} else if (!strcmp(fAttribute,"last_modified")) {
|
} else if (!strcmp(fAttribute, "last_modified")) {
|
||||||
buffer = (uint8 *)&inode->Node()->last_modified_time;
|
#ifdef BFS_NATIVE_ENDIAN
|
||||||
|
buffer = (uint8 *)&inode->Node().last_modified_time;
|
||||||
|
#else
|
||||||
|
value.Int64 = inode->Node().LastModifiedTime();
|
||||||
|
#endif
|
||||||
type = B_INT64_TYPE;
|
type = B_INT64_TYPE;
|
||||||
} else {
|
} else {
|
||||||
// then for attributes in the small_data section, and finally for the
|
// then for attributes in the small_data section, and finally for the
|
||||||
// real attributes
|
// real attributes
|
||||||
|
nodeGetter.SetToNode(inode);
|
||||||
Inode *attribute;
|
Inode *attribute;
|
||||||
|
|
||||||
inode->SmallDataLock().Lock();
|
inode->SmallDataLock().Lock();
|
||||||
small_data *smallData = inode->FindSmallData(fAttribute);
|
small_data *smallData = inode->FindSmallData(nodeGetter.Node(), fAttribute);
|
||||||
if (smallData != NULL) {
|
if (smallData != NULL) {
|
||||||
buffer = smallData->Data();
|
buffer = smallData->Data();
|
||||||
type = smallData->type;
|
type = smallData->type;
|
||||||
@ -846,10 +858,11 @@ Equation::Match(Inode *inode, const char *attributeName, int32 type, const uint8
|
|||||||
} else {
|
} else {
|
||||||
// needed to unlock the small_data section as fast as possible
|
// needed to unlock the small_data section as fast as possible
|
||||||
inode->SmallDataLock().Unlock();
|
inode->SmallDataLock().Unlock();
|
||||||
|
nodeGetter.Unset();
|
||||||
|
|
||||||
if (inode->GetAttribute(fAttribute, &attribute) == B_OK) {
|
if (inode->GetAttribute(fAttribute, &attribute) == B_OK) {
|
||||||
buffer = (uint8 *)&value;
|
buffer = (uint8 *)&value;
|
||||||
type = attribute->Node()->type;
|
type = attribute->Type();
|
||||||
size = attribute->Size();
|
size = attribute->Size();
|
||||||
|
|
||||||
if (size > INODE_FILE_NAME_LENGTH)
|
if (size > INODE_FILE_NAME_LENGTH)
|
||||||
@ -1096,14 +1109,7 @@ Equation::GetNextMatching(Volume *volume, TreeIterator *iterator,
|
|||||||
if (inode->GetName(dirent->d_name) < B_OK)
|
if (inode->GetName(dirent->d_name) < B_OK)
|
||||||
FATAL(("inode %Ld in query has no name!\n", inode->BlockNumber()));
|
FATAL(("inode %Ld in query has no name!\n", inode->BlockNumber()));
|
||||||
|
|
||||||
#ifdef KEEP_WRONG_DIRENT_RECLEN
|
|
||||||
// ToDo: The available file systems in BeOS apparently don't set the
|
|
||||||
// correct d_reclen - we are copying that behaviour if requested, but
|
|
||||||
// if it doesn't break compatibility, we will remove it.
|
|
||||||
dirent->d_reclen = strlen(dirent->d_name);
|
|
||||||
#else
|
|
||||||
dirent->d_reclen = sizeof(struct dirent) + strlen(dirent->d_name);
|
dirent->d_reclen = sizeof(struct dirent) + strlen(dirent->d_name);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == MATCH_OK)
|
if (status == MATCH_OK)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
/* Query - query parsing and evaluation
|
||||||
|
*
|
||||||
|
* Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* This file may be used under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef QUERY_H
|
#ifndef QUERY_H
|
||||||
#define QUERY_H
|
#define QUERY_H
|
||||||
/* Query - query parsing and evaluation
|
|
||||||
**
|
|
||||||
** Initial version by Axel Dörfler, axeld@pinc-software.de
|
|
||||||
** This file may be used under the terms of the OpenBeOS License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user