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 / getparent.c < prev    next >
C/C++ Source or Header  |  2008-11-19  |  1KB  |  69 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. #include <string.h>
  8.  
  9. #include "pvfs2-sysint.h"
  10. #include "str-utils.h"
  11. #include "gossip.h"
  12. #include "pvfs2-util.h"
  13.  
  14. int PVFS_sys_getparent(
  15.     PVFS_fs_id fs_id,
  16.     char *entry_name,
  17.     const PVFS_credentials *credentials,
  18.     PVFS_sysresp_getparent *resp,
  19.     PVFS_hint hints)
  20. {
  21.     int ret = -PVFS_EINVAL;
  22.     char parent_buf[PVFS_NAME_MAX] = {0};
  23.     char file_buf[PVFS_SEGMENT_MAX] = {0};
  24.     PVFS_sysresp_lookup resp_look;
  25.  
  26.     if ((entry_name == NULL) || (resp == NULL))
  27.     {
  28.         return ret;
  29.     }
  30.  
  31.     if (PINT_get_base_dir(entry_name,parent_buf,PVFS_NAME_MAX))
  32.     {
  33.         if (entry_name[0] != '/')
  34.         {
  35.             gossip_err("Invalid dirname (no leading '/')\n");
  36.         }
  37.         return ret;
  38.     }
  39.  
  40.     memset(&resp_look,0,sizeof(PVFS_sysresp_lookup));
  41.     ret = PVFS_sys_lookup(fs_id, parent_buf, credentials,
  42.                           &resp_look, PVFS2_LOOKUP_LINK_NO_FOLLOW, hints);
  43.     if (ret)
  44.     {
  45.         gossip_err("Lookup failed on %s\n",parent_buf);
  46.         return ret;
  47.     }
  48.  
  49.     if (PINT_remove_base_dir(entry_name,file_buf,PVFS_SEGMENT_MAX))
  50.     {
  51.     gossip_err("invalid filename: %s\n", entry_name);
  52.     return ret;
  53.     }
  54.  
  55.     strncpy(resp->basename, file_buf, PVFS_SEGMENT_MAX);
  56.     resp->parent_ref = resp_look.ref;
  57.  
  58.     return 0;
  59. }
  60.  
  61. /*
  62.  * Local variables:
  63.  *  c-indent-level: 4
  64.  *  c-basic-offset: 4
  65.  * End:
  66.  *
  67.  * vim: ts=8 sts=4 sw=4 expandtab
  68.  */
  69.