AMS Extensions
Version 3.0
Andrew Hanushevsky
Stanford Linear Accelerator Center
8/26/98
Acknowledgements
Urs Bertschinger, Objectivity Inc.
for co-designing the initial oofs() interface and modifying AMS v4 to use it.
Karl Quackenbush, Objectivity Inc.
for suggested improvements and modifying AMS v5 to use it.
Marcin Nowak, CERN
for invaluable debugging assistance and helpful modifications.
1 Introduction *1.1 Acronyms
*1.2 Common Definitions
*1.2.1
Constants *1.2.2
Limits *1.2.3
Data Types *1.2.4
Classes *1.2.4.1 The oofsError Class
*1.3 Client-Side Definitions
*1.3.1
Constants *1.3.2
Data Types *1.3.3
Classes *1.3.3.1 The oofsSecurity Class
*1.3.4
Opaque Information Interface *1.4 Server-Side Definitions
*1.4.1
Constants *1.4.2
Data Types *1.4.3
Classes *1.4.3.1 The oofsDesc Class
*1.4.3.2 The oofsDir Class
*1.4.3.3 The oofsFile Class
*2
oofs Interface Definition *2.1 oofsGetFileSystem()
*2.2 oofsDesc Class Methods
*2.2.1
exists() *2.2.2
GetSecToken() *2.2.3
openDir() *2.2.4
openFile() *2.2.5
remove() *2.2.6
rename() *2.3 oofsDir Class Methods
*2.3.1
close() *2.3.2
getNext() *2.3.3
open() *2.4 oofsError Class Methods
*2.4.1
getErrorInfo() *2.5 oofsFile Class Methods
*2.5.1
close() *2.5.2
getmode() *2.5.3
getsize() *2.5.4
open() *2.5.5
read() *2.5.6
sync() *2.5.7
truncate() *2.5.8
write() *3
Generic Authentication Protocol *3.1 Application Steps in GAP
*3.2 OCSK Steps in GAP
*3.3 AMS Steps in GAP
*3.4 Security Interface Definition
*3.4.1
oofs_Register_Security() *3.4.1.1 GetCred()
*4
Opaque Information Protocol *4.1 Application Steps in OIP
*4.2 OCSK Steps in OIP
*4.3 AMS Steps in OIP
*4.3.1
oofs_set_info() *5
Defer Request Protocol *5.1 AMS Steps in DRP
*5.2 OCSK Steps in DRP
*6
Request Redirection Protocol *6.1 AMS Steps in RRP
*6.2 OCSK Steps in RRP
*7 Appendix A
*7.1 oofs_set()
*This document describes Advanced Multithreaded Server (AMS) extensions providing:
The relationships between these components are shown in the following figure.
Major changes occur in the AMS. Prior to the changes, the AMS was distributed as a single module. The new AMS is distributed as two linkable components:
These two components are then linked to two site selectable components:
A functional AMS is built by linking the appropriate four components. The default AMS is normally distributed as an executable module linked to use the native Unix File System (UFS) and a null security service.
The client-side components are relatively straightforward. The Objectivity Kernel internally handles DRP and RRP. Client-supplied programs to transmit authentication and opaque information via registered callback functions implicitly use the GAP and OIP components. Hence, the Kernel is distributed as a single linkable component, as before.
AMS
Advanced Multithreaded ServerAMSC Advanced Multithreaded Server Collective
APID Autonomous Partition Identifier
DRP Defer Request Protocol
FDID Federated Database Identifier
GAP Generic Authentication Protocol
OCSK Objectivity Client-Side Kernel
OOFS Object Oriented File System
OIP Opaque Information Protocol
RRP Request Redirect Protocol
SO Security Object of class oofsSecurity
ST Security Token returned by the AMS
// Valid return values from oofs() that return an integer
#define OOFS_OK 0 // Return code -> All is well
#define OOFS_ERROR -1 // Return code -> Error occurred
// Longest filename returned by interface (including trailing null)
#define OOFS_MAX_FILE_NAME_LEN (1024+1)
// Longest error message string returned (including trailing null)
#define OOFS_MAX_ERROR_LEN (255+1)
// Maximum number of bytes of opaque information that can be set
#define OOFS_MAX_INFO_LEN 4096
// Maximum number of bytes of security information that can be set
#define OOFS_MAX_SECTOKEN_LEN 4096
typedef char oofsErrorBuf[OOFS_MAX_ERROR_LEN];
typedef oofsBuffer oofsOpaqueInfo;
typedef oofsBuffer oofsCredentials;
struct oofsErrorStruct // Error information structure
{
ooUInt32 code;
oofsErrorBuf message;
oofsErrorStruct() {code = 0; message[0] = ‘\0’;}
};
struct oofsBuffer // Generic buffer definition
{
ooUInt32 size;
char *data;
oofsBuffer() {size = 0; data = NULL;}
};
class oofsError
{protected:
oofsErrorStruct ErrorInfo;
public:
int getErrorInfo() {return ErrorInfo.code;}
int getErrorInfo(oofsErrorStruct &ErrorParm)
{strcpy(ErrorParm.message, ErrorInfo.message);
ErrorParm.code = ErrorInfo.code;
Return ErrorInfo.code;
}
}
// Parameter to the oofs_set_info() function to describe handling
#define OOFS_SOI_ALWAYS 0 // keep resending information
#define OOFS_SOI_ONCE 1 // send information only once
// Operation class codes when calling oofs_GetCred()
#define OOFS_DIRS 0x0100 // Directory operations
#define OOFS_META 0x0200 // Metadata operations
#define OOFS_MISC 0x0400 // Miscellaneous
#define OOFS_OPCL 0x0800 // Open/close operations
#define OOFS_RWTS 0x1000 // Read/write operations
// Operation codes when calling oofs_GetCred()
#define OOFS_CLOSE 0x01||OOFS_OPCL // OPCL: oofs_close()
#define OOFS_CLOSEDIR 0x02||OOFS_DIRS // Dirs: not used
#define OOFS_EXISTS 0x03||OOFS_MISC // Misc: oofs_exists()
#define OOFS_GETSIZE 0x04||OOFS_MISC // Misc: oofs_getsize()
#define OOFS_GETMODE 0x05||OOFS_MISC // Misc: oofs_getmode()
#define OOFS_OPEN 0x06||OOFS_OPCL // OPCL: oofs_open()
#define OOFS_OPENDIR 0x07||OOFS_DIRS // Dirs: oofs_opendir()
#define OOFS_READ 0x08||OOFS_RWTS // RWTS: oofs_read()
#define OOFS_READDIR 0x09||OOFS_DIRS // Dirs: not used
#define OOFS_REMOVE 0x0a||OOFS_META // Meta: oofs_remove()
#define OOFS_RENAME 0x0b||OOFS_META // Meta: oofs_rename()
#define OOFS_SYNC 0x0c||OOFS_RWTS // RWTS: oofs_sync()
#define OOFS_TRUNCATE 0x0d||OOFS_RWTS // RWTS: oofs_truncate()
#define OOFS_WRITE 0x0e||OOFS_RWTS // RWTS: oofs_write()
typedef oofsBuffer oofsSecurityToken;
struct oofsContextStruct // Info passed to Security Object Creator
{
struct sockaddr_in ServerHostAddress; // <- getpeername()
oofsSecurityToken SecToken;
ooUInt32 FDID;
ooUInt32 APID;
}
struct oofsRequestStruct // Info passed to Security Object GetCred
{
ooUInt32 operation;
ooUInt32 FDID;
ooUInt32 APID;
const char * pathname;
const char * filename;
}
class oofsSecurity : virtual public oofsError
{
public:
int getVersion()
{return OOFS_SEC_SYSTEM_DESC_VERSION;}
oofsCredentials *GetCred(oofsRequestStruct *);
// Routine to register the oofsSecurity creator
int oofs_Register_Security(oofsSecurity *);
int oofs_set_info(const char *info,
const int infolen,
const ooInt flags);
// Parameter to the oofs_Open() function to set access mode
#define OOFS_S_IRWXU 0000700 // Owner: read, write, execute perm
#define OOFS_S_IRUSR 0000400 // Owner: read permission
#define OOFS_S_IWUSR 0000200 // Owner: write permission
#define OOFS_S_IXUSR 0000100 // Owner: execute/search permission
#define OOFS_S_IRWXG 0000070 // Group: read, write, execute perm
#define OOFS_S_IRGRP 0000040 // Group: read permission
#define OOFS_S_IWGRP 0000020 // Group: write permission
#define OOFS_S_IXGRP 0000010 // Group: execute/search permission
#define OOFS_S_IRWXO 0000007 // Other: read, write, execute perm
#define OOFS_S_IROTH 0000004 // Other: read permission
#define OOFS_S_IWOTH 0000002 // Other: write permission
#define OOFS_S_IXOTH 0000001 // Other: execute/search permission
// Parameter to the oofs_Open() function to set access type
#define OOFS_O_RDONLY 0 // open read/only
#define OOFS_O_WRONLY 1 // open write/only
#define OOFS_O_RDWR 2 // open read/write
#define OOFS_O_CREAT 0x100 // open creating the file
// Current version of the oofs() interfaces
#define OOFS_FILE_SYSTEM_DESC_VERSION 1
#define OOFS_SEC_SYSTEM_DESC_VERSION 1
typedef char oofsFileNameBuf[OOFS_MAX_FILE_NAME_LEN];
typedef ooInt32 oofsFileCreateMode;
typedef ooInt32 oofsFileOpenMode;
typedef ooInt32 oofsXferSize;
struct oofsCredStruct // Credentials passed to oofs()
{
struct sockaddr_in ClientHostAddress; // <- getpeername()
struct oofsCredentials ClientCredentials;
}
struct oofsFileOffset // 64-bit file offset
{
ooUInt32 high_offset;
ooUInt32 low_offset;
};
class oofsDesc
{
public:
int getVersion() {return OOFS_FILE_SYSTEM_DESC_VERSION;}
/********** File Functions **********/
virtual oofsFile *openFile(const char *FileName,
oofsFileOpenMode,
oofsFileCreateMode,
oofsErrorStruct &,
oofsCredStruct *,
oofsOpaqueInfo *);
/********** Directory Functions **********/
virtual oofsDir *openDir(const char *DirectoryPath,
oofsErrorStruct &,
oofsCredStruct *);
/********** Miscellaneous Functions **********/
virtual int exists(const char *FileName,
int &exist_flag,
oofsErrorStruct &);
virtual int remove(const char *FileName
oofsErrorStruct &);
virtual int rename(const char *FileName1,
const char *FileName2
oofsErrorStruct &);
virtual oofsSecurityToken *GetSecToken(oofsErrorStruct &);
/********** Miscellaneous Functions + Security **********/
virtual int exists(const char *fileName,
int &exists_flag,
oofsErrorStruct &,
oofsCredStruct *)
{return exists(fileName, exists_flag);}
virtual int remove(const char *fileName,
oofsErrorStruct &,
oofsCredStruct *)
{return remove(fileName);}
virtual int rename(const char *fileName1,
const char *fileName2,
oofsErrorStruct &,
oofsCredStruct *)
{return rename(fileName1, fileName2);}
virtual oofsSecurityToken *GetSecToken
(oofsErrorStruct &,
oofsCredStruct *) {return GetSecToken();}
// destruct called at AMS exit
void (*destruct)(); // can set to 0, to not destruct
};
// Init & return -> FSDesc
oofsFileSystemDesc *oofsGetFileSystem();
class oofsDir : virtual public oofsError
{protected:
void *data;
public:
oofsDir() {data = 0;}
/********** Basic Directory Functions **********/
virtual int open( const char *dir );
// no more avail when return of 0 and error.code == 0
virtual const char *getNext();
virtual int close();
/********** Directory Functions + Security **********/
virtual int open(const char *dir,
oofsCredStruct *credentials)
{return open(dir);}
virtual const char *getNext(oofsCredStruct *credentials)
{return getNext();}
virtual int close(oofsCredStruct *credentials)
{return close();}
}; // class oofsDir
class oofsFile : virtual public oofsError
{protected:
void *data;
public:
oofsFile(){data = 0;}
/********** Basic File Functions **********/
virtual int open(const char *fileName,
oofsFileOpenMode omode,
oofsFileCreateMode cmode);
virtual int close();
virtual oofsXferSize read(oofsFileOffset,
char *buffer,
oofsXferSize buffer_size);
virtual oofsXferSize write(oofsFileOffset,
char *buffer,
oofsXferSize buffer_size);
virtual int sync();
virtual int truncate(oofsFileOffset);
virtual int getSize(oofsFileOffset &);
virtual int getMode(oofsFileCreateMode &);
/******* Basic File Functions With Security *******/
virtual int open(const char *fileName,
oofsFileOpenMode openMode,
oofsFileCreateMode createMode,
oofsCredStruct *credentials)
{return open(fileName, openMode, createMode);}
virtual int close(oofsCredentials *credentials)
{return close();}
virtual oofsXferSize read(oofsFileOffset fileOffset,
char *buffer,
oofsXferSize buffer_size,
oofsCredStruct *credentials)
{return read(fileOffset, buffer, buffer_size);
virtual oofsXferSize write(oofsFileOffset fileOffset,
char *buffer,
oofsXferSize buffer_size,
oofsCredStruct *credentials)
{return write(fileOffset, buffer, buffer_size);
virtual int sync (oofsCredStruct *credentials)
{return sync();}
virtual int truncate(oofsFileOffset fileOffset,
oofsCredStruct *credentials)
{return truncate(fileOffset);}
virtual int getSize(oofsFileOffset &fileOffset,
oofsCredStruct *credentials)
{return getSize(fileOffset);}
virtual int getMode(oofsFileCreateMode &CreateMode,
oofsCredStruct *credentials)
{return getMode(CreateMode);}
/* File Functions With Security & Opaque Information */
virtual int open(const char *fileName,
oofsFileOpenMode openMode,
oofsFileCreateMode createMode,
oofsCredStruct *credentials,
oofsOpaqueInfo *opaqueInfo)
{return open(fileName, openMode, createMode, credentials);}
}; // class oofsFile
oofsDesc *oofsGetFileSystem(); // In
Function
Provide the filesystem interface definition.
Parameters
None.
Success
A non-null pointer to the oofsDesc object is returned.
Failure
A NULL (i.e., 0) pointer is returned.
Notes
int exists(const char *path, // In
int &exists_flag // Out
oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred ]); // In
Function
Determine whether a path or file exists.
Parameters
path
is the fully qualified name of the file to be tested for existence.
exists_flag
is the address of the variable to hold the status of the test. When a success indication is returned, exists_flag will have one of the following values:
einfo
is the error information structure used when an error occurs.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned with exists_flag set.
Failure
OOFS_ERROR
is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.
oofsSecurity *GetSecToken( oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred ]); // In
Function
Return a security token to be used to initialize client-side security.
Parameters
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
einfo
is the error information structure used when an error occurs.
Success
A pointer to the security token is returned if such a token exists. Otherwise, a NULL pointer is returned.
Failure
OOFS_ERROR
is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.Notes
oofsDir *openDir( const char *dirname, // In
oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred]); // In
Function
Open a oofsDir object directory for reading.
Parameters
dirname
is the name of the directory that is to be opened. Typically, a fully qualified path is given.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
A non-NULL pointer to an oofsDir object is returned.
Failure
A NULL pointer is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.
Notes
oofsFile *openFile(const char *filename, // In
oofsFileOpenMode open_mode, // In
oofsFileCreateMode create_mode // In
oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred // In
[, oofsInfoStruct *info ] ]); // In
Function
Open an oofsFile object file; optionally creating a corresponding disk file.
Parameters
filename
is the name of the file that is to be opened
open_mode
indicates how the file is to be opened or created (i.e., read, write, or update).
create_mode
holds the access mode bits to be assigned to the file when open_mode indicates that the file is to be created.
einfo
is the error information structure used when an error occurs.
cred
are optional credentials authenticating the remote caller
info
is an optional pointer to a structure describing opaque information that may be of use during the operation.
Success
A non-NULL pointer to an oofsFile object is returned.
Failure
A NULL pointer is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.
Notes
int remove( const char *filename // In
oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred ]); // In
Function
Remove a file.
Parameters
filename
is the filename of the file to be removed. Normally, a fully qualified path is specified. Asterisks are not allowed in the filename.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
einfo
is the error information structure used when an error occurs.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.
int rename( const char *old_filename, // In
const char *new_filename, // In
oofsErrorStruct &einfo, // Out
[, oofsCredStruct *cred ]); // In
Function
Rename a file.
Parameters
old_filename
is the existing name of a file. Normally, a fully qualified path is specified.
new_filename
is the name that the file is to have. It must be different from old_filename.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
einfo
is the error information structure used when an error occurs.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.
int close([ oofsCredStruct *cred ]); // In
Function
Closes an open oofsDir object directory.
Parameters
cred
are optional credentials authenticating the remote caller. .A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
const char * getNext([ oofsCredStruct *cred ]); // In
Function
Return the next entry in an open oofsDir object directory.
Parameters
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
A pointer to a local buffer is returned. The buffer contains the next directory entry’s name.
Failure
Zero (0) is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
Notes
int open(const char *dirname // In
[, oofsCredStruct *cred]); // In
Function
Open a oofsDir object directory for reading.
Parameters
dirname
is the name of the directory that is to be opened. Typically, a fully qualified path is given.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero(0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
void getErrorInfo([oofsErrorStruct &einfo]); // Out
Function
Return error information about the last oofs() operation..
Parameters
einfo
is an optional pointer to the structure that is to hold the error information.
Success
The error code number is returned if einfo.
Failure
The function cannot fail.
Notes
int close([ oofsCredStruct *cred ]); // In
Function
Close an open oofsFile object’s file.
Parameters
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
int getmode(oofsFileCreateMode &mode // Out
[, oofsCredStruct *cred ]); // In
Function
Return an oofsFile object’s file creation mode.
Parameters
mode
is a pointer to a variable that is to hold the file’s creation mode (i.e., read-write-execute permission bits). The creation mode is returned in POSIX format and only upon success. The returned value may not be meaningful if the file is protected by an access control list.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned with mode set.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
int getsize(oofsFileOffset &flen // Out
[, oofsCredStruct *cred ]); // In
Function
Return an oofsFile object file’s current size.
Parameters
flen
is a pointer to a variable to hold the file’s current size. The size is returned only upon success.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned with flen set.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
int open(const char *filename, // In
oofsFileOpenMode open_mode, // In
oofsFileCreateMode create_mode // In
[, oofsCredStruct *cred // In
[, oofsInfoStruct *info ] ]); // In
Function
Open an oofsFile object file; optionally creating a corresponding disk file.
Parameters
filename
is the name of the file that is to be opened. Typically, a fully qualified path is given.
open_mode
indicates how the file is to be opened (i.e., read, write, or update). If open_mode indicates that the file is to be created, the file is also opened in update mode. The following are valid mode values:
OOFS_O_RDONLY
- open file for readingOOFS_O_WRONLY
- open the file for writingOOFS_O_RDWR
- open the file for reading and writing (i.e., update)OOFS_O_CREAT
- create the file and open with OOFS_O_RDWRcreate_mode
holds the access mode bits to be assigned to the file when open_mode indicates that the file is to be created. The mode must be specified in POSIX format (.e.g., 744 corresponds to rwx--r—mode).
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
info
is an optional pointer to a structure describing opaque information that may be of use during the operation. Opaque information is only meaningful to oofs() routines and is passed with modification from the client. A null pointer or a zero length opaque information indicates that opaque information was not supplied.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.Notes
oofsXferSize read(oofsFileOffset offset, // In
char *buffer, // Out
oofs XferSize buffer_size // In
[, oofsCredStruct *cred ]); // In
Function
Read zero or more bytes from an open oofsFile object’s file.
Parameters
offset
is the absolute offset, origin 0, into the file where the read is to begin.
buffer
is a pointer to a buffer that is to hold the contents of the file after the read completes
buffer_size
is the size of the actual buffer. No more than the specified number of bytes are actually read from the file.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
The actual number of bytes that were read.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
int sync([ oofsCredStruct *cred ]); // In
Function
Verify that all data is committed to permanent media.
Parameters
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
int truncate(oofsFileOffset file_size // In
[, oofsCredStruct *cred ]); // In
Function
Set the size of a file.
Parameters
file_size
is the new size of the file. If the new size is smaller than the current size, the file is reduced in size and the excess bytes are discarded. If the new size if greater than the current size, the file is extended to the new size with binary zeroes.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.
oofsXferSize write(oofsFileOffset offset, // In
const char *buffer, // In
oofs XferSize buffer_size // In
[, oofsCredStruct *cred ]); // In
Function
Write zero or more bytes into an open oofsFile object’s file.
Parameters
offset
is the absolute offset, origin 0, into the file where the write is to begin.
buffer
is a pointer to a buffer that is to hold the data to be written into the file.
buffer_size
is the size of the actual buffer. No more than the specified number of bytes are actually written to the file.
cred
are optional credentials authenticating the remote caller. A null pointer or zero-length credentials indicate that no credentials were supplied.
Success
The actual number of bytes that were written are returned.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.Notes
G
eneric Authentication Protocol (GAP) allows security information (e.g., credentials) to be transparently transferred from an Objectivity AMS client to the AMS server using a generic mechanism that can be easily modified to use site-specific security. GAP is supported only for AMS mediated connections and is suitable for private-key mechanisms such as Kerberos and Windows NT, and public-key mechanisms such as PGP. It consists of three site-definable client-side functions and a new client-side interface.The following general steps comprise GAP:
The following diagram shows the basic sequence, numbered as above.
Class mySecurity : public oofsSecurity
{
// Actual security implementation
}
oofsSecurity *NewSecurityObject(oofsContextStruct *info)
{
// Perform any required actions
return new mySecurity(info);
}
if (oofs_RegisterSecurity(NewSecurityObject))
Fatal_Error();
There is one Security Object (SO) for each distinct AMS. An SO is created by the routine passed as the argument to oofs_RegisterSecurity(). Therefore, for each new AMS that is contacted, the OSCK follows these steps:
oofsDesc::oofsGetSecToken().
For each request sent to an existing AMS, the OSCK follows these steps using the methods provided by the SO associated with the target AMS:
int oofs_Register_Security(oofsSecurity *CreateSecObj); // In
Function
Register security callback functions.
Parameters
CreateSecObj
is the routine to be called to create a new security object.
Success
Zero is returned.
Failure
A negative one (-1) is returned.
Notes
oofsCredStruct * GetCred(oofsRequestStruct request) // In
Function
Obtain credentials for a data operation.
Parameters
request
describes the nature of the request. Certain fields are meaningful for certain operations. See the notes for details.
Success
A non-zero pointer to a credentials structure is returned. The data in the structure is sent to the AMS along with the request.
Failure
OOFS_ERROR
is returned. Use getErrorInfo() to obtain the actual error code and, optionally, a null terminated string describing the nature of the error.Notes
|
operation |
fdid |
apid |
path |
fname |
|
OOFS_CLOSE |
present |
present |
null |
null |
|
OOFS_CLOSEDIR |
present |
present |
null |
null |
|
OOFS_EXISTS |
present |
present |
null |
null |
|
OOFS_GETSIZE |
present |
present |
null |
null |
|
OOFS_GETMODE |
present |
present |
null |
null |
|
OOFS_OPEN |
present |
present |
present |
present |
|
OOFS_OPENDIR |
present |
present |
present |
null |
|
OOFS_READ |
present |
present |
null |
null |
|
OOFS_READDIR |
present |
present |
null |
null |
|
OOFS_REMOVE |
present |
present |
present |
present |
|
OOFS_RENAME |
present |
present |
present |
present |
|
OOFS_SYNC |
present |
present |
null |
null |
|
OOFS_TRUNCATE |
present |
present |
null |
null |
|
OOFS_WRITE |
present |
present |
null |
null |
Opaque Information Protocol (OIP) allows arbitrary information (e.g., performance hints) to be transparently transferred from an Objectivity AMS client to the AMS server. OIP is supported only for AMS mediated connections. It consists of one new client-side function, oofs_set_info(). Opaque information is sent to the oofs_open() function on the AMS side.
Application Steps in OIP
char info[256];
·
·
// Fill in the info array, as needed·
if (oofs_set_info(info, sizeof(info), OOFS_SOI_ONCE))
Fatal_Error();
·
·
// Open objectivity database, sending it the info.·
OCSK Steps in OIP
AMS Steps in OIP
int oofs_set_info(const char *info, // In
const int infolen, // In
const ooInt flags);, // In
Function
Set opaque information for subsequent transmission to the AMS.
Parameters
info
points to a buffer containing the information to be sent to the AMS, If the pointer is NULL, current opaque information, if any, is discarded and no information is subsequently sent.
infolen
is the length of the information to be sent to the AMS, If the length is zero, current opaque information, if any, is discarded and no information is subsequently sent.
flags
indicates how the opaque information is to be handled:
OOFS_SOI_ALWAYS
- always send the information on subsequent open and create requests.OOFS_SOI_ONCE
- send the information on the subsequent open or create request and discard the information afterwards (i.e., only send it once).Success
OOFS_OK (0) is returned.
Failure
OOFS_ERROR
is returned.Notes
Defer Request Protocol (DRP) allows an AMS server to control the timeout of a client’s request. It is included as part of the AMS/OCSK protocol to allow the use of hierarchical filesystems with highly variable latencies (e.g., microseconds to several minutes).
AMS Steps in DRP
|
Function |
Failure Return |
Function |
Failure Return |
|
oofs_close() |
-1 |
oofs_read() |
-1 |
|
oofs_closedir() |
-1 |
oofs_readdir() |
-1 |
|
oofs_exists() |
-1 |
oofs_remove() |
-1 |
|
oofs_getmode() |
-1 |
oofs_rename() |
-1 |
|
oofs_getsize() |
-1 |
oofs_sync() |
-1 |
|
oofs_open() |
0 |
oofs_truncate() |
-1 |
|
oofs_opendir() |
0 |
oofs_write() |
-1 |
!wait 300
indicates that the client should wait 300 seconds then reissue the same request to the same AMS.
3. The OCSK should treat the retry request as an error if any of the following occurs:
a) The number of seconds is less than 1.
b) The number of seconds is greater than 9999.
c) The number of seconds is not a whole number.
4. Retry errors are to be treated as AMS errors and standard error recovery procedures are to be applied.
Request Redirection Protocol (RRP) allows cooperating AMS’s to perform dynamic load balancing using a simple redirection scheme. A group of cooperating AMS’s, or an AMS Collective (AMSC), is logically treated as a single AMS by the client. There is one distinguished member of the collective and all database catalogue information is tied to the distinguished member (i.e., server). This minimizes the administrative impact on client operations and database descriptions. Therefore, a client need not know the composition of the collective and, indeed, that composition is free to change at any time without impacting any database operations that the client may perform.
The following figure illustrates an AMS collective and a simple redirection interaction.
Redirection allows an AMS to direct a client to a more suitable AMS for processing the client’s request. Because the server redirects the request, it is possible to implement a highly flexible and scalable dynamic load-balancing scheme than would otherwise be possible by other mechanisms. For instance, the database load may be balanced using one or more of the following criteria, among others:
RRP also allows the AMS to dynamically replicate databases on demand. For instance, should a databases become highly used, the AMS could replicate the database at one or more other sites and redirect clients to other copies. Once the database becomes less heavily used, the extra copies can be eliminated to save space.
Dynamic load balancing does not alter any current multi-AMS protocols such as the Data Replication Option (DRO) or the Fault Tolerant Option (FTO). This is because the collective is defined outside the scope of such protocols. Furthermore, each AMSC member is effectively interchangeable in the context of the collective. Nevertheless, it is possible to implement collectives in ways that render DRO and FTO unusable.
The collective is responsible for providing update synchronization should any AMSC members allow write operations. Should a client wish to update a database and a modifiable database replica exists outside of the collective, it is the application’s responsibility to explicitly indicate that write operations will occur before performing any transactions against the database.
Redirection of requests is only supported for operations against a closed database (i.e., operations that use a filename instead of a filehandle). This includes the open() and opendir() requests.
|
Function |
Failure Return |
Function |
Failure Return |
|
oofs_close() |
-1 |
oofs_read() |
-1 |
|
oofs_closedir() |
-1 |
oofs_readdir() |
-1 |
|
oofs_exists() |
-1 |
oofs_remove() |
-1 |
|
oofs_getmode() |
-1 |
oofs_rename() |
-1 |
|
oofs_getsize() |
-1 |
oofs_sync() |
-1 |
|
oofs_open() |
0 |
oofs_truncate() |
-1 |
|
oofs_opendir() |
0 |
oofs_write() |
-1 |
!try abh.slac.stanford.edu
indicates that the client should reissue the same request to the AMS located on host "abh.slac.stanford.edu".
2. Should a redirect request be received, the OCSK must send the same request to the specified AMS.
3. The OCSK should treat the redirect request as an error if any of the following occurs:
a) The redirect specifies the same AMS.
b) More than 255 consecutive redirect requests have been received.
c) The specified AMS does not exist or refuses a connection.
4. Redirection errors are to be treated as AMS errors and standard error recovery procedures are to be applied.
Appendix A
Local Extensions to the oofs() Interface
int oofs_set( oofsFileDesc fd, // In
const char *options, // In
oofsErrorStruct &einfo) // Out
Function
Set oofs() options for a file or for the system..
Parameters
fd
is the file descriptor returned by oofs_open() or oofs_opendir() to which the options are to apply. If fd is null, then the options apply globally and affect all future file descriptors.
options
is a null terminated string of single letter, space-separated, option letters. Valid letters are:
l - log data transfer statistics into SYSLOG when oofs_close() or
oofs_closedir() is called.
p - print data transfer statistics on STDERR when oofs_close() or
oofs_closedir() is called.
t - race execution on STDERR.
Each letter may be optionally preceded by a plus (the default) to turn on the option or a minus, to turn off the option.
einfo
is the error information structure used when an error occurs.
Success
Zero (0) is returned.
Failure
OOFS_ERROR
is returned and einfo.code contains the actual error code while einfo.message contains an optional null terminated string describing the nature of the error.Notes