コード例 #1
0
ファイル: fsal_internal.c プロジェクト: ic-hep/emi3
fsal_status_t fsal_internal_inum2handle(xfsfsal_op_context_t * p_context,
                                        ino_t inum, xfsfsal_handle_t * phandle)
{
  int fd = 0;

  xfs_ino_t xfs_ino;
  xfs_bstat_t bstat;

  xfs_filehandle_t xfsfilehandle;
  xfs_fshandle_t xfsfshandle;

  if((fd = open(p_context->export_context->mount_point, O_DIRECTORY)) == -1)
    ReturnCode(posix2fsal_error(errno), errno);

  xfs_ino = inum;
  if(fsal_internal_get_bulkstat_by_inode(fd, &xfs_ino, &bstat) < 0)
    {
      close(fd);
      ReturnCode(posix2fsal_error(errno), errno);
    }

  close(fd);

  memcpy(xfsfshandle.fsh_space, p_context->export_context->mnt_fshandle_val,
         XFS_FSHANDLE_SZ);
  build_xfsfilehandle(&xfsfilehandle, &xfsfshandle, &bstat);

  memcpy(phandle->data.handle_val, &xfsfilehandle, sizeof(xfs_filehandle_t));
  phandle->data.handle_len = sizeof(xfs_filehandle_t);
  phandle->data.inode = inum;
  phandle->data.type = DT_LNK;

  ReturnCode(ERR_FSAL_NO_ERROR, 0);
}                               /* fsal_internal_inum2handle */
コード例 #2
0
ファイル: fsal_attrs.c プロジェクト: alangenfeld/cloud-nfs
/**
 * FSAL_getetxattrs:
 * Get attributes for the object specified by its filehandle.
 *
 * \param filehandle (input):
 *        The handle of the object to get parameters.
 * \param cred (input):
 *        Authentication context for the operation (user,...).
 * \param object_attributes (mandatory input/output):
 *        The retrieved attributes for the object.
 *        As input, it defines the attributes that the caller
 *        wants to retrieve (by positioning flags into this structure)
 *        and the output is built considering this input
 *        (it fills the structure according to the flags it contains).
 *
 * \return Major error codes :
 *        - ERR_FSAL_NO_ERROR     (no error)
 *        - Another error code if an error occured.
 */
fsal_status_t XFSFSAL_getextattrs(xfsfsal_handle_t * p_filehandle, /* IN */
                                  xfsfsal_op_context_t * p_context,        /* IN */
                                  fsal_extattrib_list_t * p_object_attributes /* OUT */
    )
{
  fsal_status_t st ;
  xfs_bstat_t bstat;
  xfs_ino_t xfs_ino;
  struct stat buffstat;
  int fd = 0 ;

  /* sanity checks.
   * note : object_attributes is mandatory in FSAL_getattrs.
   */
  if(!p_filehandle || !p_context || !p_object_attributes)
    Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs);

  TakeTokenFSCall();
  st = fsal_internal_handle2fd(p_context, p_filehandle, &fd, O_RDONLY);
  ReleaseTokenFSCall();

  if(FSAL_IS_ERROR(st))
    ReturnStatus(st, INDEX_FSAL_getextattrs);

  if( p_object_attributes->asked_attributes & FSAL_ATTR_GENERATION )
   {
     /* get file metadata */
     xfs_ino = p_filehandle->data.inode ;
     TakeTokenFSCall();
     if(fsal_internal_get_bulkstat_by_inode(fd, &xfs_ino, &bstat) < 0)
      {
        close(fd);
        ReleaseTokenFSCall();
        ReturnCode(posix2fsal_error(errno), errno);
      }
     ReleaseTokenFSCall();

     p_object_attributes->generation = bstat.bs_gen ;
    }
 
  Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getextattrs);
} /* XFSFSAL_getextattrs */