本文整理汇总了C++中LogFullDebug函数的典型用法代码示例。如果您正苦于以下问题:C++ LogFullDebug函数的具体用法?C++ LogFullDebug怎么用?C++ LogFullDebug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogFullDebug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nlm4_send_grant_msg
/**
*
* nlm4_send_grant_msg: Send NLMPROC4_GRANTED_MSG
*
* This runs in the nlm_asyn_thread context.
*/
static void nlm4_send_grant_msg(state_async_queue_t *arg)
{
int retval;
char buffer[1024];
state_status_t state_status = STATE_SUCCESS;
state_cookie_entry_t * cookie_entry;
fsal_op_context_t context, * pcontext = &context;
state_nlm_async_data_t * nlm_arg = &arg->state_async_data.state_nlm_async_data;
if(isDebug(COMPONENT_NLM))
{
netobj_to_string(&nlm_arg->nlm_async_args.nlm_async_grant.cookie,
buffer, sizeof(buffer));
LogDebug(COMPONENT_NLM,
"Sending GRANTED for arg=%p svid=%d start=%llx len=%llx cookie=%s",
arg, nlm_arg->nlm_async_args.nlm_async_grant.alock.svid,
(unsigned long long) nlm_arg->nlm_async_args.nlm_async_grant.alock.l_offset,
(unsigned long long) nlm_arg->nlm_async_args.nlm_async_grant.alock.l_len,
buffer);
}
retval = nlm_send_async(NLMPROC4_GRANTED_MSG,
nlm_arg->nlm_async_host,
&(nlm_arg->nlm_async_args.nlm_async_grant),
nlm_arg->nlm_async_key);
dec_nlm_client_ref(nlm_arg->nlm_async_host);
free_grant_arg(arg);
/* If success, we are done. */
if(retval == RPC_SUCCESS)
return;
/*
* We are not able call granted callback. Some client may retry
* the lock again. So remove the existing blocked nlm entry
*/
LogMajor(COMPONENT_NLM,
"GRANTED_MSG RPC call failed with return code %d. Removing the blocking lock",
retval);
if(state_find_grant(nlm_arg->nlm_async_args.nlm_async_grant.cookie.n_bytes,
nlm_arg->nlm_async_args.nlm_async_grant.cookie.n_len,
&cookie_entry,
&state_status) != STATE_SUCCESS)
{
/* This must be an old NLM_GRANTED_RES */
LogFullDebug(COMPONENT_NLM,
"Could not find cookie=%s status=%s",
buffer, state_err_str(state_status));
return;
}
PTHREAD_RWLOCK_WRLOCK(&cookie_entry->sce_pentry->state_lock);
if(cookie_entry->sce_lock_entry->sle_block_data == NULL ||
!nlm_block_data_to_fsal_context(cookie_entry->sce_lock_entry->sle_block_data,
pcontext))
{
/* Wow, we're not doing well... */
PTHREAD_RWLOCK_UNLOCK(&cookie_entry->sce_pentry->state_lock);
LogFullDebug(COMPONENT_NLM,
"Could not find block data for cookie=%s (must be an old NLM_GRANTED_RES)",
buffer);
return;
}
PTHREAD_RWLOCK_UNLOCK(&cookie_entry->sce_pentry->state_lock);
if(state_release_grant(pcontext,
cookie_entry,
&state_status) != STATE_SUCCESS)
{
/* Huh? */
LogFullDebug(COMPONENT_NLM,
"Could not release cookie=%s status=%s",
buffer, state_err_str(state_status));
}
}
示例2: fsal_internal_testAccess
/* XXX : ACL */
fsal_status_t fsal_internal_testAccess(fsal_op_context_t * p_context, /* IN */
fsal_accessflags_t access_type, /* IN */
struct stat * p_buffstat, /* IN */
fsal_attrib_list_t * p_object_attributes /* IN */ )
{
fsal_accessflags_t missing_access;
unsigned int is_grp, i;
fsal_uid_t uid;
fsal_gid_t gid;
fsal_accessmode_t mode;
fsal_uid_t userid = ((vfsfsal_op_context_t *)p_context)->credential.user;
fsal_uid_t groupid = ((vfsfsal_op_context_t *)p_context)->credential.group;
/* sanity checks. */
if((!p_object_attributes && !p_buffstat) || !p_context)
ReturnCode(ERR_FSAL_FAULT, 0);
/* If the FSAL_F_OK flag is set, returns ERR INVAL */
if(access_type & FSAL_F_OK)
ReturnCode(ERR_FSAL_INVAL, 0);
/* test root access */
if(userid == 0)
ReturnCode(ERR_FSAL_NO_ERROR, 0);
/* unsatisfied flags */
missing_access = FSAL_MODE_MASK(access_type); /* only modes, no ACLs here */
if(p_object_attributes)
{
uid = p_object_attributes->owner;
gid = p_object_attributes->group;
mode = p_object_attributes->mode;
}
else
{
uid = p_buffstat->st_uid;
gid = p_buffstat->st_gid;
mode = unix2fsal_mode(p_buffstat->st_mode);
}
/* Test if file belongs to user. */
if(userid == uid)
{
LogFullDebug(COMPONENT_FSAL, "File belongs to user %d", uid);
if(mode & FSAL_MODE_RUSR)
missing_access &= ~FSAL_R_OK;
if(mode & FSAL_MODE_WUSR)
missing_access &= ~FSAL_W_OK;
if(mode & FSAL_MODE_XUSR)
missing_access &= ~FSAL_X_OK;
/* handle the creation of a new 500 file correctly */
if((missing_access & FSAL_OWNER_OK) != 0)
missing_access = 0;
if(missing_access == 0)
ReturnCode(ERR_FSAL_NO_ERROR, 0);
else
{
LogFullDebug(COMPONENT_FSAL,
"Mode=%#o, Access=%#o, Rights missing: %#o", mode,
access_type, missing_access);
ReturnCode(ERR_FSAL_ACCESS, 0);
}
}
/* missing_access will be nonzero triggering a failure
* even though FSAL_OWNER_OK is not even a real posix file
* permission */
missing_access &= ~FSAL_OWNER_OK;
/* Test if the file belongs to user's group. */
is_grp = (groupid == gid);
if(is_grp)
LogFullDebug(COMPONENT_FSAL, "File belongs to user's group %d",
groupid);
/* Test if file belongs to alt user's groups */
if(!is_grp)
{
for(i = 0; i < ((vfsfsal_op_context_t *)p_context)->credential.nbgroups; i++)
{
is_grp = (((vfsfsal_op_context_t *)p_context)->credential.alt_groups[i] == gid);
//.........这里部分代码省略.........
示例3: XFSFSAL_BuildExportContext
/**
* build the export entry
*/
fsal_status_t XFSFSAL_BuildExportContext(xfsfsal_export_context_t * p_export_context, /* OUT */
fsal_path_t * p_export_path, /* IN */
char *fs_specific_options /* IN */
)
{
/* Get the mount point for this lustre FS,
* so it can be used for building .lustre/fid paths.
*/
FILE *fp;
struct mntent *p_mnt;
struct stat pathstat;
char rpath[MAXPATHLEN];
char mntdir[MAXPATHLEN];
char fs_spec[MAXPATHLEN];
char *first_xfs_dir = NULL;
char type[256];
size_t pathlen, outlen;
int rc;
char *handle;
size_t handle_len = 0;
/* sanity check */
if(p_export_context == NULL)
{
LogCrit(COMPONENT_FSAL, "NULL mandatory argument passed to %s()", __FUNCTION__);
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_BuildExportContext);
}
outlen = 0;
if(p_export_path != NULL)
strncpy(rpath, p_export_path->path, MAXPATHLEN);
/* open mnt file */
fp = setmntent(MOUNTED, "r");
if(fp == NULL)
{
rc = errno;
LogCrit(COMPONENT_FSAL, "Error %d in setmntent(%s): %s", rc, MOUNTED,
strerror(rc));
Return(posix2fsal_error(rc), rc, INDEX_FSAL_BuildExportContext);
}
while((p_mnt = getmntent(fp)) != NULL)
{
/* get the longer path xfs related export that matches export path */
if(p_mnt->mnt_dir != NULL)
{
pathlen = strlen(p_mnt->mnt_dir);
if(strncmp(p_mnt->mnt_type, "xfs", 256))
continue;
if(first_xfs_dir == NULL)
first_xfs_dir = p_mnt->mnt_dir;
if((pathlen > outlen) && !strcmp(p_mnt->mnt_dir, "/"))
{
LogDebug(COMPONENT_FSAL,
"Root mountpoint is allowed for matching %s, type=%s, fs=%s",
rpath, p_mnt->mnt_type, p_mnt->mnt_fsname);
outlen = pathlen;
strncpy(mntdir, p_mnt->mnt_dir, MAXPATHLEN);
strncpy(type, p_mnt->mnt_type, 256);
strncpy(fs_spec, p_mnt->mnt_fsname, MAXPATHLEN);
}
/* in other cases, the filesystem must be <mountpoint>/<smthg> or <mountpoint>\0 */
else if((pathlen > outlen) &&
!strncmp(rpath, p_mnt->mnt_dir, pathlen) &&
((rpath[pathlen] == '/') || (rpath[pathlen] == '\0')))
{
LogFullDebug(COMPONENT_FSAL, "%s is under mountpoint %s, type=%s, fs=%s",
rpath, p_mnt->mnt_dir, p_mnt->mnt_type, p_mnt->mnt_fsname);
outlen = pathlen;
strncpy(mntdir, p_mnt->mnt_dir, MAXPATHLEN);
strncpy(type, p_mnt->mnt_type, 256);
strncpy(fs_spec, p_mnt->mnt_fsname, MAXPATHLEN);
}
}
}
if(outlen <= 0)
{
if(p_export_path == NULL)
strncpy(mntdir, first_xfs_dir, MAXPATHLEN);
else
{
LogCrit(COMPONENT_FSAL, "No mount entry matches '%s' in %s", rpath, MOUNTED);
//.........这里部分代码省略.........
示例4: nfs_Fsstat
int nfs_Fsstat(nfs_arg_t *parg,
exportlist_t *pexport,
fsal_op_context_t *pcontext,
nfs_worker_data_t *pworker,
struct svc_req *preq,
nfs_res_t * pres)
{
fsal_dynamicfsinfo_t dynamicinfo;
cache_inode_status_t cache_status;
cache_entry_t *pentry = NULL;
fsal_attrib_list_t attr;
int rc = NFS_REQ_OK;
if(isDebug(COMPONENT_NFSPROTO))
{
char str[LEN_FH_STR];
nfs_FhandleToStr(preq->rq_vers,
&(parg->arg_statfs2),
&(parg->arg_fsstat3.fsroot),
NULL,
str);
LogDebug(COMPONENT_NFSPROTO,
"REQUEST PROCESSING: Calling nfs_Fsstat handle: %s", str);
}
if(preq->rq_vers == NFS_V3)
{
/* to avoid setting it on each error case */
pres->res_fsstat3.FSSTAT3res_u.resfail.obj_attributes.attributes_follow = FALSE;
}
/* convert file handle to vnode */
if((pentry = nfs_FhandleToCache(preq->rq_vers,
&(parg->arg_statfs2),
&(parg->arg_fsstat3.fsroot),
NULL,
&(pres->res_statfs2.status),
&(pres->res_fsstat3.status),
NULL, NULL, pcontext, &rc)) == NULL)
{
/* Stale NFS FH ? */
/* return NFS_REQ_DROP ; */
goto out;
}
/* Get statistics and convert from cache */
if((cache_status = cache_inode_statfs(pentry,
&dynamicinfo,
pcontext, &cache_status)) == CACHE_INODE_SUCCESS)
{
/* This call is costless, the pentry was cached during call to nfs_FhandleToCache */
if((cache_status = cache_inode_getattr(pentry,
&attr,
pcontext,
&cache_status)) == CACHE_INODE_SUCCESS)
{
LogFullDebug(COMPONENT_NFSPROTO,
"nfs_Fsstat --> dynamicinfo.total_bytes = %zu dynamicinfo.free_bytes = %zu dynamicinfo.avail_bytes = %zu",
dynamicinfo.total_bytes,
dynamicinfo.free_bytes,
dynamicinfo.avail_bytes);
LogFullDebug(COMPONENT_NFSPROTO,
"nfs_Fsstat --> dynamicinfo.total_files = %llu dynamicinfo.free_files = %llu dynamicinfo.avail_files = %llu",
dynamicinfo.total_files,
dynamicinfo.free_files,
dynamicinfo.avail_files);
switch (preq->rq_vers)
{
case NFS_V2:
pres->res_statfs2.STATFS2res_u.info.tsize = NFS2_MAXDATA;
pres->res_statfs2.STATFS2res_u.info.bsize = DEV_BSIZE;
pres->res_statfs2.STATFS2res_u.info.blocks =
dynamicinfo.total_bytes / DEV_BSIZE;
pres->res_statfs2.STATFS2res_u.info.bfree =
dynamicinfo.free_bytes / DEV_BSIZE;
pres->res_statfs2.STATFS2res_u.info.bavail =
dynamicinfo.avail_bytes / DEV_BSIZE;
pres->res_statfs2.status = NFS_OK;
break;
case NFS_V3:
nfs_SetPostOpAttr(pexport,
&attr,
&(pres->res_fsstat3.FSSTAT3res_u
.resok.obj_attributes));
pres->res_fsstat3.FSSTAT3res_u.resok.tbytes = dynamicinfo.total_bytes;
pres->res_fsstat3.FSSTAT3res_u.resok.fbytes = dynamicinfo.free_bytes;
pres->res_fsstat3.FSSTAT3res_u.resok.abytes = dynamicinfo.avail_bytes;
pres->res_fsstat3.FSSTAT3res_u.resok.tfiles = dynamicinfo.total_files;
pres->res_fsstat3.FSSTAT3res_u.resok.ffiles = dynamicinfo.free_files;
pres->res_fsstat3.FSSTAT3res_u.resok.afiles = dynamicinfo.avail_files;
pres->res_fsstat3.FSSTAT3res_u.resok.invarsec = 0; /* volatile FS */
pres->res_fsstat3.status = NFS3_OK;
LogFullDebug(COMPONENT_NFSPROTO,
"nfs_Fsstat --> tbytes=%llu fbytes=%llu abytes=%llu",
//.........这里部分代码省略.........
示例5: fsal_posixdb_getInfoFromHandle
fsal_posixdb_status_t fsal_posixdb_getInfoFromHandle(fsal_posixdb_conn * p_conn, /* IN */
posixfsal_handle_t * p_object_handle, /* IN/OUT */
fsal_path_t * p_paths, /* OUT */
int paths_size, /* IN */
int *p_count /* OUT */ )
{
fsal_posixdb_status_t st;
result_handle_t res;
MYSQL_ROW row;
posixfsal_handle_t parent_directory_handle;
int i_path;
int toomanypaths = 0;
char query[2048];
/* sanity check */
if(!p_conn || !p_object_handle || ((!p_paths || !p_count) && paths_size > 0))
{
ReturnCodeDB(ERR_FSAL_POSIXDB_FAULT, 0);
}
LogFullDebug(COMPONENT_FSAL, "OBJECT_ID=%lli\n", p_object_handle->data.id);
BeginTransaction(p_conn);
/* lookup for the handle of the file */
if(!fsal_posixdb_GetInodeCache(p_object_handle))
{
snprintf(query, 2048,
"SELECT Handle.deviceid, Handle.inode, Handle.nlink, Handle.ctime, Handle.ftype "
"FROM Handle WHERE handleid=%llu AND handlets=%u", p_object_handle->data.id,
p_object_handle->data.ts);
st = db_exec_sql(p_conn, query, &res);
if(FSAL_POSIXDB_IS_ERROR(st))
goto rollback;
/* p_res contains : Handle.deviceId, Handle.inode, Handle.nlink, Handle.ctime, Handle.ftype */
LogDebug(COMPONENT_FSAL, "lookupHandle(%llu,%u)", p_object_handle->data.id,
(unsigned int)p_object_handle->data.ts);
if((mysql_num_rows(res) != 1) || ((row = mysql_fetch_row(res)) == NULL))
{
LogDebug(COMPONENT_FSAL, "lookupHandle=%d entries", mysql_num_rows(res));
mysql_free_result(res);
RollbackTransaction(p_conn);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOENT, 0);
}
posixdb_internal_fillFileinfoFromStrValues(&(p_object_handle->data.info),
row[0], row[1], row[2], row[3], row[4]);
mysql_free_result(res);
/* update the inode */
fsal_posixdb_UpdateInodeCache(p_object_handle);
}
/* Build the paths of the object */
if(p_paths)
{
/* find all the paths to the object */
snprintf(query, 2048, "SELECT name, handleidparent, handletsparent "
"FROM Parent WHERE handleid=%llu AND handlets=%u",
p_object_handle->data.id, p_object_handle->data.ts);
st = db_exec_sql(p_conn, query, &res);
if(FSAL_POSIXDB_IS_ERROR(st))
goto rollback;
/* res contains name, handleidparent, handletsparent */
*p_count = mysql_num_rows(res);
if(*p_count == 0)
{
mysql_free_result(res);
RollbackTransaction(p_conn);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOPATH, 0);
}
else if(*p_count > paths_size)
{
toomanypaths = 1;
LogCrit(COMPONENT_FSAL, "Too many paths found for object %llu.%u: found=%u, max=%d",
p_object_handle->data.id, p_object_handle->data.ts, *p_count, paths_size);
*p_count = paths_size;
}
for(i_path = 0; i_path < *p_count; i_path++)
{
unsigned int tmp_len;
row = mysql_fetch_row(res);
if(row == NULL)
{
mysql_free_result(res);
RollbackTransaction(p_conn);
ReturnCodeDB(ERR_FSAL_POSIXDB_FAULT, 0);
}
//.........这里部分代码省略.........
示例6: vfs_reopen2
fsal_status_t vfs_reopen2(struct fsal_obj_handle *obj_hdl,
struct state_t *state,
fsal_openflags_t openflags)
{
struct vfs_fd fd, *my_fd = &fd, *my_share_fd;
struct vfs_fsal_obj_handle *myself;
fsal_status_t status = {0, 0};
int posix_flags = 0;
fsal_openflags_t old_openflags;
my_share_fd = (struct vfs_fd *)(state + 1);
fsal2posix_openflags(openflags, &posix_flags);
LogFullDebug(COMPONENT_FSAL,
posix_flags & O_TRUNC ? "Truncate" : "No truncate");
memset(my_fd, 0, sizeof(*my_fd));
fd.fd = -1;
myself = container_of(obj_hdl,
struct vfs_fsal_obj_handle,
obj_handle);
if (obj_hdl->fsal != obj_hdl->fs->fsal) {
LogDebug(COMPONENT_FSAL,
"FSAL %s operation for handle belonging to FSAL %s, return EXDEV",
obj_hdl->fsal->name, obj_hdl->fs->fsal->name);
return fsalstat(posix2fsal_error(EXDEV), EXDEV);
}
/* This can block over an I/O operation. */
PTHREAD_RWLOCK_wrlock(&obj_hdl->lock);
old_openflags = my_share_fd->openflags;
/* We can conflict with old share, so go ahead and check now. */
status = check_share_conflict(&myself->u.file.share, openflags, false);
if (FSAL_IS_ERROR(status)) {
PTHREAD_RWLOCK_unlock(&obj_hdl->lock);
return status;
}
/* Set up the new share so we can drop the lock and not have a
* conflicting share be asserted, updating the share counters.
*/
update_share_counters(&myself->u.file.share, old_openflags, openflags);
PTHREAD_RWLOCK_unlock(&obj_hdl->lock);
status = vfs_open_my_fd(myself, openflags, posix_flags, my_fd);
if (!FSAL_IS_ERROR(status)) {
/* Close the existing file descriptor and copy the new
* one over.
*/
vfs_close_my_fd(my_share_fd);
*my_share_fd = fd;
} else {
/* We had a failure on open - we need to revert the share.
* This can block over an I/O operation.
*/
PTHREAD_RWLOCK_wrlock(&obj_hdl->lock);
update_share_counters(&myself->u.file.share,
openflags,
old_openflags);
PTHREAD_RWLOCK_unlock(&obj_hdl->lock);
}
return status;
}
示例7: proxy_Fattr_To_FSAL_dynamic_fsinfo
/**
*
* proxy_Fattr_To_FSAL_dynamic_fsinfo: Converts NFSv4 attributes buffer to a FSAL dynamic fsinfo structure.
*
* Converts NFSv4 attributes buffer to a FSAL dynamic fsinfo structure.
*
* @param pdynamicinfo [OUT] pointer to FSAL attributes.
* @param Fattr [IN] pointer to NFSv4 attributes.
*
* @return 1 if successful, 0 if not supported, -1 if argument is badly formed
*
*/
int proxy_Fattr_To_FSAL_dynamic_fsinfo(fsal_dynamicfsinfo_t * pdynamicinfo,
fattr4 * Fattr)
{
u_int LastOffset = 0;
unsigned int i = 0;
char __attribute__ ((__unused__)) funcname[] = "proxy_Fattr_To_FSAL_dynamic_fsinfo";
uint32_t attrmasklist[FATTR4_MOUNTED_ON_FILEID]; /* List cannot be longer than FATTR4_MOUNTED_ON_FILEID */
uint32_t attrmasklen = 0;
uint32_t attribute_to_set = 0;
uint64_t tmp_uint64 = 0LL;
if(pdynamicinfo == NULL || Fattr == NULL)
return -1;
/* Check attributes data */
if(Fattr->attr_vals.attrlist4_val == NULL)
return -1;
/* Convert the attribute bitmap to an attribute list */
nfs4_bitmap4_to_list(&(Fattr->attrmask), &attrmasklen, attrmasklist);
LogFullDebug(COMPONENT_NFS_V4, " nfs4_bitmap4_to_list ====> attrmasklen = %d\n", attrmasklen);
/* Init */
memset((char *)pdynamicinfo, 0, sizeof(fsal_dynamicfsinfo_t));
for(i = 0; i < attrmasklen; i++)
{
attribute_to_set = attrmasklist[i];
if(attrmasklist[i] > FATTR4_MOUNTED_ON_FILEID)
{
/* Erroneous value... skip */
continue;
}
LogFullDebug(COMPONENT_NFS_V4, "=================> nfs4_Fattr_To_FSAL_attr: i=%u attr=%u\n", i,
attrmasklist[i]);
LogFullDebug(COMPONENT_NFS_V4, "Flag for Operation = %d|%d is ON, name = %s reply_size = %d\n",
attrmasklist[i], fattr4tab[attribute_to_set].val,
fattr4tab[attribute_to_set].name, fattr4tab[attribute_to_set].size_fattr4);
switch (attribute_to_set)
{
case FATTR4_FILES_AVAIL:
memcpy((char *)&tmp_uint64,
(char *)(Fattr->attr_vals.attrlist4_val + LastOffset),
sizeof(fattr4_files_avail));
pdynamicinfo->avail_files = nfs_ntohl64(tmp_uint64);
LastOffset += fattr4tab[attribute_to_set].size_fattr4;
break;
case FATTR4_FILES_FREE:
memcpy((char *)&tmp_uint64,
(char *)(Fattr->attr_vals.attrlist4_val + LastOffset),
sizeof(fattr4_files_free));
pdynamicinfo->free_files = nfs_ntohl64(tmp_uint64);
LastOffset += fattr4tab[attribute_to_set].size_fattr4;
break;
case FATTR4_FILES_TOTAL:
memcpy((char *)&tmp_uint64,
(char *)(Fattr->attr_vals.attrlist4_val + LastOffset),
sizeof(fattr4_files_total));
pdynamicinfo->total_files = nfs_ntohl64(tmp_uint64);
LastOffset += fattr4tab[attribute_to_set].size_fattr4;
break;
case FATTR4_SPACE_AVAIL:
memcpy((char *)&tmp_uint64,
(char *)(Fattr->attr_vals.attrlist4_val + LastOffset),
sizeof(fattr4_space_avail));
pdynamicinfo->avail_bytes = nfs_ntohl64(tmp_uint64);
LastOffset += fattr4tab[attribute_to_set].size_fattr4;
break;
case FATTR4_SPACE_FREE:
memcpy((char *)&tmp_uint64,
(char *)(Fattr->attr_vals.attrlist4_val + LastOffset),
sizeof(fattr4_space_free));
pdynamicinfo->free_bytes = nfs_ntohl64(tmp_uint64);
//.........这里部分代码省略.........
示例8: fsal_posixdb_add
fsal_posixdb_status_t fsal_posixdb_add(fsal_posixdb_conn * p_conn, /* IN */
fsal_posixdb_fileinfo_t * p_object_info, /* IN */
posixfsal_handle_t * p_parent_directory_handle, /* IN */
fsal_name_t * p_filename, /* IN */
posixfsal_handle_t * p_object_handle /* OUT */ )
{
PGresult *p_res;
char handleid_str[MAX_HANDLEIDSTR_SIZE];
char handlets_str[MAX_HANDLETSSTR_SIZE];
char handleidparent_str[MAX_HANDLEIDSTR_SIZE];
char handletsparent_str[MAX_HANDLETSSTR_SIZE];
char devid_str[MAX_DEVICEIDSTR_SIZE];
char inode_str[MAX_INODESTR_SIZE];
int found;
const char *paramValues[6];
fsal_posixdb_status_t st;
/*******************
* 1/ sanity check *
*******************/
/* parent_directory and filename are NULL only if it is the root directory */
if(!p_conn || !p_object_info || !p_object_handle
|| (p_filename && !p_parent_directory_handle) || (!p_filename
&& p_parent_directory_handle))
ReturnCodeDB(ERR_FSAL_POSIXDB_FAULT, 0);
CheckConn(p_conn);
LogFullDebug(COMPONENT_FSAL, "adding entry with parentid=%llu, id=%"PRIu64", name=%s\n",
p_parent_directory_handle ? p_parent_directory_handle->data.id : 0,
p_object_info ? p_object_info->inode : 0,
p_filename ? p_filename->name : "NULL");
BeginTransaction(p_conn, p_res);
/*********************************
* 2/ we check the parent handle *
*********************************/
if(p_parent_directory_handle)
{ /* the root has no parent */
snprintf(handleidparent_str, MAX_HANDLEIDSTR_SIZE, "%llu",
p_parent_directory_handle->data.id);
snprintf(handletsparent_str, MAX_HANDLETSSTR_SIZE, "%i",
p_parent_directory_handle->data.ts);
paramValues[0] = handleidparent_str;
paramValues[1] = handletsparent_str;
p_res = PQexecPrepared(p_conn, "lookupHandle", 2, paramValues, NULL, NULL, 0);
CheckResult(p_res);
if(PQntuples(p_res) != 1)
{
/* parent entry not found */
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOENT, 0);
}
PQclear(p_res);
}
/**********************************************************
* 3/ Check if there is an existing Handle for the object *
**********************************************************/
snprintf(devid_str, MAX_DEVICEIDSTR_SIZE, "%llu",
(unsigned long long int)p_object_info->devid);
snprintf(inode_str, MAX_INODESTR_SIZE, "%llu",
(unsigned long long int)p_object_info->inode);
paramValues[0] = devid_str;
paramValues[1] = inode_str;
p_res = PQexecPrepared(p_conn, "lookupHandleByInodeFU", 2, paramValues, NULL, NULL, 0);
CheckResult(p_res);
found = (PQntuples(p_res) == 1);
if(found)
{ /* a Handle (that matches devid & inode) already exists */
/* fill 'info' with information about the handle in the database */
posixdb_internal_fillFileinfoFromStrValues(&(p_object_handle->data.info), NULL, NULL, PQgetvalue(p_res, 0, 2), /* nlink */
PQgetvalue(p_res, 0, 3), /* ctime */
PQgetvalue(p_res, 0, 4) /* ftype */
);
p_object_handle->data.info.inode = p_object_info->inode;
p_object_handle->data.info.devid = p_object_info->devid;
strncpy(handleid_str, PQgetvalue(p_res, 0, 0), MAX_HANDLEIDSTR_SIZE);
strncpy(handlets_str, PQgetvalue(p_res, 0, 1), MAX_HANDLETSSTR_SIZE);
PQclear(p_res);
p_object_handle->data.id = atoll(handleid_str);
p_object_handle->data.ts = atoi(handlets_str);
/* check the consistency of the handle */
if(fsal_posixdb_consistency_check(&(p_object_handle->data.info), p_object_info))
{
/* consistency check failed */
/* p_object_handle has been filled in order to be able to fix the consistency later */
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_CONSISTENCY, 0);
}
/* update nlink & ctime if needed */
if(p_object_info->nlink != p_object_handle->data.info.nlink
|| p_object_info->ctime != p_object_handle->data.info.ctime)
//.........这里部分代码省略.........
示例9: nfs4_op_setclientid_confirm
int nfs4_op_setclientid_confirm(struct nfs_argop4 *op, compound_data_t *data,
struct nfs_resop4 *resp)
{
SETCLIENTID_CONFIRM4args * const arg_SETCLIENTID_CONFIRM4 =
&op->nfs_argop4_u.opsetclientid_confirm;
SETCLIENTID_CONFIRM4res * const res_SETCLIENTID_CONFIRM4 =
&resp->nfs_resop4_u.opsetclientid_confirm;
nfs_client_id_t *conf = NULL;
nfs_client_id_t *unconf = NULL;
nfs_client_record_t *client_record;
clientid4 clientid = 0;
char str_verifier[NFS4_VERIFIER_SIZE * 2 + 1];
const char *str_client_addr = "(unknown)";
/* The client name, for gratuitous logging */
char str_client[CLIENTNAME_BUFSIZE];
/* Display buffer for client name */
struct display_buffer dspbuf_client = {
sizeof(str_client), str_client, str_client};
/* The clientid4 broken down into fields */
char str_clientid4[DISPLAY_CLIENTID_SIZE];
/* Display buffer for clientid4 */
struct display_buffer dspbuf_clientid4 = {
sizeof(str_clientid4), str_clientid4, str_clientid4};
int rc;
/* Make sure str_client is always printable even
* if log level changes midstream.
*/
display_printf(&dspbuf_client, "(unknown)");
display_reset_buffer(&dspbuf_client);
resp->resop = NFS4_OP_SETCLIENTID_CONFIRM;
res_SETCLIENTID_CONFIRM4->status = NFS4_OK;
clientid = arg_SETCLIENTID_CONFIRM4->clientid;
display_clientid(&dspbuf_clientid4, clientid);
if (data->minorversion > 0) {
res_SETCLIENTID_CONFIRM4->status = NFS4ERR_NOTSUPP;
return res_SETCLIENTID_CONFIRM4->status;
}
if (op_ctx->client != NULL)
str_client_addr = op_ctx->client->hostaddr_str;
if (isDebug(COMPONENT_CLIENTID)) {
sprint_mem(str_verifier,
arg_SETCLIENTID_CONFIRM4->setclientid_confirm,
NFS4_VERIFIER_SIZE);
} else {
str_verifier[0] = '\0';
}
LogDebug(COMPONENT_CLIENTID,
"SETCLIENTID_CONFIRM client addr=%s clientid=%s setclientid_confirm=%s",
str_client_addr, str_clientid4, str_verifier);
/* First try to look up unconfirmed record */
rc = nfs_client_id_get_unconfirmed(clientid, &unconf);
if (rc == CLIENT_ID_SUCCESS) {
client_record = unconf->cid_client_record;
if (isFullDebug(COMPONENT_CLIENTID)) {
char str[LOG_BUFF_LEN] = "\0";
struct display_buffer dspbuf = {sizeof(str), str, str};
display_client_id_rec(&dspbuf, unconf);
LogFullDebug(COMPONENT_CLIENTID, "Found %s", str);
}
} else {
rc = nfs_client_id_get_confirmed(clientid, &conf);
if (rc != CLIENT_ID_SUCCESS) {
/* No record whatsoever of this clientid */
LogDebug(COMPONENT_CLIENTID,
"%s clientid = %s",
clientid_error_to_str(rc), str_clientid4);
res_SETCLIENTID_CONFIRM4->status =
clientid_error_to_nfsstat_no_expire(rc);
return res_SETCLIENTID_CONFIRM4->status;
}
client_record = conf->cid_client_record;
if (isFullDebug(COMPONENT_CLIENTID)) {
char str[LOG_BUFF_LEN] = "\0";
struct display_buffer dspbuf = {sizeof(str), str, str};
display_client_id_rec(&dspbuf, conf);
LogFullDebug(COMPONENT_CLIENTID, "Found %s", str);
}
}
PTHREAD_MUTEX_lock(&client_record->cr_mutex);
inc_client_record_ref(client_record);
if (isFullDebug(COMPONENT_CLIENTID)) {
//.........这里部分代码省略.........
示例10: fsal_posixdb_getInfoFromName
fsal_posixdb_status_t fsal_posixdb_getInfoFromName(fsal_posixdb_conn * p_conn, /* IN */
posixfsal_handle_t * p_parent_directory_handle, /* IN/OUT */
fsal_name_t * p_objectname, /* IN */
fsal_path_t * p_path, /* OUT */
posixfsal_handle_t *
p_handle /* OUT */ )
{
PGresult *p_res;
fsal_posixdb_status_t st;
char handleid_str[MAX_HANDLEIDSTR_SIZE];
char handlets_str[MAX_HANDLETSSTR_SIZE];
const char *paramValues[3] = { handleid_str, handlets_str, p_objectname->name };
/* sanity check */
if(!p_conn || !p_handle)
{
ReturnCodeDB(ERR_FSAL_POSIXDB_FAULT, 0);
}
CheckConn(p_conn);
LogFullDebug(COMPONENT_FSAL, "object_name='%s'\n", p_objectname->name);
BeginTransaction(p_conn, p_res);
/* lookup for the handle of the file */
if(p_parent_directory_handle && p_parent_directory_handle->data.id)
{
snprintf(handleid_str, MAX_HANDLEIDSTR_SIZE, "%lli", p_parent_directory_handle->data.id);
snprintf(handlets_str, MAX_HANDLETSSTR_SIZE, "%i", p_parent_directory_handle->data.ts);
p_res = PQexecPrepared(p_conn, "lookupHandleByName", 3, paramValues, NULL, NULL, 0);
CheckResult(p_res);
}
else
{
// get root handle :
p_res = PQexecPrepared(p_conn, "lookupRootHandle", 0, NULL, NULL, NULL, 0);
CheckResult(p_res);
}
/* p_res contains : Parent.handleid, Parent.handlets, Handle.deviceId, Handle.inode, Handle.nlink, Handle.ctime, Handle.ftype */
/* entry not found */
if(PQntuples(p_res) != 1)
{
PQclear(p_res);
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOENT, 0);
}
p_handle->data.id = atoll(PQgetvalue(p_res, 0, 0));
p_handle->data.ts = atoi(PQgetvalue(p_res, 0, 1));
posixdb_internal_fillFileinfoFromStrValues(&(p_handle->data.info), PQgetvalue(p_res, 0, 2), PQgetvalue(p_res, 0, 3), PQgetvalue(p_res, 0, 4), /* nlink */
PQgetvalue(p_res, 0, 5), /* ctime */
PQgetvalue(p_res, 0, 6) /* ftype */
);
PQclear(p_res);
/* Build the path of the object */
if(p_path && p_objectname)
{
/* build the path of the Parent */
st = fsal_posixdb_buildOnePath(p_conn, p_parent_directory_handle, p_path);
if(st.major != ERR_FSAL_POSIXDB_NOERR)
{
RollbackTransaction(p_conn, p_res);
return st;
}
/* then concatenate the filename */
if(!(p_path->len + 1 + p_objectname->len < FSAL_MAX_PATH_LEN))
{
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_PATHTOOLONG, 0);
}
p_path->path[p_path->len] = '/';
strcpy(&p_path->path[p_path->len + 1], p_objectname->name);
p_path->len += 1 + p_objectname->len;
/* add the the path to cache */
fsal_posixdb_CachePath(p_handle, p_path);
}
else
{
/* update handle if it was in cache */
fsal_posixdb_UpdateInodeCache(p_handle);
}
EndTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOERR, 0);
}
示例11: fsal_posixdb_getInfoFromHandle
fsal_posixdb_status_t fsal_posixdb_getInfoFromHandle(fsal_posixdb_conn * p_conn, /* IN */
posixfsal_handle_t * p_object_handle, /* IN/OUT */
fsal_path_t * p_paths, /* OUT */
int paths_size, /* IN */
int *p_count /* OUT */ )
{
PGresult *p_res;
fsal_posixdb_status_t st;
char handleid_str[MAX_HANDLEIDSTR_SIZE];
char handlets_str[MAX_HANDLETSSTR_SIZE];
posixfsal_handle_t parent_directory_handle;
int i_path;
int toomanypaths = 0;
const char *paramValues[2] = { handleid_str, handlets_str };
/* sanity check */
if(!p_conn || !p_object_handle || ((!p_paths || !p_count) && paths_size > 0))
{
ReturnCodeDB(ERR_FSAL_POSIXDB_FAULT, 0);
}
CheckConn(p_conn);
LogFullDebug(COMPONENT_FSAL, "OBJECT_ID=%lli\n", p_object_handle->data.id);
BeginTransaction(p_conn, p_res);
/* lookup for the handle of the file */
snprintf(handleid_str, MAX_HANDLEIDSTR_SIZE, "%lli", p_object_handle->data.id);
snprintf(handlets_str, MAX_HANDLETSSTR_SIZE, "%i", p_object_handle->data.ts);
if(!fsal_posixdb_GetInodeCache(p_object_handle))
{
p_res = PQexecPrepared(p_conn, "lookupHandle", 2, paramValues, NULL, NULL, 0);
CheckResult(p_res);
/* p_res contains : Handle.deviceId, Handle.inode, Handle.nlink, Handle.ctime, Handle.ftype */
LogDebug(COMPONENT_FSAL, "lookupHandle(%u,%u)", (unsigned int)p_object_handle->data.id,
(unsigned int)p_object_handle->data.ts);
/* entry not found */
if(PQntuples(p_res) != 1)
{
LogDebug(COMPONENT_FSAL, "lookupHandle=%d entries", PQntuples(p_res));
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOENT, 0);
}
posixdb_internal_fillFileinfoFromStrValues(&(p_object_handle->data.info), PQgetvalue(p_res, 0, 0), PQgetvalue(p_res, 0, 1), PQgetvalue(p_res, 0, 2), /* nlink */
PQgetvalue(p_res, 0, 3), /* ctime */
PQgetvalue(p_res, 0, 4) /* ftype */
);
PQclear(p_res);
/* update the inode */
fsal_posixdb_UpdateInodeCache(p_object_handle);
}
/* Build the paths of the object */
if(p_paths)
{
/* find all the paths to the object */
p_res = PQexecPrepared(p_conn, "lookupPaths", 2, paramValues, NULL, NULL, 0);
CheckResult(p_res);
/* p_res contains name, handleidparent, handletsparent */
*p_count = PQntuples(p_res);
if(*p_count == 0)
{
RollbackTransaction(p_conn, p_res);
ReturnCodeDB(ERR_FSAL_POSIXDB_NOPATH, 0);
}
if(*p_count > paths_size)
{
toomanypaths = 1;
LogCrit(COMPONENT_FSAL, "Too many paths found for object %s.%s: found=%u, max=%d",
handleid_str, handlets_str, *p_count, paths_size);
*p_count = paths_size;
}
for(i_path = 0; i_path < *p_count; i_path++)
{
unsigned int tmp_len;
/* build the path of the parent directory */
parent_directory_handle.data.id = atoll(PQgetvalue(p_res, i_path, 1));
parent_directory_handle.data.ts = atoi(PQgetvalue(p_res, i_path, 2));
st = fsal_posixdb_buildOnePath(p_conn, &parent_directory_handle,
&p_paths[i_path]);
if(st.major != ERR_FSAL_POSIXDB_NOERR)
{
RollbackTransaction(p_conn, p_res);
return st;
}
tmp_len = p_paths[i_path].len;
//.........这里部分代码省略.........
示例12: nlm_block_data_to_fsal_context
bool_t nlm_block_data_to_fsal_context(state_block_data_t * block_data,
fsal_op_context_t * fsal_context)
{
exportlist_t * pexport = NULL;
short exportid;
fsal_status_t fsal_status;
state_nlm_block_data_t * nlm_block_data = &block_data->sbd_block_data.sbd_nlm_block_data;
/* Get export ID from handle */
exportid = nlm4_FhandleToExportId(&nlm_block_data->sbd_nlm_fh);
/* Get export matching export ID */
if(exportid < 0 ||
(pexport = nfs_Get_export_by_id(nfs_param.pexportlist, exportid)) == NULL ||
(pexport->export_perms.options & EXPORT_OPTION_NFSV3) == 0)
{
/* Reject the request for authentication reason (incompatible file handle) */
if(isInfo(COMPONENT_NLM))
{
char dumpfh[1024];
char *reason;
char addrbuf[SOCK_NAME_MAX];
sprint_sockaddr(&nlm_block_data->sbd_nlm_hostaddr,
addrbuf,
sizeof(addrbuf));
if(exportid < 0)
reason = "has badly formed handle";
else if(pexport == NULL)
reason = "has invalid export";
else
reason = "V3 not allowed on this export";
sprint_fhandle_nlm(dumpfh, &nlm_block_data->sbd_nlm_fh);
LogMajor(COMPONENT_NLM,
"NLM4 granted lock from host %s %s, FH=%s",
addrbuf, reason, dumpfh);
}
return FALSE;
}
LogFullDebug(COMPONENT_NLM,
"Found export entry for path=%s as exportid=%d",
pexport->fullpath, pexport->id);
/* Build the credentials */
fsal_status = FSAL_GetClientContext(fsal_context,
&pexport->FS_export_context,
block_data->sbd_credential.user,
block_data->sbd_credential.group,
block_data->sbd_credential.alt_groups,
block_data->sbd_credential.nbgroups);
if(FSAL_IS_ERROR(fsal_status))
{
LogEvent(COMPONENT_NLM,
"Could not get credentials for (uid=%d,gid=%d), fsal error=(%d,%d)",
block_data->sbd_credential.user,
block_data->sbd_credential.group,
fsal_status.major, fsal_status.minor);
return FALSE;
}
else
LogDebug(COMPONENT_NLM,
"FSAL Cred acquired for (uid=%d,gid=%d)",
block_data->sbd_credential.user,
block_data->sbd_credential.group);
return TRUE;
}
示例13: nlm_process_share_parms
int nlm_process_share_parms(struct svc_req * preq,
nlm4_share * share,
cache_entry_t ** ppentry,
fsal_op_context_t * pcontext,
care_t care,
state_nsm_client_t ** ppnsm_client,
state_nlm_client_t ** ppnlm_client,
state_owner_t ** ppowner)
{
cache_inode_fsal_data_t fsal_data;
fsal_attrib_list_t attr;
cache_inode_status_t cache_status;
SVCXPRT *ptr_svc = preq->rq_xprt;
int rc;
*ppnsm_client = NULL;
*ppnlm_client = NULL;
*ppowner = NULL;
/* Convert file handle into a cache entry */
if(share->fh.n_len > MAX_NETOBJ_SZ ||
!nfs3_FhandleToFSAL((nfs_fh3 *) &share->fh, &fsal_data.fh_desc, pcontext))
{
/* handle is not valid */
return NLM4_STALE_FH;
}
/* Now get the cached inode attributes */
*ppentry = cache_inode_get(&fsal_data,
&attr,
pcontext,
NULL,
&cache_status);
if(*ppentry == NULL)
{
/* handle is not valid */
return NLM4_STALE_FH;
}
*ppnsm_client = get_nsm_client(care, ptr_svc, share->caller_name);
if(*ppnsm_client == NULL)
{
/* If NSM Client is not found, and we don't care (for unshare),
* just return GRANTED (the unshare must succeed, there can't be
* any shares).
*/
if(care != CARE_NOT)
rc = NLM4_DENIED_NOLOCKS;
else
rc = NLM4_GRANTED;
goto out_put;
}
*ppnlm_client = get_nlm_client(care, ptr_svc, *ppnsm_client, share->caller_name);
if(*ppnlm_client == NULL)
{
/* If NLM Client is not found, and we don't care (such as unlock),
* just return GRANTED (the unlock must succeed, there can't be
* any locks).
*/
dec_nsm_client_ref(*ppnsm_client);
if(care != CARE_NOT)
rc = NLM4_DENIED_NOLOCKS;
else
rc = NLM4_GRANTED;
goto out_put;
}
*ppowner = get_nlm_owner(care, *ppnlm_client, &share->oh, 0);
if(*ppowner == NULL)
{
LogDebug(COMPONENT_NLM,
"Could not get NLM Owner");
dec_nsm_client_ref(*ppnsm_client);
dec_nlm_client_ref(*ppnlm_client);
*ppnlm_client = NULL;
/* If owner is not found, and we don't care (such as unlock),
* just return GRANTED (the unlock must succeed, there can't be
* any locks).
*/
if(care != CARE_NOT)
rc = NLM4_DENIED_NOLOCKS;
else
rc = NLM4_GRANTED;
goto out_put;
}
LogFullDebug(COMPONENT_NLM,
"Parameters Processed");
return -1;
//.........这里部分代码省略.........
示例14: nlm_process_parameters
//.........这里部分代码省略.........
if(care != CARE_NOT)
rc = NLM4_DENIED_NOLOCKS;
else
rc = NLM4_GRANTED;
goto out_put;
}
*ppowner = get_nlm_owner(care, *ppnlm_client, &alock->oh, alock->svid);
if(*ppowner == NULL)
{
LogDebug(COMPONENT_NLM,
"Could not get NLM Owner");
dec_nsm_client_ref(*ppnsm_client);
dec_nlm_client_ref(*ppnlm_client);
*ppnlm_client = NULL;
/* If owner is not found, and we don't care (such as unlock),
* just return GRANTED (the unlock must succeed, there can't be
* any locks).
*/
if(care != CARE_NOT)
rc = NLM4_DENIED_NOLOCKS;
else
rc = NLM4_GRANTED;
goto out_put;
}
if(ppblock_data != NULL)
{
*ppblock_data = gsh_calloc(1, sizeof(**ppblock_data));
/* Fill in the block data, if we don't get one, we will just proceed
* without (which will mean the lock doesn't block.
*/
if(*ppblock_data != NULL)
{
if(copy_xprt_addr(&(*ppblock_data)->sbd_block_data.sbd_nlm_block_data.sbd_nlm_hostaddr, ptr_svc) == 0)
{
LogFullDebug(COMPONENT_NLM,
"copy_xprt_addr failed for Program %d, Version %d, Function %d",
(int)preq->rq_prog, (int)preq->rq_vers, (int)preq->rq_proc);
gsh_free(*ppblock_data);
*ppblock_data = NULL;
rc = NLM4_FAILED;
goto out_put;
}
(*ppblock_data)->sbd_granted_callback = nlm_granted_callback;
(*ppblock_data)->sbd_block_data.sbd_nlm_block_data.sbd_nlm_fh.n_bytes =
(*ppblock_data)->sbd_block_data.sbd_nlm_block_data.sbd_nlm_fh_buf;
(*ppblock_data)->sbd_block_data.sbd_nlm_block_data.sbd_nlm_fh.n_len = alock->fh.n_len;
memcpy((*ppblock_data)->sbd_block_data.sbd_nlm_block_data.sbd_nlm_fh_buf,
alock->fh.n_bytes,
alock->fh.n_len);
/* FSF TODO: Ultimately I think the following will go away, we won't need the context, just the export */
/* Copy credentials from pcontext */
#ifdef _USE_HPSS
/** @todo : PhD: Think about removing hpsscred_t from FSAL */
(*ppblock_data)->sbd_credential.user = pcontext->credential.hpss_usercred.Uid ;
(*ppblock_data)->sbd_credential.group = pcontext->credential.hpss_usercred.Gid ;
#else
(*ppblock_data)->sbd_credential = pcontext->credential;
/* Copy the alt groups list */
if(pcontext->credential.nbgroups != 0)
{
(*ppblock_data)->sbd_credential.alt_groups =
gsh_malloc(sizeof(gid_t) * pcontext->credential.nbgroups);
if((*ppblock_data)->sbd_credential.alt_groups == NULL)
{
gsh_free(*ppblock_data);
*ppblock_data = NULL;
rc = NLM4_FAILED;
goto out_put;
}
memcpy((*ppblock_data)->sbd_credential.alt_groups,
pcontext->credential.alt_groups,
pcontext->credential.nbgroups);
}
#endif
}
}
/* Fill in plock */
plock->lock_type = exclusive ? FSAL_LOCK_W : FSAL_LOCK_R;
plock->lock_start = alock->l_offset;
plock->lock_length = alock->l_len;
LogFullDebug(COMPONENT_NLM,
"Parameters Processed");
return -1;
out_put:
cache_inode_put(*ppentry);
*ppentry = NULL;
return rc;
}
示例15: vfs_setattr2
/**
* @brief Set attributes on an object
*
* This function sets attributes on an object. Which attributes are
* set is determined by attrib_set->mask. The FSAL must manage bypass
* or not of share reservations, and a state may be passed.
*
* @param[in] obj_hdl File on which to operate
* @param[in] state state_t to use for this operation
* @param[in] attrib_set Attributes to set
*
* @return FSAL status.
*/
fsal_status_t vfs_setattr2(struct fsal_obj_handle *obj_hdl,
bool bypass,
struct state_t *state,
struct attrlist *attrib_set)
{
struct vfs_fsal_obj_handle *myself;
fsal_status_t status = {0, 0};
int retval = 0;
fsal_openflags_t openflags = FSAL_O_ANY;
bool has_lock = false;
bool need_fsync = false;
bool closefd = false;
int my_fd;
const char *func;
/* apply umask, if mode attribute is to be changed */
if (FSAL_TEST_MASK(attrib_set->mask, ATTR_MODE))
attrib_set->mode &=
~op_ctx->fsal_export->exp_ops.fs_umask(op_ctx->fsal_export);
myself = container_of(obj_hdl, struct vfs_fsal_obj_handle, obj_handle);
if (obj_hdl->fsal != obj_hdl->fs->fsal) {
LogDebug(COMPONENT_FSAL,
"FSAL %s operation for handle belonging to FSAL %s, return EXDEV",
obj_hdl->fsal->name,
obj_hdl->fs->fsal != NULL
? obj_hdl->fs->fsal->name
: "(none)");
return fsalstat(posix2fsal_error(EXDEV), EXDEV);
}
#ifdef ENABLE_VFS_DEBUG_ACL
#ifdef ENABLE_RFC_ACL
if (FSAL_TEST_MASK(attrib_set->mask, ATTR_MODE) &&
!FSAL_TEST_MASK(attrib_set->mask, ATTR_ACL)) {
/* Set ACL from MODE */
struct attrlist attrs;
fsal_prepare_attrs(&attrs, ATTR_ACL);
status = obj_hdl->obj_ops.getattrs(obj_hdl, &attrs);
if (FSAL_IS_ERROR(status))
return status;
status = fsal_mode_to_acl(attrib_set, attrs.acl);
/* Done with the attrs */
fsal_release_attrs(&attrs);
} else {
/* If ATTR_ACL is set, mode needs to be adjusted no matter what.
* See 7530 s 6.4.1.3 */
if (!FSAL_TEST_MASK(attrib_set->mask, ATTR_MODE))
attrib_set->mode = myself->mode;
status = fsal_acl_to_mode(attrib_set);
}
if (FSAL_IS_ERROR(status))
return status;
#endif /* ENABLE_RFC_ACL */
#endif
/* This is yet another "you can't get there from here". If this object
* is a socket (AF_UNIX), an fd on the socket s useless _period_.
* If it is for a symlink, without O_PATH, you will get an ELOOP error
* and (f)chmod doesn't work for a symlink anyway - not that it matters
* because access checking is not done on the symlink but the final
* target.
* AF_UNIX sockets are also ozone material. If the socket is already
* active listeners et al, you can manipulate the mode etc. If it is
* just sitting there as in you made it with a mknod.
* (one of those leaky abstractions...)
* or the listener forgot to unlink it, it is lame duck.
*/
/* Test if size is being set, make sure file is regular and if so,
* require a read/write file descriptor.
*/
if (FSAL_TEST_MASK(attrib_set->mask, ATTR_SIZE)) {
if (obj_hdl->type != REGULAR_FILE) {
LogFullDebug(COMPONENT_FSAL,
"Setting size on non-regular file");
return fsalstat(ERR_FSAL_INVAL, EINVAL);
}
openflags = FSAL_O_RDWR;
}
//.........这里部分代码省略.........