diff options
author | marks <none@none> | 2008-07-09 13:27:44 -0700 |
---|---|---|
committer | marks <none@none> | 2008-07-09 13:27:44 -0700 |
commit | 93aeed832de7673ee68c1c82129a4fb8819c16bc (patch) | |
tree | 8fbe5efee4a6f1b92f53ab4151945691bab491c6 /usr/src/uts/common/fs/nfs/nfs_subr.c | |
parent | 4a179720b93e6200ddafd0f29ceabf9c78eff756 (diff) | |
download | illumos-joyent-93aeed832de7673ee68c1c82129a4fb8819c16bc.tar.gz |
6683575 Revisit handling of CREATE_XATTR_DIR
Diffstat (limited to 'usr/src/uts/common/fs/nfs/nfs_subr.c')
-rw-r--r-- | usr/src/uts/common/fs/nfs/nfs_subr.c | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/usr/src/uts/common/fs/nfs/nfs_subr.c b/usr/src/uts/common/fs/nfs/nfs_subr.c index 10391a7f42..fd1982c052 100644 --- a/usr/src/uts/common/fs/nfs/nfs_subr.c +++ b/usr/src/uts/common/fs/nfs/nfs_subr.c @@ -19,11 +19,8 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * - * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. - * All rights reserved. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -63,6 +60,7 @@ #include <sys/tsol/tnet.h> #include <sys/priv.h> #include <sys/sdt.h> +#include <sys/attr.h> #include <inet/ip6.h> @@ -5158,3 +5156,58 @@ do_rfs_label_check(bslabel_t *clabel, vnode_t *vp, int flag) label_rele(tslabel); return (result); } + +/* + * See if xattr directory to see if it has any generic user attributes + */ +int +do_xattr_exists_check(vnode_t *vp, ulong_t *valp, cred_t *cr) +{ + struct uio uio; + struct iovec iov; + char *dbuf; + struct dirent64 *dp; + size_t dlen = 8 * 1024; + size_t dbuflen; + int eof = 0; + int error; + + *valp = 0; + dbuf = kmem_alloc(dlen, KM_SLEEP); + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_fmode = 0; + uio.uio_extflg = UIO_COPY_CACHED; + uio.uio_loffset = 0; + uio.uio_resid = dlen; + iov.iov_base = dbuf; + iov.iov_len = dlen; + (void) VOP_RWLOCK(vp, V_WRITELOCK_FALSE, NULL); + error = VOP_READDIR(vp, &uio, cr, &eof, NULL, 0); + VOP_RWUNLOCK(vp, V_WRITELOCK_FALSE, NULL); + + dbuflen = dlen - uio.uio_resid; + + if (error || dbuflen == 0) { + kmem_free(dbuf, dlen); + return (error); + } + + dp = (dirent64_t *)dbuf; + + while ((intptr_t)dp < (intptr_t)dbuf + dbuflen) { + if (strcmp(dp->d_name, ".") == 0 || + strcmp(dp->d_name, "..") == 0 || strcmp(dp->d_name, + VIEW_READWRITE) == 0 || strcmp(dp->d_name, + VIEW_READONLY) == 0) { + dp = (dirent64_t *)((intptr_t)dp + dp->d_reclen); + continue; + } + + *valp = 1; + break; + } + kmem_free(dbuf, dlen); + return (0); +} |