Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:40

0001 #ifndef __SFS_INTERFACE_H__
0002 #define __SFS_INTERFACE_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                    X r d S f s I n t e r f a c e . h h                     */
0006 /*                                                                            */
0007 /* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0009 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0010 /*                                                                            */
0011 /* This file is part of the XRootD software suite.                            */
0012 /*                                                                            */
0013 /* XRootD is free software: you can redistribute it and/or modify it under    */
0014 /* the terms of the GNU Lesser General Public License as published by the     */
0015 /* Free Software Foundation, either version 3 of the License, or (at your     */
0016 /* option) any later version.                                                 */
0017 /*                                                                            */
0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0020 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0021 /* License for more details.                                                  */
0022 /*                                                                            */
0023 /* You should have received a copy of the GNU Lesser General Public License   */
0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0025 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0026 /*                                                                            */
0027 /* The copyright holder's institutional names and contributor's names may not */
0028 /* be used to endorse or promote products derived from this software without  */
0029 /* specific prior written permission of the institution or contributor.       */
0030 /******************************************************************************/
0031 
0032 #include <cstring>      // For strlcpy()
0033 #include <cerrno>
0034 #include <cstdint>
0035 #include <sys/types.h>
0036 #include <sys/stat.h>
0037 
0038 #include "XrdOuc/XrdOucErrInfo.hh"
0039 #include "XrdOuc/XrdOucIOVec.hh"
0040 #include "XrdOuc/XrdOucSFVec.hh"
0041 
0042 #include "XrdSfs/XrdSfsGPFile.hh"
0043 
0044 #include "XrdSys/XrdSysPageSize.hh"
0045 
0046 /******************************************************************************/
0047 /*                            O p e n   M o d e s                             */
0048 /******************************************************************************/
0049 
0050 #define SFS_O_RDONLY           0         // open read/only
0051 #define SFS_O_WRONLY           1         // open write/only
0052 #define SFS_O_RDWR             2         // open read/write
0053 #define SFS_O_CREAT   0x00000100         // used for file creation
0054 #define SFS_O_TRUNC   0x00000200         // used for file truncation
0055 #define SFS_O_MULTIW  0x00000400         // used for multi-write locations
0056 #define SFS_O_NOTPC   0x00000800         // used to suppress TPC opens
0057 #define SFS_O_DIRLIST 0x00010000         // used for locate only
0058 #define SFS_O_POSC    0x00100000         // persist on successful close
0059 #define SFS_O_FORCE   0x00200000         // used for locate only
0060 #define SFS_O_HNAME   0x00400000         // used for locate only
0061 #define SFS_O_LOCAL   0x00800000         // used for locate only (local cmd)
0062 #define SFS_O_NOWAIT  0x01000000         // do not impose operational delays
0063 #define SFS_O_RAWIO   0x02000000         // allow client-side decompression
0064 #define SFS_O_RESET   0x04000000         // Reset any cached information
0065 #define SFS_O_REPLICA 0x08000000         // Open for replication
0066 #define SFS_O_SEQIO   0x10000000         // Open for sequential I/O
0067 
0068 // The following flag may be set in the access mode arg for open() & mkdir()
0069 // Note that on some systems mode_t is 16-bits so we use a careful value!
0070 //
0071 #define SFS_O_MKPTH   0x00004000         // Make directory path if missing
0072 
0073 // The following options are here to provide a uniform clustering interface.
0074 // They may be passed through open/locate/stat, as applicable.
0075 //
0076 #define SFS_O_LOCATE  0x10000000         // This request generated by locate()
0077 #define SFS_O_STAT    0x20000000         // This request generated by stat()
0078 #define SFS_O_META    0x40000000         // This request generated by metaop
0079 
0080 /******************************************************************************/
0081 /*                               D e f i n e s                                */
0082 /******************************************************************************/
0083 
0084 // Common fctl  command values (0 to 255)
0085 //
0086 #define SFS_FCTL_GETFD    1 // Return file descriptor if possible
0087 #define SFS_FCTL_STATV    2 // Return visa information
0088 #define SFS_FCTL_SPEC1    3 // Return implementation defined information
0089 
0090 #define SFS_SFIO_FDVAL 0x80000000 // Use SendData() method GETFD response value
0091 
0092 // Common fsctl command values (0 to 255)
0093 //
0094 #define SFS_FSCTL_CMD   255
0095 
0096 #define SFS_FSCTL_LOCATE  1 // Locate a file
0097 #define SFS_FSCTL_STATFS  2 // Return FS data
0098 #define SFS_FSCTL_STATLS  3 // Return LS data
0099 #define SFS_FSCTL_STATXA  4 // Return XA data
0100 #define SFS_FSCTL_STATCC  5 // Return Cluster Config status
0101 #define SFS_FSCTL_PLUGIN  8 // Return Implementation Dependent Data
0102 #define SFS_FSCTL_PLUGIO 16 // Return Implementation Dependent Data
0103 #define SFS_FSCTL_PLUGXC 32 // Perform cache oriented operation
0104 
0105 // Return values for integer & XrdSfsXferSize returning XrdSfs methods
0106 //
0107 #define SFS_STALL         1 // Return value -> Seconds to stall client
0108 #define SFS_OK            0 // ErrInfo code -> All is well
0109 #define SFS_ERROR        -1 // ErrInfo code -> Error occurred
0110 #define SFS_REDIRECT   -256 // ErrInfo code -> Port number to redirect to
0111 #define SFS_STARTED    -512 // ErrInfo code -> Estimated seconds to completion
0112 #define SFS_DATA      -1024 // ErrInfo code -> Length of data
0113 #define SFS_DATAVEC   -2048 // ErrInfo code -> Num iovec elements in msgbuff
0114 
0115 // The following macros are used for dealing with special local paths
0116 //
0117 #define SFS_LCLPRFX    "/=/"
0118 #define SFS_LCLPLEN    3
0119 #define SFS_LCLPATH(x) !strncmp(x, SFS_LCLPRFX, SFS_LCLPLEN)
0120 #define SFS_LCLPRFY    "/="
0121 #define SFS_LCLROOT(x) !strncmp(x, SFS_LCLPRFX, SFS_LCLPLEN-1) \
0122                        && (*(x+SFS_LCLPLEN-1) == '/' || *(x+SFS_LCLPLEN-1) == 0)
0123 
0124 /******************************************************************************/
0125 /*                 S t r u c t u r e s   &   T y p e d e f s                  */
0126 /******************************************************************************/
0127 
0128 typedef long long     XrdSfsFileOffset;
0129 typedef int           XrdSfsFileOpenMode;
0130 typedef int           XrdSfsMode;
0131 typedef int           XrdSfsXferSize;
0132 
0133 enum XrdSfsFileExistence 
0134 {
0135      XrdSfsFileExistNo,
0136      XrdSfsFileExistIsFile,
0137      XrdSfsFileExistIsDirectory,
0138      XrdSfsFileExistIsOffline,
0139      XrdSfsFileExistIsOther
0140 };
0141 //------------------------------------------------
0142 
0143 #define Prep_PRTY0 0
0144 #define Prep_PRTY1 1
0145 #define Prep_PRTY2 2
0146 #define Prep_PRTY3 3
0147 #define Prep_PMASK 3
0148 #define Prep_SENDAOK 4
0149 #define Prep_SENDERR 8
0150 #define Prep_SENDACK 12
0151 #define Prep_WMODE   16
0152 #define Prep_STAGE   32
0153 #define Prep_COLOC   64
0154 #define Prep_FRESH  128
0155 #define Prep_CANCEL 256
0156 #define Prep_QUERY  512
0157 #define Prep_EVICT 1024
0158 
0159 class XrdOucTList;
0160 
0161 struct XrdSfsFSctl //!< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC parms
0162 {
0163  const char            *Arg1;      //!< PLUGINO, PLUGION, PLUGXC
0164        int              Arg1Len;   //!< Length
0165        int              Arg2Len;   //!< Length  or -count of args in extension
0166  union{
0167  const char            *Arg2;      //!< PLUGIN  opaque string
0168  const char           **ArgP;      //!< PLUGXC  argument list extension
0169       };
0170 };
0171 
0172 struct XrdSfsPrep  //!< Prepare parameters
0173 {
0174        char            *reqid;     //!< Request ID
0175        char            *notify;    //!< Notification path or 0
0176        int              opts;      //!< Prep_xxx
0177        XrdOucTList     *paths;     //!< List of paths
0178        XrdOucTList     *oinfo;     //!< 1-to-1 correspondence of opaque info
0179 };
0180 
0181 /******************************************************************************/
0182 /*                  F o r w a r d   D e c l a r a t i o n s                   */
0183 /******************************************************************************/
0184 
0185 class  XrdOucEnv;
0186 class  XrdSecEntity;
0187 struct XrdSfsFACtl;
0188 
0189 /******************************************************************************/
0190 /*                 O b j e c t   W r a p p i n g   G u i d e                  */
0191 /******************************************************************************/
0192 
0193 /* The XrdSfsDirectory and XrdSfsFile objects can be wrapped. Wraping can be
0194    used to add functionality. The process is common and pretty muche rote.
0195    There is only one caveat: all wrappers must use the same XrdOucErrInfo
0196    object. This is because the ErrInfo object contains client parameters that
0197    are used to control how things are done to be backward compatible. Newer
0198    client can then use more efficient internal processing. The SFS provides
0199    two ways to make sure the same ErrInfo object is used by all objects in
0200    the wrapped chain. Forward propagation (the one typically used) and
0201    backward propagation (used in certain unusual cases). In forward mode,
0202    the ErrInfo object of the last object in the chain is propagated to the
0203    front of the chain. In backward mode the reverse happens. Let's assume
0204    the following scenarion. Object-A wraps object-B (the object here can be
0205    directory or file object). In forward mode weneed to create objects in
0206    reverse order (bottom to top) which is typically what you would do anyway
0207    as you need to capture the pinter to the object your wrapping. So, using
0208    newFile() as an example where sfsP points to the Interface being wrapped:
0209 
0210    XrdSfsFile *newFile(const char *user, int MonID)
0211    {
0212       XrdSfsFile *wrapped_file = sfsP->newFile(user, MonID);
0213       if (!wrapped_file) return 0;
0214       return new mySfsFile(wrapped_file,...);
0215    }
0216    class mySfsFile : public XrdSfsFile
0217    {public:
0218       mySfsFile(XrdSfsFile *wrapped_file,...) : XrdSfsFile(*wrapped_file)
0219                {....}
0220     ....
0221    };
0222 
0223    Notice we are allocating the wrapped file ahead of the wrapper so that
0224    the wrapper can use the ErrInfo object of the wrapped file.
0225 
0226    In backward mode we want to use the ErrInfo object of the front-most
0227    wrapper for all wrappers after it. This mechanism is far more complicated
0228    due to error handling requirements. However, it's useful when a wrapped
0229    object is not necessarily instantiated to accomplish the needs of the
0230    wrapper. An example of this is the newFile and newDir implementations for
0231    XrdSsi where wrapped object creation is subject to the resource name.
0232 */
0233 
0234 /******************************************************************************/
0235 /*                       X r d S f s D i r e c t o r y                        */
0236 /******************************************************************************/
0237 
0238 //------------------------------------------------------------------------------
0239 //! The XrdSfsDirectory object is returned by XrdSfsFileSystem::newFile() when
0240 //! the caller wants to be able to perform directory oriented operations.
0241 //------------------------------------------------------------------------------
0242   
0243 class XrdSfsDirectory
0244 {
0245 public:
0246 
0247 //-----------------------------------------------------------------------------
0248 //! The error object is used to return details whenever something other than
0249 //! SFS_OK is returned from the methods in this class, when noted.
0250 //-----------------------------------------------------------------------------
0251 
0252         XrdOucErrInfo &error;
0253 
0254 //-----------------------------------------------------------------------------
0255 //! Open a directory.
0256 //!
0257 //! @param  path   - Pointer to the path of the directory to be opened.
0258 //! @param  client - Client's identify (see common description).
0259 //! @param  opaque - path's CGI information (see common description).
0260 //!
0261 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, ir SFS_STALL
0262 //-----------------------------------------------------------------------------
0263 
0264 virtual int         open(const char              *path,
0265                          const XrdSecEntity      *client = 0,
0266                          const char              *opaque = 0) = 0;
0267 
0268 //-----------------------------------------------------------------------------
0269 //! Get the next directory entry.
0270 //!
0271 //! @return A null terminated string with the directory name. Normally, "."
0272 //!         ".." are not returned. If a null pointer is returned then if this
0273 //!         is due to an error, error.code should contain errno. Otherwise,
0274 //!         error.code should contain zero to indicate that no more entries
0275 //!         exist (i.e. end of list). See autoStat() for additional caveats.
0276 //-----------------------------------------------------------------------------
0277 
0278 virtual const char *nextEntry() = 0;
0279 
0280 //-----------------------------------------------------------------------------
0281 //! Close the directory.
0282 //!
0283 //! @return One of SFS_OK or SFS_ERROR
0284 //-----------------------------------------------------------------------------
0285 
0286 virtual int         close() = 0;
0287 
0288 //-----------------------------------------------------------------------------
0289 //! Get the directory path.
0290 //!
0291 //! @return Null terminated string of the path used in open().
0292 //-----------------------------------------------------------------------------
0293 
0294 virtual const char *FName() = 0;
0295 
0296 //-----------------------------------------------------------------------------
0297 //! Set the stat() buffer where stat information is to be placed corresponding
0298 //! to the directory entry returned by nextEntry().
0299 //!
0300 //! @return If supported, SFS_OK should be returned. If not supported, then
0301 //!         SFS_ERROR should be returned with error.code set to ENOTSUP.
0302 //!
0303 //! @note: When autoStat() is in effect, directory entries that have been
0304 //!        deleted from the target directory are quietly skipped.
0305 //-----------------------------------------------------------------------------
0306 
0307 virtual int         autoStat(struct stat *buf);
0308 
0309 //-----------------------------------------------------------------------------
0310 //! Constructor (user and MonID are the ones passed to newDir()!). This
0311 //! constructor should only be used by base plugins. Plugins that wrap an
0312 //! SfsDirectory should use the second version of the constructor shown below.
0313 //!
0314 //! @param  user   - Text identifying the client responsible for this call.
0315 //!                  The pointer may be null if identification is missing.
0316 //! @param  MonID  - The monitoring identifier assigned to this and all
0317 //!                  future requests using the returned object.
0318 //-----------------------------------------------------------------------------
0319 
0320                     XrdSfsDirectory(const char *user=0, int MonID=0)
0321                                    : error(*(new XrdOucErrInfo(user, MonID)))
0322                                    {lclEI = &error;}
0323 
0324 //-----------------------------------------------------------------------------
0325 //! Constructor for plugins that wrap another SfsDirectory. This constructor
0326 //! inherits the error object from a wrapped SfsDirectory object so that only
0327 //! one identical error object exists for all directory objects in the chain.
0328 //!
0329 //! @param  wrapD  - Reference to the directory object being wrapped.
0330 //-----------------------------------------------------------------------------
0331 
0332                     XrdSfsDirectory(XrdSfsDirectory &wrapD)
0333                                    : error(wrapD.error), lclEI(0) {}
0334 
0335 //-----------------------------------------------------------------------------
0336 //! Constructor for base plugins that predefined an error object. This is a
0337 //! convenience constructor for base plugins only.
0338 //!
0339 //! @param  eInfo  - Reference to the error object to use.
0340 //-----------------------------------------------------------------------------
0341 
0342                     XrdSfsDirectory(XrdOucErrInfo &eInfo)
0343                                    : error(eInfo), lclEI(0) {}
0344 
0345 //-----------------------------------------------------------------------------
0346 //! Destructor
0347 //-----------------------------------------------------------------------------
0348 
0349 virtual            ~XrdSfsDirectory() {if (lclEI) delete lclEI;}
0350 
0351 private:
0352 XrdOucErrInfo* lclEI;
0353 
0354 }; // class XrdSfsDirectory
0355 
0356 /******************************************************************************/
0357 /*                            X r d S f s F i l e                             */
0358 /******************************************************************************/
0359 
0360 //------------------------------------------------------------------------------
0361 //! The XrdSfsFile object is returned by XrdSfsFileSystem::newFile() when
0362 //! the caller wants to be able to perform file oriented operations.
0363 //------------------------------------------------------------------------------
0364 
0365 class XrdSfsAio;
0366 class XrdSfsDio;
0367 class XrdSfsXio;
0368   
0369 class XrdSfsFile
0370 {
0371 public:
0372 
0373 //-----------------------------------------------------------------------------
0374 //! The error object is used to return details whenever something other than
0375 //! SFS_OK is returned from the methods in this class, when noted.
0376 //-----------------------------------------------------------------------------
0377 
0378         XrdOucErrInfo  &error;
0379 
0380 //-----------------------------------------------------------------------------
0381 //! Open a file.
0382 //!
0383 //! @param  fileName   - Pointer to the path of the file to be opened.
0384 //! @param  openMode   - Flags indicating how the open is to be handled.
0385 //!                      SFS_O_CREAT   create the file
0386 //!                      SFS_O_MKPTH   Make directory path if missing
0387 //!                      SFS_O_NOWAIT  do not impose operational delays
0388 //!                      SFS_O_NOTPC   do not allow TPC operation
0389 //!                      SFS_O_POSC    persist only on successful close
0390 //!                      SFS_O_RAWIO   allow client-side decompression
0391 //!                      SFS_O_RDONLY  open read/only
0392 //!                      SFS_O_RDWR    open read/write
0393 //!                      SFS_O_REPLICA Open for replication
0394 //!                      SFS_O_RESET   Reset any cached information
0395 //!                      SFS_O_TRUNC   truncate existing file to zero length
0396 //!                      SFS_O_WRONLY  open write/only
0397 //! @param  createMode - The file's mode if it will be created.
0398 //! @param  client     - Client's identify (see common description).
0399 //! @param  opaque     - path's CGI information (see common description).
0400 //!
0401 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED
0402 //-----------------------------------------------------------------------------
0403 
0404 virtual int            open(const char                *fileName,
0405                                   XrdSfsFileOpenMode   openMode,
0406                                   mode_t               createMode,
0407                             const XrdSecEntity        *client = 0,
0408                             const char                *opaque = 0) = 0;
0409 
0410 //-----------------------------------------------------------------------------
0411 //! Create, delete, query, rollback a file checkpoint or perform an action.
0412 //!
0413 //! @param  act   - The operation to be performed (see cpAct enum below).
0414 //! @param  range - Use and requirement vary by function:
0415 //!                 cpCreate  - Create a new checkpoint, one must not exist.
0416 //!                             Parameters ignored, not applicable.
0417 //!                 cpDelete  - Delete an existing checkpoint, one must exist.
0418 //!                             Parameters ignored, not applicable.
0419 //!                 cpQuery   - Where result is to be returned:
0420 //!                             range[0].offset - Amount currently in use.
0421 //!                             range[0].length - Maximum total length
0422 //!                 cpRestore - Restore data from checkpoint and delete it.
0423 //!                             Parameters ignored, not applicable.
0424 //!                 cpTrunc   - Offset target for truncation.
0425 //!                             range[0].offset - Offset for truncations.
0426 //!                 cpWrite   - Offset/lengths of the file to be checkpointed.
0427 //!                             The checkpoint must exist via previous cpCreate.
0428 //! @param  n     - Number of elements in range. Applies only to cpWrite.
0429 //!
0430 //! @return One of SFS_OK or SFS_ERROR only.
0431 //-----------------------------------------------------------------------------
0432 
0433 enum cpAct {cpCreate=0,   //!< Create a checkpoint, one must not be active.
0434             cpDelete,     //!< Delete an existing checkpoint
0435             cpRestore,    //!< Restore an active checkpoint and delete it.
0436             cpQuery,      //!< Return checkpoint limits
0437             cpTrunc,      //!< Truncate a file within  checkpoint.
0438             cpWrite       //!< Add data to an existing checkpoint.
0439            };
0440 
0441 virtual int            checkpoint(cpAct act, struct iov *range=0, int n=0);
0442 
0443 //-----------------------------------------------------------------------------
0444 //! Close the file.
0445 //!
0446 //! @return One of SFS_OK or SFS_ERROR.
0447 //-----------------------------------------------------------------------------
0448 
0449 virtual int            close() = 0;
0450 
0451 //-----------------------------------------------------------------------------
0452 //! Execute a special operation on the file (version 1)
0453 //!
0454 //! @param  cmd   - The operation to be performed (see below).
0455 //!                 SFS_FCTL_GETFD    Return file descriptor if possible
0456 //!                 SFS_FCTL_STATV    Reserved for future use.
0457 //! @param  args  - specific arguments to cmd
0458 //!                 SFS_FCTL_GETFD    Set to zero.
0459 //! @param  eInfo  - The object where error info or results are to be returned.
0460 //!                  This is legacy and the error onject may be used as well.
0461 //!
0462 //! @return If an error occurs or the operation is not support, SFS_ERROR
0463 //!         should be returned with error.code set to errno. Otherwise,
0464 //!         SFS_FCTL_GETFD  error.code holds the real file descriptor number
0465 //!                         If the value is negative, sendfile() is not used.
0466 //!                         If the value is SFS_SFIO_FDVAL then the SendData()
0467 //!                         method is used for future read requests.
0468 //-----------------------------------------------------------------------------
0469 
0470 virtual int            fctl(const int               cmd,
0471                             const char             *args,
0472                                   XrdOucErrInfo    &eInfo) = 0;
0473 
0474 //-----------------------------------------------------------------------------
0475 //! Execute a special operation on the file (version 2)
0476 //!
0477 //! @param  cmd    - The operation to be performed:
0478 //!                  SFS_FCTL_SPEC1    Perform implementation defined action
0479 //! @param  alen   - Length of data pointed to by args.
0480 //! @param  args   - Data sent with request, zero if alen is zero.
0481 //! @param  client - Client's identify (see common description).
0482 //!
0483 //! @return SFS_OK   a null response is sent.
0484 //! @return SFS_DATA error.code    length of the data to be sent.
0485 //!                  error.message contains the data to be sent.
0486 //!         o/w      one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.
0487 //-----------------------------------------------------------------------------
0488 
0489 virtual int            fctl(const int               cmd,
0490                                   int               alen,
0491                                   const char       *args,
0492                             const XrdSecEntity     *client = 0);
0493 
0494 //-----------------------------------------------------------------------------
0495 //! Get the file path.
0496 //!
0497 //! @return Null terminated string of the path used in open().
0498 //-----------------------------------------------------------------------------
0499 
0500 virtual const char    *FName() = 0;
0501 
0502 //-----------------------------------------------------------------------------
0503 //! Get file's memory mapping if one exists (memory mapped files only).
0504 //!
0505 //! @param  Addr   - Place where the starting memory address is returned.
0506 //! @param  Size   - Place where the file's size is returned.
0507 //!
0508 //! @return SFS_OK when the file is memory mapped or any other code otherwise.
0509 //-----------------------------------------------------------------------------
0510 
0511 virtual int            getMmap(void **Addr, off_t &Size) = 0;
0512 
0513 //-----------------------------------------------------------------------------
0514 //! Options for pgRead() and pgWrite() as noted below.
0515 //-----------------------------------------------------------------------------
0516 
0517 static const uint64_t
0518 Verify       = 0x8000000000000000ULL; //!< all: Verify checksums
0519 
0520 //-----------------------------------------------------------------------------
0521 //! Read file pages into a buffer and return corresponding checksums.
0522 //!
0523 //! @param  offset  - The offset where the read is to start. It may be
0524 //!                   unaligned with certain caveats relative to csvec.
0525 //! @param  buffer  - pointer to buffer where the bytes are to be placed.
0526 //! @param  rdlen   - The number of bytes to read. The amount must be an
0527 //!                   integral number of XrdSfsPage::Size bytes.
0528 //! @param  csvec   - A vector of entries to be filled with the cooresponding
0529 //!                   CRC32C checksum for each page. However, if the offset is
0530 //!                   unaligned, then csvec[0] contains the crc for the page
0531 //!                   fragment that brings it to alignment for csvec[1].
0532 //!                   It must be sized to hold all aligned XrdSys::Pagesize
0533 //!                   crc's plus additional ones for leading and ending page
0534 //!                   fragments, if any.
0535 //! @param  opts    - Processing options (see above).
0536 //!
0537 //! @return >= 0      The number of bytes that placed in buffer.
0538 //! @return SFS_ERROR File could not be read, error holds the reason.
0539 //-----------------------------------------------------------------------------
0540 
0541 virtual XrdSfsXferSize pgRead(XrdSfsFileOffset   offset,
0542                               char              *buffer,
0543                               XrdSfsXferSize     rdlen,
0544                               uint32_t          *csvec,
0545                               uint64_t           opts=0);
0546 
0547 //-----------------------------------------------------------------------------
0548 //! Read file pages and checksums using asynchronous I/O.
0549 //!
0550 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0551 //! @param  opts    - Processing options (see above).
0552 //!
0553 //! @return SFS_OK    Request accepted and will be scheduled.
0554 //! @return SFS_ERROR File could not be read, error holds the reason.
0555 //-----------------------------------------------------------------------------
0556 
0557 virtual int            pgRead(XrdSfsAio *aioparm, uint64_t opts=0);
0558 
0559 //-----------------------------------------------------------------------------
0560 //! Write file pages into a file with corresponding checksums.
0561 //!
0562 //! @param  offset  - The offset where the write is to start. It may be
0563 //!                   unaligned with certain caveats relative to csvec.
0564 //! @param  buffer  - pointer to buffer containing the bytes to write.
0565 //! @param  wrlen   - The number of bytes to write. If amount is not an
0566 //!                   integral number of XrdSys::PageSize bytes, then this must
0567 //!                   be the last write to the file at or above the offset.
0568 //! @param  csvec   - A vector which contains the corresponding CRC32 checksum
0569 //!                   for each page or page fragment. If offset is unaligned
0570 //!                   then csvec[0] is the crc of the leading fragment to
0571 //!                   align the subsequent full page who's crc is in csvec[1].
0572 //!                   It must be sized to hold all aligned XrdSys::Pagesize
0573 //!                   crc's plus additional ones for leading and ending page
0574 //!                   fragments, if any.
0575 //! @param  opts    - Processing options (see above).
0576 //!
0577 //! @return >= 0      The number of bytes written.
0578 //! @return SFS_ERROR File could not be read, error holds the reason.
0579 //-----------------------------------------------------------------------------
0580 
0581 virtual XrdSfsXferSize pgWrite(XrdSfsFileOffset   offset,
0582                                char              *buffer,
0583                                XrdSfsXferSize     wrlen,
0584                                uint32_t          *csvec,
0585                                uint64_t           opts=0);
0586 
0587 //-----------------------------------------------------------------------------
0588 //! Write file pages and checksums using asynchronous I/O.
0589 //!
0590 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0591 //! @param  opts    - Processing options (see above).
0592 //!
0593 //! @return SFS_OK    Request accepted and will be scheduled.
0594 //! @return SFS_ERROR File could not be read, error holds the reason.
0595 //-----------------------------------------------------------------------------
0596 
0597 virtual int            pgWrite(XrdSfsAio *aioparm, uint64_t opts=0);
0598 
0599 //-----------------------------------------------------------------------------
0600 //! Preread file blocks into the file system cache.
0601 //!
0602 //! @param  offset  - The offset where the read is to start.
0603 //! @param  size    - The number of bytes to pre-read.
0604 //!
0605 //! @return >= 0      The number of bytes that will be pre-read.
0606 //! @return SFS_ERROR File could not be preread, error holds the reason.
0607 //-----------------------------------------------------------------------------
0608 
0609 virtual XrdSfsXferSize read(XrdSfsFileOffset   offset,
0610                             XrdSfsXferSize     size) = 0;
0611 
0612 //-----------------------------------------------------------------------------
0613 //! Read file bytes into a buffer.
0614 //!
0615 //! @param  offset  - The offset where the read is to start.
0616 //! @param  buffer  - pointer to buffer where the bytes are to be placed.
0617 //! @param  size    - The number of bytes to read.
0618 //!
0619 //! @return >= 0      The number of bytes that placed in buffer.
0620 //! @return SFS_ERROR File could not be read, error holds the reason.
0621 //-----------------------------------------------------------------------------
0622 
0623 virtual XrdSfsXferSize read(XrdSfsFileOffset   offset,
0624                             char              *buffer,
0625                             XrdSfsXferSize     size) = 0;
0626 
0627 //-----------------------------------------------------------------------------
0628 //! Read file bytes using asynchronous I/O.
0629 //!
0630 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0631 //!
0632 //! @return SFS_OK    Request accepted and will be scheduled.
0633 //! @return SFS_ERROR File could not be read, error holds the reason.
0634 //-----------------------------------------------------------------------------
0635 
0636 virtual int            read(XrdSfsAio *aioparm) = 0;
0637 
0638 //-----------------------------------------------------------------------------
0639 //! Given an array of read requests (size rdvCnt), read them from the file
0640 //! and place the contents consecutively in the provided buffer. A dumb default
0641 //! implementation is supplied but should be replaced to increase performance.
0642 //!
0643 //! @param  readV     pointer to the array of read requests.
0644 //! @param  rdvCnt    the number of elements in readV.
0645 //!
0646 //! @return >=0       The numbe of bytes placed into the buffer.
0647 //! @return SFS_ERROR File could not be read, error holds the reason.
0648 //-----------------------------------------------------------------------------
0649 
0650 virtual XrdSfsXferSize readv(XrdOucIOVec      *readV,
0651                              int               rdvCnt);
0652 
0653 //-----------------------------------------------------------------------------
0654 //! Send file bytes via a XrdSfsDio sendfile object to a client (optional).
0655 //!
0656 //! @param  sfDio   - Pointer to the sendfile object for data transfer.
0657 //! @param  offset  - The offset where the read is to start.
0658 //! @param  size    - The number of bytes to read and send.
0659 //!
0660 //! @return SFS_ERROR File not read, error object has reason.
0661 //! @return SFS_OK    Either data has been successfully sent via sfDio or no
0662 //!                   data has been sent and a normal read() should be issued.
0663 //-----------------------------------------------------------------------------
0664 
0665 virtual int            SendData(XrdSfsDio         *sfDio,
0666                                 XrdSfsFileOffset   offset,
0667                                 XrdSfsXferSize     size);
0668 
0669 //-----------------------------------------------------------------------------
0670 //! Write file bytes from a buffer.
0671 //!
0672 //! @param  offset  - The offset where the write is to start.
0673 //! @param  buffer  - pointer to buffer where the bytes reside.
0674 //! @param  size    - The number of bytes to write.
0675 //!
0676 //! @return >= 0      The number of bytes that were written.
0677 //! @return SFS_ERROR File could not be written, error holds the reason.
0678 //-----------------------------------------------------------------------------
0679 
0680 virtual XrdSfsXferSize write(XrdSfsFileOffset  offset,
0681                              const char       *buffer,
0682                              XrdSfsXferSize    size) = 0;
0683 
0684 //-----------------------------------------------------------------------------
0685 //! Write file bytes using asynchronous I/O.
0686 //!
0687 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0688 //!
0689 //! @return  0       Request accepted and will be scheduled.
0690 //! @return !0       Request not accepted, returned value is errno.
0691 //-----------------------------------------------------------------------------
0692 
0693 virtual int            write(XrdSfsAio *aioparm) = 0;
0694 
0695 //-----------------------------------------------------------------------------
0696 //! Given an array of write requests (size wdvcnt), write them to the file
0697 //! from the provided associated buffer. A dumb default implementation is
0698 //! supplied but should be replaced to increase performance.
0699 //!
0700 //! @param  writeV    pointer to the array of write requests.
0701 //! @param  wdvCnt    the number of elements in writeV.
0702 //!
0703 //! @return >=0       The total number of bytes written to the file.
0704 //! @return SFS_ERROR File could not be written, error holds the reason.
0705 //-----------------------------------------------------------------------------
0706 
0707 virtual XrdSfsXferSize writev(XrdOucIOVec      *writeV,
0708                               int               wdvCnt);
0709 
0710 //-----------------------------------------------------------------------------
0711 //! Return state information on the file.
0712 //!
0713 //! @param  buf    - Pointer to the structure where info it to be returned.
0714 //!
0715 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL. When SFS_OK
0716 //!         is returned, buf must hold stat information.
0717 //-----------------------------------------------------------------------------
0718 
0719 virtual int            stat(struct stat *buf) = 0;
0720 
0721 //-----------------------------------------------------------------------------
0722 //! Make sure all outstanding data is actually written to the file (sync).
0723 //!
0724 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED
0725 //-----------------------------------------------------------------------------
0726 
0727 virtual int            sync() = 0;
0728 
0729 //-----------------------------------------------------------------------------
0730 //! Make sure all outstanding data is actually written to the file (async).
0731 //!
0732 //! @return SFS_OK    Request accepted and will be scheduled.
0733 //! @return SFS_ERROR Request could not be accepted, return error has reason.
0734 //-----------------------------------------------------------------------------
0735 
0736 virtual int            sync(XrdSfsAio *aiop) = 0;
0737 
0738 //-----------------------------------------------------------------------------
0739 //! Truncate the file.
0740 //!
0741 //! @param  fsize  - The size that the file is to have.
0742 //!
0743 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
0744 //-----------------------------------------------------------------------------
0745 
0746 virtual int            truncate(XrdSfsFileOffset fsize) = 0;
0747 
0748 //-----------------------------------------------------------------------------
0749 //! Get compression information for the file.
0750 //!
0751 //! @param  cxtype - Place where the compression algorithm name is to be placed
0752 //! @param  cxrsz  - Place where the compression page size is to be returned
0753 //!
0754 //! @return One of the valid SFS return codes described above. If the file
0755 //!         is not compressed or an error is returned, cxrsz must be set to 0.
0756 //-----------------------------------------------------------------------------
0757 
0758 virtual int            getCXinfo(char cxtype[4], int &cxrsz) = 0;
0759 
0760 //-----------------------------------------------------------------------------
0761 //! Enable exchange buffer I/O for write calls.
0762 //!
0763 //! @param  xioP - Pointer to the XrdSfsXio object to be used for buffer exchanges.
0764 //-----------------------------------------------------------------------------
0765 
0766 virtual void           setXio(XrdSfsXio *xioP) { (void)xioP; }
0767 
0768 //-----------------------------------------------------------------------------
0769 //! Constructor (user and MonID are the ones passed to newFile()!). This
0770 //! constructor should only be used by base plugins. Plugins that wrap an
0771 //! SfsFile should use the second version of the constructor shown below.
0772 //!
0773 //! @param  user   - Text identifying the client responsible for this call.
0774 //!                  The pointer may be null if identification is missing.
0775 //! @param  MonID  - The monitoring identifier assigned to this and all
0776 //!                  future requests using the returned object.
0777 //-----------------------------------------------------------------------------
0778 
0779                        XrdSfsFile(const char *user=0, int MonID=0)
0780                                  : error(*(new XrdOucErrInfo(user, MonID)))
0781                                  {lclEI = &error; pgwrEOF = 0;}
0782 
0783 //-----------------------------------------------------------------------------
0784 //! Constructor for plugins that wrap another SFS plugin. This constructor
0785 //! inherits the error object from a wrapped XrdSfsFile object so that only
0786 //! one identical error object exists for all file objects in the chain.
0787 //!
0788 //! @param  wrapF  - Reference to the file object being wrapped.
0789 //-----------------------------------------------------------------------------
0790 
0791                        XrdSfsFile(XrdSfsFile &wrapF)
0792                                  : error(wrapF.error), lclEI(0), pgwrEOF(0) {}
0793 
0794 //-----------------------------------------------------------------------------
0795 //! Constructor for base plugins that predefined an error object. This is a
0796 //! convenience constructor for base plugins only.
0797 //!
0798 //! @param  eInfo  - Reference to the error object to use.
0799 //-----------------------------------------------------------------------------
0800 
0801                        XrdSfsFile(XrdOucErrInfo &eInfo)
0802                                  : error(eInfo), lclEI(0), pgwrEOF(0) {}
0803 
0804 //-----------------------------------------------------------------------------
0805 //! Destructor
0806 //-----------------------------------------------------------------------------
0807 
0808 virtual               ~XrdSfsFile() {if (lclEI) delete lclEI;}
0809 
0810 private:
0811 XrdOucErrInfo*   lclEI;
0812 XrdSfsFileOffset pgwrEOF;
0813 }; // class XrdSfsFile
0814 
0815 /******************************************************************************/
0816 /*                      X r d S f s F i l e S y s t e m                       */
0817 /******************************************************************************/
0818   
0819 //-----------------------------------------------------------------------------
0820 //! Common parameters: Many of the methods have certain common parameters.
0821 //! These are documented here to avoid lengthy duplicate descriptions.
0822 //!
0823 //! @param  eInfo  - The object where error info or results are to be returned.
0824 //!                  For errors, you should return information as follows:
0825 //!                  SFS_OK       eInfo may contain results, as described in
0826 //!                               specified method description that follows.
0827 //!                  SFS_ERROR    eInfo.code    - errno number
0828 //!                               eInfo.message - error message text
0829 //!                  SFS_REDIRECT eInfo.code    - target port number
0830 //!                               eInfo.message - target host address/name
0831 //!                  SFS_STALL    eInfo.code    - expected seconds to stall
0832 //!                               eInfo.message - reason for the delay
0833 //!                  SFS_STARTED  eInfo.code    - expected seconds to completion
0834 //!                               eInfo.message - reason for the delay
0835 //!                  SFS_DATA     eInfo.code    - length of data in message
0836 //!                               eInfo.message - the request data
0837 //!
0838 //! @param  client - Pointer to the client's identity information or nil if
0839 //!                  the identity is not known.
0840 //!
0841 //! @param  opaque - Pointer to the CGI information associated with Path or
0842 //!                  nil if there is no opaque information.
0843 //-----------------------------------------------------------------------------
0844 
0845 class XrdSfsFileSystem
0846 {
0847 public:
0848 
0849 //-----------------------------------------------------------------------------
0850 //! Obtain a new director object to be used for future directory requests.
0851 //!
0852 //! @param  user   - Text identifying the client responsible for this call.
0853 //!                  The pointer may be null if identification is missing.
0854 //! @param  MonID  - The monitoring identifier assigned to this and all
0855 //!                  future requests using the returned object.
0856 //!
0857 //! @return pointer- Pointer to an XrdSfsDirectory object.
0858 //! @return nil    - Insufficient memory to allocate an object.
0859 //-----------------------------------------------------------------------------
0860 
0861 virtual XrdSfsDirectory *newDir(char *user=0, int MonID=0)  = 0;
0862 
0863 //-----------------------------------------------------------------------------
0864 //! Obtain a new wrapped directory object to be used for future requests.
0865 //!
0866 //! @param  eInfo  - Reference to the error object to be used by the new
0867 //!                  directory object. Note that an implementation is supplied
0868 //!                  for compatibility purposes but it returns a nil pointer
0869 //!                  which is considered to be a failure. You must supply an
0870 //!                  implementation for this to work correctly.
0871 //!
0872 //! @return pointer- Pointer to an XrdSfsDirectory object.
0873 //! @return nil    - Insufficient memory to allocate an object.
0874 //-----------------------------------------------------------------------------
0875 
0876 virtual XrdSfsDirectory *newDir(XrdOucErrInfo &eInfo) {(void)eInfo; return 0;}
0877 
0878 //-----------------------------------------------------------------------------
0879 //! Obtain a new file object to be used for a future file requests.
0880 //!
0881 //! @param  user   - Text identifying the client responsible for this call.
0882 //!                  The pointer may be null if identification is missing.
0883 //! @param  MonID  - The monitoring identifier assigned to this and all
0884 //!                  future requests using the returned object.
0885 //!
0886 //! @return pointer- Pointer to an XrdSfsFile object.
0887 //! @return nil    - Insufficient memory to allocate an object.
0888 //-----------------------------------------------------------------------------
0889 
0890 virtual XrdSfsFile      *newFile(char *user=0, int MonID=0) = 0;
0891 
0892 //-----------------------------------------------------------------------------
0893 //! Obtain a new wrapped file object to be used for a future requests.
0894 //!
0895 //! @param  eInfo  - Reference to the error object to be used by the new file
0896 //!                  object. Note that an implementation is supplied for
0897 //!                  compatibility purposes but it returns a nil pointer
0898 //!                  which is considered to be a failure. You must supply an
0899 //!                  implementation for this to work correctly.
0900 //!
0901 //! @return pointer- Pointer to an XrdSfsFile object.
0902 //! @return nil    - Insufficient memory to allocate an object.
0903 //-----------------------------------------------------------------------------
0904 
0905 virtual XrdSfsFile      *newFile(XrdOucErrInfo &eInfo) {(void)eInfo; return 0;}
0906 
0907 //-----------------------------------------------------------------------------
0908 //! Obtain checksum information for a file.
0909 //!
0910 //! @param  Func   - The checksum operation to be performed:
0911 //!                  csCalc  - (re)calculate and return the checksum value
0912 //!                  csGet   - return the existing checksum value, if any
0913 //!                  csSize  - return the size of the checksum value that
0914 //!                            corresponds to csName (path may be null).
0915 //! @param  csName - The name of the checksum value wanted.
0916 //! @param  path   - Pointer to the path of the file in question.
0917 //! @param  eInfo  - The object where error info or results are to be returned.
0918 //! @param  client - Client's identify (see common description).
0919 //! @param  opaque - Path's CGI information (see common description).
0920 //!
0921 //! @return One of SFS_OK, SFS_ERROR, or SFS_REDIRECT. When SFS_OK is returned,
0922 //!         eInfo should contain results, as follows:
0923 //!         csCalc/csGet eInfo.message - null terminated string with the
0924 //!                                      checksum value in ASCII hex.
0925 //!         csSize       eInfo.code    - size of binary checksum value.
0926 //-----------------------------------------------------------------------------
0927 
0928 enum    csFunc {csCalc = 0, csGet, csSize};
0929 
0930 virtual int            chksum(      csFunc            Func,
0931                               const char             *csName,
0932                               const char             *path,
0933                                     XrdOucErrInfo    &eInfo,
0934                               const XrdSecEntity     *client = 0,
0935                               const char             *opaque = 0);
0936 
0937 //-----------------------------------------------------------------------------
0938 //! Change file mode settings.
0939 //!
0940 //! @param  path   - Pointer to the path of the file in question.
0941 //! @param  mode   - The new file mode setting.
0942 //! @param  eInfo  - The object where error info or results are to be returned.
0943 //! @param  client - Client's identify (see common description).
0944 //! @param  opaque - Path's CGI information (see common description).
0945 //!
0946 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT or SFS_STALL
0947 //-----------------------------------------------------------------------------
0948 
0949 virtual int            chmod(const char             *path,
0950                                    XrdSfsMode        mode,
0951                                    XrdOucErrInfo    &eInfo,
0952                              const XrdSecEntity     *client = 0,
0953                              const char             *opaque = 0) = 0;
0954 
0955 //-----------------------------------------------------------------------------
0956 //! Notify filesystem that a client has connected.
0957 //!
0958 //! @param  client - Client's identify (see common description).
0959 //-----------------------------------------------------------------------------
0960 
0961 virtual void           Connect(const XrdSecEntity     *client = 0)
0962 {
0963   (void)client;
0964 }
0965 
0966 //-----------------------------------------------------------------------------
0967 //! Notify filesystem that a client has disconnected.
0968 //!
0969 //! @param  client - Client's identify (see common description).
0970 //-----------------------------------------------------------------------------
0971 
0972 virtual void           Disc(const XrdSecEntity *client = 0) {(void)client;}
0973 
0974 //-----------------------------------------------------------------------------
0975 //! Notify filesystem about implmentation dependent environment. This method
0976 //! may be called only once, if at all, right after obtaining this object.
0977 //!
0978 //! @param  envP   - Pointer to environmental information.
0979 //-----------------------------------------------------------------------------
0980 
0981 virtual void           EnvInfo(XrdOucEnv *envP) {(void)envP;}
0982 
0983 //-----------------------------------------------------------------------------
0984 //! Return directory/file existence information (short stat).
0985 //!
0986 //! @param  path   - Pointer to the path of the file/directory in question.
0987 //! @param  eFlag  - Where the results are to be returned.
0988 //! @param  eInfo  - The object where error info is to be returned.
0989 //! @param  client - Client's identify (see common description).
0990 //! @param  opaque - Path's CGI information (see common description).
0991 //!
0992 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED
0993 //!         When SFS_OK is returned, eFlag must be properly set, as follows:
0994 //!         XrdSfsFileExistNo            - path does not exist
0995 //!         XrdSfsFileExistIsFile        - path refers to an  online file
0996 //!         XrdSfsFileExistIsDirectory   - path refers to an  online directory
0997 //!         XrdSfsFileExistIsOffline     - path refers to an offline file
0998 //!         XrdSfsFileExistIsOther       - path is neither a file nor directory
0999 //-----------------------------------------------------------------------------
1000 
1001 virtual int            exists(const char                *path,
1002                                     XrdSfsFileExistence &eFlag,
1003                                     XrdOucErrInfo       &eInfo,
1004                               const XrdSecEntity        *client = 0,
1005                               const char                *opaque = 0) = 0;
1006 
1007 //-----------------------------------------------------------------------------
1008 //! Perform a filesystem extended attribute function.
1009 //!
1010 //! @param  faReq  - pointer to the request object (see XrdSfsFAttr.hh). If the
1011 //!                  pointer is nill, simply return whether or not extended
1012 //!                  attributes are supported.
1013 //! @param  eInfo  - The object where error info or results are to be returned.
1014 //! @param  client - Client's identify (see common description).
1015 //!
1016 //! @return SFS_OK   a null response is sent.
1017 //! @return SFS_DATA error.code    length of the data to be sent.
1018 //!                  error.message contains the data to be sent.
1019 //! @return SFS_STARTED Operation started result will be returned via callback.
1020 //!         o/w      one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.
1021 //-----------------------------------------------------------------------------
1022 
1023 virtual int            FAttr(      XrdSfsFACtl      *faReq,
1024                                    XrdOucErrInfo    &eInfo,
1025                              const XrdSecEntity     *client = 0);
1026 
1027 //-----------------------------------------------------------------------------
1028 //! Obtain file system feature set.
1029 //!
1030 //! @return The bit-wise feature set (i.e. supported or configured).
1031 //!         See include file XrdSfsFlags.hh for actual bit values.
1032 //-----------------------------------------------------------------------------
1033 
1034         uint64_t       Features() {return FeatureSet;}
1035 
1036 //-----------------------------------------------------------------------------
1037 //! Perform a filesystem control operation (version 2)
1038 //!
1039 //! @param  cmd    - The operation to be performed:
1040 //!                  SFS_FSCTL_PLUGIN  Return Implementation Dependent Data v1
1041 //!                  SFS_FSCTL_PLUGIO  Return Implementation Dependent Data v2
1042 //! @param  args   - Arguments specific to cmd.
1043 //!                  SFS_FSCTL_PLUGIN  path and opaque information.
1044 //!                  SFS_FSCTL_PLUGIO  Unscreened argument string.
1045 //! @param  eInfo  - The object where error info or results are to be returned.
1046 //! @param  client - Client's identify (see common description).
1047 //!
1048 //! @return SFS_OK   a null response is sent.
1049 //!         SFS_DATA error.code    length of the data to be sent.
1050 //!                  error.message contains the data to be sent.
1051 //!         o/w      one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.
1052 //-----------------------------------------------------------------------------
1053 
1054 virtual int            FSctl(const int               cmd,
1055                                    XrdSfsFSctl      &args,
1056                                    XrdOucErrInfo    &eInfo,
1057                              const XrdSecEntity     *client = 0);
1058 
1059 //-----------------------------------------------------------------------------
1060 //! Perform a filesystem control operation (version 1)
1061 //!
1062 //! @param  cmd    - The operation to be performed:
1063 //!                  SFS_FSCTL_LOCATE  Locate a file or file servers
1064 //!                  SFS_FSCTL_STATCC  Return cluster config status
1065 //!                  SFS_FSCTL_STATFS  Return physical filesystem information
1066 //!                  SFS_FSCTL_STATLS  Return logical  filesystem information
1067 //!                  SFS_FSCTL_STATXA  Return extended attributes
1068 //! @param  args   - Arguments specific to cmd.
1069 //!                  SFS_FSCTL_LOCATE  args points to the path to be located
1070 //!                                    ""   path is the first exported path
1071 //!                                    "*"  return all current servers
1072 //!                                    "*/" return servers exporting path
1073 //!                                    o/w  return servers having the path
1074 //!                  SFS_FSCTL_STATFS  Path in the filesystem in question.
1075 //!                  SFS_FSCTL_STATLS  Path in the filesystem in question.
1076 //!                  SFS_FSCTL_STATXA  Path of the file whose xattr is wanted.
1077 //! @param  eInfo  - The object where error info or results are to be returned.
1078 //! @param  client - Client's identify (see common description).
1079 //!
1080 //! @return SFS_OK   a null response is sent.
1081 //! @return SFS_DATA error.code    length of the data to be sent.
1082 //!                  error.message contains the data to be sent.
1083 //! @return SFS_STARTED Operation started result will be returned via callback.
1084 //!                  Valid only for for SFS_FSCTL_LOCATE, SFS_FSCTL_STATFS, and
1085 //!                  SFS_FSCTL_STATXA
1086 //!         o/w      one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.
1087 //-----------------------------------------------------------------------------
1088 
1089 virtual int            fsctl(const int               cmd,
1090                              const char             *args,
1091                                    XrdOucErrInfo    &eInfo,
1092                              const XrdSecEntity     *client = 0) = 0;
1093 
1094 //-----------------------------------------------------------------------------
1095 //! Return maximum checkpoint size.
1096 //!
1097 //! @return Maximum size of a checkpoint.
1098 //-----------------------------------------------------------------------------
1099 
1100 virtual int            getChkPSize() {return 0;}
1101 
1102 //-----------------------------------------------------------------------------
1103 //! Return statistical information.
1104 //!
1105 //! @param  buff   - Pointer to the buffer where results are to be returned.
1106 //!                  Statistics should be in standard XML format. If buff is
1107 //!                  nil then only maximum size information is wanted.
1108 //! @param  blen   - The length available in buff.
1109 //!
1110 //! @return Number of bytes placed in buff. When buff is nil, the maximum
1111 //!         number of bytes that could have been placed in buff.
1112 //-----------------------------------------------------------------------------
1113 
1114 virtual int            getStats(char *buff, int blen) = 0;
1115 
1116 //-----------------------------------------------------------------------------
1117 //! Get version string.
1118 //!
1119 //! @return The version string. Normally this is the XrdVERSION value.
1120 //-----------------------------------------------------------------------------
1121 
1122 virtual const char    *getVersion() = 0;
1123 
1124 //-----------------------------------------------------------------------------
1125 //! Perform a third party file transfer or cancel one.
1126 //!
1127 //! @param  gpAct  - What to do as one of the enums listed below.
1128 //! @param  gpReq  - reference tothe object describing the request. This object
1129 //!                  is also used communicate the request status.
1130 //! @param  eInfo  - The object where error info or results are to be returned.
1131 //! @param  client - Client's identify (see common description).
1132 //!
1133 //! @return SFS_OK   Request accepted (same as SFS_STARTED). Otherwise, one of
1134 //!                  SFS_ERROR, SFS_REDIRECT, or SFS_STALL.
1135 //-----------------------------------------------------------------------------
1136 
1137 enum gpfFunc {gpfCancel=0, //!< Cancel this request
1138               gpfGet,      //!< Perform a file retrieval
1139               gpfPut       //!< Perform a file push
1140              };
1141 
1142 virtual int            gpFile(      gpfFunc          &gpAct,
1143                                     XrdSfsGPFile     &gpReq,
1144                                     XrdOucErrInfo    &eInfo,
1145                               const XrdSecEntity     *client = 0);
1146 
1147 //-----------------------------------------------------------------------------
1148 //! Create a directory.
1149 //!
1150 //! @param  path   - Pointer to the path of the directory to be created.
1151 //! @param  mode   - The directory mode setting.
1152 //! @param  eInfo  - The object where error info is to be returned.
1153 //! @param  client - Client's identify (see common description).
1154 //! @param  opaque - Path's CGI information (see common description).
1155 //!
1156 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1157 //-----------------------------------------------------------------------------
1158 
1159 virtual int            mkdir(const char              *path,
1160                                    XrdSfsMode         mode,
1161                                    XrdOucErrInfo     &eInfo,
1162                              const XrdSecEntity      *client = 0,
1163                              const char              *opaque = 0) = 0;
1164 
1165 //-----------------------------------------------------------------------------
1166 //! Prepare a file for future processing.
1167 //!
1168 //! @param  pargs  - The preapre arguments.
1169 //! @param  eInfo  - The object where error info is to be returned.
1170 //! @param  client - Client's identify (see common description).
1171 //!
1172 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1173 //-----------------------------------------------------------------------------
1174 
1175 virtual int            prepare(      XrdSfsPrep      &pargs,
1176                                      XrdOucErrInfo   &eInfo,
1177                                const XrdSecEntity    *client = 0) = 0;
1178 
1179 //-----------------------------------------------------------------------------
1180 //! Remove a file.
1181 //!
1182 //! @param  path   - Pointer to the path of the file to be removed.
1183 //! @param  eInfo  - The object where error info is to be returned.
1184 //! @param  client - Client's identify (see common description).
1185 //! @param  opaque - Path's CGI information (see common description).
1186 //!
1187 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1188 //-----------------------------------------------------------------------------
1189 
1190 virtual int            rem(const char                *path,
1191                                  XrdOucErrInfo       &eInfo,
1192                            const XrdSecEntity        *client = 0,
1193                            const char                *opaque = 0) = 0;
1194 
1195 //-----------------------------------------------------------------------------
1196 //! Remove a directory.
1197 //!
1198 //! @param  path   - Pointer to the path of the directory to be removed.
1199 //! @param  eInfo  - The object where error info is to be returned.
1200 //! @param  client - Client's identify (see common description).
1201 //! @param  opaque - Path's CGI information (see common description).
1202 //!
1203 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1204 //-----------------------------------------------------------------------------
1205 
1206 virtual int            remdir(const char             *path,
1207                                     XrdOucErrInfo    &eInfo,
1208                               const XrdSecEntity     *client = 0,
1209                               const char             *opaque = 0) = 0;
1210 
1211 //-----------------------------------------------------------------------------
1212 //! Rename a file or directory.
1213 //!
1214 //! @param  oPath   - Pointer to the path to be renamed.
1215 //! @param  nPath   - Pointer to the path oPath is to have.
1216 //! @param  eInfo   - The object where error info is to be returned.
1217 //! @param  client  - Client's identify (see common description).
1218 //! @param  opaqueO - oPath's CGI information (see common description).
1219 //! @param  opaqueN - nPath's CGI information (see common description).
1220 //!
1221 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1222 //-----------------------------------------------------------------------------
1223 
1224 virtual int            rename(const char             *oPath,
1225                               const char             *nPath,
1226                                     XrdOucErrInfo    &eInfo,
1227                               const XrdSecEntity     *client = 0,
1228                               const char             *opaqueO = 0,
1229                               const char             *opaqueN = 0) = 0;
1230 
1231 //-----------------------------------------------------------------------------
1232 //! Return state information on a file or directory.
1233 //!
1234 //! @param  Name   - Pointer to the path in question.
1235 //! @param  buf    - Pointer to the structure where info it to be returned.
1236 //! @param  eInfo  - The object where error info is to be returned.
1237 //! @param  client - Client's identify (see common description).
1238 //! @param  opaque - path's CGI information (see common description).
1239 //!
1240 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED
1241 //!         When SFS_OK is returned, buf must contain stat information.
1242 //-----------------------------------------------------------------------------
1243 
1244 virtual int            stat(const char               *Name,
1245                                   struct stat        *buf,
1246                                   XrdOucErrInfo      &eInfo,
1247                             const XrdSecEntity       *client = 0,
1248                             const char               *opaque = 0) = 0;
1249 
1250 //-----------------------------------------------------------------------------
1251 //! Return mode information on a file or directory.
1252 //!
1253 //! @param  path   - Pointer to the path in question.
1254 //! @param  mode   - Where full mode information is to be returned.
1255 //! @param  eInfo  - The object where error info is to be returned.
1256 //! @param  client - Client's identify (see common description).
1257 //! @param  opaque - path's CGI information (see common description).
1258 //!
1259 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED
1260 //!         When SFS_OK is returned, mode must contain mode information. If
1261 //!         the mode is -1 then it is taken as an offline file.
1262 //-----------------------------------------------------------------------------
1263 
1264 virtual int            stat(const char               *path,
1265                                   mode_t             &mode,
1266                                   XrdOucErrInfo      &eInfo,
1267                             const XrdSecEntity       *client = 0,
1268                             const char               *opaque = 0) = 0;
1269 
1270 //-----------------------------------------------------------------------------
1271 //! Truncate a file.
1272 //!
1273 //! @param  path   - Pointer to the path of the file to be truncated.
1274 //! @param  fsize  - The size that the file is to have.
1275 //! @param  eInfo  - The object where error info is to be returned.
1276 //! @param  client - Client's identify (see common description).
1277 //! @param  opaque - path's CGI information (see common description).
1278 //!
1279 //! @return One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL
1280 //-----------------------------------------------------------------------------
1281 
1282 virtual int            truncate(const char             *path,
1283                                       XrdSfsFileOffset  fsize,
1284                                       XrdOucErrInfo    &eInfo,
1285                                 const XrdSecEntity     *client = 0,
1286                                 const char             *opaque = 0) = 0;
1287 
1288 //-----------------------------------------------------------------------------
1289 //! Constructor and Destructor
1290 //-----------------------------------------------------------------------------
1291 
1292                        XrdSfsFileSystem();
1293 virtual               ~XrdSfsFileSystem() {}
1294 
1295 protected:
1296 
1297 uint64_t               FeatureSet; //!< Adjust features at initialization
1298 };
1299 
1300 /******************************************************************************/
1301 /*              F i l e   S y s t e m   I n s t a n t i a t o r               */
1302 /******************************************************************************/
1303 
1304 //-----------------------------------------------------------------------------
1305 /*! When building a shared library plugin, the following "C" entry point must
1306     exist in the library:
1307 
1308     @param  nativeFS - the filesystem that would have been used. You may return
1309                        this pointer if you wish.
1310     @param  Logger   - The message logging object to be used for messages.
1311     @param  configFn - pointer to the path of the configuration file. If nil
1312                        there is no configuration file.
1313     @param  envP     - Pointer to the environment containing implementation
1314                        specific information.
1315 
1316     @return Pointer to the file system object to be used or nil if an error
1317             occurred.
1318 
1319     extern "C"
1320          {XrdSfsFileSystem *XrdSfsGetFileSystem2(XrdSfsFileSystem *nativeFS,
1321                                                  XrdSysLogger     *Logger,
1322                                                  const char       *configFn,
1323                                                  XrdOucEnv        *envP);
1324          }
1325 */
1326 
1327 typedef XrdSfsFileSystem *(*XrdSfsFileSystem2_t)(XrdSfsFileSystem *nativeFS,
1328                                                  XrdSysLogger     *Logger,
1329                                                  const char       *configFn,
1330                                                  XrdOucEnv        *envP);
1331 
1332 //-----------------------------------------------------------------------------
1333 /*! The old-style entry-point is still supported as a fallback. Should the
1334     version '2' entry point is not found, the system attempts to use the
1335     version '1' entry point.
1336 
1337     extern "C"
1338          {XrdSfsFileSystem *XrdSfsGetFileSystem(XrdSfsFileSystem *nativeFS,
1339                                                 XrdSysLogger     *Logger,
1340                                                 const char       *configFn);
1341          }
1342 */
1343 
1344 typedef XrdSfsFileSystem *(*XrdSfsFileSystem_t) (XrdSfsFileSystem *nativeFS,
1345                                                  XrdSysLogger     *Logger,
1346                                                  const char       *configFn);
1347 
1348 //------------------------------------------------------------------------------
1349 /*! Specify the compilation version.
1350 
1351     Additionally, you *should* declare the xrootd version you used to compile
1352     your plug-in. The plugin manager automatically checks for compatibility.
1353     Declare it as follows:
1354 
1355     #include "XrdVersion.hh"
1356     XrdVERSIONINFO(XrdSfsGetFileSystem,<name>);
1357 
1358     where <name> is a 1- to 15-character unquoted name identifying your plugin.
1359 */
1360 //------------------------------------------------------------------------------
1361 #endif