Files
mars-nwe/include/nwfs/comnSA/name.h

477 lines
16 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $
|
| $RCSfile$
| $Revision: 1315 $
|
|---------------------------------------------------------------------------
| This module is used to:
| This defines the interface into name spaces.
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _NAME_H_
#define _NAME_H_
#ifndef _COMNBEASTS_H_
#include <comnBeasts.h>
#endif
#ifndef _NAMESPACE_H_
#include <include/nameSpace.h>
#endif
#include <library/xUnicode.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Pre-define struct(s) so Linux compiler doesn't complain */
struct FullDirectoryInfo_s;
/*---------------------------------------------------------------------------
* Defines
*---------------------------------------------------------------------------*/
/* preferably prime numbers since these numbers are used for hashing */
#define MIN_NAME_CACHE_SIZE 17 /* The minimum number of entries that */
/* can be set for the name cache. */
#define DEFAULT_NAME_CACHE_SIZE 2111 /* The maximum number of entries that */
/* can be set for the name cache. */
#define DEFAULT_MAX_NAME_CACHE_SIZE 100000 /* Default maximum size of the name cache */
#define MAX_NAME_CACHE_SIZE 1000000 /* The largest maximum size that can be set */
/* for the name cache. */
#define DEFAULT_CACHE_NAME_LEN 110 /* length of nameBuffer in default name cache entry */
/* Long enough for one 36 character null terminated */
/* unicode string and one 36 character unterminated */
/* ASCII string */
#define NAME_CACHE_OPTIMIZE_PERIOD 300 /* Interval between name cache optimizer executions */
/*---------------------------------------------------------------------------
* Structures
*---------------------------------------------------------------------------*/
/* when you add fields to this structure update the init area in nameCache.c */
typedef struct NameCacheCtrl_s
{
QUAD changeCount; /* incremented each time an entry is added */
QUAD uniGets; /* number of unicode cache gets */
QUAD uniHits; /* number of unicode cache hits */
QUAD uniPositiveHits; /* number of unicode cache hits for existing beasts */
QUAD uniNegativeHits; /* number of unicode cache hits for non-existing beasts */
QUAD asciiGets; /* number of ASCII cache gets */
QUAD asciiHits; /* number of ASCII cache hits */
QUAD asciiPositiveHits; /* number of ASCII cache hits for existing beasts */
QUAD asciiNegativeHits; /* number of ASCII cache hits for non-existing beasts */
QUAD numAllocs; /* number of times we allocated a packet */
QUAD numNegativeAdds; /* number of adds of a negative entry */
QUAD unusedEntryHit; /* number of times we got an entry from the unused list */
QUAD numUnusedFrees; /* number of times we freed a packet from the unused list */
QUAD numCountChanged; /* number of times the count had changed during add */
QUAD numAlreadyAdded; /* number of times an entry was already added when we went to add */
QUAD numVictimSelected; /* number of entries that have been victim selected */
QUAD numRemoved; /* number of entries removed (not victom selected) */
NINT maxEntries; /* max allowed entries in the cache */
NINT maxSize; /* max value that maxEntries can grow to */
NINT numEntries; /* number of entries in the cache */
NINT numUnusedEntries; /* number of unused cache entries */
NINT minValidSize; /* minimum value of maxEntries before an invalidate should occur */
NINT maxValidSize; /* minimum value of maxEntries before an invalidate should occur */
NINT lastInvalidateSize; /* value of maxEntries at last invalidate */
Latch_s latch; /* latch to control changes in this structure */
NINT numHashEntries; /* number of entries in each hash table */
DQhead_t *uniHash; /* pointer to unicode hash array */
DQhead_t *asciiHash; /* pointer to ASCII hash array */
DQhead_t LRUqueue; /* head of the Least Recently Used queue */
DQhead_t unusedQueue; /* head of the unused cache packets queue */
FsmLite_s fsm; /* FSM for optimiser */
OneShot_s nameOptAlarm; /* One shot event structure used to periodically trigger a re-size */
LONG nameOptFlags; /* Flags to determine if Optimizer has been
* scheduled, if unload is in progress
*/
#define NAME_OPT_FLAGS_SCHEDULED 0x00000001
#define NAME_OPT_FLAGS_UNINIT 0x00000002
} NameCacheCtrl_s;
typedef struct NameCacheNode_s
{
DQlink_t uniHashLink; /* unicode hash list link field (used by unusedQueue too) */
DQlink_t asciiHashLink; /* ASCII hash list link field */
DQlink_t LRUlink; /* LRU link field */
Zid_t zid; /* zid for the entry (value to return)*/
Zid_t parentZid; /* parent zid for the entry (key)*/
VolumeID_t volGuid; /* guid for the volume (key)*/
NINT nameSpaceID; /* name space mask for the entry (key)*/
NINT nameType; /* name Type for the entry (key)*/
unicode_t *uniName; /* Pointer to the unicode name */
NINT asciiNameLen; /* length of the ASCII name */
char *asciiName; /* Pointer to the ASCII Name */
NINT nameBufferLen; /* length of the nameBuffer in Bytes */
BYTE nameBuffer[1]; /* buffer which holds the names (keys)*/
} NameCacheNode_s;
struct nameCacheOptimizerStats_s
{
NINT resizeCount; /* Number of times we've re-sized the name cache */
NINT noResizeCount; /* Number of times we've executed the optimiser and not re-sized the cache */
NINT optimizeCount; /* Number of times we've invalidated the name cache on re-size */
NINT maxSize; /* Maximum size the name cache has been */
NINT minSize; /* Minimum size the name cache has been */
NINT maxChange; /* Largest change in size in the name cache */
NINT minChange; /* Smallest change in size in the name cache */
NINT maxInvalidateChange; /* Maximum change in size that caused an invalidate */
NINT minInvalidateChange; /* Smallest change in size that caused an invalidate */
NINT maxPctInvalidateChange; /* Largest percentage change in cache size */
NINT maxReqdNodeDestroys; /* Maximum number of cache nodes that needed to be destroyed following a re-size */
};
extern struct nameCacheOptimizerStats_s NameCacheOptimizerStats;
/*---------------------------------------------------------------------------
* Functions for manipulating names in beasts
*---------------------------------------------------------------------------*/
extern STATUS NAME_InsertAndMangleName(
struct GeneralMsg_s *genMsg,
void *beast, /*beast to insert*/
void *primaryBeast, /*primary, if beast is a hardlink */
void *directory, /*directory to insert into*/
NINT primaryNameSpaceID,
NINT nameType,
unicode_t *name,
NINT flags,
Xaction_s *xaction,
// cnt NINT *retNameUniquifier,
NINT *retBeastNamesAdded, /*Optional--NULL is allowed */
NINT *retDirNamesAdded); /*Optional--Null is allowed */
#define INSNAMEFL_NULL_FLAG 0x00000000
#define INSNAMEFL_NEW_PARENT_AUTH 0x00000001 /* If set, the names are for
* a new parent so the authorization
* info should be updated */
#define INSNAMEFL_DIRECTORY_ONLY 0x00000002 /* If set, the names are only
* added in directory, there'll be no
* name operations on beast. This is
* useful for some LSS (such as CD9660)
* which only want to unpack file names
* instead of create all file beasts
*/
extern STATUS NAME_WillAddToSalvage(
struct NamedBeast_s *beast,
struct NamedBeast_s *dir,
NINT flags,
struct ParentEntry_s *pentry);
extern STATUS NAME_RemoveAllNames(
struct GeneralMsg_s *genMsg,
void *beast, /*beast to insert*/
void *primaryBeast, /*primary beast if one exists */
void *directory, /*directory to remove from*/
NINT flags, /*flags passed to beast remove routine*/
Xaction_s *xaction,
NINT *retBeastNamesRemoved, /*Optional--NULL is allowed */
NINT *retDirNamesRemoved, /*Optional--Null is allowed */
ParentEntry_s *savedParentEntry); /*Optional--Null is allow, if non-null original parent entry is returned */
extern STATUS NAME_doAddName(
GeneralMsg_s *genMsg,
NamedBeast_s *beast,
ParentEntry_s *pentry,
NINT nameSpaceMask,
unicode_t *name,
NINT nsFlags);
#define REMNAMEFL_REMOVE_ALL_NAMES 0x00000000 /* default -- names will be
* removed from the beast and the
* parent directory, and the parent
* entry is deleted. */
#define REMNAMEFL_KEEP_BEAST_NAMES 0x00000001 /* if SET, keep the beast names
* and only remove names from the
* parent directory. */
#define REMNAMEFL_KEEP_PARENT_ENTRY 0x00000002 /* if SET, keep the empty
* parent entry in the beast because we
* are renaming and we will shortly
* re-insert names back into the
* parrent*/
#define REMNAMEFL_ATOMIC 0x00000004 /* If SET, the remove will
* be atomic, either all of the name
* entries will be removed, or none
* of them will. */
#define REMNAMEFL_REMOVE_PARENT_AUTH 0x00000008 /* If set, the names are for
* a parent that is being removed, so
* the authorization info should be
* updated */
#define REMNAMEFL_ADD_TO_SALVAGE 0x00000010 /* If set, the name will be
* added to the salvage system if
* it is appropriate to do so */
#define REMNAMEFL_ERROR_BACKOUT 0x00000020 /* If set, the names are being
* removed as part of an error backout
* and it is OK if a name is not in
* the directory. */
extern STATUS NAME_MoveDeletedNames(
GeneralMsg_s *genMsg,
void *voidBeast, /*beast whose names are to be moved*/
void *voidSrcDir, /*directory to move from */
void *voidTargetDir, /*directory to insert into*/
/* cnt NINT srcNameUniquifier, uniquifier of srcNames to be moved */
Xaction_s *xaction
/* cnt NINT *retNameUniquifier*/);
extern BOOL NAME_HasThisParentZID(
void *beast,
Zid_t parentZid);
extern BOOL NAME_HasThisNameUniquifier(
void *beast
/* cnt NINT nameUniquifier*/);
extern STATUS NAME_GetParentZid(
struct GeneralMsg_s *genMsg,
void *beast,
/* cnt NINT nameUniquifier, */
Zid_t *retParentZid,
NINT *retNameType);
extern ParentEntry_s *NAME_GetParentEntry(
struct GeneralMsg_s *genMsg,
void *beast
/* cnt NINT nameUniquifier*/);
extern STATUS NAME_GetNameTypeInfo(
struct GeneralMsg_s *genMsg,
void *beast,
/* cnt NINT nameUniquifier, */
TypeSpecificPersistentParentEntry_s **nameTypeInfo);
extern BOOL NAME_BeastHasNameInParent(
void *beast,
Zid_t parentZid,
NINT nameSpaceID,
NINT nameType,
unicode_t *name);
extern BOOL NAME_AllNamesInSalvage(
void *void_beast);
BOOL NAME_ThisIsLastUndeletedName(
ParentEntry_s *pentry,
NamedBeast_s *beast);
//extern BOOL NAME_BeastHasWildcardName(
// void *void_beast,
// NINT nameUniquifier,
// NINT nameSpaceID,
// NINT nameType,
// unicode_t *wildcardPattern);
extern STATUS NAME_GetFirstNameFromBeast(
struct GeneralMsg_s *genMsg,
void *voidBeast,
NINT retNameSize, /* may be 0 */
unicode_t *retName, /* may be NULL */
NINT *retNameSpaceID, /* may be NULL */
NINT *retNameType, /* may be NULL */
NINT *retNameLen); /* may be NULL */
extern STATUS NAME_RenameBeast(
struct GeneralMsg_s *genMsg,
void *srcBeast,
void *primaryBeast,
void *srcDir,
void *targetDir,
unicode_t *srcName,
unicode_t *newName,
struct NameSpace_s *nameSpace,
NINT srcNameType,
NINT newNameType,
struct RenameMsg_s *renMsg,
Xaction_s *xaction); /* May be NULL -- In fact is usually NULL */
extern void *NAME_FindNameInAsciiNameCache(
struct GeneralMsg_s *genMsg,
struct File_s *directory,
struct NameSpace_s *nameSpace,
NINT nameType,
NINT asciiNameLen,
char *asciiName,
NINT latchType,
BOOL dontDoVisibilityCheck
/* cnt NINT *retNameUniquifier*/);
extern Zid_t NAME_FindZidForNameInDir(
struct GeneralMsg_s *genMsg,
void *directory,
struct NameSpace_s *nameSpace,
NINT nameType,
unicode_t *name,
NINT asciiNameLen, /* May be 0. If non-zero, will add ASCII name to name Cache */
char *asciiName, /* May be NULL if asciiNameLen is 0 */
BOOL negativeNameCacheFlag
/* cnt NINT *retNameUniquifier*/);
extern void *NAME_FindNameInDir(
struct GeneralMsg_s *genMsg,
void *directory,
struct NameSpace_s *nameSpace,
NINT nameType,
unicode_t *name,
NINT asciiNameLen, /* May be 0. If non-zero, will add ASCII name to name Cache */
char *asciiName, /* May be NULL if asciiNameLen is 0 */
NINT latchType,
BOOL negativeNameCacheFlag,
BOOL dontDoVisibilityCheck
/* cnt NINT *retNameUniquifier*/);
extern void *NAME_FindNameInDirSpecialRules(
struct GeneralMsg_s *genMsg,
struct NamingMsg_s *nameMsg,
struct NameSpace_s **dosNameSpace,
BOOL negativeNameCacheFlag,
BOOL dontDoVisibilityCheck
/* cnt NINT *retNameUniquifier*/);
extern STATUS NAME_RemoveBeastlessNameFromDir(
struct GeneralMsg_s *genMsg,
Zid_t badzid,
void *directory,
struct NameSpace_s *nameSpace,
NINT nameType,
struct FullDirectoryInfo_s *nameInfo);
extern void NAME_RemoveStrandedParentEntry(
struct GeneralMsg_s *genMsg,
struct NamedBeast_s *beast,
struct ParentEntry_s *pentry,
struct Xaction_s *xaction);
extern STATUS NAME_CacheInit();
extern void NAME_CacheUninit();
extern void NAME_AddNameToCache(
QUAD count,
Volume_s *volume,
Zid_t parentZid,
struct NameSpace_s *nameSpace,
NINT nameType,
unicode_t *uniName,
NINT asciiNameLen, /* May be 0 */
char *asciiName, /* May be NULL if asciiNameLen is 0 */
Zid_t zid
/* cnt NINT nameUniquifier*/);
extern Zid_t NAME_GetNameFromCacheUnicode(
VolumeID_t *volume,
Zid_t parentZid,
struct NameSpace_s *nameSpace,
NINT nameType,
unicode_t *uniName,
BOOL *negativeEntryFlag,
QUAD *count
/* cnt NINT *retNameUniquifier*/ );
extern Zid_t NAME_GetNameFromCacheAscii(
VolumeID_t *volume,
Zid_t parentZid,
struct NameSpace_s *nameSpace,
NINT nameType,
NINT asciiNameLen,
char *asciiName,
BOOL *negativeEntryFlag,
QUAD *count
/* cnt NINT *retNameUniquifier*/);
extern STATUS NAME_RemoveNameFromCache(
struct GeneralMsg_s *genMsg,
Volume_s *volume,
Zid_t parentZid,
NINT nameSpaceMask,
NINT nameType,
unicode_t *uniName,
NINT nsFlag);
extern BOOL NAME_MatchAttributes(
NINT beastAttributes,
struct zMatchAttr_s *matchAttr);
extern STATUS NAME_HardLinkSetMatchAttributesInDirectory(
struct GeneralMsg_s *genMsg,
struct File_s *curFile,
struct File_s *curDir,
NINT newFileAttributes,
NINT oldFileAttributes,
struct Xaction_s *xaction);
extern STATUS NAME_SetMatchAttributesInDirectory(
struct GeneralMsg_s *genMsg,
struct File_s *curFile,
struct File_s *curDir,
/* cnt NINT fileNameUniquifier, */
NINT newFileAttributes,
NINT oldFileAttributes,
struct Xaction_s *xaction);
extern void NAME_InvalidateCacheEntriesForVolume(
VolumeID_t *volume);
extern void NAME_InvalidateCacheEntriesForDirectory(
VolumeID_t *volume,
Zid_t directoryZid);
extern void NAME_Reoptimize(
void);
extern void NAME_ReoptimizeStarter(
void);
extern NameCacheCtrl_s NameCache;
#if NSS_DEBUG IS_ENABLED
extern CONST unicode_t *NAME_GetFirstNameForDebug(void *voidBeast);
extern void ZAS_DisplayNameCache(void);
#endif
extern BOOL NameCacheEnabled;
extern BOOL AsciiNameCacheEnabled;
#ifdef __cplusplus
}
#endif
#endif