#ifndef _XRDOSS_H #define _XRDOSS_H /******************************************************************************/ /* */ /* X r d O s s & X r d O s s D F */ /* */ /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */ /* All Rights Reserved */ /* Produced by Andrew Hanushevsky for Stanford University under contract */ /* DE-AC02-76-SFO0515 with the Department of Energy */ /* */ /* This file is part of the XRootD software suite. */ /* */ /* XRootD is free software: you can redistribute it and/or modify it under */ /* the terms of the GNU Lesser General Public License as published by the */ /* Free Software Foundation, either version 3 of the License, or (at your */ /* option) any later version. */ /* */ /* XRootD 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 Lesser General Public */ /* License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ /* COPYING (GPL license). If not, see . */ /* */ /* The copyright holder's institutional names and contributor's names may not */ /* be used to endorse or promote products derived from this software without */ /* specific prior written permission of the institution or contributor. */ /******************************************************************************/ #include #include #include #include #include #include #include "XrdOuc/XrdOucIOVec.hh" class XrdOucEnv; class XrdSysLogger; class XrdSfsAio; #ifndef XrdOssOK #define XrdOssOK 0 #endif /******************************************************************************/ /* X r d O s s D F */ /******************************************************************************/ //! This class defines the object that handles directory as well as file //! oriented requests. It is instantiated for each file/dir to be opened. //! The object is obtained by calling newDir() or newFile() in class XrdOss. //! This allows flexibility on how to structure an oss plugin. class XrdOssDF { public: // Directory oriented methods virtual int Opendir(const char *, XrdOucEnv &) {return -ENOTDIR;} virtual int Readdir(char *buff, int blen) {(void)buff; (void)blen; return -ENOTDIR;} virtual int StatRet(struct stat *buff) {(void)buff; return -ENOTSUP;} // File oriented methods virtual int Fchmod(mode_t mode) {(void)mode; return -EISDIR;} virtual int Fstat(struct stat *) {return -EISDIR;} virtual int Fsync() {return -EISDIR;} virtual int Fsync(XrdSfsAio *aiop) {(void)aiop; return -EISDIR;} virtual int Ftruncate(unsigned long long) {return -EISDIR;} virtual int getFD() {return -1;} virtual off_t getMmap(void **addr) {(void)addr; return 0;} virtual int isCompressed(char *cxidp=0) {(void)cxidp; return -EISDIR;} virtual int Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;} virtual ssize_t Read(off_t, size_t) {return (ssize_t)-EISDIR;} virtual ssize_t Read(void *, off_t, size_t) {return (ssize_t)-EISDIR;} virtual int Read(XrdSfsAio *aoip) {(void)aoip; return (ssize_t)-EISDIR;} virtual ssize_t ReadRaw( void *, off_t, size_t) {return (ssize_t)-EISDIR;} virtual ssize_t Write(const void *, off_t, size_t) {return (ssize_t)-EISDIR;} virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;} // Implemented in the header, as many folks will be happy with the default. // virtual ssize_t ReadV(XrdOucIOVec *readV, int n) {ssize_t nbytes = 0, curCount = 0; for (int i=0; i= blen) return -ENAMETOOLONG; strcpy(buff, Path); return 0; } virtual const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc) { (void)buff; (void)blen; rc = 0; return Path;} virtual int FSctl(int cmd, int alen, const char *args, char **resp=0) { (void)cmd; (void)alen; (void)args; (void)resp; return -ENOTSUP;} virtual void EnvInfo(XrdOucEnv *envP) {(void)envP;} XrdOss() {} virtual ~XrdOss() {} }; /******************************************************************************/ /* S t o r a g e S y s t e m I n s t a n t i a t o r */ /******************************************************************************/ //------------------------------------------------------------------------------ //! Get an instance of a configured XrdOss object. //! //! @param native_oss -> object that would have been used as the storage //! system. The object is not initialized (i.e., Init() //! has not yet been called). This allows one to easily //! wrap the native implementation or to completely //! replace it, as needed. //! @param Logger -> The message routing object to be used in conjunction //! with an XrdSysError object for error messages. //! @param config_fn -> The name of the config file. //! @param parms -> Any parameters specified after the path on the //! ofs.osslib directive. If there are no parameters, the //! pointer may be zero. //! //! @return Success: -> an instance of the XrdOss object to be used as the //! underlying storage system. //! Failure: Null pointer which causes initialization to fail. //! //! The object creation function must be declared as an extern "C" function //! in the plug-in shared library as follows: //------------------------------------------------------------------------------ /*! extern "C" XrdOss *XrdOssGetStorageSystem(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms); */ //------------------------------------------------------------------------------ //! Declare compilation version. //! //! Additionally, you *should* declare the xrootd version you used to compile //! your plug-in. While not currently required, it is highly recommended to //! avoid execution issues should the class definition change. Declare it as: //------------------------------------------------------------------------------ /*! #include "XrdVersion.hh" XrdVERSIONINFO(XrdOssGetStorageSystem,); where is a 1- to 15-character unquoted name identifying your plugin. */ #endif