36 #include <sys/param.h>
37 #include <sys/types.h>
72 unsigned long long opts;
75 char local_path[MAXPATHLEN+1+8];
81 if ( (retc =
GenLocalPath( path, local_path)))
return retc;
86 if (
lstat(local_path, &statbuff))
return (errno == ENOENT ? 0 : -errno);
87 if ((statbuff.st_mode & S_IFMT) != S_IFDIR)
return -ENOTDIR;
109 unsigned long long dummy, remotefs;
110 int i, retc2, doAdjust = 0, retc =
XrdOssOK;
111 struct stat statbuff;
113 char local_path[MAXPATHLEN+1+8];
114 char remote_path[MAXPATHLEN+1];
119 {strcpy(local_path, path),
130 if (
lstat(local_path, &statbuff)) retc = (errno == ENOENT ? 0 : -errno);
131 else if ((statbuff.st_mode & S_IFMT) == S_IFLNK)
133 else if ((statbuff.st_mode & S_IFMT) == S_IFDIR)
134 {i = strlen(local_path);
135 if (local_path[i-1] !=
'/') strcpy(local_path+i,
"/");
136 if ((retc =
rmdir(local_path))) retc = -errno;
137 DEBUG(
"dir rc=" <<retc <<
" path=" <<local_path);
144 {
if (
unlink(local_path)) retc = -errno;
145 else {i = strlen(local_path);
146 if (doAdjust && statbuff.st_size)
149 DEBUG(
"lcl rc=" <<retc <<
" path=" <<local_path);
155 && (!retc || retc == -ENOENT) &&
RSSCmd)
156 {
if ((retc2 =
MSS_Unlink(remote_path)) != -ENOENT) retc = retc2;
157 DEBUG(
"rmt rc=" <<retc2 <<
" path=" <<remote_path);
175 char *lP, lnkbuff[MAXPATHLEN+64];
176 int lnklen, retc = 0;
180 if ((lnklen = readlink(local_path, lnkbuff,
sizeof(lnkbuff)-1)) < 0)
185 lnkbuff[lnklen] =
'\0';
186 if (
stat(lnkbuff, &statbuff)) statbuff.st_size = 0;
187 else if (
unlink(lnkbuff) && errno != ENOENT)
189 OssEroute.
Emsg(
"BreakLink",retc,
"unlink symlink target",lnkbuff);
190 }
else {
DEBUG(
"broke link " <<local_path <<
"->" <<lnkbuff);}
195 lP = lnkbuff+lnklen-1;
197 {
if (statbuff.st_size)
201 }
else if (statbuff.st_size)
#define Check_RO(act, flags, path, opname)
int stat(const char *path, struct stat *buf)
int lstat(const char *path, struct stat *buf)
int unlink(const char *path)
int rmdir(const char *path)
static void Adjust(dev_t devid, off_t size)
static void Trim2Base(char *eP)
int GenRemotePath(const char *, char *)
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)
int GenLocalPath(const char *, char *)
int MSS_Unlink(const char *)
int BreakLink(const char *local_path, struct stat &statbuff)
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)