39 open (name, flags, perms); }
54 <<
"Destructor called on LStore file '" <<
m_name
55 <<
"' but the file is still open";
63 #define REDD_LOAD_SYMBOL( NAME, TYPE ) dlerror();\
64 NAME = reinterpret_cast<TYPE>(reinterpret_cast<size_t>( \
65 dlsym(m_library_handle, #NAME))); \
66 if ( (retval = dlerror()) ) {\
67 throw cms::Exception("LStoreFile::loadLibrary()") <<\
68 "Failed to load dlsym LStore library: " << retval;\
71 throw cms::Exception("LStoreFile::loadLibrary()") <<\
72 "Got a null pointer back from dlsym()\n";\
76 edm::LogError(
"LStoreFile::loadLibrary()") <<
"Loading library\n";
86 dlopen(
"libreddnet.so", RTLD_LAZY);
89 <<
"Can't dlopen() LStore libraries: " << dlerror();
105 <<
"Error in redd_init: " << (*redd_strerror)();
122 <<
"Error in redd_term: " << (*redd_strerror)();
128 <<
"Error on dlclose(): " << dlerror();
133 <<
"LStoreFile had an error in its destructor: " << e;
176 if ((name == 0) || (*name == 0))
178 <<
"Cannot open a file without a name";
182 <<
"Must open file '" << name <<
"' at least for read or write";
193 else if (flags & IOFlags::OpenRead)
194 openflags |= O_RDONLY;
195 else if (flags & IOFlags::OpenWrite)
196 openflags |= O_WRONLY;
202 openflags |= O_APPEND;
205 openflags |= O_CREAT;
211 openflags |= O_TRUNC;
216 <<
"redd_open(name='" << name
217 <<
"', flags=0x" << std::hex << openflags
218 <<
", permissions=0" << std::oct << perms << std::dec
219 <<
") => error '" << (*redd_strerror)()
220 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
235 <<
"LStoreFile::close(name='" <<
m_name
236 <<
"') called but the file is not open";
243 <<
"redd_close(name='" <<
m_name
244 <<
"') failed with error '" << (*redd_strerror) ()
245 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
258 (*redd_close) (
m_fd);
271 ssize_t
s = (*redd_read) (
m_fd, (
char *) into + done, n - done);
274 <<
"redd_read(name='" <<
m_name <<
"', n=" << (n-
done)
276 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
288 ssize_t
s = (*redd_write) (
m_fd, (
const char *) from + done, n - done);
291 <<
"redd_write(name='" <<
m_name <<
"', n=" << (n-
done)
293 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
307 <<
"LStoreFile::position() called on a closed file";
310 <<
"LStoreFile::position() called with incorrect 'whence' parameter";
313 uint32_t mywhence = (whence ==
SET ? SEEK_SET
316 if ((result = (*
redd_lseek) (
m_fd, (off_t) offset, (uint32_t)mywhence)) == -1)
318 <<
"redd_lseek64(name='" <<
m_name <<
"', offset=" << offset
319 <<
", whence=" << mywhence <<
") failed with error '"
320 << (*redd_strerror) () <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
328 <<
"LStoreFile::resize(name='" <<
m_name <<
"') not implemented";
337 pthread_mutex_lock(
m_lock );
343 if ( (retval = pthread_mutex_unlock( m_lock )) ) {
352 <<
"LStoreFile couldn't unlock a mutex. Not good."
353 << strerror_r( retval, buf, 1024 );
int64_t(* redd_read)(void *, char *, int64_t)
std::vector< Variable::Flags > flags
virtual void resize(IOOffset size)
const std::string &(* redd_strerror)()
MutexWrapper(pthread_mutex_t *lock)
virtual IOOffset position(void) const
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
unsigned int offset(bool)
int32_t(* redd_close)(void *)
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
int64_t(* redd_write)(void *, const char *, int64_t)
static std::string from(" from ")
void *(* redd_open)(const char *, int32_t, int32_t)
#define REDD_LOAD_SYMBOL(NAME, TYPE)
virtual IOSize write(const void *from, IOSize n)
static pthread_mutex_t m_dlopen_lock
virtual void create(const char *name, bool exclusive=false, int perms=0666)