本文整理汇总了C++中sa_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ sa_lookup函数的具体用法?C++ sa_lookup怎么用?C++ sa_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sa_lookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: zfs_log_symlink
/*
* Handles TX_SYMLINK transactions.
*/
void
zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, znode_t *zp, char *name, char *link)
{
itx_t *itx;
lr_create_t *lr;
size_t namesize = strlen(name) + 1;
size_t linksize = strlen(link) + 1;
if (zil_replaying(zilog, tx))
return;
itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize);
lr = (lr_create_t *)&itx->itx_lr;
lr->lr_doid = dzp->z_id;
lr->lr_foid = zp->z_id;
lr->lr_uid = zp->z_uid;
lr->lr_gid = zp->z_gid;
lr->lr_mode = zp->z_mode;
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
sizeof (uint64_t));
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
lr->lr_crtime, sizeof (uint64_t) * 2);
bcopy(name, (char *)(lr + 1), namesize);
bcopy(link, (char *)(lr + 1) + namesize, linksize);
zil_itx_assign(zilog, itx, tx);
}
开发者ID:Acidburn0zzz,项目名称:zfs,代码行数:31,代码来源:zfs_log.c
示例2: zfs_rmnode
void
zfs_rmnode(znode_t *zp)
{
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
objset_t *os = zfsvfs->z_os;
znode_t *xzp = NULL;
dmu_tx_t *tx;
uint64_t acl_obj;
uint64_t xattr_obj;
int error;
ASSERT(zp->z_links == 0);
ASSERT_VOP_ELOCKED(ZTOV(zp), __func__);
/*
* If this is an attribute directory, purge its contents.
*/
if (ZTOV(zp) != NULL && ZTOV(zp)->v_type == VDIR &&
(zp->z_pflags & ZFS_XATTR)) {
if (zfs_purgedir(zp) != 0) {
/*
* Not enough space to delete some xattrs.
* Leave it in the unlinked set.
*/
zfs_znode_dmu_fini(zp);
zfs_znode_free(zp);
return;
}
} else {
/*
* Free up all the data in the file. We don't do this for
* XATTR directories because we need truncate and remove to be
* in the same tx, like in zfs_znode_delete(). Otherwise, if
* we crash here we'll end up with an inconsistent truncated
* zap object in the delete queue. Note a truncated file is
* harmless since it only contains user data.
*/
error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END);
if (error) {
/*
* Not enough space. Leave the file in the unlinked
* set.
*/
zfs_znode_dmu_fini(zp);
zfs_znode_free(zp);
return;
}
}
/*
* If the file has extended attributes, we're going to unlink
* the xattr dir.
*/
error = sa_lookup(zp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs),
&xattr_obj, sizeof (xattr_obj));
if (error == 0 && xattr_obj) {
error = zfs_zget(zfsvfs, xattr_obj, &xzp);
ASSERT3S(error, ==, 0);
vn_lock(ZTOV(xzp), LK_EXCLUSIVE | LK_RETRY);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:60,代码来源:zfs_dir.c
示例3: __osd_xattr_load
/*
* Copy an extended attribute into the buffer provided, or compute the
* required buffer size.
*
* If buf is NULL, it computes the required buffer size.
*
* Returns 0 on success or a negative error number on failure.
* On success, the number of bytes used / required is stored in 'size'.
*
* No locking is done here.
*/
int __osd_xattr_load(udmu_objset_t *uos, uint64_t dnode, nvlist_t **sa_xattr)
{
sa_handle_t *sa_hdl;
char *buf;
int rc, size;
if (unlikely(dnode == ZFS_NO_OBJECT))
return -ENOENT;
rc = -sa_handle_get(uos->os, dnode, NULL, SA_HDL_PRIVATE, &sa_hdl);
if (rc)
return rc;
rc = -sa_size(sa_hdl, SA_ZPL_DXATTR(uos), &size);
if (rc) {
if (rc == -ENOENT)
rc = -nvlist_alloc(sa_xattr, NV_UNIQUE_NAME, KM_SLEEP);
goto out_sa;
}
buf = sa_spill_alloc(KM_SLEEP);
if (buf == NULL) {
rc = -ENOMEM;
goto out_sa;
}
rc = -sa_lookup(sa_hdl, SA_ZPL_DXATTR(uos), buf, size);
if (rc == 0)
rc = -nvlist_unpack(buf, size, sa_xattr, KM_SLEEP);
sa_spill_free(buf);
out_sa:
sa_handle_destroy(sa_hdl);
return rc;
}
开发者ID:karig,项目名称:lustre-stable,代码行数:45,代码来源:osd_xattr.c
示例4: ui_delete
static void
ui_delete(char *cmd)
{
char cookies_str[ISAKMP_HDR_COOKIES_LEN * 2 + 1];
char message_id_str[ISAKMP_HDR_MESSAGE_ID_LEN * 2 + 1];
u_int8_t cookies[ISAKMP_HDR_COOKIES_LEN];
u_int8_t message_id_buf[ISAKMP_HDR_MESSAGE_ID_LEN];
u_int8_t *message_id = message_id_buf;
struct sa *sa;
if (sscanf(cmd, "d %32s %8s", cookies_str, message_id_str) != 2) {
log_print("ui_delete: command \"%s\" malformed", cmd);
return;
}
if (strcmp(message_id_str, "-") == 0)
message_id = 0;
if (hex2raw(cookies_str, cookies, ISAKMP_HDR_COOKIES_LEN) == -1 ||
(message_id && hex2raw(message_id_str, message_id_buf,
ISAKMP_HDR_MESSAGE_ID_LEN) == -1)) {
log_print("ui_delete: command \"%s\" has bad arguments", cmd);
return;
}
sa = sa_lookup(cookies, message_id);
if (!sa) {
log_print("ui_delete: command \"%s\" found no SA", cmd);
return;
}
LOG_DBG((LOG_UI, 20,
"ui_delete: deleting SA for cookie \"%s\" msgid \"%s\"",
cookies_str, message_id_str));
sa_delete(sa, 1);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:33,代码来源:ui.c
示例5: zfs_sa_get_xattr
int
zfs_sa_get_xattr(znode_t *zp)
{
zfs_sb_t *zsb = ZTOZSB(zp);
char *obj;
int size;
int error;
ASSERT(RW_LOCK_HELD(&zp->z_xattr_lock));
ASSERT(!zp->z_xattr_cached);
ASSERT(zp->z_is_sa);
error = sa_size(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), &size);
if (error) {
if (error == ENOENT)
return nvlist_alloc(&zp->z_xattr_cached,
NV_UNIQUE_NAME, KM_SLEEP);
else
return (error);
}
obj = zio_buf_alloc(size);
error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), obj, size);
if (error == 0)
error = nvlist_unpack(obj, size, &zp->z_xattr_cached, KM_SLEEP);
zio_buf_free(obj, size);
return (error);
}
开发者ID:Alyseo,项目名称:zfs,代码行数:31,代码来源:zfs_sa.c
示例6: __osd_xattr_load
int __osd_xattr_load(struct osd_device *osd, uint64_t dnode, nvlist_t **sa)
{
sa_handle_t *sa_hdl;
char *buf;
int rc, size;
if (unlikely(dnode == ZFS_NO_OBJECT))
return -ENOENT;
rc = -sa_handle_get(osd->od_os, dnode, NULL, SA_HDL_PRIVATE, &sa_hdl);
if (rc)
return rc;
rc = -sa_size(sa_hdl, SA_ZPL_DXATTR(osd), &size);
if (rc) {
if (rc == -ENOENT)
rc = -nvlist_alloc(sa, NV_UNIQUE_NAME, KM_SLEEP);
goto out_sa;
}
buf = osd_zio_buf_alloc(size);
if (buf == NULL) {
rc = -ENOMEM;
goto out_sa;
}
rc = -sa_lookup(sa_hdl, SA_ZPL_DXATTR(osd), buf, size);
if (rc == 0)
rc = -nvlist_unpack(buf, size, sa, KM_SLEEP);
osd_zio_buf_free(buf, size);
out_sa:
sa_handle_destroy(sa_hdl);
return rc;
}
开发者ID:nkzxw,项目名称:lustre-stable,代码行数:34,代码来源:osd_xattr.c
示例7: zfs_sa_get_scanstamp
void
zfs_sa_get_scanstamp(znode_t *zp, xvattr_t *xvap)
{
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
xoptattr_t *xoap;
ASSERT(MUTEX_HELD(&zp->z_lock));
VERIFY((xoap = xva_getxoptattr(xvap)) != NULL);
if (zp->z_is_sa) {
if (sa_lookup(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs),
&xoap->xoa_av_scanstamp,
sizeof (xoap->xoa_av_scanstamp)) != 0)
return;
} else {
dmu_object_info_t doi;
dmu_buf_t *db = sa_get_db(zp->z_sa_hdl);
int len;
if (!(zp->z_pflags & ZFS_BONUS_SCANSTAMP))
return;
sa_object_info(zp->z_sa_hdl, &doi);
len = sizeof (xoap->xoa_av_scanstamp) +
ZFS_OLD_ZNODE_PHYS_SIZE;
if (len <= doi.doi_bonus_size) {
(void) memcpy(xoap->xoa_av_scanstamp,
(caddr_t)db->db_data + ZFS_OLD_ZNODE_PHYS_SIZE,
sizeof (xoap->xoa_av_scanstamp));
}
}
XVA_SET_RTN(xvap, XAT_AV_SCANSTAMP);
}
开发者ID:krauter,项目名称:zfs-1,代码行数:33,代码来源:zfs_sa.c
示例8: zfs_dirlook
/*
* Look up an entry in a directory.
*
* NOTE: '.' and '..' are handled as special cases because
* no directory entries are actually stored for them. If this is
* the root of a filesystem, then '.zfs' is also treated as a
* special pseudo-directory.
*/
int
zfs_dirlook(znode_t *dzp, char *name, struct inode **ipp, int flags,
int *deflg, pathname_t *rpnp)
{
zfs_dirlock_t *dl;
znode_t *zp;
int error = 0;
uint64_t parent;
if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) {
*ipp = ZTOI(dzp);
igrab(*ipp);
} else if (name[0] == '.' && name[1] == '.' && name[2] == 0) {
zfs_sb_t *zsb = ZTOZSB(dzp);
/*
* If we are a snapshot mounted under .zfs, return
* the vp for the snapshot directory.
*/
if ((error = sa_lookup(dzp->z_sa_hdl,
SA_ZPL_PARENT(zsb), &parent, sizeof (parent))) != 0)
return (error);
#ifdef HAVE_SNAPSHOT
if (parent == dzp->z_id && zsb->z_parent != zsb) {
error = zfsctl_root_lookup(zsb->z_parent->z_ctldir,
"snapshot", ipp, NULL, 0, NULL, kcred,
NULL, NULL, NULL);
return (error);
}
#endif /* HAVE_SNAPSHOT */
rw_enter(&dzp->z_parent_lock, RW_READER);
error = zfs_zget(zsb, parent, &zp);
if (error == 0)
*ipp = ZTOI(zp);
rw_exit(&dzp->z_parent_lock);
#ifdef HAVE_SNAPSHOT
} else if (zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0) {
*ipp = zfsctl_root(dzp);
#endif /* HAVE_SNAPSHOT */
} else {
int zf;
zf = ZEXISTS | ZSHARED;
if (flags & FIGNORECASE)
zf |= ZCILOOK;
error = zfs_dirent_lock(&dl, dzp, name, &zp, zf, deflg, rpnp);
if (error == 0) {
*ipp = ZTOI(zp);
zfs_dirent_unlock(dl);
dzp->z_zn_prefetch = B_TRUE; /* enable prefetching */
}
rpnp = NULL;
}
if ((flags & FIGNORECASE) && rpnp && !error)
(void) strlcpy(rpnp->pn_buf, name, rpnp->pn_bufsize);
return (error);
}
开发者ID:kohlschuetter,项目名称:zfs,代码行数:68,代码来源:zfs_dir.c
示例9: dirattrpack
void dirattrpack(attrinfo_t *aip, znode_t *zp)
{
attrgroup_t dirattr = aip->ai_attrlist->dirattr;
void *attrbufptr = *aip->ai_attrbufpp;
if (ATTR_DIR_LINKCOUNT & dirattr) {
*((u_int32_t *)attrbufptr) = 1; /* no dir hard links */
attrbufptr = ((u_int32_t *)attrbufptr) + 1;
}
if (ATTR_DIR_ENTRYCOUNT & dirattr) {
uint64_t val;
VERIFY(sa_lookup(zp->z_sa_hdl, SA_ZPL_SIZE(zp->z_zfsvfs),
&val, sizeof(val)) == 0);
*((u_int32_t *)attrbufptr) = (uint32_t)val;
attrbufptr = ((u_int32_t *)attrbufptr) + 1;
}
if (ATTR_DIR_MOUNTSTATUS & dirattr && zp) {
vnode_t *vp = ZTOV(zp);
if (vp != NULL && vnode_mountedhere(vp) != NULL)
*((u_int32_t *)attrbufptr) = DIR_MNTSTATUS_MNTPOINT;
else
*((u_int32_t *)attrbufptr) = 0;
attrbufptr = ((u_int32_t *)attrbufptr) + 1;
}
*aip->ai_attrbufpp = attrbufptr;
}
开发者ID:RJVB,项目名称:zfs,代码行数:27,代码来源:zfs_vnops_osx_lib.c
示例10: zfs_getbsdflags
uint32_t
zfs_getbsdflags(znode_t *zp)
{
uint32_t bsdflags = 0;
uint64_t zflags;
VERIFY(sa_lookup(zp->z_sa_hdl, SA_ZPL_FLAGS(zp->z_zfsvfs),
&zflags, sizeof (zflags)) == 0);
if (zflags & ZFS_NODUMP)
bsdflags |= UF_NODUMP;
if (zflags & ZFS_IMMUTABLE)
bsdflags |= UF_IMMUTABLE;
if (zflags & ZFS_APPENDONLY)
bsdflags |= UF_APPEND;
if (zflags & ZFS_OPAQUE)
bsdflags |= UF_OPAQUE;
if (zflags & ZFS_HIDDEN)
bsdflags |= UF_HIDDEN;
/*
* Due to every file getting archive set automatically, and OSX
* don't let you move/copy it as a user, we disable archive connection
* for now
if (zflags & ZFS_ARCHIVE)
bsdflags |= SF_ARCHIVED;
*/
dprintf("getbsd changing zfs %08lx to osx %08lx\n",
zflags, bsdflags);
return (bsdflags);
}
开发者ID:RJVB,项目名称:zfs,代码行数:29,代码来源:zfs_vnops_osx_lib.c
示例11: zfsctl_create
/*
* Create the '.zfs' directory. This directory is cached as part of the VFS
* structure. This results in a hold on the vfs_t. The code in zfs_umount()
* therefore checks against a vfs_count of 2 instead of 1. This reference
* is removed when the ctldir is destroyed in the unmount.
*/
void
zfsctl_create(zfsvfs_t *zfsvfs)
{
vnode_t *vp, *rvp;
zfsctl_node_t *zcp;
uint64_t crtime[2];
ASSERT(zfsvfs->z_ctldir == NULL);
vp = gfs_root_create(sizeof (zfsctl_node_t), zfsvfs->z_vfs,
&zfsctl_ops_root, ZFSCTL_INO_ROOT, zfsctl_root_entries,
zfsctl_root_inode_cb, MAXNAMELEN, NULL, NULL);
zcp = vp->v_data;
zcp->zc_id = ZFSCTL_INO_ROOT;
VERIFY(VFS_ROOT(zfsvfs->z_vfs, LK_EXCLUSIVE, &rvp) == 0);
VERIFY(0 == sa_lookup(VTOZ(rvp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs),
&crtime, sizeof (crtime)));
ZFS_TIME_DECODE(&zcp->zc_cmtime, crtime);
VN_URELE(rvp);
/*
* We're only faking the fact that we have a root of a filesystem for
* the sake of the GFS interfaces. Undo the flag manipulation it did
* for us.
*/
vp->v_vflag &= ~VV_ROOT;
zfsvfs->z_ctldir = vp;
VOP_UNLOCK(vp, 0);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:38,代码来源:zfs_ctldir.c
示例12: __osd_xattr_get_large
int __osd_xattr_get_large(const struct lu_env *env, struct osd_device *osd,
uint64_t xattr, struct lu_buf *buf,
const char *name, int *sizep)
{
dmu_buf_t *xa_data_db;
sa_handle_t *sa_hdl = NULL;
uint64_t xa_data_obj, size;
int rc;
/* are there any extended attributes? */
if (xattr == ZFS_NO_OBJECT)
return -ENOENT;
/* Lookup the object number containing the xattr data */
rc = -zap_lookup(osd->od_os, xattr, name, sizeof(uint64_t), 1,
&xa_data_obj);
if (rc)
return rc;
rc = __osd_obj2dbuf(env, osd->od_os, xa_data_obj, &xa_data_db);
if (rc)
return rc;
rc = -sa_handle_get(osd->od_os, xa_data_obj, NULL, SA_HDL_PRIVATE,
&sa_hdl);
if (rc)
goto out_rele;
/* Get the xattr value length / object size */
rc = -sa_lookup(sa_hdl, SA_ZPL_SIZE(osd), &size, 8);
if (rc)
goto out;
if (size > INT_MAX) {
rc = -EOVERFLOW;
goto out;
}
*sizep = (int)size;
if (buf == NULL || buf->lb_buf == NULL) {
/* We only need to return the required size */
goto out;
}
if (*sizep > buf->lb_len) {
rc = -ERANGE; /* match ldiskfs error */
goto out;
}
rc = -dmu_read(osd->od_os, xa_data_db->db_object, 0,
size, buf->lb_buf, DMU_READ_PREFETCH);
out:
sa_handle_destroy(sa_hdl);
out_rele:
dmu_buf_rele(xa_data_db, FTAG);
return rc;
}
开发者ID:nkzxw,项目名称:lustre-stable,代码行数:59,代码来源:osd_xattr.c
示例13: getfinderinfo
void getfinderinfo(znode_t *zp, cred_t *cr, finderinfo_t *fip)
{
vnode_t *xdvp = NULLVP;
vnode_t *xvp = NULLVP;
struct uio *auio = NULL;
struct componentname cn;
int error;
uint64_t xattr = 0;
if (sa_lookup(zp->z_sa_hdl, SA_ZPL_XATTR(zp->z_zfsvfs),
&xattr, sizeof(xattr)) ||
(xattr == 0)) {
goto nodata;
}
auio = uio_create(1, 0, UIO_SYSSPACE, UIO_READ);
if (auio == NULL) {
goto nodata;
}
uio_addiov(auio, CAST_USER_ADDR_T(fip), sizeof (finderinfo_t));
/*
* Grab the hidden attribute directory vnode.
*
* XXX - switch to embedded Finder Info when it becomes available
*/
if ((error = zfs_get_xattrdir(zp, &xdvp, cr, 0))) {
goto out;
}
bzero(&cn, sizeof (cn));
cn.cn_nameiop = LOOKUP;
cn.cn_flags = ISLASTCN;
cn.cn_nameptr = XATTR_FINDERINFO_NAME;
cn.cn_namelen = strlen(cn.cn_nameptr);
if ((error = zfs_dirlook(VTOZ(xdvp), cn.cn_nameptr, &xvp, 0, NULL, &cn))) {
goto out;
}
error = dmu_read_uio(zp->z_zfsvfs->z_os, VTOZ(xvp)->z_id, auio,
sizeof (finderinfo_t));
out:
if (auio)
uio_free(auio);
if (xvp)
vnode_put(xvp);
if (xdvp)
vnode_put(xdvp);
if (error == 0)
return;
nodata:
bzero(fip, sizeof (finderinfo_t));
}
开发者ID:RJVB,项目名称:zfs,代码行数:53,代码来源:zfs_vnops_osx_lib.c
示例14: zfs_dirlook
zfs_dirlook(znode_t *dzp, char *name, vnode_t **vpp)
#endif
{
zfs_dirlock_t *dl;
znode_t *zp;
int error = 0;
uint64_t parent;
#ifdef __APPLE__
char *name = cnp->cn_nameptr;
#endif
if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) {
*vpp = ZTOV(dzp);
VN_HOLD(*vpp);
} else if (name[0] == '.' && name[1] == '.' && name[2] == 0) {
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
/*
* If we are a snapshot mounted under .zfs, return
* the vp for the snapshot directory.
*/
if ((error = sa_lookup(dzp->z_sa_hdl,
SA_ZPL_PARENT(zfsvfs), &parent, sizeof (parent))) != 0)
return (error);
if (parent == dzp->z_id && zfsvfs->z_parent != zfsvfs) {
error = zfsctl_root_lookup(zfsvfs->z_parent->z_ctldir,
"snapshot", vpp, NULL, 0, NULL, kcred
/*, NULL, NULL, NULL*/);
return (error);
}
rw_enter(&dzp->z_parent_lock, RW_READER);
error = zfs_zget(zfsvfs, parent, &zp);
if (error == 0)
*vpp = ZTOV(zp);
rw_exit(&dzp->z_parent_lock);
} else if (zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0) {
*vpp = zfsctl_root(dzp);
} else {
#ifdef __APPLE__
error = zfs_dirent_lock(&dl, dzp, cnp, &zp, ZEXISTS | ZSHARED);
#else
error = zfs_dirent_lock(&dl, dzp, name, &zp, ZEXISTS | ZSHARED);
#endif
if (error == 0) {
*vpp = ZTOV(zp);
zfs_dirent_unlock(dl);
dzp->z_zn_prefetch = B_TRUE; /* enable prefetching */
}
}
return (error);
}
开发者ID:BjoKaSH,项目名称:zfs-osx,代码行数:52,代码来源:zfs_dir.c
示例15: zfs_inode_update
/*
* Update the embedded inode given the znode. We should work toward
* eliminating this function as soon as possible by removing values
* which are duplicated between the znode and inode. If the generic
* inode has the correct field it should be used, and the ZFS code
* updated to access the inode. This can be done incrementally.
*/
void
zfs_inode_update(znode_t *zp)
{
zfs_sb_t *zsb;
struct inode *ip;
uint32_t blksize;
uint64_t atime[2], mtime[2], ctime[2];
ASSERT(zp != NULL);
zsb = ZTOZSB(zp);
ip = ZTOI(zp);
/* Skip .zfs control nodes which do not exist on disk. */
if (zfsctl_is_node(ip))
return;
sa_lookup(zp->z_sa_hdl, SA_ZPL_ATIME(zsb), &atime, 16);
sa_lookup(zp->z_sa_hdl, SA_ZPL_MTIME(zsb), &mtime, 16);
sa_lookup(zp->z_sa_hdl, SA_ZPL_CTIME(zsb), &ctime, 16);
spin_lock(&ip->i_lock);
ip->i_generation = zp->z_gen;
ip->i_uid = SUID_TO_KUID(zp->z_uid);
ip->i_gid = SGID_TO_KGID(zp->z_gid);
set_nlink(ip, zp->z_links);
ip->i_mode = zp->z_mode;
zfs_set_inode_flags(zp, ip);
ip->i_blkbits = SPA_MINBLOCKSHIFT;
dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &blksize,
(u_longlong_t *)&ip->i_blocks);
ZFS_TIME_DECODE(&ip->i_atime, atime);
ZFS_TIME_DECODE(&ip->i_mtime, mtime);
ZFS_TIME_DECODE(&ip->i_ctime, ctime);
i_size_write(ip, zp->z_size);
spin_unlock(&ip->i_lock);
}
开发者ID:carriercomm,项目名称:zfs-crypto,代码行数:45,代码来源:zfs_znode.c
示例16: getuseraccess
/*
* Compute the same user access value as getattrlist(2)
*/
u_int32_t getuseraccess(znode_t *zp, vfs_context_t ctx)
{
vnode_t *vp;
u_int32_t user_access = 0;
zfs_acl_phys_t acl_phys;
int error;
/* Only take the expensive vnode_authorize path when we have an ACL */
error = sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zp->z_zfsvfs),
&acl_phys, sizeof (acl_phys));
if (error || acl_phys.z_acl_count == 0) {
kauth_cred_t cred = vfs_context_ucred(ctx);
uint64_t obj_uid;
uint64_t obj_mode;
/* User id 0 (root) always gets access. */
if (!vfs_context_suser(ctx)) {
return (R_OK | W_OK | X_OK);
}
sa_lookup(zp->z_sa_hdl, SA_ZPL_UID(zp->z_zfsvfs),
&obj_uid, sizeof (obj_uid));
sa_lookup(zp->z_sa_hdl, SA_ZPL_MODE(zp->z_zfsvfs),
&obj_mode, sizeof (obj_mode));
//obj_uid = pzp->zp_uid;
obj_mode = obj_mode & MODEMASK;
if (obj_uid == UNKNOWNUID) {
obj_uid = kauth_cred_getuid(cred);
}
if ((obj_uid == kauth_cred_getuid(cred)) ||
(obj_uid == UNKNOWNUID)) {
return (((u_int32_t)obj_mode & S_IRWXU) >> 6);
}
/* Otherwise, settle for 'others' access. */
return ((u_int32_t)obj_mode & S_IRWXO);
}
开发者ID:RJVB,项目名称:zfs,代码行数:41,代码来源:zfs_vnops_osx_lib.c
示例17: zfs_setbsdflags
void
zfs_setbsdflags(znode_t *zp, uint32_t bsdflags)
{
uint64_t zflags;
VERIFY(sa_lookup(zp->z_sa_hdl, SA_ZPL_FLAGS(zp->z_zfsvfs),
&zflags, sizeof (zflags)) == 0);
if (bsdflags & UF_NODUMP)
zflags |= ZFS_NODUMP;
else
zflags &= ~ZFS_NODUMP;
if (bsdflags & UF_IMMUTABLE)
zflags |= ZFS_IMMUTABLE;
else
zflags &= ~ZFS_IMMUTABLE;
if (bsdflags & UF_APPEND)
zflags |= ZFS_APPENDONLY;
else
zflags &= ~ZFS_APPENDONLY;
if (bsdflags & UF_OPAQUE)
zflags |= ZFS_OPAQUE;
else
zflags &= ~ZFS_OPAQUE;
if (bsdflags & UF_HIDDEN)
zflags |= ZFS_HIDDEN;
else
zflags &= ~ZFS_HIDDEN;
/*
if (bsdflags & SF_ARCHIVED)
zflags |= ZFS_ARCHIVE;
else
zflags &= ~ZFS_ARCHIVE;
*/
zp->z_pflags = zflags;
dprintf("setbsd changing osx %08lx to zfs %08lx\n",
bsdflags, zflags);
/*
(void )sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(zp->z_zfsvfs),
(void *)&zp->z_pflags, sizeof (uint64_t), tx);
*/
}
开发者ID:RJVB,项目名称:zfs,代码行数:48,代码来源:zfs_vnops_osx_lib.c
示例18: zfs_inode_set_ops
static void
zfs_inode_set_ops(zfs_sb_t *zsb, struct inode *ip)
{
uint64_t rdev = 0;
switch (ip->i_mode & S_IFMT) {
case S_IFREG:
ip->i_op = &zpl_inode_operations;
ip->i_fop = &zpl_file_operations;
ip->i_mapping->a_ops = &zpl_address_space_operations;
break;
case S_IFDIR:
ip->i_op = &zpl_dir_inode_operations;
ip->i_fop = &zpl_dir_file_operations;
ITOZ(ip)->z_zn_prefetch = B_TRUE;
break;
case S_IFLNK:
ip->i_op = &zpl_symlink_inode_operations;
break;
/*
* rdev is only stored in a SA only for device files.
*/
case S_IFCHR:
case S_IFBLK:
VERIFY(sa_lookup(ITOZ(ip)->z_sa_hdl, SA_ZPL_RDEV(zsb),
&rdev, sizeof (rdev)) == 0);
/*FALLTHROUGH*/
case S_IFIFO:
case S_IFSOCK:
init_special_inode(ip, ip->i_mode, rdev);
ip->i_op = &zpl_special_inode_operations;
break;
default:
printk("ZFS: Invalid mode: 0x%x\n", ip->i_mode);
VERIFY(0);
}
}
开发者ID:carriercomm,项目名称:zfs-crypto,代码行数:41,代码来源:zfs_znode.c
示例19: zfs_dd_lookup
static int
zfs_dd_lookup(znode_t *dzp, znode_t **zpp)
{
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
znode_t *zp;
uint64_t parent;
int error;
ASSERT_VOP_LOCKED(ZTOV(dzp), __func__);
ASSERT(RRM_READ_HELD(&zfsvfs->z_teardown_lock));
if (dzp->z_unlinked)
return (ENOENT);
if ((error = sa_lookup(dzp->z_sa_hdl,
SA_ZPL_PARENT(zfsvfs), &parent, sizeof (parent))) != 0)
return (error);
error = zfs_zget(zfsvfs, parent, &zp);
if (error == 0)
*zpp = zp;
return (error);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:23,代码来源:zfs_dir.c
示例20: zfsctl_create
/*
* Create the '.zfs' directory.
*/
void
zfsctl_create(zfsvfs_t *zfsvfs)
{
zfsctl_root_t *dot_zfs;
sfs_node_t *snapdir;
vnode_t *rvp;
uint64_t crtime[2];
ASSERT(zfsvfs->z_ctldir == NULL);
snapdir = sfs_alloc_node(sizeof(*snapdir), "snapshot", ZFSCTL_INO_ROOT,
ZFSCTL_INO_SNAPDIR);
dot_zfs = (zfsctl_root_t *)sfs_alloc_node(sizeof(*dot_zfs), ".zfs", 0,
ZFSCTL_INO_ROOT);
dot_zfs->snapdir = snapdir;
VERIFY(VFS_ROOT(zfsvfs->z_vfs, LK_EXCLUSIVE, &rvp) == 0);
VERIFY(0 == sa_lookup(VTOZ(rvp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs),
&crtime, sizeof(crtime)));
ZFS_TIME_DECODE(&dot_zfs->cmtime, crtime);
vput(rvp);
zfsvfs->z_ctldir = dot_zfs;
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:27,代码来源:zfs_ctldir.c
注:本文中的sa_lookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论