本文整理汇总了C++中crhold函数的典型用法代码示例。如果您正苦于以下问题:C++ crhold函数的具体用法?C++ crhold怎么用?C++ crhold使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crhold函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: zpl_sync_fs
static int
zpl_sync_fs(struct super_block *sb, int wait)
{
fstrans_cookie_t cookie;
cred_t *cr = CRED();
int error;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_sync(sb, wait, cr);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:koplover,项目名称:zfs,代码行数:16,代码来源:zpl_super.c
示例2: zpl_rmdir
static int
zpl_rmdir(struct inode * dir, struct dentry *dentry)
{
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_rmdir(dir, dname(dentry), NULL, cr, 0);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:10144161,项目名称:zfs,代码行数:16,代码来源:zpl_inode.c
示例3: zpl_fsync
/*
* Linux 2.6.x - 2.6.34 API,
* Through 2.6.34 the nfsd kernel server would pass a NULL 'file struct *'
* to the fops->fsync() hook. For this reason, we must be careful not to
* use filp unconditionally.
*/
static int
zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
{
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_fsync(dentry->d_inode, datasync, cr);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:Alyseo,项目名称:zfs,代码行数:22,代码来源:zpl_file.c
示例4: zpl_iter_read_common
static ssize_t
zpl_iter_read_common(struct kiocb *kiocb, const struct iovec *iovp,
unsigned long nr_segs, size_t count, uio_seg_t seg, size_t skip)
{
cred_t *cr = CRED();
struct file *filp = kiocb->ki_filp;
ssize_t read;
crhold(cr);
read = zpl_read_common_iovec(filp->f_mapping->host, iovp, count,
nr_segs, &kiocb->ki_pos, seg, filp->f_flags, cr, skip);
crfree(cr);
file_accessed(filp);
return (read);
}
开发者ID:krichter722,项目名称:zfs,代码行数:16,代码来源:zpl_file.c
示例5: zpl_iterate
static int
zpl_iterate(struct file *filp, struct dir_context *ctx)
{
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_readdir(file_inode(filp), ctx, cr);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:krichter722,项目名称:zfs,代码行数:16,代码来源:zpl_file.c
示例6: zpl_commit_metadata
static int
zpl_commit_metadata(struct inode *inode)
{
cred_t *cr = CRED();
fstrans_cookie_t cookie;
int error;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_fsync(inode, 0, cr);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:LlsDimple,项目名称:zfs,代码行数:16,代码来源:zpl_export.c
示例7: pgetucred
/*
* Get the "ucred" of a process.
*/
struct ucred_s *
pgetucred(proc_t *p)
{
cred_t *cr;
struct ucred_s *uc;
mutex_enter(&p->p_crlock);
cr = p->p_cred;
crhold(cr);
mutex_exit(&p->p_crlock);
uc = cred2ucred(cr, p->p_pid, NULL, CRED());
crfree(cr);
return (uc);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:19,代码来源:cred.c
示例8: mac_proc_vm_revoke
/*
* When relabeling a process, call out to the policies for the maximum
* permission allowed for each object type we know about in its memory space,
* and revoke access (in the least surprising ways we know) when necessary.
* The process lock is not held here.
*/
void
mac_proc_vm_revoke(struct thread *td)
{
struct ucred *cred;
PROC_LOCK(td->td_proc);
cred = crhold(td->td_proc->p_ucred);
PROC_UNLOCK(td->td_proc);
/* XXX freeze all other threads */
mac_proc_vm_revoke_recurse(td, cred,
&td->td_proc->p_vmspace->vm_map);
/* XXX allow other threads to continue */
crfree(cred);
}
开发者ID:FelixHaller,项目名称:libuinet,代码行数:22,代码来源:mac_process.c
示例9: zpl_xattr_set
static int
zpl_xattr_set(struct inode *ip, const char *name, const void *value,
size_t size, int flags)
{
znode_t *zp = ITOZ(ip);
zfs_sb_t *zsb = ZTOZSB(zp);
cred_t *cr = CRED();
int error;
crhold(cr);
rw_enter(&ITOZ(ip)->z_xattr_lock, RW_WRITER);
/*
* Before setting the xattr check to see if it already exists.
* This is done to ensure the following optional flags are honored.
*
* XATTR_CREATE: fail if xattr already exists
* XATTR_REPLACE: fail if xattr does not exist
*/
error = __zpl_xattr_get(ip, name, NULL, 0, cr);
if (error < 0) {
if (error != -ENODATA)
goto out;
if ((error == -ENODATA) && (flags & XATTR_REPLACE))
goto out;
} else {
error = -EEXIST;
if (flags & XATTR_CREATE)
goto out;
}
/* Preferentially store the xattr as a SA for better performance */
if (zsb->z_use_sa && zsb->z_xattr_sa && zp->z_is_sa) {
error = zpl_xattr_set_sa(ip, name, value, size, flags, cr);
if (error == 0)
goto out;
}
error = zpl_xattr_set_dir(ip, name, value, size, flags, cr);
out:
rw_exit(&ITOZ(ip)->z_xattr_lock);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:krauter,项目名称:zfs-1,代码行数:47,代码来源:zpl_xattr.c
示例10: zpl_follow_link
const char *
zpl_follow_link(struct dentry *dentry, void **symlink_cookie)
#endif
{
cred_t *cr = CRED();
struct inode *ip = dentry->d_inode;
struct iovec iov;
uio_t uio;
char *link;
int error;
fstrans_cookie_t cookie;
crhold(cr);
iov.iov_len = MAXPATHLEN;
iov.iov_base = link = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
uio.uio_skip = 0;
uio.uio_resid = (MAXPATHLEN - 1);
uio.uio_segflg = UIO_SYSSPACE;
cookie = spl_fstrans_mark();
error = -zfs_readlink(ip, &uio, cr);
spl_fstrans_unmark(cookie);
if (error)
kmem_free(link, MAXPATHLEN);
crfree(cr);
#ifdef HAVE_FOLLOW_LINK_NAMEIDATA
if (error)
nd_set_link(nd, ERR_PTR(error));
else
nd_set_link(nd, link);
return (NULL);
#else
if (error)
return (ERR_PTR(error));
else
return (*symlink_cookie = link);
#endif
}
开发者ID:10144161,项目名称:zfs,代码行数:46,代码来源:zpl_inode.c
示例11: zpl_iterate
static int
zpl_iterate(struct file *filp, struct dir_context *ctx)
{
struct dentry *dentry = filp->f_path.dentry;
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_readdir(dentry->d_inode, ctx, cr);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:Alyseo,项目名称:zfs,代码行数:17,代码来源:zpl_file.c
示例12: zpl_read
static ssize_t
zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
{
cred_t *cr = CRED();
ssize_t read;
crhold(cr);
read = zpl_read_common(filp->f_mapping->host, buf, len, *ppos,
UIO_USERSPACE, filp->f_flags, cr);
crfree(cr);
if (read < 0)
return (read);
*ppos += read;
return (read);
}
开发者ID:shenyan1,项目名称:zfs,代码行数:17,代码来源:zpl_file.c
示例13: zpl_get_parent
static struct dentry *
zpl_get_parent(struct dentry *child)
{
cred_t *cr = CRED();
struct inode *ip;
int error;
crhold(cr);
error = -zfs_lookup(child->d_inode, "..", &ip, 0, cr, NULL, NULL);
crfree(cr);
ASSERT3S(error, <=, 0);
if (error)
return ERR_PTR(error);
return zpl_dentry_obtain_alias(ip);
}
开发者ID:Kream,项目名称:zfs,代码行数:17,代码来源:zpl_export.c
示例14: zpl_write
static ssize_t
zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
{
cred_t *cr = CRED();
ssize_t wrote;
crhold(cr);
wrote = zpl_write_common(filp->f_mapping->host, buf, len, *ppos,
UIO_USERSPACE, filp->f_flags, cr);
crfree(cr);
if (wrote < 0)
return (wrote);
*ppos += wrote;
return (wrote);
}
开发者ID:shenyan1,项目名称:zfs,代码行数:17,代码来源:zpl_file.c
示例15: userenter
/*
* Passively intercepts the thread switch function to increase the thread
* priority from a user priority to a kernel priority, reducing
* syscall and trap overhead for the case where no switch occurs.
*
* Synchronizes td_ucred with p_ucred. This is used by system calls,
* signal handling, faults, AST traps, and anything else that enters the
* kernel from userland and provides the kernel with a stable read-only
* copy of the process ucred.
*/
static __inline void
userenter(struct thread *curtd, struct proc *curp)
{
struct ucred *ocred;
struct ucred *ncred;
curtd->td_release = lwkt_passive_release;
if (curtd->td_ucred != curp->p_ucred) {
ncred = crhold(curp->p_ucred);
ocred = curtd->td_ucred;
curtd->td_ucred = ncred;
if (ocred)
crfree(ocred);
}
}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:27,代码来源:trap.c
示例16: zpl_rename
static int
zpl_rename(struct inode *sdip, struct dentry *sdentry,
struct inode *tdip, struct dentry *tdentry)
{
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_rename(sdip, dname(sdentry), tdip, dname(tdentry), cr, 0);
spl_fstrans_unmark(cookie);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:MarkGavalda,项目名称:zfs,代码行数:17,代码来源:zpl_inode.c
示例17: zpl_open
static int
zpl_open(struct inode *ip, struct file *filp)
{
cred_t *cr = CRED();
int error;
error = generic_file_open(ip, filp);
if (error)
return (error);
crhold(cr);
error = -zfs_open(ip, filp->f_mode, filp->f_flags, cr);
crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:shenyan1,项目名称:zfs,代码行数:17,代码来源:zpl_file.c
示例18: zpl_fallocate_common
long
zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len)
{
int error = -EOPNOTSUPP;
#if defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE)
cred_t *cr = CRED();
flock64_t bf;
loff_t olen;
fstrans_cookie_t cookie;
if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return (error);
crhold(cr);
if (offset < 0 || len <= 0)
return (-EINVAL);
spl_inode_lock(ip);
olen = i_size_read(ip);
if (offset > olen) {
spl_inode_unlock(ip);
return (0);
}
if (offset + len > olen)
len = olen - offset;
bf.l_type = F_WRLCK;
bf.l_whence = 0;
bf.l_start = offset;
bf.l_len = len;
bf.l_pid = 0;
cookie = spl_fstrans_mark();
error = -zfs_space(ip, F_FREESP, &bf, FWRITE, offset, cr);
spl_fstrans_unmark(cookie);
spl_inode_unlock(ip);
crfree(cr);
#endif /* defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE) */
ASSERT3S(error, <=, 0);
return (error);
}
开发者ID:Alyseo,项目名称:zfs,代码行数:45,代码来源:zpl_file.c
示例19: pts_alloc_external
int
pts_alloc_external(int fflags, struct thread *td, struct file *fp,
struct cdev *dev, const char *name)
{
int ok, error;
struct tty *tp;
struct pts_softc *psc;
struct proc *p = td->td_proc;
struct ucred *cred = td->td_ucred;
/* Resource limiting. */
PROC_LOCK(p);
error = racct_add(p, RACCT_NPTS, 1);
if (error != 0) {
PROC_UNLOCK(p);
return (EAGAIN);
}
ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_NPTS));
if (!ok) {
racct_sub(p, RACCT_NPTS, 1);
PROC_UNLOCK(p);
return (EAGAIN);
}
PROC_UNLOCK(p);
/* Allocate TTY and softc. */
psc = malloc(sizeof(struct pts_softc), M_PTS, M_WAITOK|M_ZERO);
cv_init(&psc->pts_inwait, "ptsin");
cv_init(&psc->pts_outwait, "ptsout");
psc->pts_unit = -1;
psc->pts_cdev = dev;
psc->pts_cred = crhold(cred);
tp = tty_alloc(&pts_class, psc);
knlist_init_mtx(&psc->pts_inpoll.si_note, tp->t_mtx);
knlist_init_mtx(&psc->pts_outpoll.si_note, tp->t_mtx);
/* Expose the slave device as well. */
tty_makedev(tp, td->td_ucred, "%s", name);
finit(fp, fflags, DTYPE_PTS, tp, &ptsdev_ops);
return (0);
}
开发者ID:JasonFord53,项目名称:freebsd,代码行数:45,代码来源:tty_pts.c
示例20: kern_file_open
cfs_file_t *
kern_file_open(const char * filename, int flags, int mode, int *err)
{
struct nameidata nd;
cfs_file_t *fp;
register struct vnode *vp;
int rc;
extern struct fileops vnops;
extern int nfiles;
CFS_DECL_CONE_DATA;
CFS_CONE_IN;
nfiles++;
MALLOC_ZONE(fp, cfs_file_t *, sizeof(cfs_file_t), M_FILE, M_WAITOK|M_ZERO);
bzero(fp, sizeof(cfs_file_t));
fp->f_count = 1;
LIST_CIRCLE(fp, f_list);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)filename, current_proc());
if ((rc = vn_open(&nd, flags, mode)) != 0){
printf("filp_open failed at (%d)\n", rc);
if (err != NULL)
*err = rc;
FREE_ZONE(fp, sizeof *fp, M_FILE);
CFS_CONE_EX;
return NULL;
}
vp = nd.ni_vp;
fp->f_flag = flags & FMASK;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (caddr_t)vp;
fp->f_cred = current_proc()->p_ucred;
/*
* Hold cred to increase reference
*/
crhold(fp->f_cred);
/*
* vnode is locked inside vn_open for lookup,
* we should release the lock before return
*/
VOP_UNLOCK(vp, 0, current_proc());
CFS_CONE_EX;
return fp;
}
开发者ID:dmlb2000,项目名称:lustre-release,代码行数:45,代码来源:darwin-fs.c
注:本文中的crhold函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论