本文整理汇总了C++中FSAL_IS_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ FSAL_IS_ERROR函数的具体用法?C++ FSAL_IS_ERROR怎么用?C++ FSAL_IS_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSAL_IS_ERROR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:JasonZen,项目名称:nfs-ganesha,代码行数:39,代码来源:handle.c
示例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 */
开发者ID:jordan-dlh,项目名称:nfs-ganesha,代码行数:36,代码来源:mfsl_async_setattr.c
示例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);
}
开发者ID:MeghanaM,项目名称:nfs-ganesha,代码行数:60,代码来源:fsal_attrs.c
示例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);
}
开发者ID:ShyamsundarR,项目名称:nfs-ganesha,代码行数:22,代码来源:fsal_fileop.c
示例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);
}
开发者ID:chandra2,项目名称:nfs-ganesha,代码行数:43,代码来源:fsal_init.c
示例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);
}
开发者ID:ShyamsundarR,项目名称:nfs-ganesha,代码行数:57,代码来源:fsal_attrs.c
示例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 */
开发者ID:alangenfeld,项目名称:cloud-nfs,代码行数:46,代码来源:fsal_xattrs.c
示例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);
}
开发者ID:MeghanaM,项目名称:nfs-ganesha,代码行数:56,代码来源:fsal_fsinfo.c
示例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 */
开发者ID:MeghanaM,项目名称:nfs-ganesha,代码行数:51,代码来源:nfs_filehandle_mgmt.c
示例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);
}
开发者ID:eitanb,项目名称:nfs-ganesha,代码行数:61,代码来源:fsal_dirs.c
示例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;
}
开发者ID:fmarsch,项目名称:nfs-ganesha-1,代码行数:37,代码来源:fsal_glue.c
示例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;
}
开发者ID:srimalik,项目名称:nfs-ganesha,代码行数:36,代码来源:nfs4_pseudo.c
示例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;
}
开发者ID:hongjil5,项目名称:nfs-ganesha,代码行数:58,代码来源:fsal_fileop.c
示例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);
}
开发者ID:ShyamsundarR,项目名称:nfs-ganesha,代码行数:57,代码来源:fsal_attrs.c
示例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);
}
开发者ID:nfs-ganesha,项目名称:nfs-ganesha,代码行数:48,代码来源:fsal_create.c
示例16: GPFSFSAL_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 GPFSFSAL_Init(fsal_parameter_t * init_info /* IN */
)
{
char *fshandle;
size_t fshandlelen = 0;
fsal_status_t status;
int rc = 0;
/* sanity check. */
if(!init_info)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_Init);
/* save open-by-handle char device */
memcpy(open_by_handle_path, init_info->fs_specific_info.open_by_handle_dev_file,
MAXPATHLEN);
open_by_handle_fd = open(init_info->fs_specific_info.open_by_handle_dev_file, O_RDONLY);
if(open_by_handle_fd < 0)
{
LogMajor(COMPONENT_FSAL,
"FSAL INIT: ERROR: Could not open open-by-handle character device file at %s: rc = %d",
init_info->fs_specific_info.open_by_handle_dev_file, errno);
ReturnCode(ERR_FSAL_INVAL, 0);
}
/* 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);
}
开发者ID:alangenfeld,项目名称:cloud-nfs,代码行数:57,代码来源:fsal_init.c
示例17: 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, bool reopen)
*
* @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, bool reopen)
{
struct gpfs_fsal_obj_handle *myself;
struct gpfs_filesystem *gpfs_fs;
fsal_status_t status;
/* 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);
gpfs_fs = obj_hdl->fs->private_data;
LogFullDebug(COMPONENT_FSAL, "posix_flags 0x%X", posix_flags);
status = fsal_internal_handle2fd(gpfs_fs->root_fd, myself->handle,
file_desc, posix_flags, reopen);
if (FSAL_IS_ERROR(status)) {
/** In some environments, "root" is denied write access,
* so try with the request credentials if the above call
* fails.
*/
fsal_set_credentials(op_ctx->creds);
status = fsal_internal_handle2fd(gpfs_fs->root_fd,
myself->handle,
file_desc, posix_flags,
reopen);
fsal_restore_ganesha_credentials();
}
return status;
}
开发者ID:srimalik,项目名称:nfs-ganesha,代码行数:58,代码来源:fsal_fileop.c
示例18: FSAL_unlink_access_default
/**
* FSAL_unlink_access_default :
* test if a client identified by cred can unlink on a directory knowing its attributes
*
* \param pcontext user's context.
* \param pattrsrc source directory attributes
* \param pattrobj object attributes
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - ERR_FSAL_ACCESS (Permission denied)
* - ERR_FSAL_FAULT (null pointer parameter)
* - ERR_FSAL_INVAL (missing attributes : mode, group, user,...)
* - ERR_FSAL_SERVERFAULT (unexpected error)
*/
fsal_status_t FSAL_unlink_access_default(fsal_op_context_t * pcontext, /* IN */
fsal_attrib_list_t * pattrsrc, /* IN */
fsal_attrib_list_t * pattrobj) /* IN */
{
fsal_status_t fsal_status;
/* Sticky Bit on the parent directory? */
if(pattrsrc->mode & FSAL_MODE_SVTX)
{
/* The user must own the file or the parent directory. */
if( ( pattrsrc->owner != FSAL_OP_CONTEXT_TO_UID(pcontext) )
|| ( pattrobj->owner != FSAL_OP_CONTEXT_TO_UID(pcontext) ) )
Return(ERR_FSAL_ACCESS, 0, INDEX_FSAL_unlink_access);
}
/* The user must be able to lookup and write the parent directory */
fsal_status = FSAL_test_access_default(pcontext, ( FSAL_W_OK | FSAL_X_OK ), pattrsrc);
if(FSAL_IS_ERROR(fsal_status))
Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_unlink_access);
/* If this point is reached, then access is granted */
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_unlink_access);
} /* FSAL_unlink_access */
开发者ID:jordan-dlh,项目名称:nfs-ganesha,代码行数:39,代码来源:fsal_access.c
示例19: PROXYFSAL_truncate
fsal_status_t PROXYFSAL_truncate(proxyfsal_handle_t * filehandle, /* IN */
proxyfsal_op_context_t * p_context, /* IN */
fsal_size_t length, /* IN */
fsal_file_t * file_descriptor, /* [IN|OUT] */
fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */
)
{
int rc;
COMPOUND4args argnfs4;
COMPOUND4res resnfs4;
nfs_fh4 nfs4fh;
uint64_t fileid;
fsal_status_t fsal_status;
fsal_attrib_list_t open_attrs;
bitmap4 inbitmap;
bitmap4 convert_bitmap;
uint32_t inbitmap_val[2];
uint32_t bitmap_res[2];
uint32_t bitmap_set[2];
uint32_t bitmap_conv_val[2];
#define FSAL_TRUNCATE_NB_OP_ALLOC 3
nfs_argop4 argoparray[FSAL_TRUNCATE_NB_OP_ALLOC];
nfs_resop4 resoparray[FSAL_TRUNCATE_NB_OP_ALLOC];
fsal_attrib_list_t fsal_attr_set;
fattr4 fattr_set;
fsal_proxy_internal_fattr_t fattr_internal;
struct timeval timeout = { 25, 0 };
/* sanity checks.
* note : object_attributes is optional.
*/
if(!filehandle || !p_context)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate);
if(filehandle->data.object_type_reminder != FSAL_TYPE_FILE)
{
Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_truncate);
}
if(file_descriptor == NULL)
{
/* Use the stateless version */
fsal_status = FSAL_proxy_truncate_stateless(filehandle,
p_context, length, object_attributes);
Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_truncate);
}
/* First, we need to get the fileid on a filehandle base */
fsal_status = FSAL_DigestHandle(p_context->export_context,
FSAL_DIGEST_FILEID4, filehandle, (caddr_t) & fileid);
if(FSAL_IS_ERROR(fsal_status))
{
Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_truncate);
}
/* Then we have of open the file by fileid */
open_attrs.asked_attributes = FSAL_ATTRS_POSIX;
fsal_status = FSAL_open_by_fileid(filehandle,
fileid,
p_context, FSAL_O_RDWR, file_descriptor, &open_attrs);
if(FSAL_IS_ERROR(fsal_status))
{
Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_truncate);
}
/* Setup results structures */
argnfs4.argarray.argarray_val = argoparray;
resnfs4.resarray.resarray_val = resoparray;
fsal_internal_proxy_setup_fattr(&fattr_internal);
argnfs4.minorversion = 0;
/* argnfs4.tag.utf8string_val = "GANESHA NFSv4 Proxy: Truncate" ; */
argnfs4.tag.utf8string_val = NULL;
argnfs4.tag.utf8string_len = 0;
argnfs4.argarray.argarray_len = 0;
/* Get NFSv4 File handle */
if(fsal_internal_proxy_extract_fh(&nfs4fh, filehandle) == FALSE)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate);
/* Get prepared for truncate */
fsal_attr_set.asked_attributes = FSAL_ATTR_SIZE;
fsal_attr_set.filesize = length;
convert_bitmap.bitmap4_val = bitmap_conv_val;
convert_bitmap.bitmap4_len = 2;
fsal_interval_proxy_fsalattr2bitmap4(&fsal_attr_set, &convert_bitmap);
if(nfs4_FSALattr_To_Fattr(NULL, /* no exportlist required here */
&fsal_attr_set, &fattr_set, NULL, /* no compound data required here */
NULL, /* No fh here, filehandle is not a settable attribute */
&convert_bitmap) == -1)
Return(ERR_FSAL_INVAL, -1, INDEX_FSAL_truncate);
inbitmap.bitmap4_val = inbitmap_val;
inbitmap.bitmap4_len = 2;
//.........这里部分代码省略.........
开发者ID:alangenfeld,项目名称:cloud-nfs,代码行数:101,代码来源:fsal_truncate.c
示例20: LUSTREFSAL_unlink
fsal_status_t LUSTREFSAL_unlink(fsal_handle_t * p_parent_directory_handle, /* IN */
fsal_name_t * p_object_name, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_attrib_list_t * p_parent_directory_attributes /* [IN/OUT ] */
)
{
fsal_status_t status;
int rc, errsv;
struct stat buffstat, buffstat_parent;
fsal_path_t fsalpath;
/* sanity checks. */
if(!p_parent_directory_handle || !p_context || !p_object_name)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_unlink);
/* build the FID path */
status = fsal_internal_Handle2FidPath(p_context, p_parent_directory_handle, &fsalpath);
if(FSAL_IS_ERROR(status))
ReturnStatus(status, INDEX_FSAL_unlink);
/* get directory metadata */
TakeTokenFSCall();
rc = lstat(fsalpath.path, &buffstat_parent);
errsv = errno;
ReleaseTokenFSCall();
if(rc)
{
if(errsv == ENOENT)
Return(ERR_FSAL_STALE, errsv, INDEX_FSAL_unlink);
else
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_unlink);
}
/* build the child path */
status = fsal_internal_appendNameToPath(&fsalpath, p_object_name);
if(FSAL_IS_ERROR(status))
ReturnStatus(status, INDEX_FSAL_unlink);
/* get file metadata */
TakeTokenFSCall();
rc = lstat(fsalpath.path, &buffstat);
errsv = errno;
ReleaseTokenFSCall();
if(rc)
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_unlink);
/* check access rights
|
请发表评论