53 #include <sys/types.h> 56 #include "chirp_reli.h" 63 #define FIXPATH(x) ( x[0]==0 ? "/" : x ) 69 static int did_setup = 0;
70 if (did_setup)
return;
72 debug_config(
"chirp_root");
74 const char *debug_file = getenv(
"CHIRP_DEBUG_FILE");
75 if (debug_file) debug_config_file(debug_file);
77 const char *debug_flags = getenv(
"CHIRP_DEBUG_FLAGS");
78 if (debug_flags) debug_flags_set(debug_flags);
80 const char *auth_flags = getenv(
"CHIRP_AUTH");
82 auth_register_byname(auth_flags);
87 const char *timeout_string = getenv(
"CHIRP_TIMEOUT");
107 if (fOption ==
"NEW")
115 if (!create && !recreate && !
update && !
read) {
122 if (create ||
update || recreate) {
123 Int_t mode = O_RDWR | O_CREAT;
128 fD = SysOpen(path, mode, 0644);
130 fD = SysOpen(path, mode |
O_BINARY, S_IREAD | S_IWRITE);
133 SysError(
"TChirpFile",
"file %s can not be created", path);
139 fD = SysOpen(path, O_RDONLY, 0644);
141 fD = SysOpen(path, O_RDONLY |
O_BINARY, S_IREAD | S_IWRITE);
144 SysError(
"TChirpFile",
"file %s can not be opened for reading", path);
150 Init(create || recreate);
171 struct chirp_bulkio bulkio[nbuf];
176 for (i = 0; i < nbuf; i++) {
177 bulkio[i].type = CHIRP_BULKIO_PREAD;
179 bulkio[i].offset = pos[i];
180 bulkio[i].length = len[i];
181 bulkio[i].buffer = nextbuf;
236 if (whence == SEEK_SET) {
238 }
else if(whence == SEEK_CUR) {
240 }
else if(whence == SEEK_END) {
241 struct chirp_stat info;
245 SysError(
"TChirpFile",
"Unable to seek from end of file");
249 fOffset = info.cst_size + offset;
252 SysError(
"TChirpFile",
"Unknown whence!");
270 struct chirp_stat cst;
274 if (rc < 0)
return rc;
277 *size = cst.cst_size;
278 *flags = cst.cst_mode;
279 *modtime = cst.cst_mtime;
296 TChirpSystem::~TChirpSystem()
320 return chirp_reli_closedir((
struct chirp_dir *) dirp);
327 struct chirp_dirent *d = chirp_reli_readdir((
struct chirp_dir *) dirp);
340 struct chirp_stat info;
343 buf.
fDev = info.cst_dev;
344 buf.
fIno = info.cst_ino;
345 buf.
fMode = info.cst_mode;
346 buf.
fUid = info.cst_uid;
347 buf.
fGid = info.cst_gid;
348 buf.
fSize = info.cst_size;
349 buf.
fMtime = info.cst_mtime;
350 buf.
fIsLink = S_ISLNK(info.cst_mode);
381 if (rc < 0 && errno == EISDIR) {
438 struct chirp_statfs info;
443 *bsize = info.f_bsize;
444 *blocks = info.f_blocks;
445 *bfree = info.f_bfree;
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
Int_t Unlink(const char *path)
Unlink, i.e. remove, a file.
double read(const std::string &file_name)
reading
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read().
int Link(const char *from, const char *to)
Create a link from file1 to file2.
This class represents a WWW compatible URL.
void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
static int chirp_root_timeout
void SysError(const char *location, const char *msgfmt,...)
const char * GetFile() const
const char * GetHost() const
Read and write data via a Chirp server.
static void chirp_root_global_setup()
TString fRealName
Effective real file name (not original url)
void Init(TClassEdit::TInterpreterLookupHelper *helper)
int Rename(const char *from, const char *to)
Rename a file.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
void FreeDirectory(void *dirp)
Free a directory.
const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
virtual ULong_t Hash() const
Return hash value for this object.
struct chirp_file * chirp_file_ptr
virtual void SetName(const char *newname)
Set the name for directory If the directory name is changed after the directory was written once...
Int_t MakeDirectory(const char *name)
Make a directory.
int Utime(const char *file, Long_t modtime, Long_t actime)
Set the a files modification and access times.
int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write().
int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks...
Long64_t fOffset
!Seek offset cache
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open().
Abstract base class defining a generic interface to the underlying Operating System.
virtual void Close(Option_t *option="")
Close a file.
int Chmod(const char *file, UInt_t mode)
Set the file permission bits. Returns -1 in case or error, 0 otherwise.