Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef _XRDOSSWRAPPER_H
0002 #define _XRDOSSWRAPPER_H
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                      X r d O s s W r a p p e r . h h                       */
0006 /*                                                                            */
0007 /* (c) 2020 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include "XrdOss/XrdOss.hh"
0034 
0035 /******************************************************************************/
0036 //! This class defines a wrapper around the three basic XrdOss classes that
0037 //! defines the Oss interface. It is meant to be used by pushed XrdOss plugins
0038 //! that wish to intercept certain XrdOss method for an underlying Oss plugin.
0039 //! Inheriting this class and providing it the underlying wrapped object
0040 //! allows the derived class to easily intercept certain methods while
0041 //! allow non-intercepted methods to pass through.
0042 /******************************************************************************/
0043 
0044 /******************************************************************************/
0045 /*                    C l a s s   X r d O s s W r a p D F                     */
0046 /******************************************************************************/
0047 
0048 //! This class wraps the object that handles directory as well as file
0049 //! oriented requests. It is used by the derived class to wrap the object
0050 //! obtained by calling newDir() or newFile() in class XrdOss.
0051   
0052 class XrdOssWrapDF : public XrdOssDF
0053 {
0054 public:
0055 
0056 /******************************************************************************/
0057 /*            D i r e c t o r y   O r i e n t e d   M e t h o d s             */
0058 /******************************************************************************/
0059 
0060 //-----------------------------------------------------------------------------
0061 //! Open a directory.
0062 //!
0063 //! @param  path   - Pointer to the path of the directory to be opened.
0064 //! @param  env    - Reference to environmental information.
0065 //!
0066 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0067 //-----------------------------------------------------------------------------
0068 
0069 virtual int     Opendir(const char *path, XrdOucEnv &env)
0070                        {return wrapDF.Opendir(path, env);}
0071 
0072 //-----------------------------------------------------------------------------
0073 //! Get the next directory entry.
0074 //!
0075 //! @param  buff   - Pointer to buffer where a null terminated string of the
0076 //!                  entry name is to be returned. If no more entries exist,
0077 //!                  a null string is returned.
0078 //! @param  blen   - Length of the buffer.
0079 //!
0080 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0081 //-----------------------------------------------------------------------------
0082 
0083 virtual int     Readdir(char *buff, int blen)
0084                        {return wrapDF.Readdir(buff, blen);}
0085 
0086 //-----------------------------------------------------------------------------
0087 //! Set the stat() buffer where stat information is to be placed corresponding
0088 //! to the directory entry returned by Readdir().
0089 //!
0090 //! @param  Stat   - Pointer to stat structure to be used.
0091 //!
0092 //! @return 0 upon success or -ENOTSUP if not supported.
0093 //!
0094 //! @note This is a one-time call as stat structure is reused for each Readdir.
0095 //-----------------------------------------------------------------------------
0096 
0097 virtual int     StatRet(struct stat *Stat) {return wrapDF.StatRet(Stat);}
0098 
0099 /******************************************************************************/
0100 /*                 F i l e   O r i e n t e d   M e t h o d s                  */
0101 /******************************************************************************/
0102 //-----------------------------------------------------------------------------
0103 //! Change file mode settings.
0104 //!
0105 //! @param  mode   - The new file mode setting.
0106 //!
0107 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0108 //-----------------------------------------------------------------------------
0109 
0110 virtual int     Fchmod(mode_t mode) {return wrapDF.Fchmod(mode);}
0111 
0112 //-----------------------------------------------------------------------------
0113 //! Flush filesystem cached pages for this file (used for checksums).
0114 //-----------------------------------------------------------------------------
0115 
0116 virtual void    Flush() {wrapDF.Flush();}
0117 
0118 //-----------------------------------------------------------------------------
0119 //! Return state information for this file.
0120 //!
0121 //! @param  buf    - Pointer to the structure where info it to be returned.
0122 //!
0123 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0124 //-----------------------------------------------------------------------------
0125 
0126 virtual int     Fstat(struct stat *buf) {return wrapDF.Fstat(buf);}
0127 
0128 //-----------------------------------------------------------------------------
0129 //! Synchronize associated file with media (synchronous).
0130 //!
0131 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0132 //-----------------------------------------------------------------------------
0133 
0134 virtual int     Fsync() {return wrapDF.Fsync();}
0135 
0136 //-----------------------------------------------------------------------------
0137 //! Synchronize associated file with media (asynchronous).
0138 //!
0139 //! @param  aiop   - Pointer to async I/O request object.
0140 //!
0141 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0142 //-----------------------------------------------------------------------------
0143 
0144 virtual int     Fsync(XrdSfsAio *aiop) {return wrapDF.Fsync(aiop);}
0145 
0146 //-----------------------------------------------------------------------------
0147 //! Set the size of the associated file.
0148 //!
0149 //! @param  flen   - The new size of the file.
0150 //!
0151 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0152 //-----------------------------------------------------------------------------
0153 
0154 virtual int     Ftruncate(unsigned long long flen)
0155                          {return wrapDF.Ftruncate(flen);}
0156 
0157 //-----------------------------------------------------------------------------
0158 //! Return the memory mapped characteristics of the file.
0159 //!
0160 //! @param  addr   - Pointer to where the memory mapped address is to be returned.
0161 //!
0162 //! @return If mapped, the size of the file is returned and it memory location
0163 //!         is placed in addr. Otherwise, addr is set to zero and zero is
0164 //!         returned. Note that zero length files cannot be memory mapped.
0165 //-----------------------------------------------------------------------------
0166 
0167 virtual off_t   getMmap(void **addr) {return wrapDF.getMmap(addr);}
0168 
0169 //-----------------------------------------------------------------------------
0170 //! Return file compression charectistics.
0171 //!
0172 //! @param  cxidp  - Pointer to where the compression algorithm name returned.
0173 //!
0174 //! @return If the file is compressed, the region size if returned. Otherwise,
0175 //!         zero is returned (file not compressed).
0176 //-----------------------------------------------------------------------------
0177 
0178 virtual int     isCompressed(char *cxidp=0) {return wrapDF.isCompressed(cxidp);}
0179 
0180 //-----------------------------------------------------------------------------
0181 //! Open a file.
0182 //!
0183 //! @param  path   - Pointer to the path of the file to be opened.
0184 //! @param  Oflag  - Standard open flags.
0185 //! @param  Mode   - File open mode (ignored unless creating a file).
0186 //! @param  env    - Reference to environmental information.
0187 //!
0188 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0189 //-----------------------------------------------------------------------------
0190 
0191 virtual int     Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
0192                     {return wrapDF.Open(path, Oflag, Mode, env);}
0193 
0194 //-----------------------------------------------------------------------------
0195 //! Read file pages into a buffer and return corresponding checksums.
0196 //!
0197 //! @param  buffer  - pointer to buffer where the bytes are to be placed.
0198 //! @param  offset  - The offset where the read is to start. It must be
0199 //!                   page aligned.
0200 //! @param  rdlen   - The number of bytes to read. The amount must be an
0201 //!                   integral number of XrdSfsPage::Size bytes.
0202 //! @param  csvec   - A vector of entries to be filled with the cooresponding
0203 //!                   CRC32C checksum for each page. It must be size to
0204 //!                   rdlen/XrdSys::PageSize + (rdlen%XrdSys::PageSize != 0)
0205 //! @param  opts    - Processing options (see below).
0206 //!
0207 //! @return >= 0      The number of bytes that placed in buffer upon success.
0208 //! @return  < 0       -errno or -osserr upon failure. (see XrdOssError.hh).
0209 //-----------------------------------------------------------------------------
0210 
0211 virtual ssize_t pgRead (void* buffer, off_t offset, size_t rdlen,
0212                         uint32_t* csvec, uint64_t opts)
0213                        {return wrapDF.pgRead(buffer,offset,rdlen,csvec,opts);}
0214 
0215 //-----------------------------------------------------------------------------
0216 //! Read file pages and checksums using asynchronous I/O.
0217 //!
0218 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0219 //! @param  opts    - Processing options (see above).
0220 //!
0221 //! @return 0 upon if request started success or -errno or -osserr
0222 //!         (see XrdOssError.hh).
0223 //-----------------------------------------------------------------------------
0224 
0225 virtual int     pgRead (XrdSfsAio* aioparm, uint64_t opts)
0226                        {return wrapDF.pgRead(aioparm, opts);}
0227 
0228 //-----------------------------------------------------------------------------
0229 //! Write file pages into a file with corresponding checksums.
0230 //!
0231 //! @param  buffer  - pointer to buffer containing the bytes to write.
0232 //! @param  offset  - The offset where the write is to start. It must be
0233 //!                   page aligned.
0234 //! @param  wrlen   - The number of bytes to write. If amount is not an
0235 //!                   integral number of XrdSys::PageSize bytes, then this must
0236 //!                   be the last write to the file at or above the offset.
0237 //! @param  csvec   - A vector which contains the corresponding CRC32 checksum
0238 //!                   for each page. It must be size to
0239 //!                   wrlen/XrdSys::PageSize + (wrlen%XrdSys::PageSize != 0)
0240 //! @param  opts    - Processing options (see above).
0241 //!
0242 //! @return >= 0      The number of bytes written upon success.
0243 //!                   or -errno or -osserr upon failure. (see XrdOssError.hh).
0244 //! @return  < 0      -errno or -osserr upon failure. (see XrdOssError.hh).
0245 //-----------------------------------------------------------------------------
0246 
0247 virtual ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen,
0248                         uint32_t* csvec, uint64_t opts)
0249                        {return wrapDF.pgWrite(buffer,offset,wrlen,csvec,opts);}
0250 
0251 //-----------------------------------------------------------------------------
0252 //! Write file pages and checksums using asynchronous I/O.
0253 //!
0254 //! @param  aioparm - Pointer to async I/O object controlling the I/O.
0255 //! @param  opts    - Processing options (see above).
0256 //!
0257 //! @return 0 upon if request started success or -errno or -osserr
0258 //!         (see XrdOssError.hh).
0259 //-----------------------------------------------------------------------------
0260 
0261 virtual int     pgWrite(XrdSfsAio* aioparm, uint64_t opts)
0262                        {return wrapDF.pgWrite(aioparm, opts);}
0263 
0264 //-----------------------------------------------------------------------------
0265 //! Preread file blocks into the file system cache.
0266 //!
0267 //! @param  offset  - The offset where the read is to start.
0268 //! @param  size    - The number of bytes to pre-read.
0269 //!
0270 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0271 //-----------------------------------------------------------------------------
0272 
0273 virtual ssize_t Read(off_t offset, size_t size)
0274                     {return wrapDF.Read(offset, size);}
0275 
0276 //-----------------------------------------------------------------------------
0277 //! Read file bytes into a buffer.
0278 //!
0279 //! @param  buffer  - pointer to buffer where the bytes are to be placed.
0280 //! @param  offset  - The offset where the read is to start.
0281 //! @param  size    - The number of bytes to read.
0282 //!
0283 //! @return >= 0      The number of bytes that placed in buffer.
0284 //! @return  < 0      -errno or -osserr upon failure (see XrdOssError.hh).
0285 //-----------------------------------------------------------------------------
0286 
0287 virtual ssize_t Read(void *buffer, off_t offset, size_t size)
0288                     {return wrapDF.Read(buffer, offset, size);}
0289 
0290 //-----------------------------------------------------------------------------
0291 //! Read file bytes using asynchronous I/O.
0292 //!
0293 //! @param  aiop    - Pointer to async I/O object controlling the I/O.
0294 //!
0295 //! @return 0 upon if request started success or -errno or -osserr
0296 //!         (see XrdOssError.hh).
0297 //-----------------------------------------------------------------------------
0298 
0299 virtual int     Read(XrdSfsAio *aiop) {return wrapDF.Read(aiop);}
0300 
0301 //-----------------------------------------------------------------------------
0302 //! Read uncompressed file bytes into a buffer.
0303 //!
0304 //! @param  buffer  - pointer to buffer where the bytes are to be placed.
0305 //! @param  offset  - The offset where the read is to start.
0306 //! @param  size    - The number of bytes to read.
0307 //!
0308 //! @return >= 0      The number of bytes that placed in buffer.
0309 //! @return  < 0      -errno or -osserr upon failure (see XrdOssError.hh).
0310 //-----------------------------------------------------------------------------
0311 
0312 virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
0313                        {return wrapDF.ReadRaw(buffer, offset, size);}
0314 
0315 //-----------------------------------------------------------------------------
0316 //! Read file bytes as directed by the read vector.
0317 //!
0318 //! @param  readV     pointer to the array of read requests.
0319 //! @param  rdvcnt    the number of elements in readV.
0320 //!
0321 //! @return >=0       The numbe of bytes read.
0322 //! @return < 0       -errno or -osserr upon failure (see XrdOssError.hh).
0323 //-----------------------------------------------------------------------------
0324 
0325 virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
0326                      {return wrapDF.ReadV(readV, rdvcnt);}
0327 
0328 //-----------------------------------------------------------------------------
0329 //! Write file bytes from a buffer.
0330 //!
0331 //! @param  buffer  - pointer to buffer where the bytes reside.
0332 //! @param  offset  - The offset where the write is to start.
0333 //! @param  size    - The number of bytes to write.
0334 //!
0335 //! @return >= 0      The number of bytes that were written.
0336 //! @return <  0      -errno or -osserr upon failure (see XrdOssError.hh).
0337 //-----------------------------------------------------------------------------
0338 
0339 virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
0340                      {return wrapDF.Write(buffer, offset, size);}
0341 
0342 //-----------------------------------------------------------------------------
0343 //! Write file bytes using asynchronous I/O.
0344 //!
0345 //! @param  aiop    - Pointer to async I/O object controlling the I/O.
0346 //!
0347 //! @return 0 upon if request started success or -errno or -osserr
0348 //!         (see XrdOssError.hh).
0349 //-----------------------------------------------------------------------------
0350 
0351 virtual int     Write(XrdSfsAio *aiop) {return wrapDF.Write(aiop);}
0352 
0353 //-----------------------------------------------------------------------------
0354 //! Write file bytes as directed by the write vector.
0355 //!
0356 //! @param  writeV    pointer to the array of write requests.
0357 //! @param  wrvcnt    the number of elements in writeV.
0358 //!
0359 //! @return >=0       The numbe of bytes read.
0360 //! @return < 0       -errno or -osserr upon failure (see XrdOssError.hh).
0361 //-----------------------------------------------------------------------------
0362 
0363 virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt)
0364                       {return wrapDF.WriteV(writeV, wrvcnt);}
0365 
0366 /******************************************************************************/
0367 /*     C o m m o n   D i r e c t o r y   a n d   F i l e   M e t h o d s      */
0368 /******************************************************************************/
0369 //-----------------------------------------------------------------------------
0370 //! Close a directory or file.
0371 //!
0372 //! @param  retsz     If not nil, where the size of the file is to be returned.
0373 //!
0374 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0375 //-----------------------------------------------------------------------------
0376 
0377 virtual int     Close(long long *retsz=0) {return wrapDF.Close(retsz);}
0378 
0379 //-----------------------------------------------------------------------------
0380 //! Return the underlying object type.
0381 //!
0382 //! @return Type of object.
0383 //-----------------------------------------------------------------------------
0384 
0385 uint16_t        DFType() {return wrapDF.DFType();}
0386 
0387 //-----------------------------------------------------------------------------
0388 //! Execute a special operation on the directory or file.
0389 //!
0390 //! @param  cmd    - The operation to be performed:
0391 //!                  Fctl_ckpObj - Obtain checkpoint object for proxy file.
0392 //!                                Argument: None.
0393 //!                                Response: Pointer to XrdOucChkPnt object.
0394 //!                  Fctl_utimes - Set atime and mtime (no response).
0395 //!                                Argument: struct timeval tv[2]
0396 //! @param  alen   - Length of data pointed to by args.
0397 //! @param  args   - Data sent with request, zero if alen is zero.
0398 //! @param  resp   - Where the response is to be set. The caller must call
0399 //!                  delete on the returned object.
0400 //!
0401 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0402 //-----------------------------------------------------------------------------
0403 
0404 virtual int     Fctl(int cmd, int alen, const char *args, char **resp=0)
0405                     {return wrapDF.Fctl(cmd, alen, args, resp);}
0406 
0407 //-----------------------------------------------------------------------------
0408 //! Return the underlying file descriptor.
0409 //!
0410 //! @return -1 if there is no file descriptor or a non-negative FD number.
0411 //-----------------------------------------------------------------------------
0412 
0413 virtual int     getFD() {return wrapDF.getFD();}
0414 
0415 //-----------------------------------------------------------------------------
0416 //! Return trace identifier associated with this object.
0417 //!
0418 //! @return Pointer to trace identifier
0419 //-----------------------------------------------------------------------------
0420 virtual
0421 const char     *getTID() {return wrapDF.getTID();}
0422 
0423 //-----------------------------------------------------------------------------
0424 //! Constructor and Destructor
0425 //!
0426 //! @param  df2Wrap- Reference to the newFile or newDir object being wrapped.
0427 //!
0428 //! @note: The object creator is responsible for deleting the df2Wrap object.
0429 //!        The ref to this object is stored here and is accessible.
0430 //-----------------------------------------------------------------------------
0431 
0432                 XrdOssWrapDF(XrdOssDF &df2Wrap) : wrapDF(df2Wrap) {}
0433 
0434 virtual        ~XrdOssWrapDF() {}
0435 
0436 
0437 protected:
0438 
0439 XrdOssDF   &wrapDF;  // Object being wrapped
0440 };
0441   
0442 /******************************************************************************/
0443 /*                   C l a s s   X r d O s s W r a p p e r                    */
0444 /******************************************************************************/
0445   
0446 class XrdOssWrapper : public XrdOss
0447 {
0448 public:
0449 
0450 //-----------------------------------------------------------------------------
0451 //! Obtain a new director object to be used for future directory requests.
0452 //!
0453 //! @param  tident - The trace identifier.
0454 //!
0455 //! @return pointer- Pointer to a possibly wrapped XrdOssDF object.
0456 //! @return nil    - Insufficient memory to allocate an object.
0457 //-----------------------------------------------------------------------------
0458 
0459 virtual XrdOssDF     *newDir(const char *tident)
0460                             {return wrapPI.newDir(tident);}
0461 
0462 //-----------------------------------------------------------------------------
0463 //! Obtain a new file object to be used for a future file requests.
0464 //!
0465 //! @param  tident - The trace identifier.
0466 //!
0467 //! @return pointer- Pointer to a possibly wrapped XrdOssDF object.
0468 //! @return nil    - Insufficient memory to allocate an object.
0469 //-----------------------------------------------------------------------------
0470 
0471 virtual XrdOssDF     *newFile(const char *tident)
0472                              {return wrapPI.newFile(tident);}
0473 
0474 //-----------------------------------------------------------------------------
0475 //! Change file mode settings.
0476 //!
0477 //! @param  path   - Pointer to the path of the file in question.
0478 //! @param  mode   - The new file mode setting.
0479 //! @param  envP   - Pointer to environmental information.
0480 //!
0481 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0482 //-----------------------------------------------------------------------------
0483 
0484 virtual int       Chmod(const char * path, mode_t mode, XrdOucEnv *envP=0)
0485                        {return wrapPI.Chmod(path, mode, envP);}
0486 
0487 //-----------------------------------------------------------------------------
0488 //! Notify storage system that a client has connected.
0489 //!
0490 //! @param  env    - Reference to environmental information.
0491 //-----------------------------------------------------------------------------
0492 
0493 virtual void      Connect(XrdOucEnv &env) {wrapPI.Connect(env);}
0494 
0495 //-----------------------------------------------------------------------------
0496 //! Create file.
0497 //!
0498 //! @param  tid    - Pointer to the trace identifier.
0499 //! @param  path   - Pointer to the path of the file to create.
0500 //! @param  mode   - The new file mode setting.
0501 //! @param  env    - Reference to environmental information.
0502 //! @param  opts   - Create options:
0503 //!                  XRDOSS_mkpath - create dir path if it does not exist.
0504 //!                  XRDOSS_new    - the file must not already exist.
0505 //!                  oflags<<8     - open flags shifted 8 bits to the left/
0506 //!
0507 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0508 //-----------------------------------------------------------------------------
0509 
0510 virtual int       Create(const char *tid, const char *path, mode_t mode,
0511                          XrdOucEnv &env, int opts=0)
0512                         {return wrapPI.Create(tid, path, mode, env, opts);}
0513 
0514 //-----------------------------------------------------------------------------
0515 //! Notify storage system that a client has disconnected.
0516 //!
0517 //! @param  env    - Reference to environmental information.
0518 //-----------------------------------------------------------------------------
0519 
0520 virtual void      Disc(XrdOucEnv &env) {wrapPI.Disc(env);}
0521 
0522 //-----------------------------------------------------------------------------
0523 //! Notify storage system of initialization information (deprecated).
0524 //!
0525 //! @param  envP   - Pointer to environmental information.
0526 //-----------------------------------------------------------------------------
0527 
0528 virtual void      EnvInfo(XrdOucEnv *envP) {wrapPI.EnvInfo(envP);}
0529 
0530 //-----------------------------------------------------------------------------
0531 //! Return storage system features.
0532 //!
0533 //! @return Storage system features (see XRDOSS_HASxxx flags).
0534 //-----------------------------------------------------------------------------
0535 
0536 virtual uint64_t  Features() {return wrapPI.Features();}
0537 
0538 //-----------------------------------------------------------------------------
0539 //! Execute a special storage system operation.
0540 //!
0541 //! @param  cmd    - The operation to be performed:
0542 //!                  XRDOSS_FSCTLFA - Perform proxy file attribute operation
0543 //! @param  alen   - Length of data pointed to by args.
0544 //! @param  args   - Data sent with request, zero if alen is zero.
0545 //! @param  resp   - Where the response is to be set, if any.
0546 //!
0547 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0548 //-----------------------------------------------------------------------------
0549 
0550 virtual int       FSctl(int cmd, int alen, const char *args, char **resp=0)
0551                        {return wrapPI.FSctl(cmd, alen, args, resp);}
0552 
0553 //-----------------------------------------------------------------------------
0554 //! Initialize the storage system V1 (deprecated).
0555 //!
0556 //! @param  lp     - Pointer to the message logging object.
0557 //! @param  cfn    - Pointer to the configuration file.
0558 //!
0559 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0560 //-----------------------------------------------------------------------------
0561 
0562 virtual int       Init(XrdSysLogger *lp, const char *cfn)
0563                       {return wrapPI.Init(lp, cfn);}
0564 
0565 //-----------------------------------------------------------------------------
0566 //! Initialize the storage system V2.
0567 //!
0568 //! @param  lp     - Pointer to the message logging object.
0569 //! @param  cfn    - Pointer to the configuration file.
0570 //! @param  envP   - Pointer to environmental information.
0571 //!
0572 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0573 //-----------------------------------------------------------------------------
0574 
0575 virtual int       Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
0576                       {return wrapPI.Init(lp, cfn, envP);}
0577 
0578 //-----------------------------------------------------------------------------
0579 //! Create a directory.
0580 //!
0581 //! @param  path   - Pointer to the path of the directory to be created.
0582 //! @param  mode   - The directory mode setting.
0583 //! @param  mkpath - When true the path is created if it does not exist.
0584 //! @param  envP   - Pointer to environmental information.
0585 //!
0586 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0587 //-----------------------------------------------------------------------------
0588 
0589 virtual int       Mkdir(const char *path, mode_t mode, int mkpath=0,
0590                         XrdOucEnv  *envP=0)
0591                        {return wrapPI.Mkdir(path, mode, mkpath, envP);}
0592 
0593 //-----------------------------------------------------------------------------
0594 //! Relocate/Copy the file at `path' to a new location.
0595 //!
0596 //! @param  tident - -> trace identifier for this operation.
0597 //! @param  path   - -> fully qualified name of the file to relocate.
0598 //! @param  cgName - -> target space name[:path]
0599 //! @param  anchor - Processing directions (see XrdOssReloc.cc example).
0600 //!
0601 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0602 //-----------------------------------------------------------------------------
0603 
0604 virtual int       Reloc(const char *tident, const char *path,
0605                         const char *cgName, const char *anchor=0)
0606                        {return wrapPI.Reloc(tident,path,cgName,anchor);}
0607 
0608 //-----------------------------------------------------------------------------
0609 //! Remove a directory.
0610 //!
0611 //! @param  path   - Pointer to the path of the directory to be removed.
0612 //! @param  Opts   - The processing options:
0613 //!                  XRDOSS_Online   - only remove online copy
0614 //!                  XRDOSS_isPFN    - path is already translated.
0615 //! @param  envP   - Pointer to environmental information.
0616 //!
0617 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0618 //-----------------------------------------------------------------------------
0619 
0620 virtual int       Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)
0621                         {return wrapPI.Remdir(path, Opts, envP);}
0622 
0623 //-----------------------------------------------------------------------------
0624 //! Rename a file or directory.
0625 //!
0626 //! @param  oPath   - Pointer to the path to be renamed.
0627 //! @param  nPath   - Pointer to the path oPath is to have.
0628 //! @param  oEnvP   - Environmental information for oPath.
0629 //! @param  nEnvP   - Environmental information for nPath.
0630 //!
0631 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0632 //-----------------------------------------------------------------------------
0633 
0634 virtual int       Rename(const char *oPath, const char *nPath,
0635                          XrdOucEnv  *oEnvP=0, XrdOucEnv *nEnvP=0)
0636                         {return wrapPI.Rename(oPath, nPath, oEnvP, nEnvP);}
0637 
0638 //-----------------------------------------------------------------------------
0639 //! Return state information on a file or directory.
0640 //!
0641 //! @param  path   - Pointer to the path in question.
0642 //! @param  buff   - Pointer to the structure where info it to be returned.
0643 //! @param  opts   - Options:
0644 //!                  XRDOSS_preop    - this is a stat prior to open.
0645 //!                  XRDOSS_resonly  - only look for resident files.
0646 //!                  XRDOSS_updtatm  - update file access time.
0647 //! @param  envP   - Pointer to environmental information.
0648 //!
0649 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0650 //-----------------------------------------------------------------------------
0651 
0652 virtual int       Stat(const char *path, struct stat *buff,
0653                        int opts=0, XrdOucEnv *envP=0)
0654                       {return wrapPI.Stat(path, buff, opts, envP);}
0655 
0656 //-----------------------------------------------------------------------------
0657 //! Return statistics.
0658 //!
0659 //! @param  buff   - Pointer to the buffer to hold statistics.
0660 //! @param  blen   - Length of the buffer.
0661 //!
0662 //! @return The number of bytes placed in the buffer excluding null byte.
0663 //-----------------------------------------------------------------------------
0664 
0665 virtual int       Stats(char *buff, int blen)
0666                        {return wrapPI.Stats(buff, blen);}
0667 
0668 //-----------------------------------------------------------------------------
0669 //! Return filesystem physical space information associated with a path.
0670 //!
0671 //! @param  path   - Path in the partition in question.
0672 //! @param  buff   - Pointer to the buffer to hold the information.
0673 //! @param  blen   - Length of the buffer. This is updated with the actual
0674 //!                  number of bytes placed in the buffer as in snprintf().
0675 //! @param  envP   - Pointer to environmental information.
0676 //!
0677 //! @return "<wval> <fsp> <utl> <sval> <fsp> <utl>"
0678 //!         where: <wval> is "0" if XRDEXP_NOTRW specified, otherwise "1"
0679 //!                <fsp>  is free space in megabytes.
0680 //!                <utl>  is percentage utilization (i.e. allocated space)
0681 //!                <sval> is "1' if XRDEXP_STAGE specified, otherwise "0"
0682 //!         Upon failure -errno or -osserr (see XrdOssError.hh) returned.
0683 //-----------------------------------------------------------------------------
0684 
0685 virtual int       StatFS(const char *path, char *buff, int &blen,
0686                          XrdOucEnv  *envP=0)
0687                         {return wrapPI.StatFS(path, buff, blen, envP);}
0688 
0689 //-----------------------------------------------------------------------------
0690 //! Return filesystem physical space information associated with a space name.
0691 //!
0692 //! @param  env    - Ref to environmental information. If the environment
0693 //!                  has the key oss.cgroup defined, the associated value is
0694 //!                  used as the space name and the path is ignored.
0695 //! @param  path   - Path in the name space in question. The space name
0696 //!                  associated with gthe path is used unless overridden.
0697 //! @param  buff   - Pointer to the buffer to hold the information.
0698 //! @param  blen   - Length of the buffer. This is updated with the actual
0699 //!                  number of bytes placed in the buffer as in snprintf().
0700 //!
0701 //! @return "oss.cgroup=<name>&oss.space=<totbytes>&oss.free=<freebytes>
0702 //!          &oss.maxf=<maxcontigbytes>&oss.used=<bytesused>
0703 //!          &oss.quota=<quotabytes>" in buff upon success.
0704 //!         Upon failure -errno or -osserr (see XrdOssError.hh) returned.
0705 //-----------------------------------------------------------------------------
0706 
0707 virtual int       StatLS(XrdOucEnv &env, const char *path,
0708                          char *buff, int &blen)
0709                         {return wrapPI.StatLS(env, path, buff, blen);}
0710 
0711 //-----------------------------------------------------------------------------
0712 //! Return state information on a resident physical file or directory.
0713 //!
0714 //! @param  path   - Pointer to the path in question.
0715 //! @param  buff   - Pointer to the structure where info it to be returned.
0716 //! @param  opts   - Options:
0717 //!                  PF_dInfo - provide bdevID in st_rdev and partID in st_dev
0718 //!                             based on path. If path is nil then the contents
0719 //!                             of the of buff is used as the input source.
0720 //!                  PF_dNums - provide number of bdev's in st_rdev and the
0721 //!                             number of partitions in st_dev. The path
0722 //!                             argument is ignored. This superceeds PF_dInfo.
0723 //!                  PF_dStat - provide file state flags in st_rdev as shown
0724 //!                             below. Path may not be nil. This supercedes
0725 //!                             PF_dInfo and PF_dNums.
0726 //!                  PF_isLFN - Do N2N translation on path (default is none).
0727 //!
0728 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0729 //-----------------------------------------------------------------------------
0730 
0731 virtual int       StatPF(const char *path, struct stat *buff, int opts)
0732                         {return wrapPI.StatPF(path, buff, opts);}
0733 
0734 virtual int       StatPF(const char *path, struct stat *buff)
0735                         {return wrapPI.StatPF(path, buff);}
0736 
0737 //-----------------------------------------------------------------------------
0738 //! Return space information for a space name.
0739 //!
0740 //! @param  vsP    - Pointer to the XrdOssVSInfo object to hold results.
0741 //!                  It should be fully initialized (i.e. a new copy).
0742 //! @param  sname  - Pointer to the space name. If the name starts with a
0743 //!                  plus (e.g. "+public"), partition information is
0744 //!                  returned, should it exist. If nil, space information for
0745 //!                  all spaces is returned. See, XrdOssVS.hh for more info.
0746 //! @param  updt   - When true, a space update occurrs prior to a query.
0747 //!
0748 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0749 //-----------------------------------------------------------------------------
0750 
0751 virtual int       StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
0752                         {return wrapPI.StatVS(vsP, sname, updt);}
0753 
0754 //-----------------------------------------------------------------------------
0755 //! Return logical extended attributes associated with a path.
0756 //!
0757 //! @param  path   - Path in whose information is wanted.
0758 //! @param  buff   - Pointer to the buffer to hold the information.
0759 //! @param  blen   - Length of the buffer. This is updated with the actual
0760 //!                  number of bytes placed in the buffer as in snprintf().
0761 //! @param  envP   - Pointer to environmental information.
0762 //!
0763 //! @return "oss.cgroup=<name>&oss.type={'f'|'d'|'o'}&oss.used=<totbytes>
0764 //!          &oss.mt=<mtime>&oss.ct=<ctime>&oss.at=<atime>&oss.u=*&oss.g=*
0765 //!          &oss.fs={'w'|'r'}"
0766 //!         Upon failure -errno or -osserr (see XrdOssError.hh) returned.
0767 //-----------------------------------------------------------------------------
0768 
0769 virtual int       StatXA(const char *path, char *buff, int &blen,
0770                          XrdOucEnv *envP=0)
0771                         {return wrapPI.StatXA(path, buff, blen, envP);}
0772 
0773 //-----------------------------------------------------------------------------
0774 //! Return export attributes associated with a path.
0775 //!
0776 //! @param  path   - Path in whose information is wanted.
0777 //! @param  attr   - Reference to where the inforamation is to be stored.
0778 //! @param  envP   - Pointer to environmental information.
0779 //!
0780 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0781 //-----------------------------------------------------------------------------
0782 
0783 virtual int       StatXP(const char *path, unsigned long long &attr,
0784                          XrdOucEnv  *envP=0)
0785                         {return wrapPI.StatXP(path, attr, envP);}
0786 
0787 //-----------------------------------------------------------------------------
0788 //! Truncate a file.
0789 //!
0790 //! @param  path   - Pointer to the path of the file to be truncated.
0791 //! @param  fsize  - The size that the file is to have.
0792 //! @param  envP   - Pointer to environmental information.
0793 //!
0794 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0795 //-----------------------------------------------------------------------------
0796 
0797 virtual int       Truncate(const char *path, unsigned long long fsize,
0798                            XrdOucEnv *envP=0)
0799                           {return wrapPI.Truncate(path, fsize, envP);}
0800 
0801 //-----------------------------------------------------------------------------
0802 //! Remove a file.
0803 //!
0804 //! @param  path   - Pointer to the path of the file to be removed.
0805 //! @param  Opts   - Options:
0806 //!                  XRDOSS_isMIG  - this is a migratable path.
0807 //!                  XRDOSS_isPFN  - do not apply name2name to path.
0808 //!                  XRDOSS_Online - remove only the online copy.
0809 //! @param  envP   - Pointer to environmental information.
0810 //!
0811 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0812 //-----------------------------------------------------------------------------
0813 
0814 virtual int       Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)
0815                         {return wrapPI.Unlink(path, Opts, envP);}
0816 
0817                   // Default Name-to-Name Methods
0818 
0819 //-----------------------------------------------------------------------------
0820 //! Translate logical name to physical name V1 (deprecated).
0821 //!
0822 //! @param  Path   - Path in whose information is wanted.
0823 //! @param  buff   - Pointer to the buffer to hold the new path.
0824 //! @param  blen   - Length of the buffer.
0825 //!
0826 //! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
0827 //-----------------------------------------------------------------------------
0828 
0829 virtual int       Lfn2Pfn(const char *Path, char *buff, int blen)
0830                          {return wrapPI.Lfn2Pfn(Path, buff, blen);}
0831 
0832 //-----------------------------------------------------------------------------
0833 //! Translate logical name to physical name V2.
0834 //!
0835 //! @param  Path   - Path in whose information is wanted.
0836 //! @param  buff   - Pointer to the buffer to hold the new path.
0837 //! @param  blen   - Length of the buffer.
0838 //! @param  rc     - Place where failure return code is to be returned:
0839 //!                  -errno or -osserr (see XrdOssError.hh).
0840 //!
0841 //! @return Pointer to the translated path upon success or nil on failure.
0842 //-----------------------------------------------------------------------------
0843 virtual
0844 const char       *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
0845                          {return wrapPI.Lfn2Pfn(Path, buff, blen, rc);}
0846 
0847 //-----------------------------------------------------------------------------
0848 //! Constructor and Destructor.
0849 //!
0850 //! @param  ossRef - Reference to the Oss object being wrapped.
0851 //!
0852 //! @note: The object creator is responsible for deleting the ossRef object.
0853 //!        The ref to this object is stored here and is accessible.
0854 //-----------------------------------------------------------------------------
0855 
0856                 XrdOssWrapper(XrdOss &ossRef) : wrapPI(ossRef) {}
0857 virtual        ~XrdOssWrapper() {}
0858 
0859 protected:
0860 
0861 XrdOss &wrapPI;
0862 };
0863 #endif