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