36 #include <sys/types.h>
63 Hint = (dflt ==
'y' ?
" (y | n | a): " :
" (n | y | a): ");
65 do {std::cerr <<
"frm_admin: " <<Msg1 <<Msg2 <<Msg3 <<Hint;
66 std::cin.getline(Answer,
sizeof(Answer));
67 if (!*Answer)
return dflt;
70 if (!strncmp(
"yes", Answer, n))
return 'y';
71 if (!strncmp(
"no", Answer, n))
return 'n';
72 if (!strncmp(
"abort",Answer, n))
return 'a';
87 if (!(Elem = index(Url,
':')))
return 0;
88 if (Elem[1] !=
'/' || Elem[2] !=
'/')
return 0;
89 if (!(Elem = index(Elem+3,
'/')) || Elem[1] !=
'/')
return 0;
94 while(Elem[1] ==
'/') Elem++;
114 {
Say.
Emsg(
"makePath", rc,
"create directory", bPath);
129 char qPath[1040], qLink[1032];
136 if (qPath[n-1] !=
'/') qPath[n++] =
'/';
137 strcpy(qPath+n,
"Queues/");
141 if ((lksz = readlink(qPath, qLink,
sizeof(qLink)-1)) > 0)
143 if (qLink[lksz-1] !=
'/') {qLink[lksz++] =
'/'; qLink[lksz++] =
'\0';}
144 if (*qLink ==
'/') strcpy(qPath, qLink);
145 else strcpy(qPath+n, qLink);
151 {
Say.
Emsg(
"makeQDir", rc,
"create directory", qPath);
157 return strdup(qPath);
172 {
if (index(Pop,
's') || index(Pop,
'n'))
174 if (index(Pop,
'f') || !index(Pop,
'q'))
226 static const int ITNum =
sizeof(ITList)/
sizeof(
struct ITypes);
231 for (i = 0; i < ITNum; i++)
232 if (!strcmp(vName, ITList[i].IName))
233 {ICode = ITList[i].ICode;
return 1;}
243 static const int Mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
249 if ((myFD =
open(lkfn, O_RDWR|O_CREAT,
Mode)) < 0)
250 {
Say.
Emsg(
"Unique",errno,
"open",lkfn);
return 0;}
254 bzero(&lock_args,
sizeof(lock_args));
255 lock_args.l_type = F_WRLCK;
259 do {rc =
fcntl(myFD,F_SETLK,&lock_args);}
260 while(rc < 0 && errno == EINTR);
262 {
Say.
Emsg(
"Unique", errno,
"obtain the run lock on", lkfn);
263 Say.
Emsg(
"Unique",
"Another", myProg,
"may already be running!");
284 if (
stat(Pfn, &
Stat)) {
Say.
Emsg(
"updCpy", errno,
"stat pfn ",Pfn);
return 0;}
289 return cpyInfo.
Set(Pfn) == 0;
298 struct utimbuf tbuf = {tVal, tVal};
303 do {rc = utime(
Path, &tbuf);}
while(rc && errno == EINTR);
304 if (rc)
Say.
Emsg(
"Utils", errno,
"set utime for pfn",
Path);
int stat(const char *path, struct stat *buf)
int open(const char *path, int oflag,...)
int fcntl(int fd, int cmd,...)
static int chkURL(const char *Url)
static char Ask(char dflt, const char *Msg1, const char *Msg2="", const char *Msg3="")
static int MapR2Q(char Opc, int *Flags=0)
static int Unique(const char *lkfn, const char *myProg)
static char * makePath(const char *iName, const char *Path, int Mode)
static int MapV2I(const char *Opc, XrdFrcRequest::Item &ICode)
static int Utime(const char *Path, time_t tVal)
static char * makeQDir(const char *Path, int Mode)
static int MapM2O(const char *Nop, const char *Pop)
static int updtCpy(const char *Pfn, int Adj)
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static int makePath(char *path, mode_t mode, bool reset=false)
int Set(const char *Path, int fd=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)