Exemplo n.º 1
0
int
main (int argc, char **argv)
{

    irodsOper.getattr = irodsGetattr;
    irodsOper.readlink = irodsReadlink;
    irodsOper.readdir = irodsReaddir;
    irodsOper.mknod = irodsMknod;
    irodsOper.mkdir = irodsMkdir;
    irodsOper.symlink = irodsSymlink;
    irodsOper.unlink = irodsUnlink;
    irodsOper.rmdir = irodsRmdir;
    irodsOper.rename = irodsRename;
    irodsOper.link = irodsLink;
    irodsOper.chmod = irodsChmod;
    irodsOper.chown = irodsChown;
    irodsOper.truncate = irodsTruncate;
    irodsOper.utimens = irodsUtimens;
    irodsOper.open = irodsOpen;
    irodsOper.read = irodsRead;
    irodsOper.write = irodsWrite;
    irodsOper.statfs = irodsStatfs;
    irodsOper.release = irodsRelease;
    irodsOper.fsync = irodsFsync;
    irodsOper.flush = irodsFlush;


    int status;
    rodsArguments_t myRodsArgs;
    char *optStr;

#ifdef  __cplusplus
    bzero (&irodsOper, sizeof (irodsOper));
    irodsOper.getattr = irodsGetattr;
    irodsOper.readlink = irodsReadlink;
    irodsOper.readdir = irodsReaddir;
    irodsOper.mknod = irodsMknod;
    irodsOper.mkdir = irodsMkdir;
    irodsOper.symlink = irodsSymlink;
    irodsOper.unlink = irodsUnlink;
    irodsOper.rmdir = irodsRmdir;
    irodsOper.rename = irodsRename;
    irodsOper.link = irodsLink;
    irodsOper.chmod = irodsChmod;
    irodsOper.chown = irodsChown;
    irodsOper.truncate = irodsTruncate;
    irodsOper.utimens = irodsUtimens;
    irodsOper.open = irodsOpen;
    irodsOper.read = irodsRead;
    irodsOper.write = irodsWrite;
    irodsOper.statfs = irodsStatfs;
    irodsOper.release = irodsRelease;
    irodsOper.fsync = irodsFsync;
    irodsOper.flush = irodsFlush;
#endif
    optStr = "hdo:";

    status = parseCmdLineOpt (argc, argv, optStr, 0, &myRodsArgs);

    if (status < 0) {
        printf("Use -h for help.\n");
        exit (1);
    }
    if (myRodsArgs.help==True) {
        usage();
        exit(0);
    }

    status = getRodsEnv (&MyRodsEnv);

    if (status < 0) {
        rodsLogError(LOG_ERROR, status, "main: getRodsEnv error. ");
        exit (1);
    }

    srandom((unsigned int) time(0) % getpid());

#ifdef CACHE_FILE_FOR_READ
    if (setAndMkFileCacheDir () < 0) exit (1);
#endif

    initPathCache ();
    initIFuseDesc ();
    initConn();
    initFileCache();

    status = fuse_main (argc, argv, &irodsOper, NULL);

    disconnectAll ();

    if (status < 0) {
        exit (3);
    } else {
        exit(0);
    }
}
Exemplo n.º 2
0
int main(int argc, char **argv) {
  int status;

  /* 
   * seed random number generator
   * TODO: what uses this?
   */ 
  srandom((unsigned int) time(0) % getpid());

  /*
   * iquest_fuse data that will be passed in to FUSE operations
   */
  static iquest_fuse_t iquest_fuse;
  memset(&iquest_fuse, 0, sizeof(iquest_fuse));

  static iquest_fuse_conf_t iquest_fuse_conf;
  memset(&iquest_fuse_conf, 0, sizeof(iquest_fuse_conf));
  iquest_fuse.conf = &iquest_fuse_conf;

  static rodsEnv myRodsEnv;
  iquest_fuse.rods_env = &myRodsEnv;

  iquest_fuse_t *iqf = &iquest_fuse;
  
  /*
   * Use FUSE option processing to process argc/argv
   */
  struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

  /*
   * Set defaults for dynamically allocated conf fields that have not been set by options
   */
  if(iqf->conf->indicator == NULL) {
    int bufsize = strlen(IQF_DEFAULT_INDICATOR)+1;
    iqf->conf->indicator = malloc(bufsize);
    if(iqf->conf->indicator == NULL) {
      fprintf(stderr, "main: malloc(%d) setting default for iqf->conf->indicator\n", bufsize);
      exit(2);
    }
    strncpy(iqf->conf->indicator, IQF_DEFAULT_INDICATOR, bufsize);
  }
  
  if(iqf->conf->slash_remap == NULL) {
    int bufsize = strlen(IQF_DEFAULT_SLASH_REMAP)+1;
    iqf->conf->slash_remap = malloc(bufsize);
    if(iqf->conf->slash_remap == NULL) {
      fprintf(stderr, "main: malloc(%d) setting default for iqf->conf->slash_remap\n", bufsize);
      exit(2);
    }
    strncpy(iqf->conf->slash_remap, IQF_DEFAULT_SLASH_REMAP, bufsize);
  }
  
  /*
   * Set configuration in iquest_fuse_conf from command-line options and 
   * call iquest_fuse_opt_proc for other options
   */
  fuse_opt_parse(&args, &iquest_fuse_conf, iquest_fuse_opts, iquest_fuse_opt_proc);

  
  if(iqf->conf->irods_cwd != NULL) {
    rodsLog(LOG_NOTICE, "using iRODS cwd %s", iqf->conf->irods_cwd);
    status = setenv("irodsCwd", iqf->conf->irods_cwd, 1);
    if( status < 0) {
      rodsLog(LOG_ERROR, "main: could not set irodsCwd environment variable");
    }
  }
  
  if(iqf->conf->base_query != NULL) {
    rodsLog(LOG_NOTICE, "using base query %s", iqf->conf->base_query);
  }
  
  if(iqf->conf->indicator != NULL) {
    rodsLog(LOG_NOTICE, "using indicator %s", iqf->conf->indicator);
  }
  
  if(iqf->conf->slash_remap != NULL) {
    rodsLog(LOG_NOTICE, "remapping slashes [/] in metadata to [%s]", iqf->conf->slash_remap);
  }

  if(iqf->conf->show_indicator > 0) {
    rodsLog(LOG_SYS_WARNING, "showing query indicator (%s) in directory listings -- you must not attempt to recursively list directories (e.g. don't use find, du, ls -R, etc)", iqf->conf->indicator);
  }
  

#ifdef CACHE_FILE_FOR_READ
  if (setAndMkFileCacheDir () < 0) exit(3);
#endif
  
  /*
   * get iRODS configuration from environment and conf file (~/.irods/.irodsEnv)
   */
  status = getRodsEnv(iqf->rods_env);
  if( status < 0 ) {
    rodsLogError(LOG_ERROR, status, "main: getRodsEnv error. ");
    exit(1);
  }


  /* 
   * override irodsLogLevel if debug_level is greater
   */
  if(iqf->conf->debug_level > iqf->rods_env->rodsLogLevel) {
    fprintf(stderr, "overriding rodsLogLevel to debug_level=%d\n", iqf->conf->debug_level);
    rodsLogLevel(iqf->conf->debug_level);
    iqf->rods_env->rodsLogLevel = iqf->conf->debug_level;
  }
  
  initPathCache ();
  initIFuseDesc ();
  

  /*
   * Pass control to FUSE (which will call iquest_fuse_init and then start event loop 
   */
  rodsLog(LOG_DEBUG, "calling fuse_main");
  status = fuse_main (args.argc, args.argv, &iquest_fuse_operations, &iquest_fuse);
  rodsLog(LOG_DEBUG, "back from fuse_main");
  
  disconnect_all(iqf);
  
  if (status < 0) {
    rodsLogError(LOG_ERROR, status, "fuse_main");
    exit(5);
  } else {
    exit(0);
  }
}
Exemplo n.º 3
0
int 
main (int argc, char **argv)
{

#ifdef ENABLE_TRACE
   
irodsOper.getattr = traced_irodsGetattr;
irodsOper.readlink = traced_irodsReadlink;
irodsOper.readdir = traced_irodsReaddir;
irodsOper.mknod = traced_irodsMknod;
irodsOper.mkdir = traced_irodsMkdir;
irodsOper.symlink = traced_irodsSymlink;
irodsOper.unlink = traced_irodsUnlink;
irodsOper.rmdir = traced_irodsRmdir;
irodsOper.rename = traced_irodsRename;
irodsOper.link = traced_irodsLink;
irodsOper.chmod = traced_irodsChmod;
irodsOper.chown = traced_irodsChown;
irodsOper.truncate = traced_irodsTruncate;
irodsOper.utimens = traced_irodsUtimens;
irodsOper.open = traced_irodsOpen;
irodsOper.read = traced_irodsRead;
irodsOper.write = traced_irodsWrite;
irodsOper.statfs = traced_irodsStatfs;
irodsOper.release = traced_irodsRelease;
irodsOper.fsync = traced_irodsFsync;
irodsOper.flush = traced_irodsFlush;

#else
irodsOper.getattr = irodsGetattr;
irodsOper.readlink = irodsReadlink;
irodsOper.readdir = irodsReaddir;
irodsOper.mknod = irodsMknod;
irodsOper.mkdir = irodsMkdir;
irodsOper.symlink = irodsSymlink;
irodsOper.unlink = irodsUnlink;
irodsOper.rmdir = irodsRmdir;
irodsOper.rename = irodsRename;
irodsOper.link = irodsLink;
irodsOper.chmod = irodsChmod;
irodsOper.chown = irodsChown;
irodsOper.truncate = irodsTruncate;
irodsOper.utimens = irodsUtimens;
irodsOper.open = irodsOpen;
irodsOper.read = irodsRead;
irodsOper.write = irodsWrite;
irodsOper.statfs = irodsStatfs;
irodsOper.release = irodsRelease;
irodsOper.fsync = irodsFsync;
irodsOper.flush = irodsFlush;

#endif  // ENABLE_TRACE

    int status;
    rodsArguments_t myRodsArgs;
    char *optStr;
    
    int new_argc;
    char** new_argv;

#ifdef  __cplusplus
#ifdef ENABLE_TRACE
    bzero (&irodsOper, sizeof (irodsOper));
    irodsOper.getattr = traced_irodsGetattr;
    irodsOper.readlink = traced_irodsReadlink;
    irodsOper.readdir = traced_irodsReaddir;
    irodsOper.mknod = traced_irodsMknod;
    irodsOper.mkdir = traced_irodsMkdir;
    irodsOper.symlink = traced_irodsSymlink;
    irodsOper.unlink = traced_irodsUnlink;
    irodsOper.rmdir = traced_irodsRmdir;
    irodsOper.rename = traced_irodsRename;
    irodsOper.link = traced_irodsLink;
    irodsOper.chmod = traced_irodsChmod;
    irodsOper.chown = traced_irodsChown;
    irodsOper.truncate = traced_irodsTruncate;
    irodsOper.utimens = traced_irodsUtimens;
    irodsOper.open = traced_irodsOpen;
    irodsOper.read = traced_irodsRead;
    irodsOper.write = traced_irodsWrite;
    irodsOper.statfs = traced_irodsStatfs;
    irodsOper.release = traced_irodsRelease;
    irodsOper.fsync = traced_irodsFsync;
    irodsOper.flush = traced_irodsFlush;
#else // no ENABLE_TRACE
    bzero (&irodsOper, sizeof (irodsOper));
    irodsOper.getattr = irodsGetattr;
    irodsOper.readlink = irodsReadlink;
    irodsOper.readdir = irodsReaddir;
    irodsOper.mknod = irodsMknod;
    irodsOper.mkdir = irodsMkdir;
    irodsOper.symlink = irodsSymlink;
    irodsOper.unlink = irodsUnlink;
    irodsOper.rmdir = irodsRmdir;
    irodsOper.rename = irodsRename;
    irodsOper.link = irodsLink;
    irodsOper.chmod = irodsChmod;
    irodsOper.chown = irodsChown;
    irodsOper.truncate = irodsTruncate;
    irodsOper.utimens = irodsUtimens;
    irodsOper.open = irodsOpen;
    irodsOper.read = irodsRead;
    irodsOper.write = irodsWrite;
    irodsOper.statfs = irodsStatfs;
    irodsOper.release = irodsRelease;
    irodsOper.fsync = irodsFsync;
    irodsOper.flush = irodsFlush;
#endif // ENABLE_TRACE
#endif

    status = getRodsEnv (&MyRodsEnv);

    if (status < 0) {
        rodsLogError(LOG_ERROR, status, "main: getRodsEnv error. ");
        exit (1);
    }

    /* handle iRODS-FUSE specific command line options*/
    status = parseFuseSpecificCmdLineOpt (argc, argv);

    if (status < 0) {
        printf("Use -h for help.\n");
        exit (1);
    }

    status = makeCleanCmdLineOpt (argc, argv, &new_argc, &new_argv);

    argc = new_argc;
    argv = new_argv;

    optStr = "hdo:";

    status = parseCmdLineOpt (argc, argv, optStr, 0, &myRodsArgs);    

    if (status < 0) {
        printf("Use -h for help.\n");
        exit (1);
    }
    if (myRodsArgs.help==True) {
       usage();
       exit(0);
    }

    srandom((unsigned int) time(0) % getpid());

#ifdef CACHE_FILE_FOR_READ
    if (setAndMkFileCacheDir () < 0) exit (1);
#endif

    initPathCache ();
    initIFuseDesc ();
    initConn();
    initFileCache();

#ifdef ENABLE_PRELOAD
    // initialize preload
    initPreload (&MyPreloadConfig, &MyRodsEnv, &myRodsArgs);
#endif
#ifdef ENABLE_LAZY_UPLOAD
    // initialize Lazy Upload
    initLazyUpload (&MyLazyUploadConfig, &MyRodsEnv, &myRodsArgs);
#endif    
#ifdef ENABLE_TRACE

    // start tracing
    status = trace_begin( NULL );
    if( status != 0 ) {
        rodsLogError(LOG_ERROR, status, "main: trace_begin failed. ");
        exit(1);
    }

#endif

    status = fuse_main (argc, argv, &irodsOper, NULL);

#ifdef ENABLE_TRACE
    // stop tracing 
    trace_end( NULL );
#endif
    
    /* release the preload command line options */
    releaseCmdLineOpt (argc, argv);

#ifdef ENABLE_PRELOAD
    // wait preload jobs
    waitPreloadJobs();
#endif

#ifdef ENABLE_PRELOAD
    // uninitialize preload
    uninitPreload (&MyPreloadConfig);
    if (MyPreloadConfig.cachePath != NULL) {
        free(MyPreloadConfig.cachePath);
    }
#endif

#ifdef ENABLE_LAZY_UPLOAD
    // uninitialize lazy upload
    uninitLazyUpload (&MyLazyUploadConfig);
    if (MyLazyUploadConfig.bufferPath!=NULL) {
        free(MyLazyUploadConfig.bufferPath);
    }
#endif

    disconnectAll ();

    if (status < 0) {
        exit (3);
    } else {
        exit(0);
    }
}