* vnode creation operation */
| 981 | * vnode creation operation |
| 982 | */ |
| 983 | static int |
| 984 | mqfs_create(struct vop_create_args *ap) |
| 985 | { |
| 986 | struct mqfs_info *mqfs = VFSTOMQFS(ap->a_dvp->v_mount); |
| 987 | struct componentname *cnp = ap->a_cnp; |
| 988 | struct mqfs_node *pd; |
| 989 | struct mqfs_node *pn; |
| 990 | struct mqueue *mq; |
| 991 | int error; |
| 992 | |
| 993 | pd = VTON(ap->a_dvp); |
| 994 | if (pd->mn_type != mqfstype_root && pd->mn_type != mqfstype_dir) |
| 995 | return (ENOTDIR); |
| 996 | mq = mqueue_alloc(NULL); |
| 997 | if (mq == NULL) |
| 998 | return (EAGAIN); |
| 999 | sx_xlock(&mqfs->mi_lock); |
| 1000 | if ((cnp->cn_flags & HASBUF) == 0) |
| 1001 | panic("%s: no name", __func__); |
| 1002 | pn = mqfs_create_file(pd, cnp->cn_nameptr, cnp->cn_namelen, |
| 1003 | cnp->cn_cred, ap->a_vap->va_mode); |
| 1004 | if (pn == NULL) { |
| 1005 | sx_xunlock(&mqfs->mi_lock); |
| 1006 | error = ENOSPC; |
| 1007 | } else { |
| 1008 | mqnode_addref(pn); |
| 1009 | sx_xunlock(&mqfs->mi_lock); |
| 1010 | error = mqfs_allocv(ap->a_dvp->v_mount, ap->a_vpp, pn); |
| 1011 | mqnode_release(pn); |
| 1012 | if (error) |
| 1013 | mqfs_destroy(pn); |
| 1014 | else |
| 1015 | pn->mn_data = mq; |
| 1016 | } |
| 1017 | if (error) |
| 1018 | mqueue_free(mq); |
| 1019 | return (error); |
| 1020 | } |
| 1021 | |
| 1022 | /* |
| 1023 | * Remove an entry |
nothing calls this directly
no test coverage detected