+ VFS_KERNEL_DEBUG_END1(12, vp);
+
+ return error;
+}
+
+void
+mac_vnode_notify_rename(vfs_context_t ctx, struct vnode *vp,
+ struct vnode *dvp, struct componentname *cnp)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(13, vp);
+ MAC_PERFORM(vnode_notify_rename, cred, vp, vp->v_label,
+ dvp, dvp->v_label, cnp);
+ VFS_KERNEL_DEBUG_END1(13, vp);
+}
+
+void
+mac_vnode_notify_open(vfs_context_t ctx, struct vnode *vp, int acc_flags)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(14, vp);
+ MAC_PERFORM(vnode_notify_open, cred, vp, vp->v_label, acc_flags);
+ VFS_KERNEL_DEBUG_END1(14, vp);
+}
+
+void
+mac_vnode_notify_link(vfs_context_t ctx, struct vnode *vp,
+ struct vnode *dvp, struct componentname *cnp)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(15, vp);
+ MAC_PERFORM(vnode_notify_link, cred, dvp, dvp->v_label, vp, vp->v_label, cnp);
+ VFS_KERNEL_DEBUG_END1(15, vp);
+}
+
+void
+mac_vnode_notify_deleteextattr(vfs_context_t ctx, struct vnode *vp, const char *name)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(16, vp);
+ MAC_PERFORM(vnode_notify_deleteextattr, cred, vp, vp->v_label, name);
+ VFS_KERNEL_DEBUG_END1(16, vp);
+}
+
+void
+mac_vnode_notify_setacl(vfs_context_t ctx, struct vnode *vp, struct kauth_acl *acl)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(17, vp);
+ MAC_PERFORM(vnode_notify_setacl, cred, vp, vp->v_label, acl);
+ VFS_KERNEL_DEBUG_END1(17, vp);
+}
+
+void
+mac_vnode_notify_setattrlist(vfs_context_t ctx, struct vnode *vp, struct attrlist *alist)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(18, vp);
+ MAC_PERFORM(vnode_notify_setattrlist, cred, vp, vp->v_label, alist);
+ VFS_KERNEL_DEBUG_END1(18, vp);
+}
+
+void
+mac_vnode_notify_setextattr(vfs_context_t ctx, struct vnode *vp, const char *name, struct uio *uio)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(19, vp);
+ MAC_PERFORM(vnode_notify_setextattr, cred, vp, vp->v_label, name, uio);
+ VFS_KERNEL_DEBUG_END1(19, vp);
+}
+
+void
+mac_vnode_notify_setflags(vfs_context_t ctx, struct vnode *vp, u_long flags)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(20, vp);
+ MAC_PERFORM(vnode_notify_setflags, cred, vp, vp->v_label, flags);
+ VFS_KERNEL_DEBUG_END1(20, vp);
+}
+
+void
+mac_vnode_notify_setmode(vfs_context_t ctx, struct vnode *vp, mode_t mode)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(21, vp);
+ MAC_PERFORM(vnode_notify_setmode, cred, vp, vp->v_label, mode);
+ VFS_KERNEL_DEBUG_END1(21, vp);
+}
+
+void
+mac_vnode_notify_setowner(vfs_context_t ctx, struct vnode *vp, uid_t uid, gid_t gid)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(22, vp);
+ MAC_PERFORM(vnode_notify_setowner, cred, vp, vp->v_label, uid, gid);
+ VFS_KERNEL_DEBUG_END1(22, vp);
+}
+
+void
+mac_vnode_notify_setutimes(vfs_context_t ctx, struct vnode *vp, struct timespec atime, struct timespec mtime)
+{
+ kauth_cred_t cred;
+
+#if SECURITY_MAC_CHECK_ENFORCE
+ /* 21167099 - only check if we allow write */
+ if (!mac_vnode_enforce) {
+ return;
+ }
+#endif
+ cred = vfs_context_ucred(ctx);
+ if (!mac_cred_check_enforce(cred)) {
+ return;
+ }
+ VFS_KERNEL_DEBUG_START1(23, vp);
+ MAC_PERFORM(vnode_notify_setutimes, cred, vp, vp->v_label, atime, mtime);
+ VFS_KERNEL_DEBUG_END1(23, vp);
+}
+
+void
+mac_vnode_notify_truncate(vfs_context_t ctx, kauth_cred_t file_cred, struct vnode *vp)
+{
+ kauth_cred_t cred;