irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

libnonblocking.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // irods includes
3 #include "msParam.h"
4 #include "rcConnect.h"
5 #include "miscServerFunct.hpp"
6 
7 // =-=-=-=-=-=-=-
9 #include "irods_file_object.hpp"
15 #include "irods_stacktrace.hpp"
17 
18 // =-=-=-=-=-=-=-
19 // stl includes
20 #include <iostream>
21 #include <sstream>
22 #include <vector>
23 #include <string>
24 
25 // =-=-=-=-=-=-=-
26 // boost includes
27 #include <boost/function.hpp>
28 #include <boost/any.hpp>
29 
30 // =-=-=-=-=-=-=-
31 // system includes
32 #ifndef _WIN32
33 #include <sys/file.h>
34 #include <sys/param.h>
35 #endif
36 #include <errno.h>
37 #include <sys/stat.h>
38 #include <string.h>
39 #ifndef _WIN32
40 #include <unistd.h>
41 #endif
42 #include <sys/types.h>
43 #if defined(osx_platform)
44 #include <sys/malloc.h>
45 #else
46 #include <malloc.h>
47 #endif
48 #include <fcntl.h>
49 #ifndef _WIN32
50 #include <sys/file.h>
51 #include <unistd.h>
52 #endif
53 #include <dirent.h>
54 
55 #if defined(solaris_platform)
56 #include <sys/statvfs.h>
57 #endif
58 
59 #if defined(osx_platform)
60 #include <sys/param.h>
61 #include <sys/mount.h>
62 #endif
63 
64 #if defined(linux_platform)
65 #include <sys/vfs.h>
66 #endif
67 #include <sys/stat.h>
68 
69 #include <string.h>
70 
71 #define NB_READ_TOUT_SEC 60 /* 60 sec timeout */
72 #define NB_WRITE_TOUT_SEC 60 /* 60 sec timeout */
73 
74 // =-=-=-=-=-=-=-
75 // 1. Define utility functions that the operations might need
76 
77 // =-=-=-=-=-=-=-
78 // NOTE: All storage resources must do this on the physical path stored in the file object and then update
79 // the file object's physical path with the full path
80 
81 // =-=-=-=-=-=-=-
84  irods::plugin_property_map& _prop_map,
85  const std::string& _phy_path,
86  std::string& _ret_string ) {
87  irods::error result = SUCCESS();
88  irods::error ret;
89  std::string vault_path;
90  // TODO - getting vault path by property will not likely work for coordinating nodes
91  ret = _prop_map.get<std::string>( irods::RESOURCE_PATH, vault_path );
92  if ( ( result = ASSERT_ERROR( ret.ok(), SYS_INVALID_INPUT_PARAM, "resource has no vault path." ) ).ok() ) {
93  if ( _phy_path.compare( 0, 1, "/" ) != 0 &&
94  _phy_path.compare( 0, vault_path.size(), vault_path ) != 0 ) {
95  _ret_string = vault_path;
96  _ret_string += "/";
97  _ret_string += _phy_path;
98  }
99  else {
100  // The physical path already contains the vault path
101  _ret_string = _phy_path;
102  }
103  }
104 
105  return result;
106 
107 } // non_blocking_generate_full_path
108 
109 // =-=-=-=-=-=-=-
112  irods::plugin_context& _ctx ) {
113  irods::error result = SUCCESS();
114 
115  // =-=-=-=-=-=-=-
116  // try dynamic cast on ptr, throw error otherwise
117  irods::data_object_ptr data_obj = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
118  if ( ( result = ASSERT_ERROR( data_obj.get(), SYS_INVALID_INPUT_PARAM, "Failed to cast fco to data_object." ) ).ok() ) {
119 
120  // =-=-=-=-=-=-=-
121  // NOTE: Must do this for all storage resources
122  std::string full_path;
124  data_obj->physical_path(),
125  full_path );
126  if ( ( result = ASSERT_PASS( ret, "Failed generating full path for object." ) ).ok() ) {
127  data_obj->physical_path( full_path );
128  }
129  }
130 
131  return result;
132 
133 } // non_blocking_check_path
134 
135 // =-=-=-=-=-=-=-
137 template< typename DEST_TYPE >
139  irods::plugin_context& _ctx ) {
140 
141  irods::error result = SUCCESS();
142  irods::error ret;
143 
144  // =-=-=-=-=-=-=-
145  // verify that the resc context is valid
146  ret = _ctx.valid< DEST_TYPE >();
147  if ( ( result = ASSERT_PASS( ret, "resource context is invalid." ) ).ok() ) {
148  result = non_blocking_check_path( _ctx );
149  }
150 
151  return result;
152 
153 } // non_blocking_check_params_and_path
154 
155 // =-=-=-=-=-=-=-
158  irods::plugin_context& _ctx ) {
159 
160  irods::error result = SUCCESS();
161  irods::error ret;
162 
163  // =-=-=-=-=-=-=-
164  // verify that the resc context is valid
165  ret = _ctx.valid();
166  if ( ( result = ASSERT_PASS( ret, "non_blocking_check_params_and_path - resource context is invalid" ) ).ok() ) {
167  result = non_blocking_check_path( _ctx );
168  }
169 
170  return result;
171 
172 } // non_blocking_check_params_and_path
173 
174 // =-=-=-=-=-=-=-
175 //@brief Recursively make all of the dirs in the path
177  const std::string& path,
178  mode_t mode ) {
179  irods::error result = SUCCESS();
180  std::string subdir;
181  std::size_t pos = 0;
182  bool done = false;
183  while ( !done && result.ok() ) {
184  pos = path.find_first_of( '/', pos + 1 );
185  if ( pos > 0 ) {
186  subdir = path.substr( 0, pos );
187  int status = mkdir( subdir.c_str(), mode );
188 
189  // =-=-=-=-=-=-=-
190  // handle error cases
191  result = ASSERT_ERROR( status >= 0 || errno == EEXIST, UNIX_FILE_RENAME_ERR - errno, "mkdir error for \"%s\", errno = \"%s\", status = %d.",
192  subdir.c_str(), strerror( errno ), status );
193  }
194  if ( pos == std::string::npos ) {
195  done = true;
196  }
197  }
198 
199  return result;
200 
201 } // non_blocking_file_mkdir_r
202 
203 // =-=-=-=-=-=-=-
204 // 2. Define operations which will be called by the file*
205 // calls declared in server/driver/include/fileDriver.h
206 // =-=-=-=-=-=-=-
207 
208 // =-=-=-=-=-=-=-
209 // NOTE :: to access properties in the _prop_map do the
210 // :: following :
211 // :: double my_var = 0.0;
212 // :: irods::error ret = _prop_map.get< double >( "my_key", my_var );
213 // =-=-=-=-=-=-=-
214 
218  irods::plugin_context& _ctx ) {
219  irods::error result = SUCCESS();
220 
221  // Check the operation parameters and update the physical path
223  result = ASSERT_PASS( ret, "Invalid parameters or physical path." );
224 
225  // NOOP
226  return result;
227 }
228 
232  irods::plugin_context& _ctx ) {
233  irods::error result = SUCCESS();
234 
235  // Check the operation parameters and update the physical path
237  result = ASSERT_PASS( ret, "Invalid parameters or physical path." );
238 
239  // NOOP
240  return result;
241 }
242 
246  irods::plugin_context& _ctx ) {
247  irods::error result = SUCCESS();
248 
249  // Check the operation parameters and update the physical path
251  result = ASSERT_PASS( ret, "Invalid parameters or physical path." );
252 
253  // NOOP
254  return result;
255 }
256 
260  irods::plugin_context& _ctx,
261  const std::string* ) {
262  irods::error result = SUCCESS();
263  // Check the operation parameters and update the physical path
265  result = ASSERT_PASS( ret, "Invalid parameters or physical path." );
266 
267  // NOOP
268  return result;
269 }
270 
271 // =-=-=-=-=-=-=-
272 // interface to determine free space on a device given a path
274  irods::plugin_context& _ctx ) {
275  irods::error result = SUCCESS();
276 
277  // =-=-=-=-=-=-=-
278  // Check the operation parameters and update the physical path
280  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
281 
282  // =-=-=-=-=-=-=-
283  // cast down the hierarchy to the desired object
284  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
285  size_t found = fco->physical_path().find_last_of( "/" );
286  std::string path = fco->physical_path().substr( 0, found + 1 );
287  int status = -1;
289 #if defined(solaris_platform)
290  struct statvfs statbuf;
291 #else
292  struct statfs statbuf;
293 #endif
294 
295 #if defined(solaris_platform) || defined(sgi_platform) || \
296 defined(aix_platform) || defined(linux_platform) || \
297 defined(osx_platform)
298 #if defined(solaris_platform)
299  status = statvfs( path.c_str(), &statbuf );
300 #else
301 #if defined(sgi_platform)
302  status = statfs( path.c_str(), &statbuf, sizeof( struct statfs ), 0 );
303 #else
304  status = statfs( path.c_str(), &statbuf );
305 #endif
306 #endif
307 
308  // =-=-=-=-=-=-=-
309  // handle error, if any
310  int err_status = UNIX_FILE_GET_FS_FREESPACE_ERR - errno;
311  if ( ( result = ASSERT_ERROR( status >= 0, err_status, "Statfs error for \"%s\", status = %d.",
312  path.c_str(), err_status ) ).ok() ) {
313 
314 #if defined(sgi_platform)
315  if ( statbuf.f_frsize > 0 ) {
316  fssize = statbuf.f_frsize;
317  }
318  else {
319  fssize = statbuf.f_bsize;
320  }
321  fssize *= statbuf.f_bavail;
322 #endif
323 
324 #if defined(aix_platform) || defined(osx_platform) || \
325 defined(linux_platform)
326  fssize = statbuf.f_bavail * statbuf.f_bsize;
327 #endif
328 
329 #if defined(sgi_platform)
330  fssize = statbuf.f_bfree * statbuf.f_bsize;
331 #endif
332  result.code( fssize );
333  }
334 
335 #endif /* solaris_platform, sgi_platform .... */
336  }
337 
338  return result;
339 
340 } // non_blocking_file_get_fsfreespace
341 
342 // =-=-=-=-=-=-=-
343 // interface for POSIX create
345  irods::plugin_context& _ctx ) {
346  irods::error result = SUCCESS();
347 
348  // =-=-=-=-=-=-=-
349  // Check the operation parameters and update the physical path
351  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
352 
353  // =-=-=-=-=-=-=-
354  // get ref to fco
355  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
356 
357  ret = non_blocking_file_getfs_freespace( _ctx );
358  if ( ( result = ASSERT_PASS( ret, "Error determining freespace on system." ) ).ok() ) {
359  rodsLong_t file_size = fco->size();
360  if ( ( result = ASSERT_ERROR( file_size < 0 || ret.code() >= file_size, USER_FILE_TOO_LARGE, "File size: %ld is greater than space left on device: %ld",
361  file_size, ret.code() ) ).ok() ) {
362 
363  // =-=-=-=-=-=-=-
364  // make call to umask & open for create
365  mode_t myMask = umask( ( mode_t ) 0000 );
366  int fd = open( fco->physical_path().c_str(), O_RDWR | O_CREAT | O_EXCL, fco->mode() );
367  int errsav = errno;
368 
369  // =-=-=-=-=-=-=-
370  // reset the old mask
371  ( void ) umask( ( mode_t ) myMask );
372 
373  // =-=-=-=-=-=-=-
374  // if we got a 0 descriptor, try again
375  if ( fd == 0 ) {
376 
377  close( fd );
378  int null_fd = open( "/dev/null", O_RDWR, 0 );
379  fd = open( fco->physical_path().c_str(), O_RDWR | O_CREAT | O_EXCL, fco->mode() );
380  errsav = errno;
381  if ( null_fd >= 0 ) {
382  close( null_fd );
383  }
384  rodsLog( LOG_NOTICE, "non_blocking_file_create: 0 descriptor" );
385  }
386 
387  // =-=-=-=-=-=-=-
388  // trap error case with bad fd
389  if ( fd < 0 ) {
390  int status = UNIX_FILE_CREATE_ERR - errsav;
391  std::stringstream msg;
392  msg << "create error for \"";
393  msg << fco->physical_path();
394  msg << "\", errno = \"";
395  msg << strerror( errsav );
396  msg << "\".";
397  // =-=-=-=-=-=-=-
398  // WARNING :: Major Assumptions are made upstream and use the FD also as a
399  // :: Status, if this is not done EVERYTHING BREAKS!!!!111one
400  fco->file_descriptor( status );
401  result = ERROR( status, msg.str() );
402  }
403  else {
404  // =-=-=-=-=-=-=-
405  // cache file descriptor in out-variable
406  fco->file_descriptor( fd );
407  result.code( fd );
408  }
409  }
410  }
411  }
412  // =-=-=-=-=-=-=-
413  // declare victory!
414  return result;
415 
416 } // non_blocking_file_create
417 
418 // =-=-=-=-=-=-=-
419 // interface for POSIX Open
421  irods::plugin_context& _ctx ) {
422  irods::error result = SUCCESS();
423 
424  // =-=-=-=-=-=-=-
425  // Check the operation parameters and update the physical path
427  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
428 
429  // =-=-=-=-=-=-=-
430  // get ref to fco
431  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
432 
433  // =-=-=-=-=-=-=-
434  // handle OSX weirdness...
435  int flags = fco->flags();
436 
437 #if defined(osx_platform)
438  // For osx, O_TRUNC = 0x0400, O_TRUNC = 0x200 for other system
439  if ( flags & 0x200 ) {
440  flags = flags ^ 0x200;
441  flags = flags | O_TRUNC;
442  }
443 #endif
444  // =-=-=-=-=-=-=-
445  // make call to open
446  errno = 0;
447  int fd = open( fco->physical_path().c_str(), flags, fco->mode() );
448  int errsav = errno;
449 
450  // =-=-=-=-=-=-=-
451  // if we got a 0 descriptor, try again
452  if ( fd == 0 ) {
453  close( fd );
454  int null_fd = open( "/dev/null", O_RDWR, 0 );
455  fd = open( fco->physical_path().c_str(), flags, fco->mode() );
456  errsav = errno;
457  if ( null_fd >= 0 ) {
458  close( null_fd );
459  }
460  rodsLog( LOG_NOTICE, "non_blocking_file_open: 0 descriptor" );
461  }
462 
463  // =-=-=-=-=-=-=-
464  // cache status in the file object
465  fco->file_descriptor( fd );
466 
467  // =-=-=-=-=-=-=-
468  // did we still get an error?
469  int status = UNIX_FILE_OPEN_ERR - errsav;
470  if ( fd < 0 ) {
471  std::stringstream msg;
472  msg << "Open error for \"";
473  msg << fco->physical_path();
474  msg << "\", errno = \"";
475  msg << strerror( errsav );
476  msg << "\", status = ";
477  msg << status;
478  msg << ", flags = ";
479  msg << flags;
480  msg << ".";
481  result = ERROR( status, msg.str() );
482  }
483  else {
484  result.code( fd );
485  }
486  }
487 
488  // =-=-=-=-=-=-=-
489  // declare victory!
490  return result;
491 
492 } // non_blocking_file_open
493 
494 // =-=-=-=-=-=-=-
495 // interface for POSIX Read
497  irods::plugin_context& _ctx,
498  void* _buf,
499  int _len ) {
500  irods::error result = SUCCESS();
501 
502  // =-=-=-=-=-=-=-
503  // Check the operation parameters and update the physical path
505  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
506 
507  // =-=-=-=-=-=-=-
508  // get ref to fco
509  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
510  int status;
511  struct timeval tv;
512  int nbytes;
513  int toRead;
514  char *tmpPtr;
515  fd_set set;
516  int fd = fco->file_descriptor();
517 
518  bzero( &tv, sizeof( tv ) );
519  tv.tv_sec = NB_READ_TOUT_SEC;
520 
521  /* Initialize the file descriptor set. */
522  FD_ZERO( &set );
523  FD_SET( fd, &set );
524 
525  toRead = _len;
526  tmpPtr = ( char * ) _buf;
527 
528  while ( toRead > 0 ) {
529 #ifndef _WIN32
530  status = select( fd + 1, &set, NULL, NULL, &tv );
531  if ( status == 0 ) {
532  /* timedout */
533  if ( _len - toRead > 0 ) {
534  return CODE( _len - toRead );
535  }
536  else {
537  std::stringstream msg;
538  msg << "timeout error.";
539  return ERROR( UNIX_FILE_OPR_TIMEOUT_ERR - errno, msg.str() );
540  }
541  }
542  else if ( status < 0 ) {
543  if ( errno == EINTR ) {
544  errno = 0;
545  continue;
546  }
547  else {
548  std::stringstream msg;
549  msg << "file read error.";
550  return ERROR( UNIX_FILE_READ_ERR - errno, msg.str() );
551  }
552  }
553 #endif
554 
555  nbytes = read( fco->file_descriptor(), ( void * ) tmpPtr, toRead );
556  if ( nbytes < 0 ) {
557  if ( errno == EINTR ) {
558  /* interrupted */
559  errno = 0;
560  nbytes = 0;
561  }
562  else if ( toRead == _len ) {
563  return ERROR( UNIX_FILE_READ_ERR - errno, "file read error" );
564  }
565  else {
566  nbytes = 0;
567  break;
568  }
569  }
570  else if ( nbytes == 0 ) {
571  break;
572  }
573 
574  toRead -= nbytes;
575  tmpPtr += nbytes;
576 
577  } // while
578 
579  result.code( _len - toRead );
580  }
581 
582  // =-=-=-=-=-=-=-
583  // win!
584  return result;
585 
586 } // non_blocking_file_read
587 
588 // =-=-=-=-=-=-=-
589 // interface for POSIX Write
591  irods::plugin_context& _ctx,
592  void* _buf,
593  int _len ) {
594  irods::error result = SUCCESS();
595 
596  // =-=-=-=-=-=-=-
597  // Check the operation parameters and update the physical path
599  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
600  // =-=-=-=-=-=-=-
601  // get ref to fco
602  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
603 
604  int fd = fco->file_descriptor();
605  int nbytes = 0;
606  int toWrite = 0;
607  int status = 0;
608  char* tmpPtr = 0;
609 
610  struct timeval tv;
611  bzero( &tv, sizeof( tv ) );
612  tv.tv_sec = NB_WRITE_TOUT_SEC;
613 
614  /* Initialize the file descriptor set. */
615  fd_set set;
616  FD_ZERO( &set );
617  FD_SET( fd, &set );
618 
619  toWrite = _len;
620  tmpPtr = ( char * ) _buf;
621 
622  while ( toWrite > 0 ) {
623 #ifndef _WIN32
624  status = select( fd + 1, NULL, &set, NULL, &tv );
625  if ( status == 0 ) {
626  /* timedout */
627  return ERROR( UNIX_FILE_OPR_TIMEOUT_ERR - errno, "time out error" );;
628  }
629  else if ( status < 0 ) {
630  if ( errno == EINTR ) {
631  errno = 0;
632  continue;
633  }
634  else {
635  return ERROR( UNIX_FILE_WRITE_ERR - errno, "file write error" );
636  }
637  }
638 #endif
639 
640  nbytes = write( fco->file_descriptor(), ( void * ) tmpPtr, _len );
641  if ( nbytes < 0 ) {
642  if ( errno == EINTR ) {
643  /* interrupted */
644  errno = 0;
645  nbytes = 0;
646  }
647  else {
648  return ERROR( UNIX_FILE_WRITE_ERR - errno, "file write error" );
649  }
650  }
651 
652  toWrite -= nbytes;
653  tmpPtr += nbytes;
654 
655  } // while
656 
657  result.code( _len );
658 
659  }
660 
661  // =-=-=-=-=-=-=-
662  // win!
663  return result;
664 
665 } // non_blocking_file_write
666 
667 // =-=-=-=-=-=-=-
668 // interface for POSIX Close
670  irods::plugin_context& _ctx ) {
671  irods::error result = SUCCESS();
672 
673  // =-=-=-=-=-=-=-
674  // Check the operation parameters and update the physical path
676  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
677 
678  // =-=-=-=-=-=-=-
679  // get ref to fco
680  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
681 
682  // =-=-=-=-=-=-=-
683  // make the call to close
684  int status = close( fco->file_descriptor() );
685 
686  // =-=-=-=-=-=-=-
687  // log any error
688  int err_status = UNIX_FILE_CLOSE_ERR - errno;
689  if ( !( result = ASSERT_ERROR( status >= 0, err_status, "Close error for file: \"%s\", errno = \"%s\", status = %d.",
690  fco->physical_path().c_str(), strerror( errno ), err_status ) ).ok() ) {
691  result.code( err_status );
692  }
693  else {
694  result.code( status );
695  }
696  }
697 
698  return result;
699 
700 } // non_blocking_file_close
701 
702 // =-=-=-=-=-=-=-
703 // interface for POSIX Unlink
705  irods::plugin_context& _ctx ) {
706  irods::error result = SUCCESS();
707 
708  // =-=-=-=-=-=-=-
709  // Check the operation parameters and update the physical path
711  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
712 
713  // =-=-=-=-=-=-=-
714  // get ref to fco
715  irods::data_object_ptr fco = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
716 
717  // =-=-=-=-=-=-=-
718  // make the call to unlink
719  int status = unlink( fco->physical_path().c_str() );
720 
721  // =-=-=-=-=-=-=-
722  // error handling
723  int err_status = UNIX_FILE_UNLINK_ERR - errno;
724  if ( !( result = ASSERT_ERROR( status >= 0, err_status, "Unlink error for \"%s\", errno = \"%s\", status = %d.",
725  fco->physical_path().c_str(), strerror( errno ), err_status ) ).ok() ) {
726 
727  result.code( err_status );
728  }
729  else {
730  result.code( status );
731  }
732  }
733 
734  return result;
735 
736 } // non_blocking_file_unlink
737 
738 // =-=-=-=-=-=-=-
739 // interface for POSIX Stat
741  irods::plugin_context& _ctx,
742  struct stat* _statbuf ) {
743  irods::error result = SUCCESS();
744 
745  // =-=-=-=-=-=-=-
746  // NOTE:: this function assumes the object's physical path is
747  // correct and should not have the vault path
748  // prepended - hcj
749 
750  irods::error ret = _ctx.valid();
751  if ( ( result = ASSERT_PASS( ret, "resource context is invalid." ) ).ok() ) {
752 
753  // =-=-=-=-=-=-=-
754  // get ref to fco
755  irods::data_object_ptr fco = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
756 
757  // =-=-=-=-=-=-=-
758  // make the call to stat
759  int status = stat( fco->physical_path().c_str(), _statbuf );
760 
761  // =-=-=-=-=-=-=-
762  // return an error if necessary
763  int err_status = UNIX_FILE_STAT_ERR - errno;
764  if ( ( result = ASSERT_ERROR( status >= 0, err_status, "Stat error for \"%s\", errno = \"%s\", status = %d.",
765  fco->physical_path().c_str(), strerror( errno ), err_status ) ).ok() ) {
766  result.code( status );
767  }
768  }
769 
770  return result;
771 
772 } // non_blocking_file_stat
773 
774 // =-=-=-=-=-=-=-
775 // interface for POSIX lseek
777  irods::plugin_context& _ctx,
778  long long _offset,
779  int _whence ) {
780  irods::error result = SUCCESS();
781 
782  // =-=-=-=-=-=-=-
783  // Check the operation parameters and update the physical path
785  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
786 
787  // =-=-=-=-=-=-=-
788  // get ref to fco
789  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
790 
791  // =-=-=-=-=-=-=-
792  // make the call to lseek
793  long long status = lseek( fco->file_descriptor(), _offset, _whence );
794 
795  // =-=-=-=-=-=-=-
796  // return an error if necessary
797  long long err_status = UNIX_FILE_LSEEK_ERR - errno;
798  if ( ( result = ASSERT_ERROR( status >= 0, err_status, "Lseek error for \"%s\", errno = \"%s\", status = %ld.",
799  fco->physical_path().c_str(), strerror( errno ), err_status ) ).ok() ) {
800  result.code( status );
801  }
802  }
803 
804  return result;
805 
806 } // non_blocking_file_lseek
807 
808 // =-=-=-=-=-=-=-
809 // interface for POSIX mkdir
811  irods::plugin_context& _ctx ) {
812  irods::error result = SUCCESS();
813 
814  // =-=-=-=-=-=-=-
815  // NOTE :: this function assumes the object's physical path is correct and
816  // should not have the vault path prepended - hcj
817 
819  if ( ( result = ASSERT_PASS( ret, "resource context is invalid." ) ).ok() ) {
820 
821  // =-=-=-=-=-=-=-
822  // cast down the chain to our understood object type
823  irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
824 
825  // =-=-=-=-=-=-=-
826  // make the call to mkdir & umask
827  mode_t myMask = umask( ( mode_t ) 0000 );
828  int status = mkdir( fco->physical_path().c_str(), fco->mode() );
829 
830  // =-=-=-=-=-=-=-
831  // reset the old mask
832  umask( ( mode_t ) myMask );
833 
834  // =-=-=-=-=-=-=-
835  // return an error if necessary
836  result.code( status );
837  int err_status = UNIX_FILE_MKDIR_ERR - errno;
838  if ( ( result = ASSERT_ERROR( status >= 0, err_status, "Mkdir error for \"%s\", errno = \"%s\", status = %d.",
839  fco->physical_path().c_str(), strerror( errno ), err_status ) ).ok() ) {
840  result.code( status );
841  }
842  }
843  return result;
844 
845 } // non_blocking_file_mkdir
846 
847 // =-=-=-=-=-=-=-
848 // interface for POSIX rmdir
850  irods::plugin_context& _ctx ) {
851  irods::error result = SUCCESS();
852 
853  // =-=-=-=-=-=-=-
854  // Check the operation parameters and update the physical path
856  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
857 
858  // =-=-=-=-=-=-=-
859  // cast down the chain to our understood object type
860  irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
861 
862  // =-=-=-=-=-=-=-
863  // make the call to chmod
864  int status = rmdir( fco->physical_path().c_str() );
865 
866  // =-=-=-=-=-=-=-
867  // return an error if necessary
868  int err_status = UNIX_FILE_RMDIR_ERR - errno;
869  result = ASSERT_ERROR( status >= 0, err_status, "Rmdir error for \"%s\", errno = \"%s\", status = %d.",
870  fco->physical_path().c_str(), strerror( errno ), err_status );
871  }
872 
873  return result;
874 
875 } // non_blocking_file_rmdir
876 
877 // =-=-=-=-=-=-=-
878 // interface for POSIX opendir
880  irods::plugin_context& _ctx ) {
881  irods::error result = SUCCESS();
882 
883  // =-=-=-=-=-=-=-
884  // Check the operation parameters and update the physical path
885  irods::error ret = non_blocking_check_params_and_path< irods::collection_object >( _ctx );
886  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
887 
888  // =-=-=-=-=-=-=-
889  // cast down the chain to our understood object type
890  irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
891 
892  // =-=-=-=-=-=-=-
893  // make the call to opendir
894  DIR* dir_ptr = opendir( fco->physical_path().c_str() );
895 
896  // =-=-=-=-=-=-=-
897  // cache status in out variable
898  int err_status = UNIX_FILE_OPENDIR_ERR - errno;
899 
900  // =-=-=-=-=-=-=-
901  // return an error if necessary
902  if ( NULL != dir_ptr ) {
903  // =-=-=-=-=-=-=-
904  // cache dir_ptr in out variables
905  fco->directory_pointer( dir_ptr );
906  }
907  else {
908  std::stringstream msg;
909  msg << "Opendir error for \"";
910  msg << fco->physical_path();
911  msg << "\", errno = \"";
912  msg << strerror( errno );
913  msg << "\", status = ";
914  msg << err_status;
915  msg << ".";
916  result = ERROR( err_status, msg.str() );
917  }
918  }
919 
920  return result;
921 
922 } // non_blocking_file_opendir
923 
924 // =-=-=-=-=-=-=-
925 // interface for POSIX closedir
927  irods::plugin_context& _ctx ) {
928  irods::error result = SUCCESS();
929 
930  // =-=-=-=-=-=-=-
931  // Check the operation parameters and update the physical path
932  irods::error ret = non_blocking_check_params_and_path< irods::collection_object >( _ctx );
933  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
934 
935  // =-=-=-=-=-=-=-
936  // cast down the chain to our understood object type
937  irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
938 
939  // =-=-=-=-=-=-=-
940  // make the call to opendir
941  int status = closedir( fco->directory_pointer() );
942 
943  // =-=-=-=-=-=-=-
944  // return an error if necessary
945  int err_status = UNIX_FILE_CLOSEDIR_ERR - errno;
946  result = ASSERT_ERROR( status >= 0, err_status, "Closedir error for \"%s\", errno = \"%s\", status = %d.",
947  fco->physical_path().c_str(), strerror( errno ), err_status );
948  }
949 
950  return result;
951 
952 } // non_blocking_file_closedir
953 
954 // =-=-=-=-=-=-=-
955 // interface for POSIX readdir
957  irods::plugin_context& _ctx,
958  struct rodsDirent** _dirent_ptr ) {
959  irods::error result = SUCCESS();
960 
961  // =-=-=-=-=-=-=-
962  // Check the operation parameters and update the physical path
963  irods::error ret = non_blocking_check_params_and_path< irods::collection_object >( _ctx );
964  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
965 
966  // =-=-=-=-=-=-=-
967  // cast down the chain to our understood object type
968  irods::collection_object_ptr fco = boost::dynamic_pointer_cast< irods::collection_object >( _ctx.fco() );
969 
970  // =-=-=-=-=-=-=-
971  // zero out errno?
972  errno = 0;
973 
974  // =-=-=-=-=-=-=-
975  // make the call to readdir
976  struct dirent * tmp_dirent = readdir( fco->directory_pointer() );
977 
978  // =-=-=-=-=-=-=-
979  // handle error cases
980  if ( ( result = ASSERT_ERROR( tmp_dirent != NULL, -1, "End of directory list reached." ) ).ok() ) {
981 
982  // =-=-=-=-=-=-=-
983  // alloc dirent as necessary
984  if ( !( *_dirent_ptr ) ) {
985  ( *_dirent_ptr ) = ( rodsDirent_t* )malloc( sizeof( rodsDirent_t ) );
986  }
987 
988  // =-=-=-=-=-=-=-
989  // convert standard dirent to rods dirent struct
990  int status = direntToRodsDirent( ( *_dirent_ptr ), tmp_dirent );
991  if ( status < 0 ) {
992  irods::log( ERROR( status, "direntToRodsDirent failed." ) );
993  }
994 
995 #if defined(solaris_platform)
996  rstrcpy( ( *_dirent_ptr )->d_name, tmp_dirent->d_name, MAX_NAME_LEN );
997 #endif
998  }
999  else {
1000  // =-=-=-=-=-=-=-
1001  // cache status in out variable
1002  int status = UNIX_FILE_READDIR_ERR - errno;
1003  if ( ( result = ASSERT_ERROR( errno == 0, status, "Readdir error, status = %d, errno= \"%s\".",
1004  status, strerror( errno ) ) ).ok() ) {
1005  result.code( -1 );
1006  }
1007  }
1008  }
1009 
1010  return result;
1011 
1012 } // non_blocking_file_readdir
1013 
1014 // =-=-=-=-=-=-=-
1015 // interface for POSIX readdir
1017  irods::plugin_context& _ctx,
1018  const char* _new_file_name ) {
1019  irods::error result = SUCCESS();
1020 
1021  // =-=-=-=-=-=-=-
1022  // Check the operation parameters and update the physical path
1024  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
1025 
1026  // =-=-=-=-=-=-=-
1027  // manufacture a new path from the new file name
1028  std::string new_full_path;
1029  ret = non_blocking_generate_full_path( _ctx.prop_map(), _new_file_name, new_full_path );
1030  if ( ( result = ASSERT_PASS( ret, "Unable to generate full path for destination file: \"%s\".",
1031  _new_file_name ) ).ok() ) {
1032 
1033  // =-=-=-=-=-=-=-
1034  // cast down the hierarchy to the desired object
1035  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1036 
1037  // =-=-=-=-=-=-=-
1038  // make the directories in the path to the new file
1039  std::string new_path = new_full_path;
1040  std::size_t last_slash = new_path.find_last_of( '/' );
1041  new_path.erase( last_slash );
1042  ret = non_blocking_file_mkdir_r( new_path.c_str(), 0750 );
1043  if ( ( result = ASSERT_PASS( ret, "Mkdir error for \"%s\".", new_path.c_str() ) ).ok() ) {
1044 
1045  }
1046 
1047  // =-=-=-=-=-=-=-
1048  // make the call to rename
1049  int status = rename( fco->physical_path().c_str(), new_full_path.c_str() );
1050 
1051  // =-=-=-=-=-=-=-
1052  // handle error cases
1053  if ( status < 0 ) {
1054  status = UNIX_FILE_RENAME_ERR - errno;
1055 
1056  std::stringstream msg;
1057  msg << "non_blocking_file_rename: rename error for ";
1058  msg << fco->physical_path();
1059  msg << " to ";
1060  msg << new_full_path;
1061  msg << ", errno = ";
1062  msg << strerror( errno );
1063  msg << ", status = ";
1064  msg << status;
1065 
1066  return ERROR( status, msg.str() );
1067  }
1068  }
1069  }
1070 
1071  return result;
1072 
1073 } // non_blocking_file_rename
1074 
1075 // =-=-=-=-=-=-=-
1076 // interface for POSIX truncate
1078  irods::plugin_context& _ctx ) {
1079  // =-=-=-=-=-=-=-
1080  // Check the operation parameters and update the physical path
1081  irods::error ret = non_blocking_check_params_and_path< irods::file_object >( _ctx );
1082  if ( !ret.ok() ) {
1083  std::stringstream msg;
1084  msg << __FUNCTION__ << " - Invalid parameters or physical path.";
1085  return PASSMSG( msg.str(), ret );
1086  }
1087 
1088  // =-=-=-=-=-=-=-
1089  // cast down the chain to our understood object type
1090  irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1091 
1092  // =-=-=-=-=-=-=-
1093  // make the call to rename
1094  int status = truncate( file_obj->physical_path().c_str(),
1095  file_obj->size() );
1096 
1097  // =-=-=-=-=-=-=-
1098  // handle any error cases
1099  if ( status < 0 ) {
1100  // =-=-=-=-=-=-=-
1101  // cache status in out variable
1102  status = UNIX_FILE_TRUNCATE_ERR - errno;
1103 
1104  std::stringstream msg;
1105  msg << "non_blocking_file_truncate: rename error for ";
1106  msg << file_obj->physical_path();
1107  msg << ", errno = '";
1108  msg << strerror( errno );
1109  msg << "', status = ";
1110  msg << status;
1111 
1112  return ERROR( status, msg.str() );
1113  }
1114 
1115  return CODE( status );
1116 
1117 } // non_blocking_file_truncate
1118 
1119 
1122  const char* srcFileName,
1123  const char* destFileName ) {
1124  irods::error result = SUCCESS();
1125 
1126  int inFd = open( srcFileName, O_RDONLY, 0 );
1127  int open_err_status = UNIX_FILE_OPEN_ERR - errno;
1128  struct stat statbuf;
1129  int status = stat( srcFileName, &statbuf );
1130  int stat_err_status = UNIX_FILE_STAT_ERR - errno;
1131  if ( status < 0 ) {
1132  if ( inFd >= 0 ) {
1133  close( inFd );
1134  }
1135  std::stringstream msg_stream;
1136  msg_stream << "Stat of \"" << srcFileName << "\" error, status = " << stat_err_status;
1137  result = ERROR( stat_err_status, msg_stream.str() );
1138  }
1139  else if ( inFd < 0 ) {
1140  std::stringstream msg_stream;
1141  msg_stream << "Open error for srcFileName \"" << srcFileName << "\", status = " << status;
1142  result = ERROR( open_err_status, msg_stream.str() );
1143  }
1144  else if ( ( statbuf.st_mode & S_IFREG ) == 0 ) {
1145  close( inFd ); // JMC cppcheck - resource
1146  std::stringstream msg_stream;
1147  msg_stream << "srcFileName \"" << srcFileName << "\" is not a regular file.";
1148  result = ERROR( UNIX_FILE_STAT_ERR, msg_stream.str() );
1149  }
1150  else {
1151  int outFd = open( destFileName, O_WRONLY | O_CREAT | O_TRUNC, mode );
1152  int err_status = UNIX_FILE_OPEN_ERR - errno;
1153  if ( outFd < 0 ) {
1154  std::stringstream msg_stream;
1155  msg_stream << "Open error for destFileName \"" << destFileName << "\", status = " << status;
1156  result = ERROR( err_status, msg_stream.str() );
1157  }
1158  else if ( ( statbuf.st_mode & S_IFREG ) == 0 ) {
1159  close( outFd ); // JMC cppcheck - resource
1160  std::stringstream msg_stream;
1161  msg_stream << "destFileName \"" << destFileName << "\" is not a regular file.";
1162  result = ERROR( UNIX_FILE_STAT_ERR, msg_stream.str() );
1163  }
1164  else {
1165  size_t trans_buff_size;
1166  try {
1167  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
1168  } catch ( const irods::exception& e ) {
1169  close( outFd );
1170  close( inFd );
1171  return irods::error(e);
1172  }
1173 
1174  std::vector<char> myBuf( trans_buff_size );
1175 
1176  int bytesRead;
1177  rodsLong_t bytesCopied = 0;
1178  while ( result.ok() && ( bytesRead = read( inFd, ( void * ) myBuf.data(), trans_buff_size ) ) > 0 ) {
1179  int bytesWritten = write( outFd, ( void * ) myBuf.data(), bytesRead );
1180  err_status = UNIX_FILE_WRITE_ERR - errno;
1181  if ( ( result = ASSERT_ERROR( bytesWritten > 0, err_status, "Write error for srcFileName %s, status = %d",
1182  destFileName, status ) ).ok() ) {
1183  bytesCopied += bytesWritten;
1184  }
1185  }
1186 
1187  close( outFd );
1188 
1189  if ( result.ok() ) {
1190  result = ASSERT_ERROR( bytesCopied == statbuf.st_size, SYS_COPY_LEN_ERR, "Copied size %lld does not match source size %lld of %s",
1191  bytesCopied, statbuf.st_size, srcFileName );
1192  }
1193  }
1194  close( inFd );
1195  }
1196  return result;
1197 }
1198 
1199 // =-=-=-=-=-=-=-
1200 // non_blockingStageToCache - This routine is for testing the TEST_STAGE_FILE_TYPE.
1201 // Just copy the file from filename to cacheFilename. optionalInfo info
1202 // is not used.
1204  irods::plugin_context& _ctx,
1205  const char* _cache_file_name ) {
1206  irods::error result = SUCCESS();
1207 
1208  // =-=-=-=-=-=-=-
1209  // Check the operation parameters and update the physical path
1211  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
1212 
1213  // =-=-=-=-=-=-=-
1214  // cast down the hierarchy to the desired object
1215  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1216 
1217  ret = non_blockingFileCopyPlugin( fco->mode(), fco->physical_path().c_str(), _cache_file_name );
1218  result = ASSERT_PASS( ret, "Failed" );
1219  }
1220  return result;
1221 } // non_blocking_file_stage_to_cache
1222 
1223 // =-=-=-=-=-=-=-
1224 // non_blockingSyncToArch - This routine is for testing the TEST_STAGE_FILE_TYPE.
1225 // Just copy the file from cacheFilename to filename. optionalInfo info
1226 // is not used.
1228  irods::plugin_context& _ctx,
1229  const char* _cache_file_name ) {
1230  irods::error result = SUCCESS();
1231 
1232  // =-=-=-=-=-=-=-
1233  // Check the operation parameters and update the physical path
1235  if ( ( result = ASSERT_PASS( ret, "Invalid parameters or physical path." ) ).ok() ) {
1236 
1237  // =-=-=-=-=-=-=-
1238  // cast down the hierarchy to the desired object
1239  irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1240 
1241  ret = non_blockingFileCopyPlugin( fco->mode(), _cache_file_name, fco->physical_path().c_str() );
1242  result = ASSERT_PASS( ret, "Failed" );
1243  }
1244 
1245  return result;
1246 
1247 } // non_blocking_file_sync_to_arch
1248 
1249 // =-=-=-=-=-=-=-
1250 // redirect_create - code to determine redirection for create operation
1252  irods::plugin_property_map& _prop_map,
1253  const std::string& _curr_host,
1254  float& _out_vote ) {
1255  irods::error result = SUCCESS();
1256 
1257  // =-=-=-=-=-=-=-
1258  // determine if the resource is down
1259  int resc_status = 0;
1260  irods::error get_ret = _prop_map.get< int >( irods::RESOURCE_STATUS, resc_status );
1261  if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"status\" property." ) ).ok() ) {
1262 
1263  // =-=-=-=-=-=-=-
1264  // if the status is down, vote no.
1265  if ( INT_RESC_STATUS_DOWN == resc_status ) {
1266  _out_vote = 0.0;
1267  }
1268  else {
1269 
1270  // =-=-=-=-=-=-=-
1271  // get the resource host for comparison to curr host
1272  std::string host_name;
1273  get_ret = _prop_map.get< std::string >( irods::RESOURCE_LOCATION, host_name );
1274  if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"location\" property." ) ).ok() ) {
1275 
1276  // =-=-=-=-=-=-=-
1277  // vote higher if we are on the same host
1278  if ( _curr_host == host_name ) {
1279  _out_vote = 1.0;
1280  }
1281  else {
1282  _out_vote = 0.5;
1283  }
1284  }
1285  }
1286  }
1287  return result;
1288 
1289 } // non_blocking_file_redirect_create
1290 
1291 // =-=-=-=-=-=-=-
1292 // redirect_open - code to determine redirection for open operation
1294  irods::plugin_property_map& _prop_map,
1295  irods::file_object_ptr _file_obj,
1296  const std::string& _resc_name,
1297  const std::string& _curr_host,
1298  float& _out_vote ) {
1299  irods::error result = SUCCESS();
1300 
1301  // =-=-=-=-=-=-=-
1302  // initially set a good default
1303  _out_vote = 0.0;
1304 
1305  // =-=-=-=-=-=-=-
1306  // determine if the resource is down
1307  int resc_status = 0;
1308  irods::error get_ret = _prop_map.get< int >( irods::RESOURCE_STATUS, resc_status );
1309  if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"status\" property." ) ).ok() ) {
1310 
1311  // =-=-=-=-=-=-=-
1312  // if the status is down, vote no.
1313  if ( INT_RESC_STATUS_DOWN != resc_status ) {
1314 
1315  // =-=-=-=-=-=-=-
1316  // get the resource host for comparison to curr host
1317  std::string host_name;
1318  get_ret = _prop_map.get< std::string >( irods::RESOURCE_LOCATION, host_name );
1319  if ( ( result = ASSERT_PASS( get_ret, "Failed to get \"location\" property." ) ).ok() ) {
1320 
1321  // =-=-=-=-=-=-=-
1322  // set a flag to test if were at the curr host, if so we vote higher
1323  bool curr_host = ( _curr_host == host_name );
1324 
1325  // =-=-=-=-=-=-=-
1326  // make some flags to clairify decision making
1327  bool need_repl = ( _file_obj->repl_requested() > -1 );
1328 
1329  // =-=-=-=-=-=-=-
1330  // set up variables for iteration
1331  irods::error final_ret = SUCCESS();
1332  std::vector< irods::physical_object > objs = _file_obj->replicas();
1333  std::vector< irods::physical_object >::iterator itr = objs.begin();
1334 
1335  // =-=-=-=-=-=-=-
1336  // check to see if the replica is in this resource, if one is requested
1337  for ( ; itr != objs.end(); ++itr ) {
1338  // =-=-=-=-=-=-=-
1339  // run the hier string through the parser and get the last
1340  // entry.
1341  std::string last_resc;
1343  parser.set_string( itr->resc_hier() );
1344  parser.last_resc( last_resc );
1345 
1346  // =-=-=-=-=-=-=-
1347  // more flags to simplify decision making
1348  bool repl_us = ( _file_obj->repl_requested() == itr->repl_num() );
1349  bool resc_us = ( _resc_name == last_resc );
1350  bool is_dirty = ( itr->is_dirty() != 1 );
1351 
1352  // =-=-=-=-=-=-=-
1353  // success - correct resource and dont need a specific
1354  // replication, or the repl nums match
1355  if ( resc_us ) {
1356  // =-=-=-=-=-=-=-
1357  // if a specific replica is requested then we
1358  // ignore all other criteria
1359  if ( need_repl ) {
1360  if ( repl_us ) {
1361  _out_vote = 1.0;
1362  }
1363  else {
1364  // =-=-=-=-=-=-=-
1365  // repl requested and we are not it, vote
1366  // very low
1367  _out_vote = 0.25;
1368  }
1369  }
1370  else {
1371  // =-=-=-=-=-=-=-
1372  // if no repl is requested consider dirty flag
1373  if ( is_dirty ) {
1374  // =-=-=-=-=-=-=-
1375  // repl is dirty, vote very low
1376  _out_vote = 0.25;
1377  }
1378  else {
1379  // =-=-=-=-=-=-=-
1380  // if our repl is not dirty then a local copy
1381  // wins, otherwise vote middle of the road
1382  if ( curr_host ) {
1383  _out_vote = 1.0;
1384  }
1385  else {
1386  _out_vote = 0.5;
1387  }
1388  }
1389  }
1390 
1391  break;
1392 
1393  } // if resc_us
1394 
1395  } // for itr
1396  }
1397  }
1398  }
1399  return result;
1400 
1401 } // non_blocking_file_redirect_open
1402 
1403 // =-=-=-=-=-=-=-
1404 // used to allow the resource to determine which host
1405 // should provide the requested operation
1407  irods::plugin_context& _ctx,
1408  const std::string* _opr,
1409  const std::string* _curr_host,
1410  irods::hierarchy_parser* _out_parser,
1411  float* _out_vote ) {
1412  irods::error result = SUCCESS();
1413 
1414  // =-=-=-=-=-=-=-
1415  // check the context validity
1416  irods::error ret = _ctx.valid< irods::file_object >();
1417  if ( ( result = ASSERT_PASS( ret, "Invalid resource context." ) ).ok() ) {
1418 
1419  // =-=-=-=-=-=-=-
1420  // check incoming parameters
1421  if ( ( result = ASSERT_ERROR( _opr && _curr_host && _out_parser && _out_vote, SYS_INVALID_INPUT_PARAM, "Invalid input parameter." ) ).ok() ) {
1422 
1423  // =-=-=-=-=-=-=-
1424  // cast down the chain to our understood object type
1425  irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1426 
1427  // =-=-=-=-=-=-=-
1428  // get the name of this resource
1429  std::string resc_name;
1430  ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, resc_name );
1431  if ( ( result = ASSERT_PASS( ret, "Failed in get property for name." ) ).ok() ) {
1432 
1433  // =-=-=-=-=-=-=-
1434  // add ourselves to the hierarchy parser by default
1435  _out_parser->add_child( resc_name );
1436 
1437  // =-=-=-=-=-=-=-
1438  // test the operation to determine which choices to make
1439  if ( irods::OPEN_OPERATION == ( *_opr ) || irods::UNLINK_OPERATION == ( *_opr )) {
1440  // =-=-=-=-=-=-=-
1441  // call redirect determination for 'get' operation
1442  ret = non_blocking_file_redirect_open( _ctx.prop_map(), file_obj, resc_name, ( *_curr_host ), ( *_out_vote ) );
1443  result = ASSERT_PASS( ret, "Failed redirecting for open." );
1444 
1445  }
1446  else if ( irods::CREATE_OPERATION == ( *_opr ) ||
1447  irods::WRITE_OPERATION == ( *_opr ) ) {
1448  // =-=-=-=-=-=-=-
1449  // call redirect determination for 'create' operation
1450  ret = non_blocking_file_redirect_create( _ctx.prop_map(), ( *_curr_host ), ( *_out_vote ) );
1451  result = ASSERT_PASS( ret, "Failed redirecting for create." );
1452  }
1453 
1454  else {
1455  // =-=-=-=-=-=-=-
1456  // must have been passed a bad operation
1457  result = ASSERT_ERROR( false, INVALID_OPERATION, "Operation not supported." );
1458  }
1459  }
1460  }
1461  }
1462 
1463  return result;
1464 
1465 } // non_blocking_file_resolve_hierarchy
1466 
1467 // =-=-=-=-=-=-=-
1468 // non_blocking_file_rebalance - code which would rebalance the subtree
1470  irods::plugin_context& _ctx ) {
1471  return SUCCESS();
1472 
1473 } // non_blocking_file_rebalance
1474 
1475 // =-=-=-=-=-=-=-
1476 // 3. create derived class to handle non_blocking file system resources
1477 // necessary to do custom parsing of the context string to place
1478 // any useful values into the property map for reference in later
1479 // operations. semicolon is the preferred delimiter
1481  // =-=-=-=-=-=-=-
1482  // 3a. create a class to provide maintenance operations, this is only for example
1483  // and will not be called.
1485  public:
1486  maintenance_operation( const std::string& _n ) : name_( _n ) {
1487  }
1488 
1490  name_ = _rhs.name_;
1491  }
1492 
1494  name_ = _rhs.name_;
1495  return *this;
1496  }
1497 
1499  rodsLog( LOG_NOTICE, "non_blocking_resource::post_disconnect_maintenance_operation - [%s]",
1500  name_.c_str() );
1501  return SUCCESS();
1502  }
1503 
1504  private:
1505  std::string name_;
1506 
1507  }; // class maintenance_operation
1508 
1509  public:
1511  const std::string& _inst_name,
1512  const std::string& _context ) :
1513  irods::resource(
1514  _inst_name,
1515  _context ) {
1516  } // ctor
1517 
1518 
1520  _b = false;
1521  return SUCCESS();
1522  }
1523 
1524 
1525  // =-=-=-=-=-=-=-
1526  // 3b. pass along a functor for maintenance work after
1527  // the client disconnects, uncomment the first two lines for effect.
1529  irods::error result = SUCCESS();
1530  return ERROR( -1, "nop" );
1531  }
1532 }; // class non_blocking_resource
1533 
1534 // =-=-=-=-=-=-=-
1535 // 4. create the plugin factory function which will return a dynamically
1536 // instantiated object of the previously defined derived resource. use
1537 // the add_operation member to associate a 'call name' to the interfaces
1538 // defined above. for resource plugins these call names are standardized
1539 // as used by the irods facing interface defined in
1540 // server/drivers/src/fileDriver.c
1541 extern "C"
1542 irods::resource* plugin_factory( const std::string& _inst_name, const std::string& _context ) {
1543 
1544  // =-=-=-=-=-=-=-
1545  // 4a. create non_blocking_resource
1546  non_blocking_resource* resc = new non_blocking_resource( _inst_name, _context );
1547 
1548  // =-=-=-=-=-=-=-
1549  // 4b. map function names to operations. this map will be used to load
1550  // the symbols from the shared object in the delay_load stage of
1551  // plugin loading.
1552  //
1553 
1554  using namespace irods;
1555  using namespace std;
1556  resc->add_operation(
1558  function<error(plugin_context&)>(
1560 
1561  resc->add_operation(
1563  function<error(plugin_context&)>(
1565 
1566  resc->add_operation<void*,int>(
1568  std::function<
1569  error(irods::plugin_context&,void*,int)>(
1571 
1572  resc->add_operation<void*,int>(
1574  function<error(plugin_context&,void*,int)>(
1576 
1577  resc->add_operation(
1579  function<error(plugin_context&)>(
1581 
1582  resc->add_operation(
1584  function<error(plugin_context&)>(
1586 
1587  resc->add_operation<struct stat*>(
1589  function<error(plugin_context&, struct stat*)>(
1591 
1592  resc->add_operation(
1594  function<error(plugin_context&)>(
1596 
1597  resc->add_operation(
1599  function<error(plugin_context&)>(
1601 
1602  resc->add_operation<struct rodsDirent**>(
1604  function<error(plugin_context&,struct rodsDirent**)>(
1606 
1607  resc->add_operation<const char*>(
1609  function<error(plugin_context&, const char*)>(
1611 
1612  resc->add_operation(
1614  function<error(plugin_context&)>(
1616 
1617  resc->add_operation<long long, int>(
1619  function<error(plugin_context&, long long, int)>(
1621 
1622  resc->add_operation(
1624  function<error(plugin_context&)>(
1626 
1627  resc->add_operation(
1629  function<error(plugin_context&)>(
1631 
1632  resc->add_operation<const char*>(
1634  function<error(plugin_context&, const char*)>(
1636 
1637  resc->add_operation<const char*>(
1639  function<error(plugin_context&, const char*)>(
1641 
1642  resc->add_operation(
1644  function<error(plugin_context&)>(
1646 
1647  resc->add_operation(
1649  function<error(plugin_context&)>(
1651 
1652  resc->add_operation(
1654  function<error(plugin_context&)>(
1656 
1657  resc->add_operation<const std::string*>(
1659  function<error(plugin_context&, const std::string*)>(
1661 
1662  resc->add_operation(
1664  function<error(plugin_context&)>(
1666 
1667  resc->add_operation<const std::string*, const std::string*, irods::hierarchy_parser*, float*>(
1669  function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
1671 
1672  resc->add_operation(
1674  function<error(plugin_context&)>(
1676 
1677  // =-=-=-=-=-=-=-
1678  // set some properties necessary for backporting to iRODS legacy code
1679  resc->set_property< int >( irods::RESOURCE_CHECK_PATH_PERM, 2 );//DO_CHK_PATH_PERM );
1680  resc->set_property< int >( irods::RESOURCE_CREATE_PATH, 1 );//CREATE_PATH );
1681 
1682  // =-=-=-=-=-=-=-
1683  // 4c. return the pointer through the generic interface of an
1684  // irods::resource pointer
1685  return dynamic_cast<irods::resource*>( resc );
1686 
1687 } // plugin_factory
1688 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
non_blocking_file_lseek
irods::error non_blocking_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
Definition: libnonblocking.cpp:776
UNIX_FILE_GET_FS_FREESPACE_ERR
@ UNIX_FILE_GET_FS_FREESPACE_ERR
Definition: rodsErrorTable.h:316
UNIX_FILE_WRITE_ERR
@ UNIX_FILE_WRITE_ERR
Definition: rodsErrorTable.h:303
UNIX_FILE_LSEEK_ERR
@ UNIX_FILE_LSEEK_ERR
Definition: rodsErrorTable.h:308
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
irods_physical_object.hpp
irods::RESOURCE_LOCATION
const std::string RESOURCE_LOCATION("resource_property_location")
non_blocking_file_open
irods::error non_blocking_file_open(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:420
irods::lookup_table< boost::any >
non_blocking_file_getfs_freespace
irods::error non_blocking_file_getfs_freespace(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:273
irods::RESOURCE_NAME
const std::string RESOURCE_NAME("resource_property_name")
irods_server_properties.hpp
irods::RESOURCE_OP_STAT
const std::string RESOURCE_OP_STAT("resource_stat")
non_blocking_file_write
irods::error non_blocking_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libnonblocking.cpp:590
non_blocking_resource
Definition: libnonblocking.cpp:1480
msParam.h
irods::plugin_context::valid
virtual error valid()
Definition: irods_plugin_context.hpp:77
irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS
const std::string CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS("transfer_buffer_size_for_parallel_transfer_in_megabytes")
irods::resource
Definition: irods_resource_plugin.hpp:25
irods::RESOURCE_CHECK_PATH_PERM
const std::string RESOURCE_CHECK_PATH_PERM("resource_property_check_path_perm")
non_blocking_file_stat
irods::error non_blocking_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
Definition: libnonblocking.cpp:740
irods::RESOURCE_OP_MODIFIED
const std::string RESOURCE_OP_MODIFIED("resource_modified")
non_blocking_check_params_and_path
irods::error non_blocking_check_params_and_path(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:138
irods_file_object.hpp
irods::RESOURCE_OP_CLOSEDIR
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
irods_stacktrace.hpp
irods::pdmo_type
std::function< irods::error(rcComm_t *) > pdmo_type
Definition: irods_plugin_base.hpp:29
non_blocking_resource::maintenance_operation::operator=
maintenance_operation & operator=(const maintenance_operation &_rhs)
Definition: libnonblocking.cpp:1493
non_blocking_file_closedir
irods::error non_blocking_file_closedir(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:926
irods::data_object_ptr
boost::shared_ptr< data_object > data_object_ptr
Definition: irods_data_object.hpp:17
irods_collection_object.hpp
irods::RESOURCE_OP_RESOLVE_RESC_HIER
const std::string RESOURCE_OP_RESOLVE_RESC_HIER("resource_resolve_hierarchy")
irods::RESOURCE_OP_READDIR
const std::string RESOURCE_OP_READDIR("resource_readdir")
non_blocking_resource::post_disconnect_maintenance_operation
irods::error post_disconnect_maintenance_operation(irods::pdmo_type &)
Definition: libnonblocking.cpp:1528
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
irods::collection_object_ptr
boost::shared_ptr< collection_object > collection_object_ptr
Definition: irods_collection_object.hpp:85
rcConnect.h
UNIX_FILE_CLOSE_ERR
@ UNIX_FILE_CLOSE_ERR
Definition: rodsErrorTable.h:304
non_blocking_resource::maintenance_operation::name_
std::string name_
Definition: libnonblocking.cpp:1505
irods::RESOURCE_OP_READ
const std::string RESOURCE_OP_READ("resource_read")
irods::RESOURCE_OP_FREESPACE
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods::RESOURCE_PATH
const std::string RESOURCE_PATH("resource_property_path")
non_blocking_file_resolve_hierarchy
irods::error non_blocking_file_resolve_hierarchy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libnonblocking.cpp:1406
non_blocking_file_modified
irods::error non_blocking_file_modified(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:245
non_blocking_resource::maintenance_operation::maintenance_operation
maintenance_operation(const std::string &_n)
Definition: libnonblocking.cpp:1486
irods::RESOURCE_OP_LSEEK
const std::string RESOURCE_OP_LSEEK("resource_lseek")
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
UNIX_FILE_READDIR_ERR
@ UNIX_FILE_READDIR_ERR
Definition: rodsErrorTable.h:314
deploy_schemas_locally.parser
parser
Definition: deploy_schemas_locally.py:59
non_blocking_file_redirect_create
irods::error non_blocking_file_redirect_create(irods::plugin_property_map &_prop_map, const std::string &_curr_host, float &_out_vote)
Definition: libnonblocking.cpp:1251
irods::plugin_context
Definition: irods_plugin_context.hpp:18
irods::lookup_table::get
error get(const std::string &_key, ValueType &_val)
Definition: irods_lookup_table.hpp:71
irods_resource_redirect.hpp
irods::resource::resource
resource(const std::string &_inst, const std::string &_ctx)
Definition: irods_resource_plugin.hpp:29
irods::RESOURCE_STATUS
const std::string RESOURCE_STATUS("resource_property_status")
irods::plugin_base::set_property
error set_property(const std::string &_key, const T &_val)
Definition: irods_plugin_base.hpp:304
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
non_blocking_file_close
irods::error non_blocking_file_close(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:669
ASSERT_ERROR
#define ASSERT_ERROR(expr_, code_, format_,...)
Definition: irods_error.hpp:123
plugin_factory
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
Definition: libnonblocking.cpp:1542
UNIX_FILE_OPR_TIMEOUT_ERR
@ UNIX_FILE_OPR_TIMEOUT_ERR
Definition: rodsErrorTable.h:321
non_blocking_generate_full_path
irods::error non_blocking_generate_full_path(irods::plugin_property_map &_prop_map, const std::string &_phy_path, std::string &_ret_string)
Definition: libnonblocking.cpp:83
irods_resource_plugin.hpp
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
INVALID_OPERATION
@ INVALID_OPERATION
Definition: rodsErrorTable.h:760
irods::RESOURCE_OP_TRUNCATE
const std::string RESOURCE_OP_TRUNCATE("resource_truncate")
irods_string_tokenize.hpp
irods::RESOURCE_OP_RENAME
const std::string RESOURCE_OP_RENAME("resource_rename")
irods::OPEN_OPERATION
const std::string OPEN_OPERATION("OPEN")
UNIX_FILE_OPEN_ERR
@ UNIX_FILE_OPEN_ERR
Definition: rodsErrorTable.h:300
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods.pypyodbc.long
long
Definition: pypyodbc.py:43
irods::plugin_context::prop_map
virtual irods::plugin_property_map & prop_map()
Definition: irods_plugin_context.hpp:99
SYS_COPY_LEN_ERR
@ SYS_COPY_LEN_ERR
Definition: rodsErrorTable.h:95
non_blocking_resource::need_post_disconnect_maintenance_operation
irods::error need_post_disconnect_maintenance_operation(bool &_b)
Definition: libnonblocking.cpp:1519
irods::hierarchy_parser::add_child
error add_child(const std::string &_resc)
Definition: irods_hierarchy_parser.cpp:88
irods::RESOURCE_OP_CREATE
const std::string RESOURCE_OP_CREATE("resource_create")
irods
Definition: apiHandler.hpp:35
UNIX_FILE_RENAME_ERR
@ UNIX_FILE_RENAME_ERR
Definition: rodsErrorTable.h:318
non_blocking_file_truncate
irods::error non_blocking_file_truncate(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:1077
non_blocking_resource::maintenance_operation
Definition: libnonblocking.cpp:1484
UNIX_FILE_TRUNCATE_ERR
@ UNIX_FILE_TRUNCATE_ERR
Definition: rodsErrorTable.h:319
irods::RESOURCE_OP_NOTIFY
const std::string RESOURCE_OP_NOTIFY("resource_notify")
NB_WRITE_TOUT_SEC
#define NB_WRITE_TOUT_SEC
Definition: libnonblocking.cpp:72
USER_NO_SUPPORT_ERR
@ USER_NO_SUPPORT_ERR
Definition: rodsErrorTable.h:240
UNIX_FILE_OPENDIR_ERR
@ UNIX_FILE_OPENDIR_ERR
Definition: rodsErrorTable.h:312
irods::RESOURCE_CREATE_PATH
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
irods::RESOURCE_OP_WRITE
const std::string RESOURCE_OP_WRITE("resource_write")
USER_FILE_TOO_LARGE
@ USER_FILE_TOO_LARGE
Definition: rodsErrorTable.h:242
non_blocking_file_unlink
irods::error non_blocking_file_unlink(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:704
non_blocking_file_create
irods::error non_blocking_file_create(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:344
UNIX_FILE_UNLINK_ERR
@ UNIX_FILE_UNLINK_ERR
Definition: rodsErrorTable.h:305
ASSERT_PASS
#define ASSERT_PASS(prev_error_, format_,...)
Definition: irods_error.hpp:124
irods::collection_object
Definition: irods_collection_object.hpp:14
non_blocking_file_mkdir
irods::error non_blocking_file_mkdir(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:810
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
non_blocking_file_registered
irods::error non_blocking_file_registered(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:217
irods::RESOURCE_OP_CLOSE
const std::string RESOURCE_OP_CLOSE("resource_close")
non_blocking_file_rmdir
irods::error non_blocking_file_rmdir(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:849
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rodsDirent
Definition: rodsType.h:70
irods::RESOURCE_OP_UNLINK
const std::string RESOURCE_OP_UNLINK("resource_unlink")
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
non_blocking_file_notify
irods::error non_blocking_file_notify(irods::plugin_context &_ctx, const std::string *)
Definition: libnonblocking.cpp:259
irods::RESOURCE_OP_RMDIR
const std::string RESOURCE_OP_RMDIR("resource_rmdir")
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::RESOURCE_OP_UNREGISTERED
const std::string RESOURCE_OP_UNREGISTERED("resource_unregistered")
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
INT_RESC_STATUS_DOWN
#define INT_RESC_STATUS_DOWN
Definition: rodsDef.h:282
non_blocking_file_read
irods::error non_blocking_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libnonblocking.cpp:496
non_blocking_file_unregistered
irods::error non_blocking_file_unregistered(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:231
irods::RESOURCE_OP_REGISTERED
const std::string RESOURCE_OP_REGISTERED("resource_registered")
non_blocking_file_redirect_open
irods::error non_blocking_file_redirect_open(irods::plugin_property_map &_prop_map, irods::file_object_ptr _file_obj, const std::string &_resc_name, const std::string &_curr_host, float &_out_vote)
Definition: libnonblocking.cpp:1293
UNIX_FILE_READ_ERR
@ UNIX_FILE_READ_ERR
Definition: rodsErrorTable.h:302
irods_hierarchy_parser.hpp
non_blocking_file_rebalance
irods::error non_blocking_file_rebalance(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:1469
non_blocking_file_sync_to_arch
irods::error non_blocking_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libnonblocking.cpp:1227
irods::file_object
Definition: irods_file_object.hpp:19
irods::RESOURCE_OP_MKDIR
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
irods::RESOURCE_OP_OPENDIR
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
irods::RESOURCE_OP_STAGETOCACHE
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
UNIX_FILE_CREATE_ERR
@ UNIX_FILE_CREATE_ERR
Definition: rodsErrorTable.h:301
direntToRodsDirent
int direntToRodsDirent(rodsDirent_t *rodsDirent, struct dirent *fileDirent)
Definition: rcMisc.cpp:330
error
int error
Definition: filesystem.cpp:101
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
irods::WRITE_OPERATION
const std::string WRITE_OPERATION("WRITE")
irods::plugin_base::add_operation
error add_operation(const std::string &_op, std::function< error(plugin_context &)> _f)
Definition: irods_plugin_base.hpp:122
UNIX_FILE_RMDIR_ERR
@ UNIX_FILE_RMDIR_ERR
Definition: rodsErrorTable.h:311
irods::plugin_context::fco
virtual first_class_object_ptr fco()
Definition: irods_plugin_context.hpp:102
irods::RESOURCE_OP_SYNCTOARCH
const std::string RESOURCE_OP_SYNCTOARCH("resource_synctoarch")
irods::exception
Definition: irods_exception.hpp:15
non_blocking_resource::non_blocking_resource
non_blocking_resource(const std::string &_inst_name, const std::string &_context)
Definition: libnonblocking.cpp:1510
non_blocking_file_stage_to_cache
irods::error non_blocking_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libnonblocking.cpp:1203
UNIX_FILE_CLOSEDIR_ERR
@ UNIX_FILE_CLOSEDIR_ERR
Definition: rodsErrorTable.h:313
non_blocking_file_opendir
irods::error non_blocking_file_opendir(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:879
irods::experimental::filesystem::client::rename
auto rename(rcComm_t &_comm, const path &_from, const path &_to) -> void
Definition: filesystem.cpp:805
UNIX_FILE_STAT_ERR
@ UNIX_FILE_STAT_ERR
Definition: rodsErrorTable.h:306
irods::RESOURCE_OP_REBALANCE
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
mode
int mode
Definition: filesystem.cpp:104
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
non_blocking_file_mkdir_r
irods::error non_blocking_file_mkdir_r(const std::string &path, mode_t mode)
Definition: libnonblocking.cpp:176
non_blocking_check_path
irods::error non_blocking_check_path(irods::plugin_context &_ctx)
Definition: libnonblocking.cpp:111
non_blockingFileCopyPlugin
irods::error non_blockingFileCopyPlugin(int mode, const char *srcFileName, const char *destFileName)
Definition: libnonblocking.cpp:1121
non_blocking_file_readdir
irods::error non_blocking_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
Definition: libnonblocking.cpp:956
non_blocking_resource::maintenance_operation::maintenance_operation
maintenance_operation(const maintenance_operation &_rhs)
Definition: libnonblocking.cpp:1489
CODE
#define CODE(code_)
Definition: irods_error.hpp:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
non_blocking_file_rename
irods::error non_blocking_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
Definition: libnonblocking.cpp:1016
irods::RESOURCE_OP_OPEN
const std::string RESOURCE_OP_OPEN("resource_open")
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
non_blocking_resource::maintenance_operation::operator()
irods::error operator()(rcComm_t *)
Definition: libnonblocking.cpp:1498
NB_READ_TOUT_SEC
#define NB_READ_TOUT_SEC
Definition: libnonblocking.cpp:71
irods::UNLINK_OPERATION
const std::string UNLINK_OPERATION("UNLINK")
UNIX_FILE_MKDIR_ERR
@ UNIX_FILE_MKDIR_ERR
Definition: rodsErrorTable.h:310
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32