63 open (name, flags, perms); }
78 <<
"Destructor called on LStore file '" <<
m_name 79 <<
"' but the file is still open";
87 #define REDD_LOAD_SYMBOL( NAME, TYPE ) dlerror();\ 88 NAME = reinterpret_cast<TYPE>(reinterpret_cast<size_t>( \ 89 dlsym(m_library_handle, #NAME))); \ 90 if ( (retval = dlerror()) ) {\ 91 throw cms::Exception("LStoreFile::loadLibrary()") <<\ 92 "Failed to load dlsym LStore library: " << retval;\ 95 throw cms::Exception("LStoreFile::loadLibrary()") <<\ 96 "Got a null pointer back from dlsym()\n";\ 100 edm::LogError(
"LStoreFile::loadLibrary()") <<
"Loading library\n";
110 dlopen(
"libreddnet.so", RTLD_LAZY);
113 <<
"Can't dlopen() LStore libraries: " << dlerror();
116 char * retval =
NULL;
129 <<
"Error in redd_init: " << (*redd_strerror)();
146 <<
"Error in redd_term: " << (*redd_strerror)();
152 <<
"Error on dlclose(): " << dlerror();
157 <<
"LStoreFile had an error in its destructor: " <<
e;
198 if ((name == 0) || (*name == 0))
200 <<
"Cannot open a file without a name";
204 <<
"Must open file '" << name <<
"' at least for read or write";
215 else if (flags & IOFlags::OpenRead)
216 openflags |= O_RDONLY;
217 else if (flags & IOFlags::OpenWrite)
218 openflags |= O_WRONLY;
224 openflags |= O_APPEND;
227 openflags |= O_CREAT;
233 openflags |= O_TRUNC;
238 <<
"redd_open(name='" << name
239 <<
"', flags=0x" << std::hex << openflags
240 <<
", permissions=0" << std::oct << perms <<
std::dec 241 <<
") => error '" << (*redd_strerror)()
242 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
258 <<
"LStoreFile::close(name='" <<
m_name 259 <<
"') called but the file is not open";
266 <<
"redd_close(name='" <<
m_name 267 <<
"') failed with error '" << (*redd_strerror) ()
268 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
281 (*redd_close) (
m_fd);
294 ssize_t
s = (*redd_read) (
m_fd, (
char *) into + done, n - done);
297 <<
"redd_read(name='" <<
m_name <<
"', n=" << (n-done)
299 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
311 ssize_t
s = (*redd_write) (
m_fd, (
const char *) from + done, n - done);
314 <<
"redd_write(name='" <<
m_name <<
"', n=" << (n-done)
316 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
330 <<
"LStoreFile::position() called on a closed file";
333 <<
"LStoreFile::position() called with incorrect 'whence' parameter";
336 uint32_t mywhence = (whence ==
SET ? SEEK_SET
339 if ((result = (*
redd_lseek) (
m_fd, (off_t) offset, (uint32_t)mywhence)) == -1)
341 <<
"redd_lseek64(name='" <<
m_name <<
"', offset=" << offset
342 <<
", whence=" << mywhence <<
") failed with error '" 343 << (*redd_strerror) () <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
351 <<
"LStoreFile::resize(name='" <<
m_name <<
"') not implemented";
360 pthread_mutex_lock( m_lock );
366 if ( (retval = pthread_mutex_unlock( m_lock )) ) {
375 <<
"LStoreFile couldn't unlock a mutex. Not good." 376 << strerror_r( retval, buf, 1024 );
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
std::vector< Variable::Flags > flags
virtual void resize(IOOffset size)
int64_t(* redd_write)(void *, const char *, int64_t)
MutexWrapper(pthread_mutex_t *lock)
void *(* redd_open)(const char *, int32_t, int32_t)
virtual IOOffset position(void) const
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
#define REDD_LOAD_SYMBOL(NAME, TYPE)
const std::string &(* redd_strerror)()
virtual IOSize write(const void *from, IOSize n)
int32_t(* redd_close)(void *)
int64_t(* redd_read)(void *, char *, int64_t)
static pthread_mutex_t m_dlopen_lock
virtual void create(const char *name, bool exclusive=false, int perms=0666)