本文整理汇总了C++中FSAL_IS_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ FSAL_IS_ERROR函数的具体用法?C++ FSAL_IS_ERROR怎么用?C++ FSAL_IS_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSAL_IS_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makedir
static fsal_status_t makedir(struct fsal_obj_handle *dir_hdl,
const char *name, struct attrlist *attrib,
struct fsal_obj_handle **handle)
{
fsal_errors_t fsal_error = ERR_FSAL_NO_ERROR;
int retval = 0;
struct pt_fsal_obj_handle *hdl;
fsal_status_t status;
ptfsal_handle_t *fh = alloca(sizeof(ptfsal_handle_t));
*handle = NULL; /* poison it */
if (!dir_hdl->ops->handle_is(dir_hdl, DIRECTORY)) {
LogCrit(COMPONENT_FSAL,
"Parent handle is not a directory. hdl = 0x%p",
dir_hdl);
return fsalstat(ERR_FSAL_NOTDIR, 0);
}
memset(fh, 0, sizeof(ptfsal_handle_t));
fh->data.handle.handle_size = FSI_CCL_PERSISTENT_HANDLE_N_BYTES;
attrib->mask =
op_ctx->fsal_export->ops->fs_supported_attrs(op_ctx->fsal_export);
status = PTFSAL_mkdir(dir_hdl, name, op_ctx, attrib->mode, fh, attrib);
if (FSAL_IS_ERROR(status))
return status;
/* allocate an obj_handle and fill it up */
hdl = alloc_handle(fh, attrib, NULL, NULL, NULL, op_ctx->fsal_export);
if (hdl == NULL) {
retval = ENOMEM;
goto fileerr;
}
*handle = &hdl->obj_handle;
return fsalstat(ERR_FSAL_NO_ERROR, 0);
fileerr:
fsal_error = posix2fsal_error(retval);
return fsalstat(fsal_error, retval);
}
示例2: MFSL_setattrs_check_perms
/**
*
* MFSL_setattrs_check_perms : Checks authorization to perform an asynchronous setattr.
*
* Checks authorization to perform an asynchronous setattr.
*
* @param filehandle [IN] mfsl object to be operated on.
* @param pspecdata [INOUT] mfsl object associated specific data
* @param p_context [IN] associated fsal context
* @param p_mfsl_context [INOUT] associated mfsl context
* @param attrib_set [IN] attributes to be set
*
* @return always FSAL_NO_ERROR (not yet implemented
*/
fsal_status_t MFSL_setattrs_check_perms(mfsl_object_t * filehandle, /* IN */
mfsl_object_specific_data_t * pspecdata, /* IN */
fsal_op_context_t * p_context, /* IN */
mfsl_context_t * p_mfsl_context, /* IN */
fsal_attrib_list_t * attrib_set /* IN */ )
{
fsal_status_t fsal_status;
/* Root is the only one that can chown or chgrp */
if(attrib_set->asked_attributes & (FSAL_ATTR_OWNER | FSAL_ATTR_GROUP))
{
if(p_context->user_credential.user != 0)
MFSL_return(ERR_FSAL_ACCESS, 0);
}
fsal_status = FSAL_setattr_access(p_context, attrib_set, &pspecdata->async_attr);
if(FSAL_IS_ERROR(fsal_status))
return fsal_status;
MFSL_return(ERR_FSAL_NO_ERROR, 0);
} /* MFSL_setattr_check_perms */
示例3: CEPHFSAL_getattrs
/**
* FSAL_getattrs:
* Get attributes for the object specified by its filehandle.
*
* \param filehandle (input):
* The handle of the object to get parameters.
* \param context (input):
* Authentication context for the operation (user, export...).
* \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)
* - ERR_FSAL_STALE (object_handle does not address an existing object)
* - ERR_FSAL_FAULT (a NULL pointer was passed as mandatory argument)
* - Another error code if an error occured.
*/
fsal_status_t CEPHFSAL_getattrs(fsal_handle_t * exthandle,
fsal_op_context_t * extcontext,
fsal_attrib_list_t * object_attributes)
{
int rc;
struct stat st;
fsal_status_t status;
cephfsal_handle_t* filehandle = (cephfsal_handle_t*) exthandle;
cephfsal_op_context_t* context = (cephfsal_op_context_t*) extcontext;
int uid = FSAL_OP_CONTEXT_TO_UID(context);
int gid = FSAL_OP_CONTEXT_TO_GID(context);
/* sanity checks.
* note : object_attributes is mandatory in FSAL_getattrs.
*/
if(!filehandle || !context || !object_attributes)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs);
TakeTokenFSCall();
rc = ceph_ll_getattr(context->export_context->cmount, VINODE(filehandle),
&st, uid, gid);
ReleaseTokenFSCall();
if (rc < 0)
Return(posix2fsal_error(rc), 0, INDEX_FSAL_getattrs);
/* convert attributes */
status = posix2fsal_attributes(&st, object_attributes);
if(FSAL_IS_ERROR(status))
{
FSAL_CLEAR_MASK(object_attributes->asked_attributes);
FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs);
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs);
}
示例4: FUSEFSAL_open_by_name
fsal_status_t FUSEFSAL_open_by_name(fsal_handle_t * dirhandle, /* IN */
fsal_name_t * filename, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_openflags_t openflags, /* IN */
fsal_file_t * file_descriptor, /* OUT */
fsal_attrib_list_t *
file_attributes /* [ IN/OUT ] */ )
{
fsal_status_t fsal_status;
fsal_handle_t filehandle;
if(!dirhandle || !filename || !p_context || !file_descriptor)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_open_by_name);
fsal_status =
FUSEFSAL_lookup(dirhandle, filename, p_context, &filehandle, file_attributes);
if(FSAL_IS_ERROR(fsal_status))
return fsal_status;
return FUSEFSAL_open(&filehandle, p_context, openflags, file_descriptor,
file_attributes);
}
示例5: VFSFSAL_Init
/**
* FSAL_Init : Initializes the FileSystem Abstraction Layer.
*
* \param init_info (input, fsal_parameter_t *) :
* Pointer to a structure that contains
* all initialization parameters for the FSAL.
* Specifically, it contains settings about
* the filesystem on which the FSAL is based,
* security settings, logging policy and outputs,
* and other general FSAL options.
*
* \return Major error codes :
* ERR_FSAL_NO_ERROR (initialisation OK)
* ERR_FSAL_FAULT (init_info pointer is null)
* ERR_FSAL_SERVERFAULT (misc FSAL error)
* ERR_FSAL_ALREADY_INIT (The FS is already initialized)
* ERR_FSAL_BAD_INIT (FS specific init error,
* minor error code gives the reason
* for this error.)
* ERR_FSAL_SEC_INIT (Security context init error).
*/
fsal_status_t VFSFSAL_Init(fsal_parameter_t * init_info /* IN */
)
{
fsal_status_t status;
/* sanity check. */
if(!init_info)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_Init);
/* proceeds FSAL internal initialization */
status = fsal_internal_init_global(&(init_info->fsal_info),
&(init_info->fs_common_info),
& (init_info->fs_specific_info));
if(FSAL_IS_ERROR(status))
Return(status.major, status.minor, INDEX_FSAL_Init);
/* Regular exit */
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_Init);
}
示例6: VFSFSAL_getattrs
/**
* VFSFSAL_getattrs:
* 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 VFSFSAL_getattrs(fsal_handle_t * p_filehandle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_attrib_list_t * p_object_attributes /* IN/OUT */
)
{
fsal_status_t st;
int rc = 0 ;
int errsv;
struct stat buffstat;
/* sanity checks.
* note : object_attributes is mandatory in VFSFSAL_getattrs.
*/
if(!p_filehandle || !p_context || !p_object_attributes)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs);
TakeTokenFSCall();
rc = vfs_stat_by_handle( ((vfsfsal_op_context_t *)p_context)->export_context->mount_root_fd,
&((vfsfsal_handle_t *)p_filehandle)->data.vfs_handle,
&buffstat ) ;
errsv = errno;
ReleaseTokenFSCall();
if( rc == -1 )
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_getattrs);
/* convert attributes */
st = posix2fsal_attributes(&buffstat, p_object_attributes);
if(FSAL_IS_ERROR(st))
{
FSAL_CLEAR_MASK(p_object_attributes->asked_attributes);
FSAL_SET_MASK(p_object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
ReturnStatus(st, INDEX_FSAL_getattrs);
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs);
}
示例7: FSAL_GetXAttrAttrs
/**
* Get the attributes of an extended attribute from its index.
*
* \param p_objecthandle Handle of the object you want to get attribute for.
* \param p_context pointer to the current security context.
* \param xattr_cookie xattr's cookie (as returned by listxattrs).
* \param p_attrs xattr's attributes.
*/
fsal_status_t FSAL_GetXAttrAttrs(fsal_handle_t * p_objecthandle, /* IN */
fsal_op_context_t * p_context, /* IN */
unsigned int xattr_id, /* IN */
fsal_attrib_list_t * p_attrs
/**< IN/OUT xattr attributes (if supported) */
)
{
int rc;
char buff[MAXNAMLEN];
fsal_status_t st;
fsal_attrib_list_t file_attrs;
/* sanity checks */
if(!p_objecthandle || !p_context || !p_attrs)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetXAttrAttrs);
/* object attributes we want to retrieve from parent */
file_attrs.asked_attributes = FSAL_ATTR_MODE | FSAL_ATTR_FILEID | FSAL_ATTR_OWNER
| FSAL_ATTR_GROUP | FSAL_ATTR_ATIME | FSAL_ATTR_MTIME
| FSAL_ATTR_CTIME | FSAL_ATTR_CREATION | FSAL_ATTR_CHGTIME | FSAL_ATTR_FSID;
/* don't retrieve attributes not asked */
file_attrs.asked_attributes &= p_attrs->asked_attributes;
st = FSAL_getattrs(p_objecthandle, p_context, &file_attrs);
if(FSAL_IS_ERROR(st))
Return(st.major, st.minor, INDEX_FSAL_GetXAttrAttrs);
if((rc = file_attributes_to_xattr_attrs(&file_attrs, p_attrs, xattr_id)))
{
Return(ERR_FSAL_INVAL, rc, INDEX_FSAL_GetXAttrAttrs);
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetXAttrAttrs);
} /* FSAL_GetXAttrAttrs */
示例8: LUSTREFSAL_dynamic_fsinfo
/**
* FSAL_dynamic_fsinfo:
* Return dynamic filesystem info such as
* used size, free size, number of objects...
*
* \param filehandle (input):
* Handle of an object in the filesystem
* whom info is to be retrieved.
* \param cred (input):
* Authentication context for the operation (user,...).
* \param dynamicinfo (output):
* Pointer to the static info of the filesystem.
*
* \return Major error codes:
* - ERR_FSAL_NO_ERROR: no error.
* - ERR_FSAL_FAULT: NULL pointer passed as input parameter.
* - ERR_FSAL_SERVERFAULT: Unexpected error.
*/
fsal_status_t LUSTREFSAL_dynamic_fsinfo(fsal_handle_t * p_filehandle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_dynamicfsinfo_t * p_dynamicinfo /* OUT */
)
{
fsal_path_t pathfsal;
fsal_status_t status;
struct statvfs buffstatvfs;
int rc, errsv;
/* sanity checks. */
if(!p_filehandle || !p_dynamicinfo || !p_context)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_dynamic_fsinfo);
status = fsal_internal_Handle2FidPath(p_context, p_filehandle, &pathfsal);
if(FSAL_IS_ERROR(status))
Return(status.major, status.minor, INDEX_FSAL_dynamic_fsinfo);
TakeTokenFSCall();
rc = statvfs(pathfsal.path, &buffstatvfs);
errsv = errno;
ReleaseTokenFSCall();
if(rc)
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_dynamic_fsinfo);
p_dynamicinfo->total_bytes = buffstatvfs.f_frsize * buffstatvfs.f_blocks;
p_dynamicinfo->free_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bfree;
p_dynamicinfo->avail_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bavail;
p_dynamicinfo->total_files = buffstatvfs.f_files;
p_dynamicinfo->free_files = buffstatvfs.f_ffree;
p_dynamicinfo->avail_files = buffstatvfs.f_favail;
p_dynamicinfo->time_delta.seconds = 1;
p_dynamicinfo->time_delta.nseconds = 0;
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_dynamic_fsinfo);
}
示例9: nfs2_FSALToFhandle
/**
*
* nfs2_FSALToFhandle: converts a FSAL file handle to a nfs2 file handle.
*
* Converts a nfs2 file handle to a FSAL file handle.
*
* @param pfh2 [OUT] pointer to the extracted file handle
* @param pfsalhandle [IN] pointer to the FSAL handle to be converted
* @param pfsalhandle [IN] pointer to the FSAL handle to be converted
*
* @return 1 if successful, 0 otherwise
*
*/
int nfs2_FSALToFhandle(fhandle2 * pfh2, fsal_handle_t * pfsalhandle,
exportlist_t * pexport)
{
fsal_status_t fsal_status;
file_handle_v2_t file_handle;
print_buff(COMPONENT_FILEHANDLE, (char *)pfsalhandle, sizeof(fsal_handle_t));
/* zero-ification of the buffer to be used as handle */
memset(pfh2, 0, NFS2_FHSIZE);
memset((caddr_t) &file_handle, 0, sizeof(file_handle_v2_t));
/* Fill in the fs opaque part */
fsal_status =
FSAL_DigestHandle(&pexport->FS_export_context, FSAL_DIGEST_NFSV2, pfsalhandle,
(caddr_t) & file_handle.fsopaque);
if(FSAL_IS_ERROR(fsal_status))
{
if( fsal_status.major == ERR_FSAL_TOOSMALL )
LogCrit( COMPONENT_FILEHANDLE, "NFSv2 file handle is too small to manage this fsal" ) ;
else
LogCrit( COMPONENT_FILEHANDLE, "FSAL_DigestHandle return (%u,%u) when called from %s",
fsal_status.major, fsal_status.minor, __func__ ) ;
return 0;
}
/* keep track of the export id */
file_handle.exportid = pexport->id;
/* Set the last byte */
file_handle.xattr_pos = 0;
/* Set the data */
memcpy((caddr_t) pfh2, &file_handle, sizeof(file_handle_v2_t));
print_fhandle2(COMPONENT_FILEHANDLE, pfh2);
return 1;
} /* nfs2_FSALToFhandle */
示例10: SNMPFSAL_opendir
/**
* FSAL_opendir :
* Opens a directory for reading its content.
*
* \param dir_handle (input)
* the handle of the directory to be opened.
* \param p_context (input)
* Permission context for the operation (user, export context...).
* \param dir_descriptor (output)
* pointer to an allocated structure that will receive
* directory stream informations, on successfull completion.
* \param dir_attributes (optional output)
* On successfull completion,the structure pointed
* by dir_attributes receives the new directory attributes.
* Can be NULL.
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - ERR_FSAL_ACCESS (user does not have read permission on directory)
* - ERR_FSAL_STALE (dir_handle does not address an existing object)
* - ERR_FSAL_FAULT (a NULL pointer was passed as mandatory argument)
* - Other error codes can be returned :
* ERR_FSAL_IO, ...
*/
fsal_status_t SNMPFSAL_opendir(fsal_handle_t * dir_handle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_dir_t * dir_descriptor, /* OUT */
fsal_attrib_list_t * dir_attributes /* [ IN/OUT ] */
)
{
fsal_status_t st;
/* sanity checks
* note : dir_attributes is optionnal.
*/
if(!dir_handle || !p_context || !dir_descriptor)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_opendir);
/* check it is a node... */
if(((snmpfsal_handle_t *)dir_handle)->data.object_type_reminder == FSAL_NODETYPE_LEAF)
Return(ERR_FSAL_NOTDIR, 0, INDEX_FSAL_opendir);
/* save request info to the dir_dircriptor */
memcpy(&((snmpfsal_dir_t *)dir_descriptor)->node_handle,
(snmpfsal_handle_t *)dir_handle, sizeof(snmpfsal_handle_t));
((snmpfsal_dir_t *)dir_descriptor)->p_context = (snmpfsal_op_context_t *)p_context;
if(dir_attributes && dir_attributes->asked_attributes)
{
st = SNMPFSAL_getattrs(dir_handle, p_context, dir_attributes);
if(FSAL_IS_ERROR(st))
{
FSAL_CLEAR_MASK(dir_attributes->asked_attributes);
FSAL_SET_MASK(dir_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
}
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_opendir);
}
示例11: FSAL_get_cookieverf
fsal_status_t FSAL_get_cookieverf(fsal_handle_t * handle,
fsal_op_context_t * p_context,
uint64_t * verf)
{
fsal_status_t rc;
msectimer_t timer_start, timer_end;
timer_start = timer_get();
if (fsal_functions.fsal_get_cookieverf)
{
rc = fsal_functions.fsal_get_cookieverf(handle,
verf);
}
else
{
fsal_attrib_list_t attributes;
memset(&attributes, 0, sizeof(fsal_attrib_list_t));
attributes.asked_attributes = FSAL_ATTR_MTIME;
rc = FSAL_getattrs(handle,
p_context,
&attributes);
if (!FSAL_IS_ERROR(rc))
{
memcpy(verf, &attributes.mtime, sizeof(uint64_t));
ReturnCode(ERR_FSAL_NO_ERROR, 0);
}
}
timer_end = timer_get();
p_context->latency += timer_end - timer_start;
p_context->count++;
return rc;
}
示例12: make_pseudofs_node
bool make_pseudofs_node(char *name, struct pseudofs_state *state)
{
struct fsal_obj_handle *new_node = NULL;
fsal_status_t fsal_status;
bool retried = false;
struct attrlist sattr;
retry:
/* First, try to lookup the entry */
fsal_status = fsal_lookup(state->obj, name, &new_node, NULL);
if (!FSAL_IS_ERROR(fsal_status)) {
/* Make sure new node is a directory */
if (new_node->type != DIRECTORY) {
LogCrit(COMPONENT_EXPORT,
"BUILDING PSEUDOFS: Export_Id %d Path %s Pseudo Path %s LOOKUP %s is not a directory",
state->export->export_id,
state->export->fullpath,
state->export->pseudopath,
name);
/* Release the reference on the new node */
new_node->obj_ops.put_ref(new_node);
return false;
}
LogDebug(COMPONENT_EXPORT,
"BUILDING PSEUDOFS: Parent %p entry %p %s FSAL %s already exists",
state->obj, new_node, name,
new_node->fsal->name);
state->obj->obj_ops.put_ref(state->obj);
/* Make new node the current node */
state->obj = new_node;
return true;
}
示例13: GPFSFSAL_open
/** @fn fsal_status_t
* GPFSFSAL_open(struct fsal_obj_handle *obj_hdl,
* const struct req_op_context *op_ctx,
* fsal_openflags_t openflags, int *file_desc,
* struct attrlist *fsal_attr)
*
* @brief Open a regular file for reading/writing its data content.
*
* @param obj_hdl Handle of the file to be read/modified.
* @param op_ctx Authentication context for the operation (user,...).
* @param openflags Flags that indicates behavior for file opening and access.
* This is an inclusive OR of the following values
* ( such of them are not compatible) :
* - FSAL_O_RDONLY: opening file for reading only.
* - FSAL_O_RDWR: opening file for reading and writing.
* - FSAL_O_WRONLY: opening file for writting only.
* - FSAL_O_APPEND: always write at the end of the file.
* - FSAL_O_TRUNC: truncate the file to 0 on opening.
* @param file_desc The file descriptor to be used for FSAL_read/write ops.
*
* @return ERR_FSAL_NO_ERROR on success, error otherwise
*/
fsal_status_t
GPFSFSAL_open(struct fsal_obj_handle *obj_hdl,
const struct req_op_context *op_ctx, int posix_flags,
int *file_desc)
{
struct gpfs_fsal_obj_handle *myself;
fsal_status_t status;
struct gpfs_fsal_export *exp = container_of(op_ctx->fsal_export,
struct gpfs_fsal_export, export);
int export_fd = exp->export_fd;
/* sanity checks. */
if (!obj_hdl || !file_desc)
return fsalstat(ERR_FSAL_FAULT, 0);
myself = container_of(obj_hdl, struct gpfs_fsal_obj_handle,
obj_handle);
LogFullDebug(COMPONENT_FSAL, "posix_flags 0x%X export_fd %d",
posix_flags, export_fd);
fsal_set_credentials(op_ctx->creds);
status = fsal_internal_handle2fd(export_fd, myself->handle,
file_desc, posix_flags);
fsal_restore_ganesha_credentials();
if (FSAL_IS_ERROR(status)) {
/** Try open as root access if the above call fails,
* permission will be checked somewhere else in the code.
*/
status = fsal_internal_handle2fd(export_fd,
myself->handle,
file_desc, posix_flags);
}
return status;
}
示例14: VFSFSAL_getattrs_descriptor
/**
* VFSFSAL_getattrs_descriptor:
* Get attributes for the object specified by its descriptor or by it's filehandle.
*
* \param p_file_descriptor (input):
* The file descriptor of the object to get parameters.
* \param p_filehandle (input):
* The handle of the object to get parameters.
* \param p_context (input):
* Authentication context for the operation (user,...).
* \param p_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 VFSFSAL_getattrs_descriptor(fsal_file_t * p_file_descriptor, /* IN */
fsal_handle_t * p_filehandle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_attrib_list_t * p_object_attributes /* IN/OUT */
)
{
fsal_status_t st;
struct stat64 buffstat;
int rc, errsv;
/* sanity checks.
* note : object_attributes is mandatory in VFSFSAL_getattrs.
*/
if(!p_file_descriptor || !p_filehandle || !p_context || !p_object_attributes)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs_descriptor);
TakeTokenFSCall();
rc = fstat64(((vfsfsal_file_t *)p_file_descriptor)->fd, &buffstat);
errsv = errno;
ReleaseTokenFSCall();
if(rc == -1)
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_getattrs_descriptor);
/* convert attributes */
st = posixstat64_2_fsal_attributes(&buffstat, p_object_attributes);
if(FSAL_IS_ERROR(st))
{
FSAL_CLEAR_MASK(p_object_attributes->asked_attributes);
FSAL_SET_MASK(p_object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
ReturnStatus(st, INDEX_FSAL_getattrs_descriptor);
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs_descriptor);
}
示例15: GPFSFSAL_mkdir
/**
* @brief Create a directory.
*
* @param dir_hdl Handle of the parent directory
* @param dir_name Pointer to the name of the directory to be created.
* @param op_ctx Authentication context for the operation (user,...).
* @param accessmode Mode for the directory to be created.
* @param gpfs_fh Pointer to the handle of the created directory.
* @param fsal_attr Attributes of the created directory.
* @return ERR_FSAL_NO_ERROR on success, error otherwise
*
*/
fsal_status_t
GPFSFSAL_mkdir(struct fsal_obj_handle *dir_hdl, const char *dir_name,
const struct req_op_context *op_ctx, uint32_t accessmode,
struct gpfs_file_handle *gpfs_fh, struct attrlist *obj_attr)
{
mode_t unix_mode;
fsal_status_t status;
/* note : obj_attr is optional. */
if (!dir_hdl || !op_ctx || !gpfs_fh || !dir_name)
return fsalstat(ERR_FSAL_FAULT, 0);
/* convert FSAL mode to unix mode. */
unix_mode = fsal2unix_mode(accessmode);
/* Apply umask */
unix_mode = unix_mode &
~op_ctx->fsal_export->exp_ops.fs_umask(op_ctx->fsal_export);
/* build new entry path */
/* creates the directory and get its handle */
fsal_set_credentials(op_ctx->creds);
status = fsal_internal_create(dir_hdl, dir_name, unix_mode | S_IFDIR,
0, gpfs_fh, NULL);
fsal_restore_ganesha_credentials();
if (FSAL_IS_ERROR(status))
return status;
/* retrieve file attributes */
return GPFSFSAL_getattrs(op_ctx->fsal_export,
dir_hdl->fs->private_data,
op_ctx, gpfs_fh, obj_attr);
}