XrdBwm.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                             X r d B w m . c c                              */
00004 /*                                                                            */
00005 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*               DE-AC03-76-SFO0515 with the Deprtment of Energy              */
00009 /******************************************************************************/
00010 
00011 //         $Id: XrdBwm.cc 35287 2010-09-14 21:19:35Z ganis $
00012 
00013 const char *XrdBwmCVSID = "$Id: XrdBwm.cc 35287 2010-09-14 21:19:35Z ganis $";
00014 
00015 #include <unistd.h>
00016 #include <errno.h>
00017 #include <string.h>
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #include <sys/param.h>
00021 #include <sys/stat.h>
00022 #include <sys/types.h>
00023 
00024 #include "XrdVersion.hh"
00025 
00026 #include "XrdBwm/XrdBwm.hh"
00027 #include "XrdBwm/XrdBwmTrace.hh"
00028 
00029 #include "XrdAcc/XrdAccAuthorize.hh"
00030 
00031 #include "XrdNet/XrdNetDNS.hh"
00032 
00033 #include "XrdOuc/XrdOucEnv.hh"
00034 #include "XrdOuc/XrdOucTrace.hh"
00035 
00036 #include "XrdSec/XrdSecEntity.hh"
00037 
00038 #include "XrdSfs/XrdSfsAio.hh"
00039 #include "XrdSfs/XrdSfsInterface.hh"
00040 
00041 #include "XrdSys/XrdSysError.hh"
00042 #include "XrdSys/XrdSysHeaders.hh"
00043 #include "XrdSys/XrdSysLogger.hh"
00044 #include "XrdSys/XrdSysPlatform.hh"
00045 #include "XrdSys/XrdSysPthread.hh"
00046 
00047 /******************************************************************************/
00048 /*                  E r r o r   R o u t i n g   O b j e c t                   */
00049 /******************************************************************************/
00050 
00051 XrdSysError      BwmEroute(0);
00052 
00053 XrdOucTrace      BwmTrace(&BwmEroute);
00054 
00055 /******************************************************************************/
00056 /*                        S t a t i c   O b j e c t s                         */
00057 /******************************************************************************/
00058   
00059 XrdBwmHandle     *XrdBwm::dummyHandle;
00060 
00061 /******************************************************************************/
00062 /*                    F i l e   S y s t e m   O b j e c t                     */
00063 /******************************************************************************/
00064   
00065 XrdBwm XrdBwmFS;
00066 
00067 /******************************************************************************/
00068 /*                    X r d B w m   C o n s t r u c t o r                     */
00069 /******************************************************************************/
00070 
00071 XrdBwm::XrdBwm()
00072 {
00073    unsigned int myIPaddr = 0;
00074    char buff[256], *bp;
00075    int myPort, i;
00076 
00077 // Establish defaults
00078 //
00079    Authorization = 0;
00080    Authorize     = 0;
00081    AuthLib       = 0;
00082    AuthParm      = 0;
00083    Logger        = 0;
00084    PolLib        = 0;
00085    PolParm       = 0;
00086    PolSlotsIn    = 1;
00087    PolSlotsOut   = 1;
00088 
00089 // Obtain port number we will be using
00090 //
00091    myPort = (bp = getenv("XRDPORT")) ? strtol(bp, (char **)NULL, 10) : 0;
00092 
00093 // Establish our hostname and IPV4 address
00094 //
00095    HostName      = XrdNetDNS::getHostName();
00096    if (!XrdNetDNS::Host2IP(HostName, &myIPaddr)) myIPaddr = 0x7f000001;
00097    strcpy(buff, "[::"); bp = buff+3;
00098    bp += XrdNetDNS::IP2String(myIPaddr, 0, bp, 128);
00099    *bp++ = ']'; *bp++ = ':';
00100    sprintf(bp, "%d", myPort);
00101    locResp = strdup(buff); locRlen = strlen(buff);
00102    for (i = 0; HostName[i] && HostName[i] != '.'; i++);
00103    HostName[i] = '\0';
00104    HostPref = strdup(HostName);
00105    HostName[i] = '.';
00106    myDomain = &HostName[i+1];
00107    myDomLen = strlen(myDomain);
00108 
00109 // Set the configuration file name abd dummy handle
00110 //
00111    ConfigFN = 0;
00112    dummyHandle = XrdBwmHandle::Alloc("*", "/", "?", "?", 0);
00113 }
00114   
00115 /******************************************************************************/
00116 /*                X r d B w m F i l e   C o n s t r u c t o r                 */
00117 /******************************************************************************/
00118 
00119 XrdBwmFile::XrdBwmFile(const char *user) : XrdSfsFile(user)
00120 {
00121    oh = XrdBwm::dummyHandle;
00122    tident = (user ? user : "");
00123 }
00124   
00125 /******************************************************************************/
00126 /*                         G e t F i l e S y s t e m                          */
00127 /******************************************************************************/
00128   
00129 extern "C"
00130 {
00131 XrdSfsFileSystem *XrdSfsGetFileSystem(XrdSfsFileSystem *native_fs, 
00132                                       XrdSysLogger     *lp,
00133                                       const char       *configfn)
00134 {
00135 // Do the herald thing
00136 //
00137    BwmEroute.SetPrefix("bwm_");
00138    BwmEroute.logger(lp);
00139    BwmEroute.Say("Copr.  2008 Stanford University, Bwm Version " XrdVSTRING);
00140 
00141 // Initialize the subsystems
00142 //
00143    XrdBwmFS.ConfigFN = (configfn && *configfn ? strdup(configfn) : 0);
00144    if ( XrdBwmFS.Configure(BwmEroute) ) return 0;
00145 
00146 // All done, we can return the callout vector to these routines.
00147 //
00148    return &XrdBwmFS;
00149 }
00150 }
00151 
00152 /******************************************************************************/
00153 /*                                                                            */
00154 /*           D i r e c t o r y   O b j e c t   I n t e r f a c e s            */
00155 /*                                                                            */
00156 /******************************************************************************/
00157 /******************************************************************************/
00158 /*                                  o p e n                                   */
00159 /******************************************************************************/
00160 
00161 int XrdBwmDirectory::open(const char              *dir_path, // In
00162                           const XrdSecEntity      *client,   // In
00163                           const char              *info)      // In
00164 /*
00165   Function: Open the directory `path' and prepare for reading.
00166 
00167   Input:    path      - The fully qualified name of the directory to open.
00168             client    - Authentication credentials, if any.
00169             info      - Opaque information to be used as seen fit.
00170 
00171   Output:   Returns SFS_OK upon success, otherwise SFS_ERROR.
00172 
00173   Notes: 1. Currently, function not supported.
00174 */
00175 {
00176 // Return an error
00177 //
00178    return XrdBwmFS.Emsg("opendir", error, ENOTDIR, "open directory", dir_path);
00179 }
00180 
00181 /******************************************************************************/
00182 /*                             n e x t E n t r y                              */
00183 /******************************************************************************/
00184 
00185 const char *XrdBwmDirectory::nextEntry()
00186 /*
00187   Function: Read the next directory entry.
00188 
00189   Input:    n/a
00190 
00191   Output:   n/a
00192 */
00193 {
00194 // Return an error
00195 //
00196    XrdBwmFS.Emsg("readdir", error, EBADF, "read directory");
00197    return 0;
00198 }
00199 
00200 /******************************************************************************/
00201 /*                                 c l o s e                                  */
00202 /******************************************************************************/
00203   
00204 int XrdBwmDirectory::close()
00205 /*
00206   Function: Close the directory object.
00207 
00208   Input:    n/a
00209 
00210   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00211 */
00212 {
00213 // Return an error
00214 //
00215    XrdBwmFS.Emsg("closedir", error, EBADF, "close directory");
00216    return SFS_ERROR;
00217 }
00218 
00219 /******************************************************************************/
00220 /*                                                                            */
00221 /*                F i l e   O b j e c t   I n t e r f a c e s                 */
00222 /*                                                                            */
00223 /******************************************************************************/
00224 /******************************************************************************/
00225 /*                                  o p e n                                   */
00226 /******************************************************************************/
00227 
00228 int XrdBwmFile::open(const char          *path,      // In
00229                      XrdSfsFileOpenMode   open_mode, // In
00230                      mode_t               Mode,      // In
00231                const XrdSecEntity        *client,    // In
00232                const char                *info)      // In
00233 /*
00234   Function: Open the file `path' in the mode indicated by `open_mode'.  
00235 
00236   Input:    path      - The fully qualified name of the file to open.
00237                         The path must start with "/_bwm_" and the lfn that
00238                         will eventually be opened start at the next slash.
00239             open_mode - One of the following flag values:
00240                         SFS_O_RDONLY - Open file for reading.
00241                         SFS_O_WRONLY - Open file for writing.           n/a
00242                         SFS_O_RDWR   - Open file for update             n/a
00243                         SFS_O_CREAT  - Create the file open in RW mode  n/a
00244                         SFS_O_TRUNC  - Trunc  the file open in RW mode  n/a
00245             Mode      - The Posix access mode bits to be assigned to the file.
00246                         These bits are ignored.
00247             client    - Authentication credentials, if any.
00248             info      - Opaque information:
00249                         bwm.src=<src  host>
00250                         bwm.dst=<dest host>
00251 
00252   Output:   Returns SFS_OK upon success, otherwise SFS_ERROR is returned.
00253 */
00254 {
00255    EPNAME("open");
00256    XrdBwmHandle *hP;
00257    int incomming;
00258    const char *miss, *theUsr, *theSrc, *theDst=0, *theLfn=0, *lclNode, *rmtNode;
00259    XrdOucEnv Open_Env(info);
00260 
00261 // Trace entry
00262 //
00263    ZTRACE(calls,std::hex <<open_mode <<std::dec <<" fn=" <<path);
00264 
00265 // Verify that this object is not already associated with an open file
00266 //
00267    XrdBwmFS.ocMutex.Lock();
00268    if (oh != XrdBwm::dummyHandle)
00269       {XrdBwmFS.ocMutex.UnLock();
00270        return XrdBwmFS.Emsg("open",error,EADDRINUSE,"open file",path);
00271       }
00272    XrdBwmFS.ocMutex.UnLock();
00273 
00274 // Verify that the file is being opened in r/w mode only!
00275 //
00276    if (!(open_mode & SFS_O_RDWR))
00277       return XrdBwmFS.Emsg("open", error, EINVAL, "open", path);
00278 
00279 // Apply security. Note that we reject r/w access but apply r/o access
00280 // restrictions if so wanted.
00281 //
00282    if (client && XrdBwmFS.Authorization
00283    &&  !XrdBwmFS.Authorization->Access(client, path, AOP_Update, &Open_Env))
00284       return XrdBwmFS.Emsg("open", error, EACCES, "open", path);
00285 
00286 // Make sure that all of the relevant information is present
00287 //
00288         if (!(theSrc = Open_Env.Get("bwm.src"))) miss = "bwm.src";
00289    else if (!(theDst = Open_Env.Get("bwm.dst"))) miss = "bwm.dst";
00290    else if (!(theLfn = index(path+1,'/'))
00291         ||  !(*(theLfn+1)))                     miss = "lfn";
00292    else                                         miss = 0;
00293 
00294    if (miss) return XrdBwmFS.Emsg("open", error, miss, "open", path);
00295    theUsr = error.getErrUser();
00296 
00297 // Determine the direction of flow
00298 //
00299         if (XrdNetDNS::isDomain(theSrc, XrdBwmFS.myDomain, XrdBwmFS.myDomLen))
00300            {incomming = 0; lclNode = theSrc; rmtNode = theDst;}
00301    else if (XrdNetDNS::isDomain(theDst, XrdBwmFS.myDomain, XrdBwmFS.myDomLen))
00302            {incomming = 1; lclNode = theDst; rmtNode = theSrc;}
00303    else return XrdBwmFS.Emsg("open", error, EREMOTE, "open", path);
00304 
00305 // Get a handle for this file.
00306 //
00307    if (!(hP = XrdBwmHandle::Alloc(theUsr,theLfn,lclNode,rmtNode,incomming)))
00308       return XrdBwmFS.Stall(error, 13, path);
00309 
00310 // All done
00311 //
00312    XrdBwmFS.ocMutex.Lock(); oh = hP; XrdBwmFS.ocMutex.UnLock();
00313    return SFS_OK;
00314 }
00315 
00316 /******************************************************************************/
00317 /*                                 c l o s e                                  */
00318 /******************************************************************************/
00319 
00320 int XrdBwmFile::close()  // In
00321 /*
00322   Function: Close the file object.
00323 
00324   Input:    n/a
00325 
00326   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00327 */
00328 {
00329    EPNAME("close");
00330    XrdBwmHandle *hP;
00331 
00332 // Trace the call
00333 //
00334    FTRACE(calls, "close" <<oh->Name());
00335 
00336 // Verify the handle (we briefly maintain a global lock)
00337 //
00338    XrdBwmFS.ocMutex.Lock();
00339    if (oh == XrdBwm::dummyHandle)
00340       {XrdBwmFS.ocMutex.UnLock(); return SFS_OK;}
00341    hP = oh; oh = XrdBwm::dummyHandle;
00342    XrdBwmFS.ocMutex.UnLock();
00343 
00344 // Now retire it and possibly return the token
00345 //
00346    hP->Retire();
00347 
00348 // All done
00349 //
00350    return SFS_OK;
00351 }
00352 
00353 /******************************************************************************/
00354 /*                                  f c t l                                   */
00355 /******************************************************************************/
00356   
00357 int            XrdBwmFile::fctl(const int               cmd,
00358                                 const char             *args,
00359                                       XrdOucErrInfo    &out_error)
00360 /*
00361   Function: perform request control operation.
00362 
00363   Input:    cmd       - The operation:
00364                         SFS_FCTL_GETFD - not supported.
00365                         SFS_FCTL_STATV - returns visa information
00366             args      - Dependent on the cmd.
00367             out_error - Place where response goes.
00368 
00369   Output:   Returns SFS_OK upon success and SFS_ERROR o/w.
00370 */
00371 {
00372 
00373 // Make sure the file is open
00374 //
00375    if (oh == XrdBwm::dummyHandle)
00376       return XrdBwmFS.Emsg("fctl", out_error, EBADF, "fctl file");
00377 
00378 // Scan through the fctl operations
00379 //
00380    switch(cmd)
00381          {case SFS_FCTL_GETFD:  out_error.setErrInfo(-1,"");
00382                                 return SFS_OK;
00383           case SFS_FCTL_STATV:  return oh->Activate(out_error);
00384           default:              break;
00385          }
00386 
00387 // Invalid fctl
00388 //
00389    out_error.setErrInfo(EINVAL, "invalid fctl command");
00390    return SFS_ERROR;
00391 }
00392 
00393 /******************************************************************************/
00394 /*                                  r e a d                                   */
00395 /******************************************************************************/
00396 
00397 int            XrdBwmFile::read(XrdSfsFileOffset  offset,    // In
00398                                 XrdSfsXferSize    blen)      // In
00399 /*
00400   Function: Preread `blen' bytes at `offset'
00401 
00402   Input:    offset    - The absolute byte offset at which to start the read.
00403             blen      - The amount to preread.
00404 
00405   Output:   Returns SFS_OK upon success and SFS_ERROR o/w.
00406 */
00407 {
00408    EPNAME("read");
00409 
00410 // Perform required tracing
00411 //
00412    FTRACE(calls,"preread " <<blen <<"@" <<offset);
00413 
00414 // Return number of bytes read
00415 //
00416    return 0;
00417 }
00418   
00419 /******************************************************************************/
00420 /*                                  r e a d                                   */
00421 /******************************************************************************/
00422 
00423 XrdSfsXferSize XrdBwmFile::read(XrdSfsFileOffset  offset,    // In
00424                                 char             *buff,      // Out
00425                                 XrdSfsXferSize    blen)      // In
00426 /*
00427   Function: Read `blen' bytes at `offset' into 'buff' and return the actual
00428             number of bytes read.
00429 
00430   Input:    offset    - The absolute byte offset at which to start the read.
00431             buff      - Address of the buffer in which to place the data.
00432             blen      - The size of the buffer. This is the maximum number
00433                         of bytes that will be read from 'fd'.
00434 
00435   Output:   Returns the number of bytes read upon success and SFS_ERROR o/w.
00436 
00437   Notes: 1. Currently, we have no information so we always return 0 bytes.
00438 */
00439 {
00440    EPNAME("read");
00441 
00442 // Perform required tracing
00443 //
00444    FTRACE(calls,blen <<"@" <<offset);
00445 
00446 // Return number of bytes read
00447 //
00448    return 0;
00449 }
00450   
00451 /******************************************************************************/
00452 /*                              r e a d   A I O                               */
00453 /******************************************************************************/
00454   
00455 /*
00456   Function: Read `blen' bytes at `offset' into 'buff' and return the actual
00457             number of bytes read using asynchronous I/O, if possible.
00458 
00459   Output:   Returns the 0 if successfullt queued, otherwise returns an error.
00460             The underlying implementation will convert the request to
00461             synchronous I/O is async mode is not possible.
00462 */
00463 
00464 int XrdBwmFile::read(XrdSfsAio *aiop)
00465 {
00466 
00467 // Async mode not supported.
00468 //
00469    aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
00470                                        (char *)aiop->sfsAio.aio_buf,
00471                                (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
00472    aiop->doneRead();
00473    return 0;
00474 }
00475 
00476 /******************************************************************************/
00477 /*                                 w r i t e                                  */
00478 /******************************************************************************/
00479 
00480 XrdSfsXferSize XrdBwmFile::write(XrdSfsFileOffset  offset,    // In
00481                                  const char       *buff,      // Out
00482                                  XrdSfsXferSize    blen)      // In
00483 /*
00484   Function: Write `blen' bytes at `offset' from 'buff' and return the actual
00485             number of bytes written.
00486 
00487   Input:    offset    - The absolute byte offset at which to start the write.
00488             buff      - Address of the buffer from which to get the data.
00489             blen      - The size of the buffer. This is the maximum number
00490                         of bytes that will be written to 'fd'.
00491 
00492   Output:   Returns the number of bytes written upon success and SFS_ERROR o/w.
00493 
00494   Notes: 1. An error return may be delayed until the next write(), close(), or
00495             sync() call.
00496          2. Currently, we do not accept write activated commands.
00497 */
00498 {
00499    EPNAME("write");
00500 
00501 // Perform any required tracing
00502 //
00503    FTRACE(calls, blen <<"@" <<offset);
00504 
00505 // Return number of bytes written
00506 //
00507    return 0;
00508 }
00509 
00510 /******************************************************************************/
00511 /*                             w r i t e   A I O                              */
00512 /******************************************************************************/
00513   
00514 // For now, this reverts to synchronous I/O
00515 //
00516 int XrdBwmFile::write(XrdSfsAio *aiop)
00517 {
00518 
00519 // Async mode not supported.
00520 //
00521    aiop->Result = this->write((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
00522                                         (char *)aiop->sfsAio.aio_buf,
00523                                 (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
00524    aiop->doneWrite();
00525    return 0;
00526 }
00527 
00528 /******************************************************************************/
00529 /*                               g e t M m a p                                */
00530 /******************************************************************************/
00531 
00532 int XrdBwmFile::getMmap(void **Addr, off_t &Size)         // Out
00533 /*
00534   Function: Return memory mapping for file, if any.
00535 
00536   Output:   Addr        - Address of memory location
00537             Size        - Size of the file or zero if not memory mapped.
00538             Returns SFS_OK upon success and SFS_ERROR upon failure.
00539 */
00540 {
00541 
00542 // Mapping is not supported
00543 //
00544    *Addr= 0;
00545    Size = 0;
00546 
00547    return SFS_OK;
00548 }
00549   
00550 /******************************************************************************/
00551 /*                                  s t a t                                   */
00552 /******************************************************************************/
00553 
00554 int XrdBwmFile::stat(struct stat     *buf)         // Out
00555 /*
00556   Function: Return file status information
00557 
00558   Input:    buf         - The stat structiure to hold the results
00559 
00560   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00561 */
00562 {
00563    EPNAME("fstat");
00564    static unsigned int myInode = 0;
00565    union {long long   Fill;
00566           int         Xor[2];
00567           XrdBwmFile *fP;
00568           dev_t       Num;
00569          } theDev;
00570 
00571 // Perform any required tracing
00572 //
00573    FTRACE(calls, FName());
00574 
00575 // Develop the device number
00576 //
00577    theDev.Fill = 0; theDev.fP = this; theDev.Xor[0] ^= theDev.Xor[1];
00578 
00579 // Fill out the stat structure for this pseudo file
00580 //
00581    memset(buf, 0, sizeof(struct stat));
00582    buf->st_ino = myInode++;
00583    buf->st_dev = theDev.Num;
00584    buf->st_blksize = 4096;
00585    buf->st_mode = S_IFBLK;
00586    return SFS_OK;
00587 }
00588 
00589 /******************************************************************************/
00590 /*                                  s y n c                                   */
00591 /******************************************************************************/
00592 
00593 int XrdBwmFile::sync()  // In
00594 /*
00595   Function: Commit all unwritten bytes to physical media.
00596 
00597   Input:    n/a
00598 
00599   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00600 */
00601 {
00602    EPNAME("sync");
00603 
00604 // Perform any required tracing
00605 //
00606    FTRACE(calls,"");
00607 
00608 // We always succeed
00609 //
00610    return SFS_OK;
00611 }
00612 
00613 /******************************************************************************/
00614 /*                              s y n c   A I O                               */
00615 /******************************************************************************/
00616   
00617 // For now, reverts to synchronous case
00618 //
00619 int XrdBwmFile::sync(XrdSfsAio *aiop)
00620 {
00621    aiop->Result = this->sync();
00622    aiop->doneWrite();
00623    return 0;
00624 }
00625 
00626 /******************************************************************************/
00627 /*                              t r u n c a t e                               */
00628 /******************************************************************************/
00629 
00630 int XrdBwmFile::truncate(XrdSfsFileOffset  flen)  // In
00631 /*
00632   Function: Set the length of the file object to 'flen' bytes.
00633 
00634   Input:    flen      - The new size of the file.
00635 
00636   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00637 
00638   Notes: 1. Truncate is not supported.
00639 */
00640 {
00641    EPNAME("trunc");
00642 
00643 // Lock the file handle and perform any tracing
00644 //
00645    FTRACE(calls, "len=" <<flen);
00646 
00647 // Return an error
00648 //
00649    return  XrdBwmFS.Emsg("trunc", error, ENOTSUP, "truncate", oh->Name());
00650 }
00651 
00652 /******************************************************************************/
00653 /*                             g e t C X i n f o                              */
00654 /******************************************************************************/
00655   
00656 int XrdBwmFile::getCXinfo(char cxtype[4], int &cxrsz)
00657 /*
00658   Function: Set the length of the file object to 'flen' bytes.
00659 
00660   Input:    n/a
00661 
00662   Output:   cxtype - Compression algorithm code
00663             cxrsz  - Compression region size
00664 
00665             Returns SFS_OK upon success and SFS_ERROR upon failure.
00666 */
00667 {
00668 
00669 // Indicate not compressed
00670 //
00671    cxrsz = 0;
00672    cxtype[0] = cxtype[1] = cxtype[2] = cxtype[3] = 0;
00673    return SFS_OK;
00674 }
00675 
00676 /******************************************************************************/
00677 /*                                                                            */
00678 /*         F i l e   S y s t e m   O b j e c t   I n t e r f a c e s          */
00679 /*                                                                            */
00680 /******************************************************************************/
00681 /******************************************************************************/
00682 /*                                 c h m o d                                  */
00683 /******************************************************************************/
00684 
00685 int XrdBwm::chmod(const char             *path,    // In
00686                         XrdSfsMode        Mode,    // In
00687                         XrdOucErrInfo    &einfo,   // Out
00688                   const XrdSecEntity     *client,  // In
00689                   const char             *info)    // In
00690 /*
00691   Function: Change the mode on a file or directory.
00692 
00693   Input:    path      - Is the fully qualified name of the file to be removed.
00694             einfo     - Error information object to hold error details.
00695             client    - Authentication credentials, if any.
00696             info      - Opaque information to be used as seen fit.
00697 
00698   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00699 */
00700 {
00701 // Return an error
00702 //
00703    return XrdBwmFS.Emsg("chmod", einfo, ENOTSUP, "change", path);
00704 }
00705 
00706 /******************************************************************************/
00707 /*                                e x i s t s                                 */
00708 /******************************************************************************/
00709 
00710 int XrdBwm::exists(const char                *path,        // In
00711                          XrdSfsFileExistence &file_exists, // Out
00712                          XrdOucErrInfo       &einfo,       // Out
00713                    const XrdSecEntity        *client,      // In
00714                    const char                *info)        // In
00715 /*
00716   Function: Determine if file 'path' actually exists.
00717 
00718   Input:    path        - Is the fully qualified name of the file to be tested.
00719             file_exists - Is the address of the variable to hold the status of
00720                           'path' when success is returned. The values may be:
00721                           XrdSfsFileExistsIsDirectory - file not found but path is valid.
00722                           XrdSfsFileExistsIsFile      - file found.
00723                           XrdSfsFileExistsIsNo        - neither file nor directory.
00724             einfo       - Error information object holding the details.
00725             client      - Authentication credentials, if any.
00726             info        - Opaque information to be used as seen fit.
00727 
00728   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00729 
00730   Notes:    When failure occurs, 'file_exists' is not modified.
00731 */
00732 {
00733 
00734    file_exists=XrdSfsFileExistNo;
00735    return SFS_OK;
00736 }
00737 
00738 /******************************************************************************/
00739 /*                                 f s c t l                                  */
00740 /******************************************************************************/
00741 
00742 int XrdBwm::fsctl(const int               cmd,
00743                   const char             *args,
00744                   XrdOucErrInfo          &einfo,
00745                   const XrdSecEntity     *client)
00746 /*
00747   Function: Perform filesystem operations:
00748 
00749   Input:    cmd       - Operation command (currently supported):
00750                         None.
00751             arg       - Command dependent argument:
00752                       - STATXV: The file handle
00753             einfo     - Error/Response information structure.
00754             client    - Authentication credentials, if any.
00755 
00756   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00757 */
00758 {
00759 // Operation is not supported
00760 //
00761    return XrdBwmFS.Emsg("fsctl", einfo, ENOTSUP, "fsctl", args);
00762 }
00763 
00764 /******************************************************************************/
00765 /*                            g e t V e r s i o n                             */
00766 /******************************************************************************/
00767   
00768 const char *XrdBwm::getVersion() {return XrdVSTRING;}
00769 
00770 /******************************************************************************/
00771 /*                                 m k d i r                                  */
00772 /******************************************************************************/
00773 
00774 int XrdBwm::mkdir(const char             *path,    // In
00775                         XrdSfsMode        Mode,    // In
00776                         XrdOucErrInfo    &einfo,   // Out
00777                   const XrdSecEntity     *client,  // In
00778                   const char             *info)    // In
00779 /*
00780   Function: Create a directory entry.
00781 
00782   Input:    path      - Is the fully qualified name of the file to be removed.
00783             Mode      - Is the POSIX mode value the directory is to have.
00784                         Additionally, Mode may contain SFS_O_MKPTH if the
00785                         full dircectory path should be created.
00786             einfo     - Error information object to hold error details.
00787             client    - Authentication credentials, if any.
00788             info      - Opaque information to be used as seen fit.
00789 
00790   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00791 */
00792 {
00793 // Return an error
00794 //
00795    return XrdBwmFS.Emsg("mkdir", einfo, ENOTSUP, "mkdir", path);
00796 }
00797 
00798 /******************************************************************************/
00799 /*                               p r e p a r e                                */
00800 /******************************************************************************/
00801 
00802 int XrdBwm::prepare(      XrdSfsPrep       &pargs,      // In
00803                           XrdOucErrInfo    &out_error,  // Out
00804                     const XrdSecEntity     *client)     // In
00805 {
00806    return 0;
00807 }
00808   
00809 /******************************************************************************/
00810 /*                                r e m o v e                                 */
00811 /******************************************************************************/
00812 
00813 int XrdBwm::remove(const char              type,    // In
00814                    const char             *path,    // In
00815                          XrdOucErrInfo    &einfo,   // Out
00816                    const XrdSecEntity     *client,  // In
00817                    const char             *info)    // In
00818 /*
00819   Function: Delete a file from the namespace and release it's data storage.
00820 
00821   Input:    type      - 'f' for file and 'd' for directory.
00822             path      - Is the fully qualified name of the file to be removed.
00823             einfo     - Error information object to hold error details.
00824             client    - Authentication credentials, if any.
00825             info      - Opaque information to be used as seen fit.
00826 
00827   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00828 */
00829 {
00830 // Return an error
00831 //
00832    return XrdBwmFS.Emsg("remove", einfo, ENOTSUP, "remove", path);
00833 }
00834 
00835 /******************************************************************************/
00836 /*                                r e n a m e                                 */
00837 /******************************************************************************/
00838 
00839 int XrdBwm::rename(const char             *old_name,  // In
00840                    const char             *new_name,  // In
00841                          XrdOucErrInfo    &einfo,     //Out
00842                    const XrdSecEntity     *client,    // In
00843                    const char             *infoO,     // In
00844                    const char             *infoN)     // In
00845 /*
00846   Function: Renames a file with name 'old_name' to 'new_name'.
00847 
00848   Input:    old_name  - Is the fully qualified name of the file to be renamed.
00849             new_name  - Is the fully qualified name that the file is to have.
00850             einfo     - Error information structure, if an error occurs.
00851             client    - Authentication credentials, if any.
00852             infoO     - old_name opaque information to be used as seen fit.
00853             infoN     - new_name opaque information to be used as seen fit.
00854 
00855   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00856 */
00857 {
00858 // Return an error
00859 //
00860    return XrdBwmFS.Emsg("rename", einfo, ENOTSUP, "rename", old_name);
00861 }
00862 
00863 /******************************************************************************/
00864 /*                                  s t a t                                   */
00865 /******************************************************************************/
00866 
00867 int XrdBwm::stat(const char             *path,        // In
00868                        struct stat      *buf,         // Out
00869                        XrdOucErrInfo    &einfo,       // Out
00870                  const XrdSecEntity     *client,      // In
00871                  const char             *info)        // In
00872 /*
00873   Function: Return file status information
00874 
00875   Input:    path      - The path for which status is wanted
00876             buf       - The stat structure to hold the results
00877             einfo     - Error information structure, if an error occurs.
00878             client    - Authentication credentials, if any.
00879             info      - opaque information to be used as seen fit.
00880 
00881   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00882 */
00883 {
00884 // Return an error
00885 //
00886    return XrdBwmFS.Emsg("stat", einfo, ENOTSUP, "locate", path);
00887 }
00888 
00889 /******************************************************************************/
00890 
00891 int XrdBwm::stat(const char             *path,        // In
00892                        mode_t           &mode,        // Out
00893                        XrdOucErrInfo    &einfo,       // Out
00894                  const XrdSecEntity     *client,      // In
00895                  const char             *info)        // In
00896 /*
00897   Function: Return file status information (resident files only)
00898 
00899   Input:    path      - The path for which status is wanted
00900             mode      - The stat mode entry (faked -- do not trust it)
00901             einfo     - Error information structure, if an error occurs.
00902             client    - Authentication credentials, if any.
00903             info      - opaque information to be used as seen fit.
00904 
00905   Output:   Always returns SFS_ERROR if a delay needs to be imposed. Otherwise,
00906             SFS_OK is returned and mode is appropriately, if inaccurately, set.
00907             If file residency cannot be determined, mode is set to -1.
00908 */
00909 {
00910 // Return an error
00911 //
00912    return XrdBwmFS.Emsg("stat", einfo, ENOTSUP, "locate", path);
00913 }
00914 
00915 /******************************************************************************/
00916 /*                              t r u n c a t e                               */
00917 /******************************************************************************/
00918 
00919 int XrdBwm::truncate(const char             *path,    // In
00920                            XrdSfsFileOffset  Size,    // In
00921                            XrdOucErrInfo    &einfo,   // Out
00922                      const XrdSecEntity     *client,  // In
00923                      const char             *info)    // In
00924 /*
00925   Function: Change the mode on a file or directory.
00926 
00927   Input:    path      - Is the fully qualified name of the file to be removed.
00928             Size      - the size the file should have.
00929             einfo     - Error information object to hold error details.
00930             client    - Authentication credentials, if any.
00931             info      - Opaque information to be used as seen fit.
00932 
00933   Output:   Returns SFS_OK upon success and SFS_ERROR upon failure.
00934 */
00935 {
00936 // Return an error
00937 //
00938    return XrdBwmFS.Emsg("truncate", einfo, ENOTSUP, "truncate", path);
00939 }
00940 
00941 /******************************************************************************/
00942 /*                                  E m s g                                   */
00943 /******************************************************************************/
00944 
00945 int XrdBwm::Emsg(const char    *pfx,    // Message prefix value
00946                  XrdOucErrInfo &einfo,  // Place to put text & error code
00947                  int            ecode,  // The error code
00948                  const char    *op,     // Operation being performed
00949                  const char    *target) // The target (e.g., fname)
00950 {
00951    char *etext, buffer[MAXPATHLEN+80], unkbuff[64];
00952 
00953 // Get the reason for the error
00954 //
00955    if (ecode < 0) ecode = -ecode;
00956    if (!(etext = BwmEroute.ec2text(ecode))) 
00957       {sprintf(unkbuff, "reason unknown (%d)", ecode); etext = unkbuff;}
00958 
00959 // Format the error message
00960 //
00961    snprintf(buffer,sizeof(buffer),"Unable to %s %s; %s", op, target, etext);
00962 
00963 // Print it out if debugging is enabled
00964 //
00965 #ifndef NODEBUG
00966    BwmEroute.Emsg(pfx, einfo.getErrUser(), buffer);
00967 #endif
00968 
00969 // Place the error message in the error object and return
00970 //
00971    einfo.setErrInfo(ecode, buffer);
00972    return SFS_ERROR;
00973 }
00974 
00975 /******************************************************************************/
00976 
00977 int XrdBwm::Emsg(const char    *pfx,    // Message prefix value
00978                  XrdOucErrInfo &einfo,  // Place to put text & error code
00979                  const char    *item,   // What is missing
00980                  const char    *op,     // Operation being performed
00981                  const char    *target) // The target (e.g., fname)
00982 {
00983    char buffer[MAXPATHLEN+80];
00984 
00985 // Format the error message
00986 //
00987    snprintf(buffer,sizeof(buffer),"Unable to %s %s; %s missing",
00988                                    op, target, item);
00989 
00990 // Print it out if debugging is enabled
00991 //
00992 #ifndef NODEBUG
00993    BwmEroute.Emsg(pfx, einfo.getErrUser(), buffer);
00994 #endif
00995 
00996 // Place the error message in the error object and return
00997 //
00998    einfo.setErrInfo(EINVAL, buffer);
00999    return SFS_ERROR;
01000 }
01001 
01002 /******************************************************************************/
01003 /*                                 S t a l l                                  */
01004 /******************************************************************************/
01005   
01006 int XrdBwm::Stall(XrdOucErrInfo   &einfo, // Error text & code
01007                   int              stime, // Seconds to stall
01008                   const char      *path)  // The path to stall on
01009 {
01010     EPNAME("Stall")
01011 #ifndef NODEBUG
01012     const char *tident = einfo.getErrUser();
01013 #endif
01014 
01015 // Trace the stall
01016 //
01017    ZTRACE(delay, "Stall " <<stime <<" for " <<path);
01018 
01019 // Place the error message in the error object and return
01020 //
01021    einfo.setErrInfo(0, "");
01022    return stime;
01023 }

Generated on Tue Jul 5 14:46:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1