43 #include <sys/types.h>
44 #include <sys/param.h>
45 #if defined(__solaris__) || defined(AIX)
46 #include <sys/vnode.h>
117 const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH;
118 char local_path[MAXPATHLEN+1], *p, pc;
119 local_path[0] =
'\0';
120 unsigned long long remotefs;
121 int isLink = 0, Missing = 1, retc = 0, datfd;
131 if ((retc =
GenLocalPath(path, local_path)))
return retc;
135 if ((Missing =
lstat(local_path, &buf))) retc = errno;
136 else {
if ((isLink = ((buf.st_mode & S_IFMT) == S_IFLNK)))
137 {
if (
stat(local_path, &buf))
138 {
if (errno != ENOENT)
return -errno;
139 OssEroute.
Emsg(
"Create",
"removing dangling link",local_path);
140 if (
unlink(local_path)) retc = errno;
141 Missing = 1; isLink = 0;
145 if (retc && retc != ENOENT)
return -retc;
149 bool forcecg =
false;
152 const char *colocenv = env.
Get(
"oss.coloc");
153 std::string coloc(colocenv ? colocenv :
"");
155 char coloc_local[MAXPATHLEN+1];
156 coloc_local[0] =
'\0';
157 if ((retc =
GenLocalPath(coloc.c_str(), coloc_local)))
return retc;
160 if (cp) gpath = cp->
group + std::string(
":") + cp->
path;
170 access_mode, crInfo.
pOpts);
177 if ((buf.st_mode & S_IFMT) == S_IFDIR)
return -EISDIR;
178 do {datfd =
open(local_path,
Opts>>8, access_mode);}
179 while(datfd < 0 && errno == EINTR);
180 if (datfd < 0)
return -errno;
181 if ((retc =
SetFattr(crInfo, datfd, buf.st_mtime)))
return retc;
182 if (
Opts>>8 & O_TRUNC && buf.st_size)
183 {off_t theSize = buf.st_size;
184 if (isLink) {buf.st_mode = (buf.st_mode & ~S_IFMT) | S_IFLNK;
194 {p++; pc = *p; *p =
'\0';
202 {
char remote_path[MAXPATHLEN+1];
211 {
if ((retc =
MSS_Create(remote_path, access_mode, env)) < 0)
213 <<
" remote path=" <<remote_path);
217 {
if (!(retc =
MSS_Stat(remote_path)))
return -EEXIST;
218 else if (retc != -ENOENT)
return retc;
284 strlen(crInfo.
Path)+1, pbuff, datfd)))
285 {
close(datfd);
return rc;}
290 if ((rc =
SetFattr(crInfo, datfd, 1)))
return rc;
294 if ((symlink(pbuff, crInfo.
Path) && errno != EEXIST)
296 {rc = -errno;
unlink(pbuff);}
314 do {datfd =
open(crInfo.
Path, O_RDWR|O_CREAT|O_TRUNC, crInfo.
Amode);}
315 while(datfd < 0 && errno == EINTR);
316 if (datfd < 0)
return -errno;
321 if ((rc =
SetFattr(crInfo, datfd, 1)))
return rc;
338 int Done(
int rc) {
if (rc)
unlink(
Path);
return rc;}
339 fdCloser(
const char *pn,
int fd) :
Path(pn), theFD(fd) {}
340 ~fdCloser() {
close(theFD);}
341 } Act(crInfo.
Path, fd);
#define Check_RO(act, flags, path, opname)
static const char * Name()
static int Alloc(allocInfo &aInfo)
static char * Parse(const char *token, char *cbuff, int cblen)
static XrdOssCache_FS * fsfirst
static XrdOssCache_FS * Find(const char *Path, int lklen=0)
static void Adjust(dev_t devid, off_t size)
XrdOssCreateInfo(const char *path, const char *lfn, mode_t amode, int opts)
static const int minSNbsz
int GenRemotePath(const char *, char *)
virtual int Stage(const char *, const char *, XrdOucEnv &, int, mode_t, unsigned long long)
int SetFattr(XrdOssCreateInfo &crInfo, int datfd, time_t mtime)
int Alloc_Cache(XrdOssCreateInfo &, XrdOucEnv &, bool)
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0)
int GenLocalPath(const char *, char *)
int MSS_Stat(const char *, struct stat *buff=0)
int MSS_Create(const char *path, mode_t, XrdOucEnv &)
int Alloc_Local(XrdOssCreateInfo &, XrdOucEnv &)
char * Get(const char *varname)
void Put(const char *varname, const char *value)
XrdOucPList * About(const char *pathname)
void Default(unsigned long long x)
unsigned long long Flag()
static std::string UrlDecode(const std::string &input)
static int makePath(char *path, mode_t mode, bool reset=false)
int Set(const char *Path, int fd=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
virtual int Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd=-1, int isNew=0)=0