Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Defines | Functions | Variables
info_files.cpp File Reference
#include <string>
#include <list>
#include <iostream>
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <errno.h>
#include <limits>
#include <arc/StringConv.h>
#include <arc/DateTime.h>
#include "../files/delete.h"
#include "../misc/escaped.h"
#include "../run/run_function.h"
#include "../run/run_redirected.h"
#include "../conf/conf.h"
#include "info_types.h"
#include "info_files.h"

Go to the source code of this file.

Classes

struct  job_mark_add_t
struct  job_dir_remove_t
struct  job_file_read_t

Defines

#define istream_readline(__f, __s, __n)

Functions

bool fix_file_permissions (const std::string &fname, bool executable)
static bool fix_file_permissions (const std::string &fname, const JobUser &user)
bool fix_file_owner (const std::string &fname, const JobUser &user)
bool fix_file_owner (const std::string &fname, const JobDescription &desc, const JobUser &user)
bool check_file_owner (const std::string &fname, const JobUser &user)
bool check_file_owner (const std::string &fname, const JobUser &user, uid_t &uid, gid_t &gid)
bool check_file_owner (const std::string &fname, const JobUser &user, uid_t &uid, gid_t &gid, time_t &t)
bool job_lrms_mark_put (const JobDescription &desc, JobUser &user, int code)
bool job_lrms_mark_put (const JobDescription &desc, JobUser &user, LRMSResult r)
bool job_lrms_mark_check (JobId &id, JobUser &user)
bool job_lrms_mark_remove (JobId &id, JobUser &user)
LRMSResult job_lrms_mark_read (JobId &id, JobUser &user)
bool job_cancel_mark_put (const JobDescription &desc, JobUser &user)
bool job_cancel_mark_check (JobId &id, JobUser &user)
bool job_cancel_mark_remove (JobId &id, JobUser &user)
bool job_restart_mark_put (const JobDescription &desc, JobUser &user)
bool job_restart_mark_check (JobId &id, JobUser &user)
bool job_restart_mark_remove (JobId &id, JobUser &user)
bool job_clean_mark_put (const JobDescription &desc, JobUser &user)
bool job_clean_mark_check (JobId &id, JobUser &user)
bool job_clean_mark_remove (JobId &id, JobUser &user)
bool job_errors_mark_put (const JobDescription &desc, JobUser &user)
bool job_failed_mark_put (const JobDescription &desc, JobUser &user, const std::string &content)
bool job_failed_mark_add (const JobDescription &desc, JobUser &user, const std::string &content)
bool job_failed_mark_check (const JobId &id, JobUser &user)
bool job_failed_mark_remove (const JobId &id, JobUser &user)
std::string job_failed_mark_read (const JobId &id, JobUser &user)
static int job_mark_put_callback (void *arg)
static int job_mark_remove_callback (void *arg)
static int job_dir_create_callback (void *arg)
static int job_mark_add_callback (void *arg)
static int job_dir_remove_callback (void *arg)
bool job_diagnostics_mark_put (const JobDescription &desc, JobUser &user)
bool job_session_create (const JobDescription &desc, JobUser &user)
bool job_controldiag_mark_put (const JobDescription &desc, JobUser &user, char const *const args[])
bool job_lrmsoutput_mark_put (const JobDescription &desc, JobUser &user)
bool job_diagnostics_mark_add (const JobDescription &desc, JobUser &user, const std::string &content)
bool job_diagnostics_mark_remove (const JobDescription &desc, JobUser &user)
bool job_lrmsoutput_mark_remove (const JobDescription &desc, JobUser &user)
static int job_file_read_callback (void *arg)
bool job_diagnostics_mark_move (const JobDescription &desc, JobUser &user)
bool job_stdlog_move (const JobDescription &, JobUser &, const std::string &)
bool job_dir_create (const std::string &dname)
bool job_mark_put (const std::string &fname)
bool job_mark_check (const std::string &fname)
bool job_mark_remove (const std::string &fname)
std::string job_mark_read_s (const std::string &fname)
long int job_mark_read_i (const std::string &fname)
bool job_mark_write_s (const std::string &fname, const std::string &content)
bool job_mark_add_s (const std::string &fname, const std::string &content)
time_t job_mark_time (const std::string &fname)
long int job_mark_size (const std::string &fname)
bool job_diskusage_create_file (const JobDescription &desc, JobUser &, unsigned long long int &requested)
bool job_diskusage_read_file (const JobDescription &desc, JobUser &, unsigned long long int &requested, unsigned long long int &used)
bool job_diskusage_change_file (const JobDescription &desc, JobUser &, signed long long int used, bool &result)
bool job_diskusage_remove_file (const JobDescription &desc, JobUser &)
time_t job_state_time (const JobId &id, JobUser &user)
job_state_t job_state_read_file (const JobId &id, const JobUser &user)
job_state_t job_state_read_file (const JobId &id, const JobUser &user, bool &pending)
bool job_state_write_file (const JobDescription &desc, JobUser &user, job_state_t state, bool pending)
job_state_t job_state_read_file (const std::string &fname, bool &pending)
bool job_state_write_file (const std::string &fname, job_state_t state, bool pending)
bool job_description_read_file (JobId &id, JobUser &user, std::string &rsl)
bool job_description_read_file (const std::string &fname, std::string &rsl)
bool job_description_write_file (const std::string &fname, std::string &rsl)
bool job_description_write_file (const std::string &fname, const char *rsl)
bool job_acl_read_file (JobId &id, JobUser &user, std::string &acl)
bool job_acl_write_file (JobId &id, JobUser &user, std::string &acl)
bool job_local_write_file (const JobDescription &desc, const JobUser &user, const JobLocalDescription &job_desc)
void write_pair (std::ofstream &f, const std::string &name, const std::string &value)
void write_pair (std::ofstream &f, const std::string &name, const Arc::Time &value)
void write_pair (std::ofstream &f, const std::string &name, bool value)
bool job_local_write_file (const std::string &fname, const JobLocalDescription &job_desc)
bool job_local_read_file (const JobId &id, const JobUser &user, JobLocalDescription &job_desc)
bool job_local_read_file (const std::string &fname, JobLocalDescription &job_desc)
bool job_local_read_var (const std::string &fname, const std::string &vnam, std::string &value)
bool job_local_read_lifetime (const JobId &id, const JobUser &user, time_t &lifetime)
bool job_local_read_cleanuptime (const JobId &id, const JobUser &user, time_t &cleanuptime)
bool job_local_read_notify (const JobId &id, const JobUser &user, std::string &notify)
bool job_local_read_string (const std::string &fname, unsigned int num, std::string &str)
bool job_input_write_file (const JobDescription &desc, JobUser &user, std::list< FileData > &files)
bool job_input_read_file (const JobId &id, JobUser &user, std::list< FileData > &files)
std::string job_proxy_filename (const JobId &id, const JobUser &user)
bool job_rte_write_file (const JobDescription &desc, JobUser &user, std::list< std::string > &rtes)
bool job_rte_read_file (const JobId &id, JobUser &user, std::list< std::string > &rtes)
bool job_output_write_file (const JobDescription &desc, JobUser &user, std::list< FileData > &files)
bool job_output_read_file (const JobId &id, JobUser &user, std::list< FileData > &files)
bool job_Xput_write_file (const std::string &fname, std::list< FileData > &files)
bool job_Xput_read_file (std::list< FileData > &files)
bool job_Xput_read_file (const std::string &fname, std::list< FileData > &files)
bool job_strings_write_file (const std::string &fname, std::list< std::string > &strs)
bool job_strings_read_file (const std::string &fname, std::list< std::string > &strs)
bool job_clean_finished (const JobId &id, JobUser &user)
bool job_clean_deleted (const JobDescription &desc, JobUser &user, std::list< std::string > cache_per_job_dirs)
bool job_clean_final (const JobDescription &desc, JobUser &user)

Variables

const char *const sfx_failed = ".failed"
const char *const sfx_cancel = ".cancel"
const char *const sfx_restart = ".restart"
const char *const sfx_clean = ".clean"
const char *const sfx_status = ".status"
const char *const sfx_local = ".local"
const char *const sfx_errors = ".errors"
const char *const sfx_rsl = ".description"
const char *const sfx_diag = ".diag"
const char *const sfx_lrmsoutput = ".comment"
const char *const sfx_diskusage = ".disk"
const char *const sfx_acl = ".acl"
const char *const sfx_proxy = ".proxy"
static Arc::Loggerlogger = Arc::Logger::getRootLogger()

Class Documentation

struct job_mark_add_t

Definition at line 261 of file info_files.cpp.

Collaboration diagram for job_mark_add_t:
Class Members
const string * content
const string * fname
struct job_dir_remove_t

Definition at line 273 of file info_files.cpp.

Collaboration diagram for job_dir_remove_t:
Class Members
const string * dname
const list< FileData > * flist
struct job_file_read_t

Definition at line 360 of file info_files.cpp.

Collaboration diagram for job_file_read_t:
Class Members
const string * fname
int h

Define Documentation

#define istream_readline (   __f,
  __s,
  __n 
)
Value:
{      \
   __f.get(__s,__n,'\n');         \
   if(__f.fail()) __f.clear();               \
   __f.ignore(INT_MAX,'\n'); \
}

Definition at line 44 of file info_files.cpp.


Function Documentation

bool check_file_owner ( const std::string &  fname,
const JobUser user 
)

Definition at line 110 of file info_files.cpp.

                                                                  {
  uid_t uid;
  gid_t gid;
  time_t t;
  return check_file_owner(fname,user,uid,gid,t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_file_owner ( const std::string &  fname,
const JobUser user,
uid_t &  uid,
gid_t &  gid 
)

Definition at line 117 of file info_files.cpp.

                                                                                        {
  time_t t;
  return check_file_owner(fname,user,uid,gid,t);
}

Here is the call graph for this function:

bool check_file_owner ( const std::string &  fname,
const JobUser user,
uid_t &  uid,
gid_t &  gid,
time_t &  t 
)

Definition at line 122 of file info_files.cpp.

                                                                                                  {
  struct stat st;
  if(lstat(fname.c_str(),&st) != 0) return false;
  if(!S_ISREG(st.st_mode)) return false;
  uid=st.st_uid; gid=st.st_gid; t=st.st_ctime;
  /* superuser can't run jobs */
  if(uid == 0) return false;
  /* accept any file if superuser */
  if(user.get_uid() != 0) {
    if(uid != user.get_uid()) return false;
  };
  return true;
}

Here is the call graph for this function:

bool fix_file_owner ( const std::string &  fname,
const JobUser user 
)

Definition at line 85 of file info_files.cpp.

                                                                {
  if(getuid() == 0) {
    if(lchown(fname.c_str(),user.get_uid(),user.get_gid()) == -1) {
      logger.msg(Arc::ERROR,"Failed setting file owner: %s",fname);
      return false;
    };
  };
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fix_file_owner ( const std::string &  fname,
const JobDescription desc,
const JobUser user 
)

Definition at line 95 of file info_files.cpp.

                                                                                           {
  if(getuid() == 0) {
    uid_t uid = desc.get_uid();
    gid_t gid = desc.get_gid();
    if( uid == 0 ) {
      uid=user.get_uid(); gid=user.get_gid();
    };
    if(lchown(fname.c_str(),uid,gid) == -1) {
      logger.msg(Arc::ERROR,"Failed setting file owner: %s",fname);
      return false;
    };
  };
  return true;
}

Here is the call graph for this function:

bool fix_file_permissions ( const std::string &  fname,
bool  executable 
)

Definition at line 69 of file info_files.cpp.

                                                                  {
  mode_t mode = S_IRUSR | S_IWUSR;
  if(executable) { mode |= S_IXUSR; };
  return (chmod(fname.c_str(),mode) == 0);
}

Here is the caller graph for this function:

static bool fix_file_permissions ( const std::string &  fname,
const JobUser user 
) [static]

Definition at line 75 of file info_files.cpp.

                                                                             {
  mode_t mode = S_IRUSR | S_IWUSR;
  if(user.ShareLevel() == JobUser::jobinfo_share_group) {
    mode |= S_IRGRP;
  } else if(user.ShareLevel() == JobUser::jobinfo_share_all) {
    mode |= S_IRGRP | S_IROTH;
  };
  return (chmod(fname.c_str(),mode) == 0);
}

Here is the call graph for this function:

bool job_acl_read_file ( JobId id,
JobUser user,
std::string &  acl 
)

Definition at line 637 of file info_files.cpp.

                                                               {
  std::string fname = user.ControlDir() + "/job." + id + sfx_acl;
  return job_description_read_file(fname,acl);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_acl_write_file ( JobId id,
JobUser user,
std::string &  acl 
)

Definition at line 642 of file info_files.cpp.

                                                                {
  std::string fname = user.ControlDir() + "/job." + id + sfx_acl;
  return job_description_write_file(fname,acl.c_str());
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_cancel_mark_check ( JobId id,
JobUser user 
)

Definition at line 172 of file info_files.cpp.

                                                    {
  std::string fname = user.ControlDir() + "/job." + id + sfx_cancel;
  return job_mark_check(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_cancel_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 167 of file info_files.cpp.

                                                                   {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_cancel;
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_cancel_mark_remove ( JobId id,
JobUser user 
)

Definition at line 177 of file info_files.cpp.

                                                     {
  std::string fname = user.ControlDir() + "/job." + id + sfx_cancel;
  return job_mark_remove(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_deleted ( const JobDescription desc,
JobUser user,
std::list< std::string >  cache_per_job_dirs 
)

Definition at line 988 of file info_files.cpp.

                                                                                                       {
  std::string id = desc.get_id();
  job_clean_finished(id,user);
  std::string fname;
  fname = user.ControlDir()+"/job."+id+".proxy"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_restart; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_errors; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_cancel; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_clean;  remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".output"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".input"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".rte"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".grami_log"; remove(fname.c_str());
  fname = user.SessionRoot(id)+"/"+id+sfx_lrmsoutput; remove(fname.c_str());
  /* remove session directory */
  std::list<FileData> flist;
  std::string dname = user.SessionRoot(id)+"/"+id;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    job_dir_remove_t arg; arg.dname=&dname; arg.flist=&flist;
    return (RunFunction::run(tmp_user,"job_clean_deleted",&job_dir_remove_callback,&arg,10) == 0);
  } else {
    delete_all_files(dname,flist,true);
    remove(dname.c_str());
  };
  // remove cache per-job links, in case this failed earlier
  // list all files in the dir and delete them
  for (std::list<std::string>::iterator i = cache_per_job_dirs.begin(); i != cache_per_job_dirs.end(); i++) {
    std::string cache_job_dir = (*i) + "/" + id;
    DIR * dirp = opendir(cache_job_dir.c_str());
    if ( dirp == NULL) return true; // already deleted
    struct dirent *dp;
    while ((dp = readdir(dirp)))  {
      if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue;
      std::string to_delete = cache_job_dir + "/" + dp->d_name; 
      remove(to_delete.c_str());
    }
    closedir(dirp);
    // remove now-empty dir
    rmdir(cache_job_dir.c_str());
  }
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_final ( const JobDescription desc,
JobUser user 
)

Definition at line 1032 of file info_files.cpp.

                                                               {
  std::string id = desc.get_id();
  job_clean_finished(id,user);
  job_clean_deleted(desc,user);
  std::string fname;
  fname = user.ControlDir()+"/job."+id+sfx_local;  remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".grami"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_failed; remove(fname.c_str());
  job_diagnostics_mark_remove(desc,user);
  job_lrmsoutput_mark_remove(desc,user);
  fname = user.ControlDir()+"/job."+id+sfx_status; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+sfx_rsl;    remove(fname.c_str());
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_finished ( const JobId id,
JobUser user 
)

Definition at line 981 of file info_files.cpp.

                                                       {
  std::string fname;
  fname = user.ControlDir()+"/job."+id+".proxy.tmp"; remove(fname.c_str());
  fname = user.ControlDir()+"/job."+id+".lrms_done"; remove(fname.c_str());
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_mark_check ( JobId id,
JobUser user 
)

Definition at line 202 of file info_files.cpp.

                                                   {
  std::string fname = user.ControlDir() + "/job." + id + sfx_clean;
  return job_mark_check(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 197 of file info_files.cpp.

                                                                  {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_clean;
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_clean_mark_remove ( JobId id,
JobUser user 
)

Definition at line 207 of file info_files.cpp.

                                                    {
  std::string fname = user.ControlDir() + "/job." + id + sfx_clean;
  return job_mark_remove(fname);
}

Here is the call graph for this function:

bool job_controldiag_mark_put ( const JobDescription desc,
JobUser user,
char const *const  args[] 
)

Definition at line 304 of file info_files.cpp.

                                                                                                  {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_diag;
  if(!job_mark_put(fname)) return false;
  if(!fix_file_owner(fname,desc,user)) return false;
  if(!fix_file_permissions(fname)) return false;
  if(args == NULL) return true;
  int h = open(fname.c_str(),O_WRONLY);
  if(h == -1) return false;
  int r;
  int t = 10;
  JobUser tmp_user((uid_t)0);
  r=RunRedirected::run(tmp_user,"job_controldiag_mark_put",-1,h,-1,(char**)args,t);
  close(h);
  if(r != 0) return false;
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_description_read_file ( JobId id,
JobUser user,
std::string &  rsl 
)

Definition at line 604 of file info_files.cpp.

                                                                       {
  std::string fname = user.ControlDir() + "/job." + id + sfx_rsl;
  return job_description_read_file(fname,rsl);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_description_read_file ( const std::string &  fname,
std::string &  rsl 
)

Definition at line 609 of file info_files.cpp.

                                                                      {
  char buf[256];
  std::string::size_type n=0;
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  rsl.erase();
  while(!f.eof()) {
    memset(buf,0,256);
    f.read(buf,255); rsl+=buf;
    for(;(n=rsl.find('\n',n)) != std::string::npos;) rsl.erase(n,1);
    n=rsl.length();
  };
  f.close();
  return true;
}
bool job_description_write_file ( const std::string &  fname,
std::string &  rsl 
)

Definition at line 625 of file info_files.cpp.

                                                                       {
  return job_description_write_file(fname,rsl.c_str());
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_description_write_file ( const std::string &  fname,
const char *  rsl 
)

Definition at line 629 of file info_files.cpp.

                                                                        {
  std::ofstream f(fname.c_str(),std::ios::out | std::ios::trunc);
  if(! f.is_open() ) return false; /* can't open file */
  f.write(rsl,strlen(rsl));
  f.close();
  return true;
}
bool job_diagnostics_mark_add ( const JobDescription desc,
JobUser user,
const std::string &  content 
)

Definition at line 330 of file info_files.cpp.

                                                                                                 {
  std::string fname = desc.SessionDir() + sfx_diag;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    job_mark_add_t arg; arg.fname=&fname; arg.content=&content;
    return (RunFunction::run(tmp_user,"job_diagnostics_mark_add",&job_mark_add_callback,&arg,10) == 0);
  };
  return job_mark_add_s(fname,content) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

bool job_diagnostics_mark_move ( const JobDescription desc,
JobUser user 
)

Definition at line 382 of file info_files.cpp.

                                                                         {
  std::string fname2 = user.ControlDir() + "/job." + desc.get_id() + sfx_diag;
  int h2=open(fname2.c_str(),O_WRONLY | O_APPEND,S_IRUSR | S_IWUSR);
  if(h2==-1) return false;
  fix_file_owner(fname2,desc,user);
  fix_file_permissions(fname2,user);
  std::string fname1 = user.SessionRoot(desc.get_id()) + "/" + desc.get_id() + sfx_diag;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    job_file_read_t arg; arg.h=h2; arg.fname=&fname1;
    RunFunction::run(tmp_user,"job_diagnostics_mark_move",&job_file_read_callback,&arg,10);
    close(h2);
    return true;
  };
  int h1=open(fname1.c_str(),O_RDONLY);
  if(h1==-1) { close(h2); return false; };
  char buf[256];
  int l;
  for(;;) {
    l=read(h1,buf,256);
    if((l==0) || (l==-1)) break;
    (write(h2,buf,l) != -1);
  };
  close(h1); close(h2);
  unlink(fname1.c_str());
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_diagnostics_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 286 of file info_files.cpp.

                                                                        {
  std::string fname = desc.SessionDir() + sfx_diag;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    return (RunFunction::run(tmp_user,"job_diagnostics_mark_put",&job_mark_put_callback,&fname,10) == 0);
  };
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_diagnostics_mark_remove ( const JobDescription desc,
JobUser user 
)

Definition at line 340 of file info_files.cpp.

                                                                           {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_diag;
  bool res1 = job_mark_remove(fname);
  fname = desc.SessionDir() + sfx_diag;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    return (res1 | (RunFunction::run(tmp_user,"job_diagnostics_mark_remove",&job_mark_remove_callback,&fname,10) == 0));
  };
  return (res1 | job_mark_remove(fname));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_dir_create ( const std::string &  dname)

Definition at line 419 of file info_files.cpp.

                                            {
  int err=mkdir(dname.c_str(),S_IRUSR | S_IWUSR | S_IXUSR);
  return (err==0);
}

Here is the caller graph for this function:

static int job_dir_create_callback ( void *  arg) [static]

Definition at line 255 of file info_files.cpp.

                                              {
  std::string& dname = *((std::string*)arg);
  if(job_dir_create(dname) & fix_file_permissions(dname,true)) return 0;
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int job_dir_remove_callback ( void *  arg) [static]

Definition at line 278 of file info_files.cpp.

                                              {
  const std::string& dname = *(((job_dir_remove_t*)arg)->dname);
  const std::list<FileData>& flist = *(((job_dir_remove_t*)arg)->flist);
  delete_all_files(dname,flist,true);
  remove(dname.c_str());
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_diskusage_change_file ( const JobDescription desc,
JobUser ,
signed long long int  used,
bool &  result 
)

Definition at line 507 of file info_files.cpp.

                                                                                                             {
  // lock file, read, write, unlock
  std::string fname = desc.SessionDir() + sfx_diskusage;
  int h=open(fname.c_str(),O_RDWR);
  if(h==-1) return false;
  struct flock lock;
  lock.l_type=F_WRLCK;
  lock.l_whence=SEEK_SET;
  lock.l_start=0;
  lock.l_len=0;
  for(;;) {
    if(fcntl(h,F_SETLKW,&lock) != -1) break;
    if(errno == EINTR) continue;
    close(h); return false;
  };
  char content[200];
  ssize_t l=read(h,content,199);
  if(l==-1) {
    lock.l_whence=SEEK_SET; lock.l_start=0; lock.l_len=0;
    lock.l_type=F_UNLCK; fcntl(h,F_SETLK,&lock);
    close(h); return false;
  };
  content[l]=0;
  unsigned long long int req_,use_;
  if(sscanf(content,"%llu %llu",&req_,&use_) != 2) {
    lock.l_whence=SEEK_SET; lock.l_start=0; lock.l_len=0;
    lock.l_type=F_UNLCK; fcntl(h,F_SETLK,&lock);
    close(h); return false;
  };
  if((-used) > use_) {
    result=true; use_=0; // ??????
  }
  else {
    use_+=used; result=true;
    if(use_>req_) result=false;
  };
  lseek(h,0,SEEK_SET);  
  snprintf(content,sizeof(content),"%llu %llu\n",req_,use_);
  (write(h,content,strlen(content)) != -1);
  lock.l_whence=SEEK_SET; lock.l_start=0; lock.l_len=0;
  lock.l_type=F_UNLCK; fcntl(h,F_SETLK,&lock);
  close(h); return true;
}

Here is the call graph for this function:

bool job_diskusage_create_file ( const JobDescription desc,
JobUser ,
unsigned long long int &  requested 
)

Definition at line 483 of file info_files.cpp.

                                                                                                        {
  std::string fname = desc.SessionDir() + sfx_diskusage;
  int h=open(fname.c_str(),O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR);
  if(h==-1) return false;
  char content[200];
  snprintf(content, sizeof(content), "%llu 0\n",requested);
  (write(h,content,strlen(content)) != -1);
  close(h); return true;
}

Here is the call graph for this function:

bool job_diskusage_read_file ( const JobDescription desc,
JobUser ,
unsigned long long int &  requested,
unsigned long long int &  used 
)

Definition at line 493 of file info_files.cpp.

                                                                                                                                   {
  std::string fname = desc.SessionDir() + sfx_diskusage;
  int h=open(fname.c_str(),O_RDONLY);
  if(h==-1) return false;
  char content[200];
  ssize_t l=read(h,content,199);
  if(l==-1) { close(h); return false; };
  content[l]=0;
  unsigned long long int req_,use_;
  if(sscanf(content,"%llu %llu",&req_,&use_) != 2) { close(h); return false; };
  requested=req_; used=use_;  
  close(h); return true;
}

Here is the call graph for this function:

bool job_diskusage_remove_file ( const JobDescription desc,
JobUser  
)

Definition at line 551 of file info_files.cpp.

                                                                      {
  std::string fname = desc.SessionDir() + sfx_diskusage;
  return job_mark_remove(fname);
}

Here is the call graph for this function:

bool job_errors_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 212 of file info_files.cpp.

                                                                   {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_errors;
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_failed_mark_add ( const JobDescription desc,
JobUser user,
const std::string &  content 
)

Definition at line 223 of file info_files.cpp.

                                                                                            {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_failed;
  return job_mark_add_s(fname,content) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname,user);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_failed_mark_check ( const JobId id,
JobUser user 
)

Definition at line 228 of file info_files.cpp.

                                                          {
  std::string fname = user.ControlDir() + "/job." + id + sfx_failed;
  return job_mark_check(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_failed_mark_put ( const JobDescription desc,
JobUser user,
const std::string &  content 
)

Definition at line 217 of file info_files.cpp.

                                                                                            {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_failed;
  if(job_mark_size(fname) > 0) return true;
  return job_mark_write_s(fname,content) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname,user);
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string job_failed_mark_read ( const JobId id,
JobUser user 
)

Definition at line 238 of file info_files.cpp.

                                                              {
  std::string fname = user.ControlDir() + "/job." + id + sfx_failed;
  return job_mark_read_s(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_failed_mark_remove ( const JobId id,
JobUser user 
)

Definition at line 233 of file info_files.cpp.

                                                           {
  std::string fname = user.ControlDir() + "/job." + id + sfx_failed;
  return job_mark_remove(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int job_file_read_callback ( void *  arg) [static]

Definition at line 365 of file info_files.cpp.

                                             {
  int h = ((job_file_read_t*)arg)->h;
  const std::string& fname = *(((job_file_read_t*)arg)->fname);
  int h1=open(fname.c_str(),O_RDONLY);
  if(h1==-1) return -1;
  char buf[256];
  int l;
  for(;;) {
    l=read(h1,buf,256);
    if((l==0) || (l==-1)) break;
    (write(h,buf,l) != -1);
  };
  close(h1); close(h);
  unlink(fname.c_str());
  return 0;
}

Here is the caller graph for this function:

bool job_input_read_file ( const JobId id,
JobUser user,
std::list< FileData > &  files 
)

Definition at line 878 of file info_files.cpp.

                                                                                 {
  std::string fname = user.ControlDir() + "/job." + id + ".input";
  return job_Xput_read_file(fname,files);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_input_write_file ( const JobDescription desc,
JobUser user,
std::list< FileData > &  files 
)

Definition at line 873 of file info_files.cpp.

                                                                                             {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + ".input";
  return job_Xput_write_file(fname,files) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_local_read_cleanuptime ( const JobId id,
const JobUser user,
time_t &  cleanuptime 
)

Definition at line 843 of file info_files.cpp.

                                                                                         {
  std::string fname = user.ControlDir() + "/job." + id + sfx_local;
  std::string str;
  if(!job_local_read_var(fname,"cleanuptime",str)) return false;
  cleanuptime=Arc::Time(str).GetTime();
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_local_read_file ( const JobId id,
const JobUser user,
JobLocalDescription job_desc 
)

Definition at line 725 of file info_files.cpp.

                                                                                            {
  std::string fname = user.ControlDir() + "/job." + id + sfx_local;
  return job_local_read_file(fname,job_desc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_local_read_file ( const std::string &  fname,
JobLocalDescription job_desc 
)

Definition at line 730 of file info_files.cpp.

                                                                               {
  char buf[4096];
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  std::string name;
  job_desc.activityid.clear();
  for(;!f.eof();) {
    istream_readline(f,buf,sizeof(buf));
    name.erase();
    int p=input_escaped_string(buf,name,'=');
    if(name.length() == 0) continue;
    if(buf[p] == 0) continue;
    if(name == "lrms") { job_desc.lrms = buf+p; }
    else if(name == "queue") { job_desc.queue = buf+p; }
    else if(name == "localid") { job_desc.localid = buf+p; }
    else if(name == "subject") { job_desc.DN = buf+p; }
    else if(name == "starttime") { job_desc.starttime = buf+p; }
//    else if(name == "UI") { job_desc.UI = buf+p; }
    else if(name == "lifetime") { job_desc.lifetime = buf+p; }
    else if(name == "notify") { job_desc.notify = buf+p; }
    else if(name == "processtime") { job_desc.processtime = buf+p; }
    else if(name == "exectime") { job_desc.exectime = buf+p; }
    else if(name == "jobreport") { job_desc.jobreport.push_back(std::string(buf+p)); }
    else if(name == "globalid") { job_desc.globalid = buf+p; }
    else if(name == "jobname") { job_desc.jobname = buf+p; }
    else if(name == "projectname") { job_desc.projectnames.push_back(std::string(buf+p)); }
    else if(name == "gmlog") { job_desc.stdlog = buf+p; }
    else if(name == "rerun") {
      std::string temp_s(buf+p); int n;
      if(!Arc::stringto(temp_s,n)) { f.close(); return false; };
      job_desc.reruns = n;
    }
    else if(name == "downloads") {
      std::string temp_s(buf+p); int n;
      if(!Arc::stringto(temp_s,n)) { f.close(); return false; };
      job_desc.downloads = n;
    }
    else if(name == "uploads") {
      std::string temp_s(buf+p); int n;
      if(!Arc::stringto(temp_s,n)) { f.close(); return false; };
      job_desc.uploads = n;
    }
    else if(name == "rtes") {
      std::string temp_s(buf+p); int n;
      if(!Arc::stringto(temp_s,n)) { f.close(); return false; };
      job_desc.rtes = n;
    }
    else if(name == "args") {
      job_desc.arguments.clear();
      for(int n=p;buf[n] != 0;) {
        std::string arg;
        n+=input_escaped_string(buf+n,arg);
        job_desc.arguments.push_back(arg);
      };
    }
    else if(name == "cleanuptime") { job_desc.cleanuptime = buf+p; }
    else if(name == "delegexpiretime") { job_desc.expiretime = buf+p; }
    else if(name == "clientname") { job_desc.clientname = buf+p; }
    else if(name == "clientsoftware") { job_desc.clientsoftware = buf+p; }
    else if(name == "sessiondir") { job_desc.sessiondir = buf+p; }
    else if(name == "failedstate") { job_desc.failedstate = buf+p; }
    else if(name == "credentialserver") { job_desc.credentialserver = buf+p; }
    else if(name == "diskspace") {
      std::string temp_s(buf+p);
      unsigned long long int n;
      if(!Arc::stringto(temp_s,n)) { f.close(); return false; };
      job_desc.diskspace = n;
    }
    else if(name == "activityid") { 
      std::string temp_s(buf+p);
      job_desc.activityid.push_back(temp_s);
    }
    else if(name == "migrateactivityid") { job_desc.migrateactivityid = buf+p; }
    else if(name == "forcemigration") { 
      if(strcasecmp("yes",buf+p) == 0) { job_desc.forcemigration = true; }
      else if(strcasecmp("true",buf+p) == 0) { job_desc.forcemigration = true; }
      else job_desc.forcemigration = false;
    }
    else if(name == "transfershare") { job_desc.transfershare = buf+p; };
  }
  f.close();
  return true;
}

Here is the call graph for this function:

bool job_local_read_lifetime ( const JobId id,
const JobUser user,
time_t &  lifetime 
)

Definition at line 832 of file info_files.cpp.

                                                                                   {
  std::string fname = user.ControlDir() + "/job." + id + sfx_local;
  std::string str;
  if(!job_local_read_var(fname,"lifetime",str)) return false;
  char* str_e;
  unsigned long int t = strtoul(str.c_str(),&str_e,10);
  if((*str_e) != 0) return false;
  lifetime=t;
  return true;
}

Here is the call graph for this function:

bool job_local_read_notify ( const JobId id,
const JobUser user,
std::string &  notify 
)

Definition at line 851 of file info_files.cpp.

                                                                                  {
  std::string fname = user.ControlDir() + "/job." + id + sfx_local;
  if(!job_local_read_var(fname,"notify",notify)) return false;
  return true;
}

Here is the call graph for this function:

bool job_local_read_string ( const std::string &  fname,
unsigned int  num,
std::string &  str 
)

Definition at line 857 of file info_files.cpp.

                                                                                   {
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  for(;num;num--) {
    f.ignore(INT_MAX,'\n'); 
  };
  if(f.eof()) { f.close(); return false; };
  char buf[256];
  f.get(buf,255,'\n'); if(!buf[0]) { f.close(); return false; };
  str=buf; 
  f.close();
  return true;
}
bool job_local_read_var ( const std::string &  fname,
const std::string &  vnam,
std::string &  value 
)

Definition at line 814 of file info_files.cpp.

                                                                                       {
  char buf[1024];
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  std::string name;
  bool found = false;
  for(;!f.eof();) {
    istream_readline(f,buf,sizeof(buf));
    name.erase();
    int p=input_escaped_string(buf,name,'=');
    if(name.length() == 0) continue;
    if(buf[p] == 0) continue;
    if(name == vnam) { value = buf+p; found=true; break; };
  };
  f.close();
  return found;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_local_write_file ( const JobDescription desc,
const JobUser user,
const JobLocalDescription job_desc 
)

Definition at line 647 of file info_files.cpp.

                                                                                                              {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_local;
  return job_local_write_file(fname,job_desc) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname,user);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_local_write_file ( const std::string &  fname,
const JobLocalDescription job_desc 
)

Definition at line 664 of file info_files.cpp.

                                                                                      {
  std::ofstream f(fname.c_str(),std::ios::out | std::ios::trunc);
  if(! f.is_open() ) return false; /* can't open file */
  for (std::list<std::string>::const_iterator it=job_desc.jobreport.begin();
       it!=job_desc.jobreport.end();
       it++)
    {
      write_pair(f,"jobreport",*it);
    }
  write_pair(f,"globalid",job_desc.globalid);
  write_pair(f,"lrms",job_desc.lrms);
  write_pair(f,"queue",job_desc.queue);
  write_pair(f,"localid",job_desc.localid);
  f << "args=";
  if(job_desc.arguments.size()) {
    for(std::list<std::string>::const_iterator i=job_desc.arguments.begin(); \
        i!=job_desc.arguments.end(); ++i) {
      output_escaped_string(f,*i);
      f << " ";
    };
  };
  f << std::endl;
  write_pair(f,"subject",job_desc.DN);
  write_pair(f,"starttime",job_desc.starttime);
  write_pair(f,"lifetime",job_desc.lifetime);
  write_pair(f,"notify",job_desc.notify);
  write_pair(f,"processtime",job_desc.processtime);
  write_pair(f,"exectime",job_desc.exectime);
  write_pair(f,"rerun",Arc::tostring(job_desc.reruns));
  if(job_desc.downloads>=0) write_pair(f,"downloads",Arc::tostring(job_desc.downloads));
  if(job_desc.uploads>=0) write_pair(f,"uploads",Arc::tostring(job_desc.uploads));
  if(job_desc.rtes>=0) write_pair(f,"rtes",Arc::tostring(job_desc.rtes));
  write_pair(f,"jobname",job_desc.jobname);
  for (std::list<std::string>::const_iterator ppn=job_desc.projectnames.begin();
       ppn!=job_desc.projectnames.end();
       ++ppn)
    {
      write_pair(f,"projectname",*ppn);
    }
  write_pair(f,"gmlog",job_desc.stdlog);
  write_pair(f,"cleanuptime",job_desc.cleanuptime);
  write_pair(f,"delegexpiretime",job_desc.expiretime);
  write_pair(f,"clientname",job_desc.clientname);
  write_pair(f,"clientsoftware",job_desc.clientsoftware);
  write_pair(f,"sessiondir",job_desc.sessiondir);
  write_pair(f,"diskspace",Arc::tostring(job_desc.diskspace));
  write_pair(f,"failedstate",job_desc.failedstate);
  write_pair(f,"credentialserver",job_desc.credentialserver);
  for(std::list<std::string>::const_iterator act_id=job_desc.activityid.begin();
      act_id != job_desc.activityid.end(); ++act_id) {
    write_pair(f,"activityid",(*act_id));
  };
  if (job_desc.migrateactivityid != "") {
    write_pair(f,"migrateactivityid",job_desc.migrateactivityid);
    write_pair(f,"forcemigration",job_desc.forcemigration);
  }
  write_pair(f,"transfershare",job_desc.transfershare);
  f.close();
  return true;
}

Here is the call graph for this function:

bool job_lrms_mark_check ( JobId id,
JobUser user 
)

Definition at line 149 of file info_files.cpp.

                                                  {
  std::string fname = user.ControlDir() + "/job." + id + ".lrms_done";
  return job_mark_check(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_lrms_mark_put ( const JobDescription desc,
JobUser user,
int  code 
)

Definition at line 136 of file info_files.cpp.

                                                                          {
  LRMSResult r(code);
  return job_lrms_mark_put(desc,user,r);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_lrms_mark_put ( const JobDescription desc,
JobUser user,
LRMSResult  r 
)

Definition at line 141 of file info_files.cpp.

                                                                              {
  std::string fname = user.ControlDir()+"/job."+desc.get_id()+".lrms_done";
  std::string content = Arc::tostring(r.code());
  content+=" ";
  content+=r.description();
  return job_mark_write_s(fname,content) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

LRMSResult job_lrms_mark_read ( JobId id,
JobUser user 
)

Definition at line 159 of file info_files.cpp.

                                                       {
  std::string fname = user.ControlDir() + "/job." + id + ".lrms_done";
  LRMSResult r("-1 Internal error");
  std::ifstream f(fname.c_str()); if(! f.is_open() ) return r;
  f>>r;
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_lrms_mark_remove ( JobId id,
JobUser user 
)

Definition at line 154 of file info_files.cpp.

                                                   {
  std::string fname = user.ControlDir() + "/job." + id + ".lrms_done";
  return job_mark_remove(fname);
}

Here is the call graph for this function:

bool job_lrmsoutput_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 321 of file info_files.cpp.

                                                                       {
  std::string fname = desc.SessionDir() + sfx_lrmsoutput;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    return (RunFunction::run(tmp_user,"job_lrmsoutput_mark_put",&job_mark_put_callback,&fname,10) == 0);
  };
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_lrmsoutput_mark_remove ( const JobDescription desc,
JobUser user 
)

Definition at line 351 of file info_files.cpp.

                                                                          {
  std::string fname = desc.SessionDir() + sfx_lrmsoutput;
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    return (RunFunction::run(tmp_user,"job_lrmsoutpur_mark_remove",&job_mark_remove_callback,&fname,10) == 0);
  };
  return job_mark_remove(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int job_mark_add_callback ( void *  arg) [static]

Definition at line 266 of file info_files.cpp.

                                            {
  const std::string& fname = *(((job_mark_add_t*)arg)->fname);
  const std::string& content = *(((job_mark_add_t*)arg)->content);
  if(job_mark_add_s(fname,content) & fix_file_permissions(fname)) return 0;
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_mark_add_s ( const std::string &  fname,
const std::string &  content 
)

Definition at line 463 of file info_files.cpp.

                                                                     {
  int h=open(fname.c_str(),O_WRONLY | O_CREAT | O_APPEND,S_IRUSR | S_IWUSR);
  if(h==-1) return false;
  (write(h,(const void *)content.c_str(),content.length()) != -1);
  close(h); return true;
}

Here is the caller graph for this function:

bool job_mark_check ( const std::string &  fname)

Definition at line 429 of file info_files.cpp.

                                            {
  struct stat st;
  if(lstat(fname.c_str(),&st) != 0) return false;
  if(!S_ISREG(st.st_mode)) return false;
  return true;
}

Here is the caller graph for this function:

bool job_mark_put ( const std::string &  fname)

Definition at line 424 of file info_files.cpp.

                                          {
  int h=open(fname.c_str(),O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR);
  if(h==-1) return false; close(h); return true;
}

Here is the caller graph for this function:

static int job_mark_put_callback ( void *  arg) [static]

Definition at line 243 of file info_files.cpp.

                                            {
  std::string& fname = *((std::string*)arg);
  if(job_mark_put(fname) & fix_file_permissions(fname)) return 0;
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long int job_mark_read_i ( const std::string &  fname)

Definition at line 448 of file info_files.cpp.

                                                 {
  std::ifstream f(fname.c_str()); if(! f.is_open() ) return -1;
  char buf[32]; f.getline(buf,30); f.close();
  char* e; long int i;
  i=strtol(buf,&e,10); if((*e) == 0) return i;
  return -1;
}
std::string job_mark_read_s ( const std::string &  fname)

Definition at line 441 of file info_files.cpp.

                                                  {
  std::string s("");
  std::ifstream f(fname.c_str()); if(! f.is_open() ) return s;
  char buf[256]; f.getline(buf,254); s=buf;
  return s;
}

Here is the caller graph for this function:

bool job_mark_remove ( const std::string &  fname)

Definition at line 436 of file info_files.cpp.

                                             {
  if(unlink(fname.c_str()) != 0) { if(errno != ENOENT) return false; };
  return true;
}

Here is the caller graph for this function:

static int job_mark_remove_callback ( void *  arg) [static]

Definition at line 249 of file info_files.cpp.

                                               {
  std::string& fname = *((std::string*)arg);
  if(job_mark_remove(fname)) return 0;
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long int job_mark_size ( const std::string &  fname)

Definition at line 476 of file info_files.cpp.

                                               {
  struct stat st;
  if(lstat(fname.c_str(),&st) != 0) return 0;
  if(!S_ISREG(st.st_mode)) return 0;
  return st.st_size;
}

Here is the caller graph for this function:

time_t job_mark_time ( const std::string &  fname)

Definition at line 470 of file info_files.cpp.

                                             {
  struct stat st;
  if(lstat(fname.c_str(),&st) != 0) return 0;
  return st.st_mtime;
}

Here is the caller graph for this function:

bool job_mark_write_s ( const std::string &  fname,
const std::string &  content 
)

Definition at line 456 of file info_files.cpp.

                                                                       {
  int h=open(fname.c_str(),O_WRONLY | O_CREAT | O_TRUNC,S_IRUSR | S_IWUSR);
  if(h==-1) return false;
  (write(h,(const void *)content.c_str(),content.length()) != -1);
  close(h); return true;
}

Here is the caller graph for this function:

bool job_output_read_file ( const JobId id,
JobUser user,
std::list< FileData > &  files 
)

Definition at line 918 of file info_files.cpp.

                                                                                  {
  std::string fname = user.ControlDir() + "/job." + id + ".output";
  return job_Xput_read_file(fname,files);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_output_write_file ( const JobDescription desc,
JobUser user,
std::list< FileData > &  files 
)

Definition at line 906 of file info_files.cpp.

                                                                                              {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + ".output";
  return job_Xput_write_file(fname,files) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string job_proxy_filename ( const JobId id,
const JobUser user 
)

Definition at line 883 of file info_files.cpp.

                                                                  {
       return user.ControlDir() + "/job." + id + sfx_proxy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_restart_mark_check ( JobId id,
JobUser user 
)

Definition at line 187 of file info_files.cpp.

                                                     {
  std::string fname = user.ControlDir() + "/job." + id + sfx_restart;
  return job_mark_check(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_restart_mark_put ( const JobDescription desc,
JobUser user 
)

Definition at line 182 of file info_files.cpp.

                                                                    {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_restart;
  return job_mark_put(fname) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_restart_mark_remove ( JobId id,
JobUser user 
)

Definition at line 192 of file info_files.cpp.

                                                      {
  std::string fname = user.ControlDir() + "/job." + id + sfx_restart;
  return job_mark_remove(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_rte_read_file ( const JobId id,
JobUser user,
std::list< std::string > &  rtes 
)

Definition at line 893 of file info_files.cpp.

                                                                               {
  std::string fname = user.ControlDir() + "/job." + id + ".rte";
  return job_strings_read_file(fname,rtes);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_rte_write_file ( const JobDescription desc,
JobUser user,
std::list< std::string > &  rtes 
)

Definition at line 888 of file info_files.cpp.

                                                                                           {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + ".rte";
  return job_strings_write_file(fname,rtes) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_session_create ( const JobDescription desc,
JobUser user 
)

Definition at line 295 of file info_files.cpp.

                                                                  {
  std::string dname = desc.SessionDir();
  if(user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    return (RunFunction::run(tmp_user,"job_session_create",&job_dir_create_callback,&dname,10) == 0);
  };
  return job_dir_create(dname) & fix_file_owner(dname,desc,user) & fix_file_permissions(dname,true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

job_state_t job_state_read_file ( const JobId id,
const JobUser user 
)

Definition at line 561 of file info_files.cpp.

                                                                     {
  std::string fname = user.ControlDir() + "/job." + id + sfx_status;
  bool pending;
  return job_state_read_file(fname,pending);
}

Here is the call graph for this function:

Here is the caller graph for this function:

job_state_t job_state_read_file ( const JobId id,
const JobUser user,
bool &  pending 
)

Definition at line 567 of file info_files.cpp.

                                                                                   {
  std::string fname = user.ControlDir() + "/job." + id + sfx_status;
  return job_state_read_file(fname,pending);
}

Here is the call graph for this function:

job_state_t job_state_read_file ( const std::string &  fname,
bool &  pending 
)

Definition at line 577 of file info_files.cpp.

                                                                      {
  std::ifstream f(fname.c_str());
  if(!f.is_open() ) return JOB_STATE_UNDEFINED; /* can't open file */
  char buf[32];
  f.getline(buf,30);
  /* interpret information */
  char* p = buf;
  if(!strncmp("PENDING:",p,8)) { p+=8; pending=true; } else { pending=false; };
  for(int i = 0;states_all[i].name != NULL;i++) {
    if(!strcmp(states_all[i].name,p)) {
      f.close();
      return states_all[i].id;
    };
  };
  f.close();
  return JOB_STATE_UNDEFINED; /* broken file */
}
time_t job_state_time ( const JobId id,
JobUser user 
)

Definition at line 556 of file info_files.cpp.

                                                     {
  std::string fname = user.ControlDir() + "/job." + id + sfx_status;
  return job_mark_time(fname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_state_write_file ( const JobDescription desc,
JobUser user,
job_state_t  state,
bool  pending 
)

Definition at line 572 of file info_files.cpp.

                                                                                                   {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + sfx_status;
  return job_state_write_file(fname,state,pending) & fix_file_owner(fname,desc,user) & fix_file_permissions(fname,user);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool job_state_write_file ( const std::string &  fname,
job_state_t  state,
bool  pending 
)

Definition at line 595 of file info_files.cpp.

                                                                                 {
  std::ofstream f(fname.c_str(),std::ios::out | std::ios::trunc);
  if(! f.is_open() ) return false; /* can't open file */
  if(pending) f<<"PENDING:";
  f<<states_all[state].name<<std::endl;
  f.close();
  return true;
}
bool job_stdlog_move ( const JobDescription ,
JobUser ,
const std::string &   
)

Definition at line 410 of file info_files.cpp.

                                                                            {
/*

 Status data is now available during runtime.

*/
  return true;
}

Here is the caller graph for this function:

bool job_strings_read_file ( const std::string &  fname,
std::list< std::string > &  strs 
)

Definition at line 970 of file info_files.cpp.

                                                                            {
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  for(;!f.eof();) {
    std::string str; f >> str;
    if(!str.empty()) strs.push_back(str);
  };
  f.close();
  return true;
}

Here is the caller graph for this function:

bool job_strings_write_file ( const std::string &  fname,
std::list< std::string > &  strs 
)

Definition at line 960 of file info_files.cpp.

                                                                             {
  std::ofstream f(fname.c_str(),std::ios::out | std::ios::trunc);
  if(! f.is_open() ) return false; /* can't open file */
  for(std::list<std::string>::iterator i=strs.begin();i!=strs.end(); ++i) {
    f << (*i) << std::endl;
  };
  f.close();
  return true;
}

Here is the caller graph for this function:

bool job_Xput_read_file ( std::list< FileData > &  files)

Definition at line 935 of file info_files.cpp.

                                                  {
  for(;!std::cin.eof();) {
    FileData fd; std::cin >> fd;
//    if((fd.pfn.length() != 0) && (fd.pfn != "/")) {
    if(fd.pfn.length() != 0) {  /* returns zero length only if empty std::string */
      files.push_back(fd);
    };
  };
  return true;
}

Here is the caller graph for this function:

bool job_Xput_read_file ( const std::string &  fname,
std::list< FileData > &  files 
)

Definition at line 946 of file info_files.cpp.

                                                                         {
  std::ifstream f(fname.c_str());
  if(! f.is_open() ) return false; /* can't open file */
  for(;!f.eof();) {
    FileData fd; f >> fd;
//    if((fd.pfn.length() != 0) && (fd.pfn != "/")) {
    if(fd.pfn.length() != 0) {  /* returns zero length only if empty std::string */
      files.push_back(fd);
    };
  };
  f.close();
  return true;
}
bool job_Xput_write_file ( const std::string &  fname,
std::list< FileData > &  files 
)

Definition at line 925 of file info_files.cpp.

                                                                          {
  std::ofstream f(fname.c_str(),std::ios::out | std::ios::trunc);
  if(! f.is_open() ) return false; /* can't open file */
  for(FileData::iterator i=files.begin();i!=files.end(); ++i) { 
    f << (*i) << std::endl;
  };
  f.close();
  return true;
}

Here is the caller graph for this function:

void write_pair ( std::ofstream &  f,
const std::string &  name,
const std::string &  value 
) [inline]

Definition at line 652 of file info_files.cpp.

                                                                                    {
  if(value.length()) f << name << '=' << value << std::endl;
}

Here is the caller graph for this function:

void write_pair ( std::ofstream &  f,
const std::string &  name,
const Arc::Time value 
) [inline]

Definition at line 656 of file info_files.cpp.

                                                                                  {
  if(value != -1) f << name << '=' << value.str(Arc::MDSTime) << std::endl;
}

Here is the call graph for this function:

void write_pair ( std::ofstream &  f,
const std::string &  name,
bool  value 
) [inline]

Definition at line 660 of file info_files.cpp.

                                                                        {
  f << name << '=' << (value?"yes":"no") << std::endl;
}

Variable Documentation

Definition at line 67 of file info_files.cpp.

const char* const sfx_acl = ".acl"

Definition at line 64 of file info_files.cpp.

const char* const sfx_cancel = ".cancel"

Definition at line 54 of file info_files.cpp.

const char* const sfx_clean = ".clean"

Definition at line 56 of file info_files.cpp.

const char* const sfx_diag = ".diag"

Definition at line 61 of file info_files.cpp.

const char* const sfx_diskusage = ".disk"

Definition at line 63 of file info_files.cpp.

const char* const sfx_errors = ".errors"

Definition at line 59 of file info_files.cpp.

const char* const sfx_failed = ".failed"

Definition at line 53 of file info_files.cpp.

const char* const sfx_local = ".local"

Definition at line 58 of file info_files.cpp.

const char* const sfx_lrmsoutput = ".comment"

Definition at line 62 of file info_files.cpp.

const char* const sfx_proxy = ".proxy"

Definition at line 65 of file info_files.cpp.

const char* const sfx_restart = ".restart"

Definition at line 55 of file info_files.cpp.

const char* const sfx_rsl = ".description"

Definition at line 60 of file info_files.cpp.

const char* const sfx_status = ".status"

Definition at line 57 of file info_files.cpp.