home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / client / sysint / pint-sysint-utils.c < prev    next >
C/C++ Source or Header  |  2008-11-19  |  2KB  |  89 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. #include <unistd.h>
  8. #include <sys/types.h>
  9.  
  10. #include "pvfs2-sysint.h"
  11. #include "pvfs2-req-proto.h"
  12. #include "pint-sysint-utils.h"
  13. #include "pint-cached-config.h"
  14. #include "acache.h"
  15. #include "PINT-reqproto-encode.h"
  16. #include "trove.h"
  17. #include "server-config-mgr.h"
  18. #include "str-utils.h"
  19. #include "pvfs2-util.h"
  20. #include "client-state-machine.h"
  21.  
  22. /*
  23.   analogous to 'get_server_config_struct' in pvfs2-server.c -- only an
  24.   fs_id is required since any client may know about different server
  25.   configurations during run-time
  26. */
  27. struct server_configuration_s *PINT_get_server_config_struct(
  28.     PVFS_fs_id fs_id)
  29. {
  30.     return PINT_server_config_mgr_get_config(fs_id);
  31. }
  32.  
  33. void PINT_put_server_config_struct(struct server_configuration_s *config)
  34. {
  35.     PINT_server_config_mgr_put_config(config);
  36. }
  37.  
  38. /* PINT_lookup_parent()
  39.  *
  40.  * given a pathname and an fsid, looks up the handle of the parent
  41.  * directory
  42.  *
  43.  * returns 0 on success, -PVFS_errno on failure
  44.  */
  45. int PINT_lookup_parent(
  46.     char *filename,
  47.     PVFS_fs_id fs_id,
  48.     PVFS_credentials *credentials,
  49.     PVFS_handle * handle)
  50. {
  51.     int ret = -PVFS_EINVAL;
  52.     char buf[PVFS_SEGMENT_MAX] = {0};
  53.     PVFS_sysresp_lookup resp_look;
  54.  
  55.     memset(&resp_look, 0, sizeof(PVFS_sysresp_lookup));
  56.  
  57.     if (PINT_get_base_dir(filename, buf, PVFS_SEGMENT_MAX))
  58.     {
  59.         if (filename[0] != '/')
  60.         {
  61.             gossip_err("Invalid dirname (no leading '/')\n");
  62.         }
  63.         gossip_err("cannot get parent directory of %s\n", filename);
  64.         *handle = PVFS_HANDLE_NULL;
  65.         return ret;
  66.     }
  67.  
  68.     ret = PVFS_sys_lookup(fs_id, buf, credentials,
  69.                           &resp_look, PVFS2_LOOKUP_LINK_FOLLOW, NULL);
  70.     if (ret < 0)
  71.     {
  72.         gossip_err("Lookup failed on %s\n", buf);
  73.         *handle = PVFS_HANDLE_NULL;
  74.         return ret;
  75.     }
  76.  
  77.     *handle = resp_look.ref.handle;
  78.     return 0;
  79. }
  80.  
  81. /*
  82.  * Local variables:
  83.  *  c-indent-level: 4
  84.  *  c-basic-offset: 4
  85.  * End:
  86.  *
  87.  * vim: ts=8 sts=4 sw=4 expandtab
  88.  */
  89.