xrootd
Loading...
Searching...
No Matches
XrdClFileSystemOperations.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN)
3// Author: Krzysztof Jamrog <krzysztof.piotr.jamrog@cern.ch>,
4// Michal Simon <michal.simon@cern.ch>
5//------------------------------------------------------------------------------
6// This file is part of the XRootD software suite.
7//
8// XRootD is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Lesser General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12//
13// XRootD is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public License
19// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
20//
21// In applying this licence, CERN does not waive the privileges and immunities
22// granted to it by virtue of its status as an Intergovernmental Organization
23// or submit itself to any jurisdiction.
24//------------------------------------------------------------------------------
25
26#ifndef __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__
27#define __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__
28
32#include "XrdCl/XrdClCtx.hh"
33
34namespace XrdCl
35{
36
37 //----------------------------------------------------------------------------
43 //----------------------------------------------------------------------------
44 template<template<bool> class Derived, bool HasHndl, typename Response, typename ... Args>
45 class FileSystemOperation: public ConcreteOperation<Derived, HasHndl, Response, Args...>
46 {
47
48 template<template<bool> class, bool, typename, typename ...> friend class FileSystemOperation;
49
50 public:
51 //------------------------------------------------------------------------
56 //------------------------------------------------------------------------
58 false, Response, Args...>( std::move( args )... ), filesystem( std::move( fs ) )
59 {
60 }
61
62 //------------------------------------------------------------------------
68 //------------------------------------------------------------------------
69 template<bool from>
71 ConcreteOperation<Derived, HasHndl, Response, Args...>( std::move( op ) ), filesystem( op.filesystem )
72 {
73 }
74
75 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
79 {
80 }
81
82 protected:
83
84 //------------------------------------------------------------------------
86 //------------------------------------------------------------------------
88 };
89
90 //----------------------------------------------------------------------------
92 //----------------------------------------------------------------------------
93 template<bool HasHndl>
96 {
97 public:
98
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
103 Arg<OpenFlags::Flags>>::FileSystemOperation;
104
105 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
108 enum { PathArg, FlagsArg };
109
110 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
113 std::string ToString()
114 {
115 return "Locate";
116 }
117
118 protected:
119
120 //------------------------------------------------------------------------
126 //------------------------------------------------------------------------
127 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
128 {
129 std::string &path = std::get<PathArg>( this->args ).Get();
130 OpenFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
131 uint16_t timeout = pipelineTimeout < this->timeout ?
132 pipelineTimeout : this->timeout;
133 return this->filesystem->Locate( path, flags, handler, timeout );
134 }
135 };
137
138 //----------------------------------------------------------------------------
140 //----------------------------------------------------------------------------
141 template<bool HasHndl>
142 class DeepLocateImpl: public FileSystemOperation<DeepLocateImpl, HasHndl,
143 Resp<LocationInfo>, Arg<std::string>, Arg<OpenFlags::Flags>>
144 {
145 public:
146
147 //------------------------------------------------------------------------
149 //------------------------------------------------------------------------
152
153 //------------------------------------------------------------------------
155 //------------------------------------------------------------------------
156 enum { PathArg, FlagsArg };
157
158 //------------------------------------------------------------------------
160 //------------------------------------------------------------------------
161 std::string ToString()
162 {
163 return "DeepLocate";
164 }
165
166 protected:
167
168 //------------------------------------------------------------------------
174 //------------------------------------------------------------------------
175 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
176 {
177 std::string &path = std::get<PathArg>( this->args ).Get();
178 OpenFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
179 uint16_t timeout = pipelineTimeout < this->timeout ?
180 pipelineTimeout : this->timeout;
181 return this->filesystem->DeepLocate( path, flags, handler, timeout );
182 }
183 };
185
186 //----------------------------------------------------------------------------
188 //----------------------------------------------------------------------------
189 template<bool HasHndl>
190 class MvImpl: public FileSystemOperation<MvImpl, HasHndl, Resp<void>, Arg<std::string>,
191 Arg<std::string>>
192 {
193 public:
194
195 //------------------------------------------------------------------------
197 //------------------------------------------------------------------------
200
201 //------------------------------------------------------------------------
203 //------------------------------------------------------------------------
205
206 //------------------------------------------------------------------------
208 //------------------------------------------------------------------------
209 std::string ToString()
210 {
211 return "Mv";
212 }
213
214 protected:
215
216 //------------------------------------------------------------------------
222 //------------------------------------------------------------------------
223 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
224 {
225 std::string &source = std::get<SourceArg>( this->args ).Get();
226 std::string &dest = std::get<DestArg>( this->args ).Get();
227 uint16_t timeout = pipelineTimeout < this->timeout ?
228 pipelineTimeout : this->timeout;
229 return this->filesystem->Mv( source, dest, handler, timeout );
230 }
231 };
233
234 //----------------------------------------------------------------------------
236 //----------------------------------------------------------------------------
237 template<bool HasHndl>
238 class QueryImpl: public FileSystemOperation<QueryImpl, HasHndl, Resp<Buffer>,
239 Arg<QueryCode::Code>, Arg<Buffer>>
240 {
241 public:
242
243 //------------------------------------------------------------------------
245 //------------------------------------------------------------------------
248
249 //------------------------------------------------------------------------
251 //------------------------------------------------------------------------
253
254 //------------------------------------------------------------------------
256 //------------------------------------------------------------------------
257 std::string ToString()
258 {
259 return "Query";
260 }
261
262 protected:
263
264 //------------------------------------------------------------------------
270 //------------------------------------------------------------------------
271 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
272 {
273 QueryCode::Code queryCode = std::get<QueryCodeArg>( this->args ).Get();
274 const Buffer &buffer( std::get<BufferArg>( this->args ).Get() );
275 uint16_t timeout = pipelineTimeout < this->timeout ?
276 pipelineTimeout : this->timeout;
277 return this->filesystem->Query( queryCode, buffer, handler, timeout );
278 }
279 };
281
282 //----------------------------------------------------------------------------
284 //----------------------------------------------------------------------------
285 template<bool HasHndl>
286 class TruncateFsImpl: public FileSystemOperation<TruncateFsImpl, HasHndl, Resp<void>,
287 Arg<std::string>, Arg<uint64_t>>
288 {
289 public:
290
291 //------------------------------------------------------------------------
293 //------------------------------------------------------------------------
296
297 //------------------------------------------------------------------------
299 //------------------------------------------------------------------------
300 enum { PathArg, SizeArg };
301
302 //------------------------------------------------------------------------
304 //------------------------------------------------------------------------
305 std::string ToString()
306 {
307 return "Truncate";
308 }
309
310 protected:
311
312 //------------------------------------------------------------------------
318 //------------------------------------------------------------------------
319 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
320 {
321 std::string &path = std::get<PathArg>( this->args ).Get();
322 uint64_t size = std::get<SizeArg>( this->args ).Get();
323 uint16_t timeout = pipelineTimeout < this->timeout ?
324 pipelineTimeout : this->timeout;
325 return this->filesystem->Truncate( path, size, handler, timeout );
326 }
327 };
328
330 {
331 return TruncateFsImpl<false>( std::move( fs ), std::move( path ), std::move( size ) );
332 }
333
334
335 //----------------------------------------------------------------------------
337 //----------------------------------------------------------------------------
338 template<bool HasHndl>
339 class RmImpl: public FileSystemOperation<RmImpl, HasHndl, Resp<void>, Arg<std::string>>
340 {
341 public:
342
343 //------------------------------------------------------------------------
345 //------------------------------------------------------------------------
347
348 //------------------------------------------------------------------------
350 //------------------------------------------------------------------------
351 enum { PathArg };
352
353 //------------------------------------------------------------------------
355 //------------------------------------------------------------------------
356 std::string ToString()
357 {
358 return "Rm";
359 }
360
361 protected:
362
363 //------------------------------------------------------------------------
369 //------------------------------------------------------------------------
370 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
371 {
372 std::string &path = std::get<PathArg>( this->args ).Get();
373 uint16_t timeout = pipelineTimeout < this->timeout ?
374 pipelineTimeout : this->timeout;
375 return this->filesystem->Rm( path, handler, timeout );
376 }
377 };
379
380 //----------------------------------------------------------------------------
382 //----------------------------------------------------------------------------
383 template<bool HasHndl>
384 class MkDirImpl: public FileSystemOperation<MkDirImpl, HasHndl, Resp<void>,
385 Arg<std::string>, Arg<MkDirFlags::Flags>, Arg<Access::Mode>>
386 {
387 public:
388
389 //------------------------------------------------------------------------
391 //------------------------------------------------------------------------
394
395 //------------------------------------------------------------------------
397 //------------------------------------------------------------------------
399
400 //------------------------------------------------------------------------
402 //------------------------------------------------------------------------
403 std::string ToString()
404 {
405 return "MkDir";
406 }
407
408 protected:
409
410 //------------------------------------------------------------------------
416 //------------------------------------------------------------------------
417 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
418 {
419 std::string &path = std::get<PathArg>( this->args ).Get();
420 MkDirFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
421 Access::Mode mode = std::get<ModeArg>( this->args ).Get();
422 uint16_t timeout = pipelineTimeout < this->timeout ?
423 pipelineTimeout : this->timeout;
424 return this->filesystem->MkDir( path, flags, mode, handler, timeout );
425 }
426 };
428
429 //----------------------------------------------------------------------------
431 //----------------------------------------------------------------------------
432 template<bool HasHndl>
433 class RmDirImpl: public FileSystemOperation<RmDirImpl, HasHndl, Resp<void>,
434 Arg<std::string>>
435 {
436 public:
437
438 //------------------------------------------------------------------------
440 //------------------------------------------------------------------------
442
443 //------------------------------------------------------------------------
445 //------------------------------------------------------------------------
446 enum { PathArg };
447
448 //------------------------------------------------------------------------
450 //------------------------------------------------------------------------
451 std::string ToString()
452 {
453 return "RmDir";
454 }
455
456 protected:
457
458 //------------------------------------------------------------------------
464 //------------------------------------------------------------------------
465 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
466 {
467 std::string &path = std::get<PathArg>( this->args ).Get();
468 uint16_t timeout = pipelineTimeout < this->timeout ?
469 pipelineTimeout : this->timeout;
470 return this->filesystem->RmDir( path, handler, timeout );
471 }
472 };
474
475 //----------------------------------------------------------------------------
477 //----------------------------------------------------------------------------
478 template<bool HasHndl>
479 class ChModImpl: public FileSystemOperation<ChModImpl, HasHndl, Resp<void>,
480 Arg<std::string>, Arg<Access::Mode>>
481 {
482 public:
483
484 //------------------------------------------------------------------------
486 //------------------------------------------------------------------------
489
490 //------------------------------------------------------------------------
492 //------------------------------------------------------------------------
493 enum { PathArg, ModeArg };
494
495 //------------------------------------------------------------------------
497 //------------------------------------------------------------------------
498 std::string ToString()
499 {
500 return "ChMod";
501 }
502
503 protected:
504
505 //------------------------------------------------------------------------
511 //------------------------------------------------------------------------
512 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
513 {
514 std::string &path = std::get<PathArg>( this->args ).Get();
515 Access::Mode mode = std::get<ModeArg>( this->args ).Get();
516 uint16_t timeout = pipelineTimeout < this->timeout ?
517 pipelineTimeout : this->timeout;
518 return this->filesystem->ChMod( path, mode, handler, timeout );
519 }
520 };
522
523 //----------------------------------------------------------------------------
525 //----------------------------------------------------------------------------
526 template<bool HasHndl>
527 class PingImpl: public FileSystemOperation<PingImpl, HasHndl, Resp<void>>
528 {
529 public:
530
531 //------------------------------------------------------------------------
533 //------------------------------------------------------------------------
535
536 //------------------------------------------------------------------------
538 //------------------------------------------------------------------------
539 std::string ToString()
540 {
541 return "Ping";
542 }
543
544 protected:
545
546 //------------------------------------------------------------------------
552 //------------------------------------------------------------------------
553 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
554 {
555 uint16_t timeout = pipelineTimeout < this->timeout ?
556 pipelineTimeout : this->timeout;
557 return this->filesystem->Ping( handler, timeout );
558 }
559 };
561
562 //----------------------------------------------------------------------------
564 //----------------------------------------------------------------------------
565 template<bool HasHndl>
566 class StatFsImpl: public FileSystemOperation<StatFsImpl, HasHndl, Resp<StatInfo>,
567 Arg<std::string>>
568 {
569 public:
570
571 //------------------------------------------------------------------------
573 //------------------------------------------------------------------------
576
577 //------------------------------------------------------------------------
579 //------------------------------------------------------------------------
580 enum { PathArg };
581
582 //------------------------------------------------------------------------
584 //------------------------------------------------------------------------
585 std::string ToString()
586 {
587 return "Stat";
588 }
589
590 protected:
591
592 //------------------------------------------------------------------------
598 //------------------------------------------------------------------------
599 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
600 {
601 std::string &path = std::get<PathArg>( this->args ).Get();
602 uint16_t timeout = pipelineTimeout < this->timeout ?
603 pipelineTimeout : this->timeout;
604 return this->filesystem->Stat( path, handler, timeout );
605 }
606 };
607
609 {
610 return StatFsImpl<false>( std::move( fs ), std::move( path ) );
611 }
612
613 //----------------------------------------------------------------------------
615 //----------------------------------------------------------------------------
616 template<bool HasHndl>
617 class StatVFSImpl: public FileSystemOperation<StatVFSImpl, HasHndl,
618 Resp<StatInfoVFS>, Arg<std::string>>
619 {
620 public:
621
622 //------------------------------------------------------------------------
624 //------------------------------------------------------------------------
627
628 //------------------------------------------------------------------------
630 //------------------------------------------------------------------------
631 enum { PathArg };
632
633 //------------------------------------------------------------------------
635 //------------------------------------------------------------------------
636 std::string ToString()
637 {
638 return "StatVFS";
639 }
640
641 protected:
642
643 //------------------------------------------------------------------------
649 //------------------------------------------------------------------------
650 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
651 {
652 std::string &path = std::get<PathArg>( this->args ).Get();
653 uint16_t timeout = pipelineTimeout < this->timeout ?
654 pipelineTimeout : this->timeout;
655 return this->filesystem->StatVFS( path, handler, timeout );
656 }
657 };
659
660 //----------------------------------------------------------------------------
662 //----------------------------------------------------------------------------
663 template<bool HasHndl>
664 class ProtocolImpl: public FileSystemOperation<ProtocolImpl, HasHndl,
665 Resp<ProtocolInfo>>
666 {
667 public:
668
669 //------------------------------------------------------------------------
671 //------------------------------------------------------------------------
673
674 //------------------------------------------------------------------------
676 //------------------------------------------------------------------------
677 std::string ToString()
678 {
679 return "Protocol";
680 }
681
682 protected:
683
684 //------------------------------------------------------------------------
690 //------------------------------------------------------------------------
691 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
692 {
693 uint16_t timeout = pipelineTimeout < this->timeout ?
694 pipelineTimeout : this->timeout;
695 return this->filesystem->Protocol( handler, timeout );
696 }
697 };
699
700 //----------------------------------------------------------------------------
702 //----------------------------------------------------------------------------
703 template<bool HasHndl>
704 class DirListImpl: public FileSystemOperation<DirListImpl, HasHndl, Resp<DirectoryList>,
705 Arg<std::string>, Arg<DirListFlags::Flags>>
706 {
707 public:
708
709 //------------------------------------------------------------------------
711 //------------------------------------------------------------------------
714
715 //------------------------------------------------------------------------
717 //------------------------------------------------------------------------
718 enum { PathArg, FlagsArg };
719
720 //------------------------------------------------------------------------
722 //------------------------------------------------------------------------
723 std::string ToString()
724 {
725 return "DirList";
726 }
727
728 protected:
729
730 //------------------------------------------------------------------------
736 //------------------------------------------------------------------------
737 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
738 {
739 std::string &path = std::get<PathArg>( this->args ).Get();
740 DirListFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
741 uint16_t timeout = pipelineTimeout < this->timeout ?
742 pipelineTimeout : this->timeout;
743 return this->filesystem->DirList( path, flags, handler, timeout );
744 }
745 };
747
748 //----------------------------------------------------------------------------
750 //----------------------------------------------------------------------------
751 template<bool HasHndl>
752 class SendInfoImpl: public FileSystemOperation<SendInfoImpl, HasHndl, Resp<Buffer>,
753 Arg<std::string>>
754 {
755 public:
756
757 //------------------------------------------------------------------------
759 //------------------------------------------------------------------------
762
763 //------------------------------------------------------------------------
765 //------------------------------------------------------------------------
766 enum { InfoArg };
767
768 //------------------------------------------------------------------------
770 //------------------------------------------------------------------------
771 std::string ToString()
772 {
773 return "SendInfo";
774 }
775
776 protected:
777
778 //------------------------------------------------------------------------
784 //------------------------------------------------------------------------
785 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
786 {
787 std::string &info = std::get<InfoArg>( this->args ).Get();
788 uint16_t timeout = pipelineTimeout < this->timeout ?
789 pipelineTimeout : this->timeout;
790 return this->filesystem->SendInfo( info, handler, timeout );
791 }
792 };
794
795 //----------------------------------------------------------------------------
797 //----------------------------------------------------------------------------
798 template<bool HasHndl>
799 class PrepareImpl: public FileSystemOperation<PrepareImpl, HasHndl, Resp<Buffer>,
800 Arg<std::vector<std::string>>, Arg<PrepareFlags::Flags>, Arg<uint8_t>>
801 {
802 public:
803
804 //------------------------------------------------------------------------
806 //------------------------------------------------------------------------
809
810 //------------------------------------------------------------------------
812 //------------------------------------------------------------------------
814
815 //------------------------------------------------------------------------
817 //------------------------------------------------------------------------
818 std::string ToString()
819 {
820 return "Prepare";
821 }
822
823 protected:
824
825 //------------------------------------------------------------------------
831 //------------------------------------------------------------------------
832 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
833 {
834 std::vector<std::string> &fileList = std::get<FileListArg>( this->args ).Get();
835 PrepareFlags::Flags flags = std::get<FlagsArg>( this->args ).Get();
836 uint8_t priority = std::get<PriorityArg>( this->args ).Get();
837 uint16_t timeout = pipelineTimeout < this->timeout ?
838 pipelineTimeout : this->timeout;
839 return this->filesystem->Prepare( fileList, flags, priority,
840 handler, timeout );
841 }
842 };
844
845 //----------------------------------------------------------------------------
847 //----------------------------------------------------------------------------
848 template<bool HasHndl>
849 class SetXAttrFsImpl: public FileSystemOperation<SetXAttrFsImpl, HasHndl, Resp<void>,
850 Arg<std::string>, Arg<std::string>, Arg<std::string>>
851 {
852 public:
853
854 //------------------------------------------------------------------------
856 //------------------------------------------------------------------------
859
860 //------------------------------------------------------------------------
862 //------------------------------------------------------------------------
864
865 //------------------------------------------------------------------------
867 //------------------------------------------------------------------------
868 std::string ToString()
869 {
870 return "SetXAttrFsImpl";
871 }
872
873 protected:
874
875 //------------------------------------------------------------------------
881 //------------------------------------------------------------------------
882 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
883 {
884 std::string &path = std::get<PathArg>( this->args ).Get();
885 std::string &name = std::get<NameArg>( this->args ).Get();
886 std::string &value = std::get<ValueArg>( this->args ).Get();
887 // wrap the arguments with a vector
888 std::vector<xattr_t> attrs;
889 attrs.push_back( xattr_t( name, value ) );
890 // wrap the PipelineHandler so the response gets unpacked properly
892 uint16_t timeout = pipelineTimeout < this->timeout ?
893 pipelineTimeout : this->timeout;
894 XRootDStatus st = this->filesystem->SetXAttr( path, attrs, h, timeout );
895 if( !st.IsOK() ) delete h;
896 return st;
897 }
898 };
899
900 //----------------------------------------------------------------------------
903 //----------------------------------------------------------------------------
906 {
907 return SetXAttrFsImpl<false>( std::move( fs ), std::move( path ), std::move( name ),
908 std::move( value ) );
909 }
910
911 //----------------------------------------------------------------------------
913 //----------------------------------------------------------------------------
914 template<bool HasHndl>
915 class SetXAttrFsBulkImpl: public FileSystemOperation<SetXAttrFsBulkImpl, HasHndl,
916 Resp<std::vector<XAttrStatus>>, Arg<std::string>, Arg<std::vector<xattr_t>>>
917 {
918 public:
919
920 //------------------------------------------------------------------------
922 //------------------------------------------------------------------------
925
926 //------------------------------------------------------------------------
928 //------------------------------------------------------------------------
929 enum { PathArg, AttrsArg };
930
931 //------------------------------------------------------------------------
933 //------------------------------------------------------------------------
934 std::string ToString()
935 {
936 return "SetXAttrBulkImpl";
937 }
938
939
940 protected:
941
942 //------------------------------------------------------------------------
946 //------------------------------------------------------------------------
947 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
948 {
949 std::string &path = std::get<PathArg>( this->args ).Get();
950 std::vector<xattr_t> &attrs = std::get<AttrsArg>( this->args ).Get();
951 uint16_t timeout = pipelineTimeout < this->timeout ?
952 pipelineTimeout : this->timeout;
953 return this->filesystem->SetXAttr( path, attrs, handler, timeout );
954 }
955 };
956
957 //----------------------------------------------------------------------------
960 //----------------------------------------------------------------------------
962 Arg<std::vector<xattr_t>> attrs )
963 {
964 return SetXAttrFsBulkImpl<false>( std::move( fs ), std::move( path ), std::move( attrs ) );
965 }
966
967 //----------------------------------------------------------------------------
969 //----------------------------------------------------------------------------
970 template<bool HasHndl>
971 class GetXAttrFsImpl: public FileSystemOperation<GetXAttrFsImpl, HasHndl, Resp<std::string>,
972 Arg<std::string>, Arg<std::string>>
973 {
974 public:
975
976 //------------------------------------------------------------------------
978 //------------------------------------------------------------------------
981
982 //------------------------------------------------------------------------
984 //------------------------------------------------------------------------
985 enum { PathArg, NameArg };
986
987 //------------------------------------------------------------------------
989 //------------------------------------------------------------------------
990 std::string ToString()
991 {
992 return "GetXAttrFsImpl";
993 }
994
995 protected:
996
997 //------------------------------------------------------------------------
1001 //------------------------------------------------------------------------
1002 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1003 {
1004 std::string &path = std::get<PathArg>( this->args ).Get();
1005 std::string &name = std::get<NameArg>( this->args ).Get();
1006 // wrap the argument with a vector
1007 std::vector<std::string> attrs;
1008 attrs.push_back( name );
1009 // wrap the PipelineHandler so the response gets unpacked properly
1010 UnpackXAttr *h = new UnpackXAttr( handler );
1011 uint16_t timeout = pipelineTimeout < this->timeout ?
1012 pipelineTimeout : this->timeout;
1013 XRootDStatus st = this->filesystem->GetXAttr( path, attrs, h, timeout );
1014 if( !st.IsOK() ) delete h;
1015 return st;
1016 }
1017 };
1018
1019 //----------------------------------------------------------------------------
1022 //----------------------------------------------------------------------------
1024 Arg<std::string> name )
1025 {
1026 return GetXAttrFsImpl<false>( std::move( fs ), std::move( path ), std::move( name ) );
1027 }
1028
1029 //----------------------------------------------------------------------------
1031 //----------------------------------------------------------------------------
1032 template<bool HasHndl>
1033 class GetXAttrFsBulkImpl: public FileSystemOperation<GetXAttrFsBulkImpl, HasHndl,
1034 Resp<std::vector<XAttr>>, Arg<std::string>, Arg<std::vector<std::string>>>
1035 {
1036 public:
1037
1038 //------------------------------------------------------------------------
1040 //------------------------------------------------------------------------
1043
1044 //------------------------------------------------------------------------
1046 //------------------------------------------------------------------------
1048
1049 //------------------------------------------------------------------------
1051 //------------------------------------------------------------------------
1052 std::string ToString()
1053 {
1054 return "GetXAttrFsBulkImpl";
1055 }
1056
1057
1058 protected:
1059
1060 //------------------------------------------------------------------------
1064 //------------------------------------------------------------------------
1065 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1066 {
1067 std::string &path = std::get<PathArg>( this->args ).Get();
1068 std::vector<std::string> &attrs = std::get<NamesArg>( this->args ).Get();
1069 uint16_t timeout = pipelineTimeout < this->timeout ?
1070 pipelineTimeout : this->timeout;
1071 return this->filesystem->GetXAttr( path, attrs, handler, timeout );
1072 }
1073 };
1074
1075 //----------------------------------------------------------------------------
1078 //----------------------------------------------------------------------------
1080 Arg<std::vector<std::string>> attrs )
1081 {
1082 return GetXAttrFsBulkImpl<false>( std::move( fs ), std::move( path ), std::move( attrs ) );
1083 }
1084
1085 //----------------------------------------------------------------------------
1087 //----------------------------------------------------------------------------
1088 template<bool HasHndl>
1089 class DelXAttrFsImpl: public FileSystemOperation<DelXAttrFsImpl, HasHndl, Resp<void>,
1090 Arg<std::string>, Arg<std::string>>
1091 {
1092 public:
1093
1094 //------------------------------------------------------------------------
1096 //------------------------------------------------------------------------
1099
1100 //------------------------------------------------------------------------
1102 //------------------------------------------------------------------------
1103 enum { PathArg, NameArg };
1104
1105 //------------------------------------------------------------------------
1107 //------------------------------------------------------------------------
1108 std::string ToString()
1109 {
1110 return "DelXAttrFsImpl";
1111 }
1112
1113 protected:
1114
1115 //------------------------------------------------------------------------
1121 //------------------------------------------------------------------------
1122 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1123 {
1124 std::string &path = std::get<PathArg>( this->args ).Get();
1125 std::string &name = std::get<NameArg>( this->args ).Get();
1126 // wrap the argument with a vector
1127 std::vector<std::string> attrs;
1128 attrs.push_back( name );
1129 // wrap the PipelineHandler so the response gets unpacked properly
1131 uint16_t timeout = pipelineTimeout < this->timeout ?
1132 pipelineTimeout : this->timeout;
1133 XRootDStatus st = this->filesystem->DelXAttr( path, attrs, h, timeout );
1134 if( !st.IsOK() ) delete h;
1135 return st;
1136 }
1137 };
1138
1139 //----------------------------------------------------------------------------
1142 //----------------------------------------------------------------------------
1144 Arg<std::string> name )
1145 {
1146 return DelXAttrFsImpl<false>( std::move( fs ), std::move( path ), std::move( name ) );
1147 }
1148
1149 //----------------------------------------------------------------------------
1151 //----------------------------------------------------------------------------
1152 template<bool HasHndl>
1153 class DelXAttrFsBulkImpl: public FileSystemOperation<DelXAttrFsBulkImpl, HasHndl,
1154 Resp<std::vector<XAttrStatus>>, Arg<std::string>, Arg<std::vector<std::string>>>
1155 {
1156 public:
1157
1158 //------------------------------------------------------------------------
1160 //------------------------------------------------------------------------
1163
1164 //------------------------------------------------------------------------
1166 //------------------------------------------------------------------------
1168
1169 //------------------------------------------------------------------------
1171 //------------------------------------------------------------------------
1172 std::string ToString()
1173 {
1174 return "DelXAttrBulkImpl";
1175 }
1176
1177
1178 protected:
1179
1180 //------------------------------------------------------------------------
1186 //------------------------------------------------------------------------
1187 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1188 {
1189 std::string &path = std::get<PathArg>( this->args ).Get();
1190 std::vector<std::string> &attrs = std::get<NamesArg>( this->args ).Get();
1191 uint16_t timeout = pipelineTimeout < this->timeout ?
1192 pipelineTimeout : this->timeout;
1193 return this->filesystem->DelXAttr( path, attrs, handler, timeout );
1194 }
1195 };
1196
1197 //----------------------------------------------------------------------------
1200 //----------------------------------------------------------------------------
1202 Arg<std::vector<std::string>> attrs )
1203 {
1204 return DelXAttrFsBulkImpl<false>( std::move( fs ), std::move( path ), std::move( attrs ) );
1205 }
1206
1207 //----------------------------------------------------------------------------
1209 //----------------------------------------------------------------------------
1210 template<bool HasHndl>
1211 class ListXAttrFsImpl: public FileSystemOperation<ListXAttrFsImpl, HasHndl,
1212 Resp<std::vector<XAttr>>, Arg<std::string>>
1213 {
1214 public:
1215
1216 //------------------------------------------------------------------------
1218 //------------------------------------------------------------------------
1221
1222 //------------------------------------------------------------------------
1224 //------------------------------------------------------------------------
1225 enum { PathArg };
1226
1227 //------------------------------------------------------------------------
1229 //------------------------------------------------------------------------
1230 std::string ToString()
1231 {
1232 return "ListXAttrFsImpl";
1233 }
1234
1235 protected:
1236
1237 //------------------------------------------------------------------------
1243 //------------------------------------------------------------------------
1244 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
1245 {
1246 std::string &path = std::get<PathArg>( this->args ).Get();
1247 uint16_t timeout = pipelineTimeout < this->timeout ?
1248 pipelineTimeout : this->timeout;
1249 return this->filesystem->ListXAttr( path, handler, timeout );
1250 }
1251 };
1252
1253 //----------------------------------------------------------------------------
1256 //----------------------------------------------------------------------------
1258 {
1259 return ListXAttrFsImpl<false>( std::move( fs ), std::move( path ) );
1260 }
1261}
1262
1263#endif // __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__
Definition XrdClArg.hh:234
Binary blob representation.
Definition XrdClBuffer.hh:34
ChMod operation (.
Definition XrdClFileSystemOperations.hh:481
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:512
@ PathArg
Definition XrdClFileSystemOperations.hh:493
@ ModeArg
Definition XrdClFileSystemOperations.hh:493
std::string ToString()
Definition XrdClFileSystemOperations.hh:498
Definition XrdClOperations.hh:552
std::tuple< Args... > args
Operation arguments.
Definition XrdClOperations.hh:771
uint16_t timeout
Operation timeout.
Definition XrdClOperations.hh:776
DeepLocate operation (.
Definition XrdClFileSystemOperations.hh:144
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:175
std::string ToString()
Definition XrdClFileSystemOperations.hh:161
@ PathArg
Definition XrdClFileSystemOperations.hh:156
@ FlagsArg
Definition XrdClFileSystemOperations.hh:156
DelXAttr bulk operation (.
Definition XrdClFileSystemOperations.hh:1155
@ NamesArg
Definition XrdClFileSystemOperations.hh:1167
@ PathArg
Definition XrdClFileSystemOperations.hh:1167
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:1187
std::string ToString()
Definition XrdClFileSystemOperations.hh:1172
DelXAttr operation (.
Definition XrdClFileSystemOperations.hh:1091
std::string ToString()
Definition XrdClFileSystemOperations.hh:1108
@ NameArg
Definition XrdClFileSystemOperations.hh:1103
@ PathArg
Definition XrdClFileSystemOperations.hh:1103
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:1122
DirList operation (.
Definition XrdClFileSystemOperations.hh:706
@ FlagsArg
Definition XrdClFileSystemOperations.hh:718
@ PathArg
Definition XrdClFileSystemOperations.hh:718
std::string ToString()
Definition XrdClFileSystemOperations.hh:723
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:737
Definition XrdClFileSystemOperations.hh:46
Ctx< FileSystem > filesystem
The file system object itself.
Definition XrdClFileSystemOperations.hh:87
virtual ~FileSystemOperation()
Destructor.
Definition XrdClFileSystemOperations.hh:78
FileSystemOperation(FileSystemOperation< Derived, from, Response, Args... > &&op)
Definition XrdClFileSystemOperations.hh:70
FileSystemOperation(Ctx< FileSystem > fs, Args... args)
Definition XrdClFileSystemOperations.hh:57
friend class FileSystemOperation
Definition XrdClFileSystemOperations.hh:48
GetXAttr bulk operation (.
Definition XrdClFileSystemOperations.hh:1035
@ PathArg
Definition XrdClFileSystemOperations.hh:1047
@ NamesArg
Definition XrdClFileSystemOperations.hh:1047
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:1065
std::string ToString()
Definition XrdClFileSystemOperations.hh:1052
GetXAttr operation (.
Definition XrdClFileSystemOperations.hh:973
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:1002
@ NameArg
Definition XrdClFileSystemOperations.hh:985
@ PathArg
Definition XrdClFileSystemOperations.hh:985
std::string ToString()
Definition XrdClFileSystemOperations.hh:990
ListXAttr bulk operation (.
Definition XrdClFileSystemOperations.hh:1213
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:1244
@ PathArg
Definition XrdClFileSystemOperations.hh:1225
std::string ToString()
Definition XrdClFileSystemOperations.hh:1230
Locate operation (.
Definition XrdClFileSystemOperations.hh:96
std::string ToString()
Definition XrdClFileSystemOperations.hh:113
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:127
MkDir operation (.
Definition XrdClFileSystemOperations.hh:386
std::string ToString()
Definition XrdClFileSystemOperations.hh:403
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:417
@ FlagsArg
Definition XrdClFileSystemOperations.hh:398
@ ModeArg
Definition XrdClFileSystemOperations.hh:398
@ PathArg
Definition XrdClFileSystemOperations.hh:398
Mv operation (.
Definition XrdClFileSystemOperations.hh:192
@ SourceArg
Definition XrdClFileSystemOperations.hh:204
@ DestArg
Definition XrdClFileSystemOperations.hh:204
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:223
std::string ToString()
Definition XrdClFileSystemOperations.hh:209
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition XrdClOperations.hh:309
Ping operation (.
Definition XrdClFileSystemOperations.hh:528
std::string ToString()
Definition XrdClFileSystemOperations.hh:539
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:553
Definition XrdClOperations.hh:64
Prepare operation (.
Definition XrdClFileSystemOperations.hh:801
@ PriorityArg
Definition XrdClFileSystemOperations.hh:813
@ FlagsArg
Definition XrdClFileSystemOperations.hh:813
@ FileListArg
Definition XrdClFileSystemOperations.hh:813
std::string ToString()
Definition XrdClFileSystemOperations.hh:818
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:832
Protocol operation (.
Definition XrdClFileSystemOperations.hh:666
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:691
std::string ToString()
Definition XrdClFileSystemOperations.hh:677
Query operation (.
Definition XrdClFileSystemOperations.hh:240
@ BufferArg
Definition XrdClFileSystemOperations.hh:252
@ QueryCodeArg
Definition XrdClFileSystemOperations.hh:252
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:271
std::string ToString()
Definition XrdClFileSystemOperations.hh:257
RmDir operation (.
Definition XrdClFileSystemOperations.hh:435
std::string ToString()
Definition XrdClFileSystemOperations.hh:451
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:465
@ PathArg
Definition XrdClFileSystemOperations.hh:446
Rm operation (.
Definition XrdClFileSystemOperations.hh:340
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:370
@ PathArg
Definition XrdClFileSystemOperations.hh:351
std::string ToString()
Definition XrdClFileSystemOperations.hh:356
SendInfo operation (.
Definition XrdClFileSystemOperations.hh:754
std::string ToString()
Definition XrdClFileSystemOperations.hh:771
@ InfoArg
Definition XrdClFileSystemOperations.hh:766
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:785
SetXAttr bulk operation (.
Definition XrdClFileSystemOperations.hh:917
@ AttrsArg
Definition XrdClFileSystemOperations.hh:929
@ PathArg
Definition XrdClFileSystemOperations.hh:929
std::string ToString()
Definition XrdClFileSystemOperations.hh:934
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:947
SetXAttr operation (.
Definition XrdClFileSystemOperations.hh:851
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:882
std::string ToString()
Definition XrdClFileSystemOperations.hh:868
@ PathArg
Definition XrdClFileSystemOperations.hh:863
@ ValueArg
Definition XrdClFileSystemOperations.hh:863
@ NameArg
Definition XrdClFileSystemOperations.hh:863
Stat operation (.
Definition XrdClFileSystemOperations.hh:568
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:599
@ PathArg
Definition XrdClFileSystemOperations.hh:580
std::string ToString()
Definition XrdClFileSystemOperations.hh:585
StatVS operation (.
Definition XrdClFileSystemOperations.hh:619
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:650
@ PathArg
Definition XrdClFileSystemOperations.hh:631
std::string ToString()
Definition XrdClFileSystemOperations.hh:636
Truncate operation (.
Definition XrdClFileSystemOperations.hh:288
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClFileSystemOperations.hh:319
@ SizeArg
Definition XrdClFileSystemOperations.hh:300
@ PathArg
Definition XrdClFileSystemOperations.hh:300
std::string ToString()
Definition XrdClFileSystemOperations.hh:305
Helper class for unpacking single XAttrStatus from bulk response.
Definition XrdClOperationHandlers.hh:42
Helper class for unpacking single XAttr from bulk response.
Definition XrdClOperationHandlers.hh:77
Request status.
Definition XrdClXRootDResponses.hh:219
Definition XrdClAction.hh:34
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
Definition XrdClFileOperations.hh:1139
SendInfoImpl< false > SendInfo
Definition XrdClFileSystemOperations.hh:793
ChModImpl< false > ChMod
Definition XrdClFileSystemOperations.hh:521
MkDirImpl< false > MkDir
Definition XrdClFileSystemOperations.hh:427
RmImpl< false > Rm
Definition XrdClFileSystemOperations.hh:378
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
Definition XrdClFileOperations.hh:535
MvImpl< false > Mv
Definition XrdClFileSystemOperations.hh:232
LocateImpl< false > Locate
Definition XrdClFileSystemOperations.hh:136
DelXAttrImpl< false > DelXAttr(Ctx< File > file, Arg< std::string > name)
Definition XrdClFileOperations.hh:1256
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size, uint16_t timeout)
Definition XrdClFileOperations.hh:692
DeepLocateImpl< false > DeepLocate
Definition XrdClFileSystemOperations.hh:184
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
Definition XrdClFileOperations.hh:1021
ProtocolImpl< false > Protocol
Definition XrdClFileSystemOperations.hh:698
ListXAttrImpl< false > ListXAttr(Ctx< File > file)
Definition XrdClFileOperations.hh:1361
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition XrdClXRootDResponses.hh:289
RmDirImpl< false > RmDir
Definition XrdClFileSystemOperations.hh:473
PrepareImpl< false > Prepare
Definition XrdClFileSystemOperations.hh:843
StatVFSImpl< false > StatVFS
Definition XrdClFileSystemOperations.hh:658
PingImpl< false > Ping
Definition XrdClFileSystemOperations.hh:560
DirListImpl< false > DirList
Definition XrdClFileSystemOperations.hh:746
QueryImpl< false > Query
Definition XrdClFileSystemOperations.hh:280
Definition XrdOucJson.hh:4517
Mode
Access mode.
Definition XrdClFileSystem.hh:122
Utility class for storing a pointer to operation context.
Definition XrdClCtx.hh:39
Flags
Definition XrdClFileSystem.hh:156
Flags
Definition XrdClFileSystem.hh:143
Flags
Open flags, may be or'd when appropriate.
Definition XrdClFileSystem.hh:76
Flags
Definition XrdClFileSystem.hh:176
Code
XRootD query request codes.
Definition XrdClFileSystem.hh:53
Definition XrdClOperationHandlers.hh:662
bool IsOK() const
We're fine.
Definition XrdClStatus.hh:124