Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef __SFS_DIO_H__
0002 #define __SFS_DIO_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                          X r d S f s D i o . h h                           */
0006 /*                                                                            */
0007 /* (c) 2013 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 <sys/types.h>
0033 #include <unistd.h>
0034 
0035 #include "XrdOuc/XrdOucSFVec.hh"
0036 
0037 
0038 //-----------------------------------------------------------------------------
0039 //! XrdSfsDio.hh
0040 //!
0041 //! This class is used to define specialized I/O interfaces that can be
0042 //! provided to the underlying filesystem. This object is normally passed via
0043 //! the read() call should fctl() indicate this interface is to be used.
0044 //-----------------------------------------------------------------------------
0045 
0046 class XrdSfsDio
0047 {
0048 public:
0049 
0050 //-----------------------------------------------------------------------------
0051 //! Send data to a client using the sendfile() system interface.
0052 //!
0053 //! @param  fildes - The file descriptor to use to effect a sendfile() for
0054 //!                  all of the requested data. The original offset and
0055 //!                  length are used relative to this file descriptor.
0056 //!
0057 //! @return >0     - data has been sent in a previous call. This is indicative
0058 //!                  of a logic error in SendData() as only one call is allowed.
0059 //! @return =0     - data has been sent.
0060 //! @return <0     - A fatal transmission error occurred. SendData() should
0061 //!                  return SFS_ERROR to force the connection to be closed.
0062 //-----------------------------------------------------------------------------
0063 
0064 virtual int SendFile(int fildes) = 0;
0065 
0066 //-----------------------------------------------------------------------------
0067 //! Send data to a client using the sendfile() system interface.
0068 //!
0069 //! @param  sfvec  - One or more XrdOucSFVec elements describing what should be
0070 //!                  transferred. The first element of the vector *must* be
0071 //!                  available for use by the interface for proper framing.
0072 //!                  That is, start filling in elements at sfvec[1] and sfvnum
0073 //!                  should be the count of elements filled in plus 1.
0074 //! @param  sfvnum - total number of elements in sfvec and includes the first
0075 //!                  unused element. There is a maximum number of elements
0076 //!                  that the vector may have; defined inside XrdOucSFVec.
0077 //!
0078 //! @return >0     - either data has been sent in a previous call or the total
0079 //!                  amount of data in sfvec is greater than the original
0080 //!                  request. This is indicative of a SendData() logic error.
0081 //! @return =0     - data has been sent.
0082 //! @return <0     - A fatal transmission error occurred. SendData() should
0083 //!                  return SFS_ERROR to force the connection to be closed.
0084 //-----------------------------------------------------------------------------
0085 
0086 virtual int  SendFile(XrdOucSFVec *sfvec, int sfvnum) = 0;
0087 
0088 //-----------------------------------------------------------------------------
0089 //! Change the file descriptor setting and, consequently, interface processing.
0090 //!
0091 //! @param  fildes - The file descriptor to use in the future, as follows:
0092 //!                  <  0 - Disable sendfile and always use read().
0093 //!                  >= 0 - Enable  sendfile and always use sendfile() w/o
0094 //!                         invoking this interface (i.e. fast path).
0095 //-----------------------------------------------------------------------------
0096 
0097 virtual void SetFD(int fildes) = 0;
0098 
0099 //-----------------------------------------------------------------------------
0100 //! Constructor and destructor
0101 //-----------------------------------------------------------------------------
0102 
0103              XrdSfsDio() {}
0104 virtual     ~XrdSfsDio() {}
0105 };
0106 #endif