XRootD
Loading...
Searching...
No Matches
XrdBwm.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d B w m . c c */
4/* */
5/* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* Produced by Andrew Hanushevsky for Stanford University under contract */
7/* DE-AC02-76-SFO0515 with the Deprtment of Energy */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/******************************************************************************/
29
30#include <unistd.h>
31#include <cerrno>
32#include <cstring>
33#include <cstdio>
34#include <cstdlib>
35#include <sys/param.h>
36#include <sys/stat.h>
37#include <sys/types.h>
38
39#include "XrdVersion.hh"
40
41#include "XrdBwm/XrdBwm.hh"
42#include "XrdBwm/XrdBwmTrace.hh"
43
45
46#include "XrdNet/XrdNetAddr.hh"
47
48#include "XrdOuc/XrdOucEnv.hh"
49#include "XrdOuc/XrdOucUtils.hh"
50#include "XrdOuc/XrdOucTrace.hh"
51
53
54#include "XrdSfs/XrdSfsAio.hh"
56
57#include "XrdSys/XrdSysError.hh"
62
63/******************************************************************************/
64/* E r r o r R o u t i n g O b j e c t */
65/******************************************************************************/
66
68
70
71/******************************************************************************/
72/* S t a t i c O b j e c t s */
73/******************************************************************************/
74
75XrdBwmHandle *XrdBwm::dummyHandle;
76
77/******************************************************************************/
78/* F i l e S y s t e m O b j e c t */
79/******************************************************************************/
80
82
84
85/******************************************************************************/
86/* X r d B w m C o n s t r u c t o r */
87/******************************************************************************/
88
90{
91 XrdNetAddr myAddr(0);
92 char buff[256], *bp;
93 int myPort, i;
94
95// Establish defaults
96//
97 Authorization = 0;
98 Authorize = 0;
99 AuthLib = 0;
100 AuthParm = 0;
101 Logger = 0;
102 PolLib = 0;
103 PolParm = 0;
104 PolSlotsIn = 1;
105 PolSlotsOut = 1;
106
107// Obtain port number we will be using
108//
109 myPort = (bp = getenv("XRDPORT")) ? strtol(bp, (char **)NULL, 10) : 0;
110
111// Establish our hostname and address
112//
113 myAddr.Port(myPort);
114 HostName = strdup(myAddr.Name("*unknown*"));
115 myAddr.Format(buff, sizeof(buff), XrdNetAddr::fmtAdv6, XrdNetAddr::old6Map4);
116 locResp = strdup(buff); locRlen = strlen(buff);
117 for (i = 0; HostName[i] && HostName[i] != '.'; i++) {}
118 HostName[i] = '\0';
119 HostPref = strdup(HostName);
120 HostName[i] = '.';
121 myDomain = &HostName[i+1];
122 myDomLen = strlen(myDomain);
123 myVersion = &XrdVERSIONINFOVAR(XrdSfsGetFileSystem);
124
125// Set the configuration file name abd dummy handle
126//
127 ConfigFN = 0;
128 dummyHandle = XrdBwmHandle::Alloc("*", "/", "?", "?", 0);
129}
130
131/******************************************************************************/
132/* X r d B w m F i l e C o n s t r u c t o r */
133/******************************************************************************/
134
135XrdBwmFile::XrdBwmFile(const char *user, int monid) : XrdSfsFile(user, monid)
136{
137 oh = XrdBwm::dummyHandle;
138 tident = (user ? user : "");
139}
140
141/******************************************************************************/
142/* G e t F i l e S y s t e m */
143/******************************************************************************/
144
145extern "C"
146{
148 XrdSysLogger *lp,
149 const char *configfn)
150{
151// Do the herald thing
152//
153 BwmEroute.SetPrefix("bwm_");
154 BwmEroute.logger(lp);
155 BwmEroute.Say("Copr. 2008 Stanford University, Bwm Version " XrdVSTRING);
156
157// Initialize the subsystems
158//
159 XrdBwmFS.ConfigFN = (configfn && *configfn ? strdup(configfn) : 0);
160 if ( XrdBwmFS.Configure(BwmEroute) ) return 0;
161
162// All done, we can return the callout vector to these routines.
163//
164 return &XrdBwmFS;
165}
166}
167
168/******************************************************************************/
169/* */
170/* 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 */
171/* */
172/******************************************************************************/
173/******************************************************************************/
174/* o p e n */
175/******************************************************************************/
176
177int XrdBwmDirectory::open(const char *dir_path, // In
178 const XrdSecEntity *client, // In
179 const char *info) // In
180/*
181 Function: Open the directory `path' and prepare for reading.
182
183 Input: path - The fully qualified name of the directory to open.
184 client - Authentication credentials, if any.
185 info - Opaque information to be used as seen fit.
186
187 Output: Returns SFS_OK upon success, otherwise SFS_ERROR.
188
189 Notes: 1. Currently, function not supported.
190*/
191{
192// Return an error
193//
194 return XrdBwmFS.Emsg("opendir", error, ENOTDIR, "open directory", dir_path);
195}
196
197/******************************************************************************/
198/* n e x t E n t r y */
199/******************************************************************************/
200
202/*
203 Function: Read the next directory entry.
204
205 Input: n/a
206
207 Output: n/a
208*/
209{
210// Return an error
211//
212 XrdBwmFS.Emsg("readdir", error, EBADF, "read directory");
213 return 0;
214}
215
216/******************************************************************************/
217/* c l o s e */
218/******************************************************************************/
219
221/*
222 Function: Close the directory object.
223
224 Input: n/a
225
226 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
227*/
228{
229// Return an error
230//
231 XrdBwmFS.Emsg("closedir", error, EBADF, "close directory");
232 return SFS_ERROR;
233}
234
235/******************************************************************************/
236/* */
237/* F i l e O b j e c t I n t e r f a c e s */
238/* */
239/******************************************************************************/
240/******************************************************************************/
241/* o p e n */
242/******************************************************************************/
243
244int XrdBwmFile::open(const char *path, // In
245 XrdSfsFileOpenMode open_mode, // In
246 mode_t Mode, // In
247 const XrdSecEntity *client, // In
248 const char *info) // In
249/*
250 Function: Open the file `path' in the mode indicated by `open_mode'.
251
252 Input: path - The fully qualified name of the file to open.
253 The path must start with "/_bwm_" and the lfn that
254 will eventually be opened start at the next slash.
255 open_mode - One of the following flag values:
256 SFS_O_RDONLY - Open file for reading.
257 SFS_O_WRONLY - Open file for writing. n/a
258 SFS_O_RDWR - Open file for update n/a
259 SFS_O_CREAT - Create the file open in RW mode n/a
260 SFS_O_TRUNC - Trunc the file open in RW mode n/a
261 Mode - The Posix access mode bits to be assigned to the file.
262 These bits are ignored.
263 client - Authentication credentials, if any.
264 info - Opaque information:
265 bwm.src=<src host>
266 bwm.dst=<dest host>
267
268 Output: Returns SFS_OK upon success, otherwise SFS_ERROR is returned.
269*/
270{
271 EPNAME("open");
272 XrdBwmHandle *hP;
273 int incoming;
274 const char *miss, *theUsr, *theSrc, *theDst=0, *theLfn=0, *lclNode, *rmtNode;
275 XrdOucEnv Open_Env(info);
276
277// Trace entry
278//
279 ZTRACE(calls,std::hex <<open_mode <<std::dec <<" fn=" <<path);
280
281// Verify that this object is not already associated with an open file
282//
283 XrdBwmFS.ocMutex.Lock();
284 if (oh != XrdBwm::dummyHandle)
285 {XrdBwmFS.ocMutex.UnLock();
286 return XrdBwmFS.Emsg("open",error,EADDRINUSE,"open file",path);
287 }
288 XrdBwmFS.ocMutex.UnLock();
289
290// Verify that the file is being opened in r/w mode only!
291//
292 if (!(open_mode & SFS_O_RDWR))
293 return XrdBwmFS.Emsg("open", error, EINVAL, "open", path);
294
295// Apply security. Note that we reject r/w access but apply r/o access
296// restrictions if so wanted.
297//
298 if (client && XrdBwmFS.Authorization
299 && !XrdBwmFS.Authorization->Access(client, path, AOP_Update, &Open_Env))
300 return XrdBwmFS.Emsg("open", error, EACCES, "open", path);
301
302// Make sure that all of the relevant information is present
303//
304 if (!(theSrc = Open_Env.Get("bwm.src"))) miss = "bwm.src";
305 else if (!(theDst = Open_Env.Get("bwm.dst"))) miss = "bwm.dst";
306 else if (!(theLfn = index(path+1,'/'))
307 || !(*(theLfn+1))) miss = "lfn";
308 else miss = 0;
309
310 if (miss) return XrdBwmFS.Emsg("open", error, miss, "open", path);
311 theUsr = error.getErrUser();
312
313// Determine the direction of flow
314//
316 {incoming = 0; lclNode = theSrc; rmtNode = theDst;}
318 {incoming = 1; lclNode = theDst; rmtNode = theSrc;}
319 else return XrdBwmFS.Emsg("open", error, EREMOTE, "open", path);
320
321// Get a handle for this file.
322//
323 if (!(hP = XrdBwmHandle::Alloc(theUsr,theLfn,lclNode,rmtNode,incoming)))
324 return XrdBwmFS.Stall(error, 13, path);
325
326// All done
327//
328 XrdBwmFS.ocMutex.Lock(); oh = hP; XrdBwmFS.ocMutex.UnLock();
329 return SFS_OK;
330}
331
332/******************************************************************************/
333/* c l o s e */
334/******************************************************************************/
335
337/*
338 Function: Close the file object.
339
340 Input: n/a
341
342 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
343*/
344{
345 EPNAME("close");
346 XrdBwmHandle *hP;
347
348// Trace the call
349//
350 FTRACE(calls, "close" <<oh->Name());
351
352// Verify the handle (we briefly maintain a global lock)
353//
354 XrdBwmFS.ocMutex.Lock();
355 if (oh == XrdBwm::dummyHandle)
356 {XrdBwmFS.ocMutex.UnLock(); return SFS_OK;}
357 hP = oh; oh = XrdBwm::dummyHandle;
358 XrdBwmFS.ocMutex.UnLock();
359
360// Now retire it and possibly return the token
361//
362 hP->Retire();
363
364// All done
365//
366 return SFS_OK;
367}
368
369/******************************************************************************/
370/* f c t l */
371/******************************************************************************/
372
373int XrdBwmFile::fctl(const int cmd,
374 const char *args,
375 XrdOucErrInfo &out_error)
376/*
377 Function: perform request control operation.
378
379 Input: cmd - The operation:
380 SFS_FCTL_GETFD - not supported.
381 SFS_FCTL_STATV - returns visa information
382 args - Dependent on the cmd.
383 out_error - Place where response goes.
384
385 Output: Returns SFS_OK upon success and SFS_ERROR o/w.
386*/
387{
388
389// Make sure the file is open
390//
391 if (oh == XrdBwm::dummyHandle)
392 return XrdBwmFS.Emsg("fctl", out_error, EBADF, "fctl file");
393
394// Scan through the fctl operations
395//
396 switch(cmd)
397 {case SFS_FCTL_GETFD: out_error.setErrInfo(-1,"");
398 return SFS_OK;
399 case SFS_FCTL_STATV: return oh->Activate(out_error);
400 default: break;
401 }
402
403// Invalid fctl
404//
405 out_error.setErrInfo(EINVAL, "invalid fctl command");
406 return SFS_ERROR;
407}
408
409/******************************************************************************/
410/* r e a d */
411/******************************************************************************/
412
414 XrdSfsXferSize blen) // In
415/*
416 Function: Preread `blen' bytes at `offset'
417
418 Input: offset - The absolute byte offset at which to start the read.
419 blen - The amount to preread.
420
421 Output: Returns SFS_OK upon success and SFS_ERROR o/w.
422*/
423{
424 EPNAME("read");
425
426// Perform required tracing
427//
428 FTRACE(calls,"preread " <<blen <<"@" <<offset);
429
430// Return number of bytes read
431//
432 return 0;
433}
434
435/******************************************************************************/
436/* r e a d */
437/******************************************************************************/
438
440 char *buff, // Out
441 XrdSfsXferSize blen) // In
442/*
443 Function: Read `blen' bytes at `offset' into 'buff' and return the actual
444 number of bytes read.
445
446 Input: offset - The absolute byte offset at which to start the read.
447 buff - Address of the buffer in which to place the data.
448 blen - The size of the buffer. This is the maximum number
449 of bytes that will be read from 'fd'.
450
451 Output: Returns the number of bytes read upon success and SFS_ERROR o/w.
452
453 Notes: 1. Currently, we have no information so we always return 0 bytes.
454*/
455{
456 EPNAME("read");
457
458// Perform required tracing
459//
460 FTRACE(calls,blen <<"@" <<offset);
461
462// Return number of bytes read
463//
464 return 0;
465}
466
467/******************************************************************************/
468/* r e a d A I O */
469/******************************************************************************/
470
471/*
472 Function: Read `blen' bytes at `offset' into 'buff' and return the actual
473 number of bytes read using asynchronous I/O, if possible.
474
475 Output: Returns the 0 if successfullt queued, otherwise returns an error.
476 The underlying implementation will convert the request to
477 synchronous I/O is async mode is not possible.
478*/
479
481{
482
483// Async mode not supported.
484//
485 aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
486 (char *)aiop->sfsAio.aio_buf,
488 aiop->doneRead();
489 return 0;
490}
491
492/******************************************************************************/
493/* w r i t e */
494/******************************************************************************/
495
497 const char *buff, // Out
498 XrdSfsXferSize blen) // In
499/*
500 Function: Write `blen' bytes at `offset' from 'buff' and return the actual
501 number of bytes written.
502
503 Input: offset - The absolute byte offset at which to start the write.
504 buff - Address of the buffer from which to get the data.
505 blen - The size of the buffer. This is the maximum number
506 of bytes that will be written to 'fd'.
507
508 Output: Returns the number of bytes written upon success and SFS_ERROR o/w.
509
510 Notes: 1. An error return may be delayed until the next write(), close(), or
511 sync() call.
512 2. Currently, we do not accept write activated commands.
513*/
514{
515 EPNAME("write");
516
517// Perform any required tracing
518//
519 FTRACE(calls, blen <<"@" <<offset);
520
521// Return number of bytes written
522//
523 return 0;
524}
525
526/******************************************************************************/
527/* w r i t e A I O */
528/******************************************************************************/
529
530// For now, this reverts to synchronous I/O
531//
533{
534
535// Async mode not supported.
536//
537 aiop->Result = this->write((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
538 (char *)aiop->sfsAio.aio_buf,
540 aiop->doneWrite();
541 return 0;
542}
543
544/******************************************************************************/
545/* g e t M m a p */
546/******************************************************************************/
547
548int XrdBwmFile::getMmap(void **Addr, off_t &Size) // Out
549/*
550 Function: Return memory mapping for file, if any.
551
552 Output: Addr - Address of memory location
553 Size - Size of the file or zero if not memory mapped.
554 Returns SFS_OK upon success and SFS_ERROR upon failure.
555*/
556{
557
558// Mapping is not supported
559//
560 *Addr= 0;
561 Size = 0;
562
563 return SFS_OK;
564}
565
566/******************************************************************************/
567/* s t a t */
568/******************************************************************************/
569
570int XrdBwmFile::stat(struct stat *buf) // Out
571/*
572 Function: Return file status information
573
574 Input: buf - The stat structiure to hold the results
575
576 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
577*/
578{
579 EPNAME("fstat");
580 static unsigned int myInode = 0;
581 union {long long Fill;
582 int Xor[2];
583 XrdBwmFile *fP;
584 dev_t Num;
585 } theDev;
586
587// Perform any required tracing
588//
589 FTRACE(calls, FName());
590
591// Develop the device number
592//
593 theDev.Fill = 0; theDev.fP = this; theDev.Xor[0] ^= theDev.Xor[1];
594
595// Fill out the stat structure for this pseudo file
596//
597 memset(buf, 0, sizeof(struct stat));
598 buf->st_ino = myInode++;
599 buf->st_dev = theDev.Num;
600 buf->st_blksize = 4096;
601 buf->st_mode = S_IFBLK;
602 return SFS_OK;
603}
604
605/******************************************************************************/
606/* s y n c */
607/******************************************************************************/
608
610/*
611 Function: Commit all unwritten bytes to physical media.
612
613 Input: n/a
614
615 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
616*/
617{
618 EPNAME("sync");
619
620// Perform any required tracing
621//
622 FTRACE(calls,"");
623
624// We always succeed
625//
626 return SFS_OK;
627}
628
629/******************************************************************************/
630/* s y n c A I O */
631/******************************************************************************/
632
633// For now, reverts to synchronous case
634//
636{
637 aiop->Result = this->sync();
638 aiop->doneWrite();
639 return 0;
640}
641
642/******************************************************************************/
643/* t r u n c a t e */
644/******************************************************************************/
645
647/*
648 Function: Set the length of the file object to 'flen' bytes.
649
650 Input: flen - The new size of the file.
651
652 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
653
654 Notes: 1. Truncate is not supported.
655*/
656{
657 EPNAME("trunc");
658
659// Lock the file handle and perform any tracing
660//
661 FTRACE(calls, "len=" <<flen);
662
663// Return an error
664//
665 return XrdBwmFS.Emsg("trunc", error, ENOTSUP, "truncate", oh->Name());
666}
667
668/******************************************************************************/
669/* g e t C X i n f o */
670/******************************************************************************/
671
672int XrdBwmFile::getCXinfo(char cxtype[4], int &cxrsz)
673/*
674 Function: Set the length of the file object to 'flen' bytes.
675
676 Input: n/a
677
678 Output: cxtype - Compression algorithm code
679 cxrsz - Compression region size
680
681 Returns SFS_OK upon success and SFS_ERROR upon failure.
682*/
683{
684
685// Indicate not compressed
686//
687 cxrsz = 0;
688 cxtype[0] = cxtype[1] = cxtype[2] = cxtype[3] = 0;
689 return SFS_OK;
690}
691
692/******************************************************************************/
693/* */
694/* 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 */
695/* */
696/******************************************************************************/
697/******************************************************************************/
698/* c h m o d */
699/******************************************************************************/
700
701int XrdBwm::chmod(const char *path, // In
702 XrdSfsMode Mode, // In
703 XrdOucErrInfo &einfo, // Out
704 const XrdSecEntity *client, // In
705 const char *info) // In
706/*
707 Function: Change the mode on a file or directory.
708
709 Input: path - Is the fully qualified name of the file to be removed.
710 einfo - Error information object to hold error details.
711 client - Authentication credentials, if any.
712 info - Opaque information to be used as seen fit.
713
714 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
715*/
716{
717// Return an error
718//
719 return XrdBwmFS.Emsg("chmod", einfo, ENOTSUP, "change", path);
720}
721
722/******************************************************************************/
723/* e x i s t s */
724/******************************************************************************/
725
726int XrdBwm::exists(const char *path, // In
727 XrdSfsFileExistence &file_exists, // Out
728 XrdOucErrInfo &einfo, // Out
729 const XrdSecEntity *client, // In
730 const char *info) // In
731/*
732 Function: Determine if file 'path' actually exists.
733
734 Input: path - Is the fully qualified name of the file to be tested.
735 file_exists - Is the address of the variable to hold the status of
736 'path' when success is returned. The values may be:
737 XrdSfsFileExistsIsDirectory - file not found but path is valid.
738 XrdSfsFileExistsIsFile - file found.
739 XrdSfsFileExistsIsNo - neither file nor directory.
740 einfo - Error information object holding the details.
741 client - Authentication credentials, if any.
742 info - Opaque information to be used as seen fit.
743
744 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
745
746 Notes: When failure occurs, 'file_exists' is not modified.
747*/
748{
749
750 file_exists=XrdSfsFileExistNo;
751 return SFS_OK;
752}
753
754/******************************************************************************/
755/* f s c t l */
756/******************************************************************************/
757
758int XrdBwm::fsctl(const int cmd,
759 const char *args,
760 XrdOucErrInfo &einfo,
761 const XrdSecEntity *client)
762/*
763 Function: Perform filesystem operations:
764
765 Input: cmd - Operation command (currently supported):
766 None.
767 arg - Command dependent argument:
768 - STATXV: The file handle
769 einfo - Error/Response information structure.
770 client - Authentication credentials, if any.
771
772 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
773*/
774{
775// Operation is not supported
776//
777 return XrdBwmFS.Emsg("fsctl", einfo, ENOTSUP, "fsctl", args);
778}
779
780/******************************************************************************/
781/* g e t V e r s i o n */
782/******************************************************************************/
783
784const char *XrdBwm::getVersion() {return XrdVERSION;}
785
786/******************************************************************************/
787/* m k d i r */
788/******************************************************************************/
789
790int XrdBwm::mkdir(const char *path, // In
791 XrdSfsMode Mode, // In
792 XrdOucErrInfo &einfo, // Out
793 const XrdSecEntity *client, // In
794 const char *info) // In
795/*
796 Function: Create a directory entry.
797
798 Input: path - Is the fully qualified name of the file to be removed.
799 Mode - Is the POSIX mode value the directory is to have.
800 Additionally, Mode may contain SFS_O_MKPTH if the
801 full dircectory path should be created.
802 einfo - Error information object to hold error details.
803 client - Authentication credentials, if any.
804 info - Opaque information to be used as seen fit.
805
806 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
807*/
808{
809// Return an error
810//
811 return XrdBwmFS.Emsg("mkdir", einfo, ENOTSUP, "mkdir", path);
812}
813
814/******************************************************************************/
815/* p r e p a r e */
816/******************************************************************************/
817
818int XrdBwm::prepare( XrdSfsPrep &pargs, // In
819 XrdOucErrInfo &out_error, // Out
820 const XrdSecEntity *client) // In
821{
822 return 0;
823}
824
825/******************************************************************************/
826/* r e m o v e */
827/******************************************************************************/
828
829int XrdBwm::remove(const char type, // In
830 const char *path, // In
831 XrdOucErrInfo &einfo, // Out
832 const XrdSecEntity *client, // In
833 const char *info) // In
834/*
835 Function: Delete a file from the namespace and release it's data storage.
836
837 Input: type - 'f' for file and 'd' for directory.
838 path - Is the fully qualified name of the file to be removed.
839 einfo - Error information object to hold error details.
840 client - Authentication credentials, if any.
841 info - Opaque information to be used as seen fit.
842
843 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
844*/
845{
846// Return an error
847//
848 return XrdBwmFS.Emsg("remove", einfo, ENOTSUP, "remove", path);
849}
850
851/******************************************************************************/
852/* r e n a m e */
853/******************************************************************************/
854
855int XrdBwm::rename(const char *old_name, // In
856 const char *new_name, // In
857 XrdOucErrInfo &einfo, //Out
858 const XrdSecEntity *client, // In
859 const char *infoO, // In
860 const char *infoN) // In
861/*
862 Function: Renames a file with name 'old_name' to 'new_name'.
863
864 Input: old_name - Is the fully qualified name of the file to be renamed.
865 new_name - Is the fully qualified name that the file is to have.
866 einfo - Error information structure, if an error occurs.
867 client - Authentication credentials, if any.
868 infoO - old_name opaque information to be used as seen fit.
869 infoN - new_name opaque information to be used as seen fit.
870
871 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
872*/
873{
874// Return an error
875//
876 return XrdBwmFS.Emsg("rename", einfo, ENOTSUP, "rename", old_name);
877}
878
879/******************************************************************************/
880/* s t a t */
881/******************************************************************************/
882
883int XrdBwm::stat(const char *path, // In
884 struct stat *buf, // Out
885 XrdOucErrInfo &einfo, // Out
886 const XrdSecEntity *client, // In
887 const char *info) // In
888/*
889 Function: Return file status information
890
891 Input: path - The path for which status is wanted
892 buf - The stat structure to hold the results
893 einfo - Error information structure, if an error occurs.
894 client - Authentication credentials, if any.
895 info - opaque information to be used as seen fit.
896
897 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
898*/
899{
900// Return an error
901//
902 return XrdBwmFS.Emsg("stat", einfo, ENOTSUP, "locate", path);
903}
904
905/******************************************************************************/
906
907int XrdBwm::stat(const char *path, // In
908 mode_t &mode, // Out
909 XrdOucErrInfo &einfo, // Out
910 const XrdSecEntity *client, // In
911 const char *info) // In
912/*
913 Function: Return file status information (resident files only)
914
915 Input: path - The path for which status is wanted
916 mode - The stat mode entry (faked -- do not trust it)
917 einfo - Error information structure, if an error occurs.
918 client - Authentication credentials, if any.
919 info - opaque information to be used as seen fit.
920
921 Output: Always returns SFS_ERROR if a delay needs to be imposed. Otherwise,
922 SFS_OK is returned and mode is appropriately, if inaccurately, set.
923 If file residency cannot be determined, mode is set to -1.
924*/
925{
926// Return an error
927//
928 return XrdBwmFS.Emsg("stat", einfo, ENOTSUP, "locate", path);
929}
930
931/******************************************************************************/
932/* t r u n c a t e */
933/******************************************************************************/
934
935int XrdBwm::truncate(const char *path, // In
936 XrdSfsFileOffset Size, // In
937 XrdOucErrInfo &einfo, // Out
938 const XrdSecEntity *client, // In
939 const char *info) // In
940/*
941 Function: Change the mode on a file or directory.
942
943 Input: path - Is the fully qualified name of the file to be removed.
944 Size - the size the file should have.
945 einfo - Error information object to hold error details.
946 client - Authentication credentials, if any.
947 info - Opaque information to be used as seen fit.
948
949 Output: Returns SFS_OK upon success and SFS_ERROR upon failure.
950*/
951{
952// Return an error
953//
954 return XrdBwmFS.Emsg("truncate", einfo, ENOTSUP, "truncate", path);
955}
956
957/******************************************************************************/
958/* E m s g */
959/******************************************************************************/
960
961int XrdBwm::Emsg(const char *pfx, // Message prefix value
962 XrdOucErrInfo &einfo, // Place to put text & error code
963 int ecode, // The error code
964 const char *op, // Operation being performed
965 const char *target) // The target (e.g., fname)
966{
967 const char *etext;
968 char buffer[MAXPATHLEN+80];
969
970// Get the reason for the error
971//
972 if (ecode < 0) ecode = -ecode;
973 etext = BwmEroute.ec2text(ecode);
974
975// Format the error message
976//
977 snprintf(buffer,sizeof(buffer),"Unable to %s %s; %s", op, target, etext);
978
979// Print it out if debugging is enabled
980//
981#ifndef NODEBUG
982 BwmEroute.Emsg(pfx, einfo.getErrUser(), buffer);
983#endif
984
985// Place the error message in the error object and return
986//
987 einfo.setErrInfo(ecode, buffer);
988 return SFS_ERROR;
989}
990
991/******************************************************************************/
992
993int XrdBwm::Emsg(const char *pfx, // Message prefix value
994 XrdOucErrInfo &einfo, // Place to put text & error code
995 const char *item, // What is missing
996 const char *op, // Operation being performed
997 const char *target) // The target (e.g., fname)
998{
999 char buffer[MAXPATHLEN+80];
1000
1001// Format the error message
1002//
1003 snprintf(buffer,sizeof(buffer),"Unable to %s %s; %s missing",
1004 op, target, item);
1005
1006// Print it out if debugging is enabled
1007//
1008#ifndef NODEBUG
1009 BwmEroute.Emsg(pfx, einfo.getErrUser(), buffer);
1010#endif
1011
1012// Place the error message in the error object and return
1013//
1014 einfo.setErrInfo(EINVAL, buffer);
1015 return SFS_ERROR;
1016}
1017
1018/******************************************************************************/
1019/* S t a l l */
1020/******************************************************************************/
1021
1022int XrdBwm::Stall(XrdOucErrInfo &einfo, // Error text & code
1023 int stime, // Seconds to stall
1024 const char *path) // The path to stall on
1025{
1026 EPNAME("Stall")
1027#ifndef NODEBUG
1028 const char *tident = einfo.getErrUser();
1029#endif
1030
1031// Trace the stall
1032//
1033 ZTRACE(delay, "Stall " <<stime <<" for " <<path);
1034
1035// Place the error message in the error object and return
1036//
1037 einfo.setErrInfo(0, "");
1038 return stime;
1039}
@ AOP_Update
open() r/w or append
#define tident
XrdOucTrace BwmTrace
#define EPNAME(x)
#define FTRACE(act, x)
#define ZTRACE(act, x)
XrdBwm XrdBwmFS
Definition XrdBwm.cc:83
XrdVERSIONINFO(XrdSfsGetFileSystem, XrdBwm)
XrdSfsFileSystem * XrdSfsGetFileSystem(XrdSfsFileSystem *native_fs, XrdSysLogger *lp, const char *configfn)
Definition XrdBwm.cc:147
XrdSysError BwmEroute(0)
Definition XrdBwm.cc:69
#define write(a, b, c)
Definition XrdPosix.hh:115
#define stat(a, b)
Definition XrdPosix.hh:101
#define read(a, b, c)
Definition XrdPosix.hh:82
int Mode
off_t aio_offset
Definition XrdSfsAio.hh:49
size_t aio_nbytes
Definition XrdSfsAio.hh:48
void * aio_buf
Definition XrdSfsAio.hh:47
int XrdSfsMode
#define SFS_ERROR
XrdSfsFileExistence
@ XrdSfsFileExistNo
#define SFS_FCTL_STATV
#define SFS_FCTL_GETFD
#define SFS_O_RDWR
int XrdSfsFileOpenMode
#define SFS_OK
long long XrdSfsFileOffset
int XrdSfsXferSize
< Prepare parameters
virtual XrdAccPrivs Access(const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *Env=0)=0
int open(const char *dirName, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:177
const char * nextEntry()
Definition XrdBwm.cc:201
int close()
Definition XrdBwm.cc:336
int sync()
Definition XrdBwm.cc:609
int fctl(const int cmd, const char *args, XrdOucErrInfo &out_error)
Definition XrdBwm.cc:373
int truncate(XrdSfsFileOffset fileOffset)
Definition XrdBwm.cc:646
int getMmap(void **Addr, off_t &Size)
Definition XrdBwm.cc:548
int read(XrdSfsFileOffset fileOffset, XrdSfsXferSize amount)
Definition XrdBwm.cc:413
XrdBwmFile(const char *user, int monid)
Definition XrdBwm.cc:135
int open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:244
int stat(struct stat *buf)
Definition XrdBwm.cc:570
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition XrdBwm.cc:496
const char * tident
Definition XrdBwm.hh:134
const char * FName()
Definition XrdBwm.hh:100
int getCXinfo(char cxtype[4], int &cxrsz)
Definition XrdBwm.cc:672
const char * Name()
int Activate(XrdOucErrInfo &einfo)
static XrdBwmHandle * Alloc(const char *theUsr, const char *thePath, const char *lclNode, const char *rmtNode, int Incoming)
int chmod(const char *Name, XrdSfsMode Mode, XrdOucErrInfo &out_error, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:701
XrdBwm()
Definition XrdBwm.cc:89
XrdVersionInfo * myVersion
Definition XrdBwm.hh:244
int stat(const char *Name, struct stat *buf, XrdOucErrInfo &out_error, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:883
char * myDomain
Definition XrdBwm.hh:249
int myDomLen
Definition XrdBwm.hh:250
char * ConfigFN
Definition XrdBwm.hh:246
int fsctl(const int cmd, const char *args, XrdOucErrInfo &out_error, const XrdSecEntity *client)
Definition XrdBwm.cc:758
char * HostPref
Definition XrdBwm.hh:248
int truncate(const char *Name, XrdSfsFileOffset fileOffset, XrdOucErrInfo &out_error, const XrdSecEntity *client=0, const char *opaque=0)
Definition XrdBwm.cc:935
const char * getVersion()
Definition XrdBwm.cc:784
char * HostName
Definition XrdBwm.hh:247
int mkdir(const char *dirName, XrdSfsMode Mode, XrdOucErrInfo &out_error, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:790
char Authorize
Definition XrdBwm.hh:251
int rename(const char *oldFileName, const char *newFileName, XrdOucErrInfo &out_error, const XrdSecEntity *client, const char *infoO=0, const char *infoN=0)
Definition XrdBwm.cc:855
int prepare(XrdSfsPrep &pargs, XrdOucErrInfo &out_error, const XrdSecEntity *client=0)
Definition XrdBwm.cc:818
virtual int Configure(XrdSysError &)
int Emsg(const char *, XrdOucErrInfo &, int, const char *, const char *y="")
Definition XrdBwm.cc:961
int exists(const char *fileName, XrdSfsFileExistence &exists_flag, XrdOucErrInfo &out_error, const XrdSecEntity *client, const char *opaque=0)
Definition XrdBwm.cc:726
int Stall(XrdOucErrInfo &, int, const char *)
Definition XrdBwm.cc:1022
static const int old6Map4
Use deprecated IPV6 mapped format.
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
const char * Name(const char *eName=0, const char **eText=0)
int Port(int pNum=-1)
char * Get(const char *varname)
Definition XrdOucEnv.hh:69
const char * getErrUser()
int setErrInfo(int code, const char *emsg)
static bool endsWith(const char *text, const char *ending, int endlen)
ssize_t Result
Definition XrdSfsAio.hh:65
virtual void doneRead()=0
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
virtual void doneWrite()=0
XrdOucErrInfo & error
XrdOucErrInfo & error
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
static const char * ec2text(int ecode)
const char * SetPrefix(const char *prefix)
XrdSysLogger * logger(XrdSysLogger *lp=0)