uipc_mqueue.c (416ba5c74546f32a993436a99516d35008e9f384) | uipc_mqueue.c (adb023ae59d5535b8288fb779fd6e24b96cbd8ca) |
---|---|
1/*- 2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 47 48#include "opt_capsicum.h" 49#include "opt_compat.h" 50 51#include <sys/param.h> 52#include <sys/kernel.h> 53#include <sys/systm.h> 54#include <sys/limits.h> | 1/*- 2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 47 48#include "opt_capsicum.h" 49#include "opt_compat.h" 50 51#include <sys/param.h> 52#include <sys/kernel.h> 53#include <sys/systm.h> 54#include <sys/limits.h> |
55#include <sys/malloc.h> |
|
55#include <sys/buf.h> 56#include <sys/capsicum.h> 57#include <sys/dirent.h> 58#include <sys/event.h> 59#include <sys/eventhandler.h> 60#include <sys/fcntl.h> 61#include <sys/file.h> 62#include <sys/filedesc.h> | 56#include <sys/buf.h> 57#include <sys/capsicum.h> 58#include <sys/dirent.h> 59#include <sys/event.h> 60#include <sys/eventhandler.h> 61#include <sys/fcntl.h> 62#include <sys/file.h> 63#include <sys/filedesc.h> |
64#include <sys/jail.h> |
|
63#include <sys/lock.h> | 65#include <sys/lock.h> |
64#include <sys/malloc.h> | |
65#include <sys/module.h> 66#include <sys/mount.h> 67#include <sys/mqueue.h> 68#include <sys/mutex.h> 69#include <sys/namei.h> 70#include <sys/posix4.h> 71#include <sys/poll.h> 72#include <sys/priv.h> --- 54 unchanged lines hidden (view full) --- 127 */ 128struct mqfs_node { 129 char mn_name[MQFS_NAMELEN+1]; 130 struct mqfs_info *mn_info; 131 struct mqfs_node *mn_parent; 132 LIST_HEAD(,mqfs_node) mn_children; 133 LIST_ENTRY(mqfs_node) mn_sibling; 134 LIST_HEAD(,mqfs_vdata) mn_vnodes; | 66#include <sys/module.h> 67#include <sys/mount.h> 68#include <sys/mqueue.h> 69#include <sys/mutex.h> 70#include <sys/namei.h> 71#include <sys/posix4.h> 72#include <sys/poll.h> 73#include <sys/priv.h> --- 54 unchanged lines hidden (view full) --- 128 */ 129struct mqfs_node { 130 char mn_name[MQFS_NAMELEN+1]; 131 struct mqfs_info *mn_info; 132 struct mqfs_node *mn_parent; 133 LIST_HEAD(,mqfs_node) mn_children; 134 LIST_ENTRY(mqfs_node) mn_sibling; 135 LIST_HEAD(,mqfs_vdata) mn_vnodes; |
136 const void *mn_pr_root; |
|
135 int mn_refcount; 136 mqfs_type_t mn_type; 137 int mn_deleted; 138 uint32_t mn_fileno; 139 void *mn_data; 140 struct timespec mn_birth; 141 struct timespec mn_ctime; 142 struct timespec mn_atime; --- 4 unchanged lines hidden (view full) --- 147}; 148 149#define VTON(vp) (((struct mqfs_vdata *)((vp)->v_data))->mv_node) 150#define VTOMQ(vp) ((struct mqueue *)(VTON(vp)->mn_data)) 151#define VFSTOMQFS(m) ((struct mqfs_info *)((m)->mnt_data)) 152#define FPTOMQ(fp) ((struct mqueue *)(((struct mqfs_node *) \ 153 (fp)->f_data)->mn_data)) 154 | 137 int mn_refcount; 138 mqfs_type_t mn_type; 139 int mn_deleted; 140 uint32_t mn_fileno; 141 void *mn_data; 142 struct timespec mn_birth; 143 struct timespec mn_ctime; 144 struct timespec mn_atime; --- 4 unchanged lines hidden (view full) --- 149}; 150 151#define VTON(vp) (((struct mqfs_vdata *)((vp)->v_data))->mv_node) 152#define VTOMQ(vp) ((struct mqueue *)(VTON(vp)->mn_data)) 153#define VFSTOMQFS(m) ((struct mqfs_info *)((m)->mnt_data)) 154#define FPTOMQ(fp) ((struct mqueue *)(((struct mqfs_node *) \ 155 (fp)->f_data)->mn_data)) 156 |
157struct mqfs_osd { 158 struct task mo_task; 159 const void *mo_pr_root; 160}; 161 |
|
155TAILQ_HEAD(msgq, mqueue_msg); 156 157struct mqueue; 158 159struct mqueue_notifier { 160 LIST_ENTRY(mqueue_notifier) nt_link; 161 struct sigevent nt_sigev; 162 ksiginfo_t nt_ksi; --- 51 unchanged lines hidden (view full) --- 214/* Only one instance per-system */ 215static struct mqfs_info mqfs_data; 216static uma_zone_t mqnode_zone; 217static uma_zone_t mqueue_zone; 218static uma_zone_t mvdata_zone; 219static uma_zone_t mqnoti_zone; 220static struct vop_vector mqfs_vnodeops; 221static struct fileops mqueueops; | 162TAILQ_HEAD(msgq, mqueue_msg); 163 164struct mqueue; 165 166struct mqueue_notifier { 167 LIST_ENTRY(mqueue_notifier) nt_link; 168 struct sigevent nt_sigev; 169 ksiginfo_t nt_ksi; --- 51 unchanged lines hidden (view full) --- 221/* Only one instance per-system */ 222static struct mqfs_info mqfs_data; 223static uma_zone_t mqnode_zone; 224static uma_zone_t mqueue_zone; 225static uma_zone_t mvdata_zone; 226static uma_zone_t mqnoti_zone; 227static struct vop_vector mqfs_vnodeops; 228static struct fileops mqueueops; |
229static unsigned mqfs_osd_jail_slot; |
|
222 223/* 224 * Directory structure construction and manipulation 225 */ 226#ifdef notyet 227static struct mqfs_node *mqfs_create_dir(struct mqfs_node *parent, 228 const char *name, int namelen, struct ucred *cred, int mode); 229static struct mqfs_node *mqfs_create_link(struct mqfs_node *parent, 230 const char *name, int namelen, struct ucred *cred, int mode); 231#endif 232 233static struct mqfs_node *mqfs_create_file(struct mqfs_node *parent, 234 const char *name, int namelen, struct ucred *cred, int mode); 235static int mqfs_destroy(struct mqfs_node *mn); 236static void mqfs_fileno_alloc(struct mqfs_info *mi, struct mqfs_node *mn); 237static void mqfs_fileno_free(struct mqfs_info *mi, struct mqfs_node *mn); 238static int mqfs_allocv(struct mount *mp, struct vnode **vpp, struct mqfs_node *pn); | 230 231/* 232 * Directory structure construction and manipulation 233 */ 234#ifdef notyet 235static struct mqfs_node *mqfs_create_dir(struct mqfs_node *parent, 236 const char *name, int namelen, struct ucred *cred, int mode); 237static struct mqfs_node *mqfs_create_link(struct mqfs_node *parent, 238 const char *name, int namelen, struct ucred *cred, int mode); 239#endif 240 241static struct mqfs_node *mqfs_create_file(struct mqfs_node *parent, 242 const char *name, int namelen, struct ucred *cred, int mode); 243static int mqfs_destroy(struct mqfs_node *mn); 244static void mqfs_fileno_alloc(struct mqfs_info *mi, struct mqfs_node *mn); 245static void mqfs_fileno_free(struct mqfs_info *mi, struct mqfs_node *mn); 246static int mqfs_allocv(struct mount *mp, struct vnode **vpp, struct mqfs_node *pn); |
247static int mqfs_prison_create(void *obj, void *data); 248static void mqfs_prison_destructor(void *data); 249static void mqfs_prison_remove_task(void *context, int pending); |
|
239 240/* 241 * Message queue construction and maniplation 242 */ 243static struct mqueue *mqueue_alloc(const struct mq_attr *attr); 244static void mqueue_free(struct mqueue *mq); 245static int mqueue_send(struct mqueue *mq, const char *msg_ptr, 246 size_t msg_len, unsigned msg_prio, int waitok, --- 184 unchanged lines hidden (view full) --- 431static struct mqfs_node * 432mqfs_create_node(const char *name, int namelen, struct ucred *cred, int mode, 433 int nodetype) 434{ 435 struct mqfs_node *node; 436 437 node = mqnode_alloc(); 438 strncpy(node->mn_name, name, namelen); | 250 251/* 252 * Message queue construction and maniplation 253 */ 254static struct mqueue *mqueue_alloc(const struct mq_attr *attr); 255static void mqueue_free(struct mqueue *mq); 256static int mqueue_send(struct mqueue *mq, const char *msg_ptr, 257 size_t msg_len, unsigned msg_prio, int waitok, --- 184 unchanged lines hidden (view full) --- 442static struct mqfs_node * 443mqfs_create_node(const char *name, int namelen, struct ucred *cred, int mode, 444 int nodetype) 445{ 446 struct mqfs_node *node; 447 448 node = mqnode_alloc(); 449 strncpy(node->mn_name, name, namelen); |
450 node->mn_pr_root = cred->cr_prison->pr_root; |
|
439 node->mn_type = nodetype; 440 node->mn_refcount = 1; 441 vfs_timestamp(&node->mn_birth); 442 node->mn_ctime = node->mn_atime = node->mn_mtime 443 = node->mn_birth; 444 node->mn_uid = cred->cr_uid; 445 node->mn_gid = cred->cr_gid; 446 node->mn_mode = mode; --- 192 unchanged lines hidden (view full) --- 639/* 640 * Initialize a mqfs instance 641 */ 642static int 643mqfs_init(struct vfsconf *vfc) 644{ 645 struct mqfs_node *root; 646 struct mqfs_info *mi; | 451 node->mn_type = nodetype; 452 node->mn_refcount = 1; 453 vfs_timestamp(&node->mn_birth); 454 node->mn_ctime = node->mn_atime = node->mn_mtime 455 = node->mn_birth; 456 node->mn_uid = cred->cr_uid; 457 node->mn_gid = cred->cr_gid; 458 node->mn_mode = mode; --- 192 unchanged lines hidden (view full) --- 651/* 652 * Initialize a mqfs instance 653 */ 654static int 655mqfs_init(struct vfsconf *vfc) 656{ 657 struct mqfs_node *root; 658 struct mqfs_info *mi; |
659 struct prison *pr; 660 osd_method_t methods[PR_MAXMETHOD] = { 661 [PR_METHOD_CREATE] = mqfs_prison_create, 662 }; |
|
647 648 mqnode_zone = uma_zcreate("mqnode", sizeof(struct mqfs_node), 649 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 650 mqueue_zone = uma_zcreate("mqueue", sizeof(struct mqueue), 651 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 652 mvdata_zone = uma_zcreate("mvdata", 653 sizeof(struct mqfs_vdata), NULL, NULL, NULL, 654 NULL, UMA_ALIGN_PTR, 0); --- 10 unchanged lines hidden (view full) --- 665 mi->mi_root = root; 666 mqfs_fileno_init(mi); 667 mqfs_fileno_alloc(mi, root); 668 mqfs_fixup_dir(root); 669 exit_tag = EVENTHANDLER_REGISTER(process_exit, mq_proc_exit, NULL, 670 EVENTHANDLER_PRI_ANY); 671 mq_fdclose = mqueue_fdclose; 672 p31b_setcfg(CTL_P1003_1B_MESSAGE_PASSING, _POSIX_MESSAGE_PASSING); | 663 664 mqnode_zone = uma_zcreate("mqnode", sizeof(struct mqfs_node), 665 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 666 mqueue_zone = uma_zcreate("mqueue", sizeof(struct mqueue), 667 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 668 mvdata_zone = uma_zcreate("mvdata", 669 sizeof(struct mqfs_vdata), NULL, NULL, NULL, 670 NULL, UMA_ALIGN_PTR, 0); --- 10 unchanged lines hidden (view full) --- 681 mi->mi_root = root; 682 mqfs_fileno_init(mi); 683 mqfs_fileno_alloc(mi, root); 684 mqfs_fixup_dir(root); 685 exit_tag = EVENTHANDLER_REGISTER(process_exit, mq_proc_exit, NULL, 686 EVENTHANDLER_PRI_ANY); 687 mq_fdclose = mqueue_fdclose; 688 p31b_setcfg(CTL_P1003_1B_MESSAGE_PASSING, _POSIX_MESSAGE_PASSING); |
689 /* Note current jails */ 690 mqfs_osd_jail_slot = osd_jail_register(mqfs_prison_destructor, methods); 691 sx_slock(&allprison_lock); 692 TAILQ_FOREACH(pr, &allprison, pr_list) 693 (void)mqfs_prison_create(pr, NULL); 694 sx_sunlock(&allprison_lock); |
|
673 return (0); 674} 675 676/* 677 * Destroy a mqfs instance 678 */ 679static int 680mqfs_uninit(struct vfsconf *vfc) 681{ | 695 return (0); 696} 697 698/* 699 * Destroy a mqfs instance 700 */ 701static int 702mqfs_uninit(struct vfsconf *vfc) 703{ |
704 unsigned slot; |
|
682 struct mqfs_info *mi; 683 684 if (!unloadable) 685 return (EOPNOTSUPP); | 705 struct mqfs_info *mi; 706 707 if (!unloadable) 708 return (EOPNOTSUPP); |
709 slot = mqfs_osd_jail_slot; 710 mqfs_osd_jail_slot = 0; 711 osd_jail_deregister(slot); |
|
686 EVENTHANDLER_DEREGISTER(process_exit, exit_tag); 687 mi = &mqfs_data; 688 mqfs_destroy(mi->mi_root); 689 mi->mi_root = NULL; 690 mqfs_fileno_uninit(mi); 691 sx_destroy(&mi->mi_lock); 692 uma_zdestroy(mqnode_zone); 693 uma_zdestroy(mqueue_zone); --- 101 unchanged lines hidden (view full) --- 795 sx_xunlock(&mqfs->mi_lock); 796 return (0); 797} 798 799/* 800 * Search a directory entry 801 */ 802static struct mqfs_node * | 712 EVENTHANDLER_DEREGISTER(process_exit, exit_tag); 713 mi = &mqfs_data; 714 mqfs_destroy(mi->mi_root); 715 mi->mi_root = NULL; 716 mqfs_fileno_uninit(mi); 717 sx_destroy(&mi->mi_lock); 718 uma_zdestroy(mqnode_zone); 719 uma_zdestroy(mqueue_zone); --- 101 unchanged lines hidden (view full) --- 821 sx_xunlock(&mqfs->mi_lock); 822 return (0); 823} 824 825/* 826 * Search a directory entry 827 */ 828static struct mqfs_node * |
803mqfs_search(struct mqfs_node *pd, const char *name, int len) | 829mqfs_search(struct mqfs_node *pd, const char *name, int len, struct ucred *cred) |
804{ 805 struct mqfs_node *pn; | 830{ 831 struct mqfs_node *pn; |
832 const void *pr_root; |
|
806 807 sx_assert(&pd->mn_info->mi_lock, SX_LOCKED); | 833 834 sx_assert(&pd->mn_info->mi_lock, SX_LOCKED); |
835 pr_root = cred->cr_prison->pr_root; |
|
808 LIST_FOREACH(pn, &pd->mn_children, mn_sibling) { | 836 LIST_FOREACH(pn, &pd->mn_children, mn_sibling) { |
809 if (strncmp(pn->mn_name, name, len) == 0 && | 837 /* Only match names within the same prison root directory */ 838 if ((pn->mn_pr_root == NULL || pn->mn_pr_root == pr_root) && 839 strncmp(pn->mn_name, name, len) == 0 && |
810 pn->mn_name[len] == '\0') 811 return (pn); 812 } 813 return (NULL); 814} 815 816/* 817 * Look up a file or directory. --- 55 unchanged lines hidden (view full) --- 873 pn = pd->mn_parent; 874 error = mqfs_allocv(dvp->v_mount, vpp, pn); 875 vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); 876 return (error); 877 } 878 879 /* named node */ 880 sx_xlock(&mqfs->mi_lock); | 840 pn->mn_name[len] == '\0') 841 return (pn); 842 } 843 return (NULL); 844} 845 846/* 847 * Look up a file or directory. --- 55 unchanged lines hidden (view full) --- 903 pn = pd->mn_parent; 904 error = mqfs_allocv(dvp->v_mount, vpp, pn); 905 vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); 906 return (error); 907 } 908 909 /* named node */ 910 sx_xlock(&mqfs->mi_lock); |
881 pn = mqfs_search(pd, pname, namelen); | 911 pn = mqfs_search(pd, pname, namelen, cnp->cn_cred); |
882 if (pn != NULL) 883 mqnode_addref(pn); 884 sx_xunlock(&mqfs->mi_lock); 885 886 /* found */ 887 if (pn != NULL) { 888 /* DELETE */ 889 if (nameiop == DELETE && (flags & ISLASTCN)) { --- 468 unchanged lines hidden (view full) --- 1358mqfs_readdir(struct vop_readdir_args *ap) 1359{ 1360 struct vnode *vp; 1361 struct mqfs_info *mi; 1362 struct mqfs_node *pd; 1363 struct mqfs_node *pn; 1364 struct dirent entry; 1365 struct uio *uio; | 912 if (pn != NULL) 913 mqnode_addref(pn); 914 sx_xunlock(&mqfs->mi_lock); 915 916 /* found */ 917 if (pn != NULL) { 918 /* DELETE */ 919 if (nameiop == DELETE && (flags & ISLASTCN)) { --- 468 unchanged lines hidden (view full) --- 1388mqfs_readdir(struct vop_readdir_args *ap) 1389{ 1390 struct vnode *vp; 1391 struct mqfs_info *mi; 1392 struct mqfs_node *pd; 1393 struct mqfs_node *pn; 1394 struct dirent entry; 1395 struct uio *uio; |
1396 const void *pr_root; |
|
1366 int *tmp_ncookies = NULL; 1367 off_t offset; 1368 int error, i; 1369 1370 vp = ap->a_vp; 1371 mi = VFSTOMQFS(vp->v_mount); 1372 pd = VTON(vp); 1373 uio = ap->a_uio; --- 8 unchanged lines hidden (view full) --- 1382 tmp_ncookies = ap->a_ncookies; 1383 *ap->a_ncookies = 0; 1384 ap->a_ncookies = NULL; 1385 } 1386 1387 error = 0; 1388 offset = 0; 1389 | 1397 int *tmp_ncookies = NULL; 1398 off_t offset; 1399 int error, i; 1400 1401 vp = ap->a_vp; 1402 mi = VFSTOMQFS(vp->v_mount); 1403 pd = VTON(vp); 1404 uio = ap->a_uio; --- 8 unchanged lines hidden (view full) --- 1413 tmp_ncookies = ap->a_ncookies; 1414 *ap->a_ncookies = 0; 1415 ap->a_ncookies = NULL; 1416 } 1417 1418 error = 0; 1419 offset = 0; 1420 |
1421 pr_root = ap->a_cred->cr_prison->pr_root; |
|
1390 sx_xlock(&mi->mi_lock); 1391 1392 LIST_FOREACH(pn, &pd->mn_children, mn_sibling) { 1393 entry.d_reclen = sizeof(entry); | 1422 sx_xlock(&mi->mi_lock); 1423 1424 LIST_FOREACH(pn, &pd->mn_children, mn_sibling) { 1425 entry.d_reclen = sizeof(entry); |
1426 /* 1427 * Only show names within the same prison root directory 1428 * (or not associated with a prison, e.g. "." and ".."). 1429 */ 1430 if (pn->mn_pr_root != NULL && pn->mn_pr_root != pr_root) 1431 continue; |
|
1394 if (!pn->mn_fileno) 1395 mqfs_fileno_alloc(mi, pn); 1396 entry.d_fileno = pn->mn_fileno; 1397 for (i = 0; i < MQFS_NAMELEN - 1 && pn->mn_name[i] != '\0'; ++i) 1398 entry.d_name[i] = pn->mn_name[i]; 1399 entry.d_name[i] = 0; 1400 entry.d_namlen = i; 1401 switch (pn->mn_type) { --- 116 unchanged lines hidden (view full) --- 1518 mqnode_release(pt); 1519 sx_xunlock(&mqfs->mi_lock); 1520 cache_purge(ap->a_vp); 1521 return (0); 1522} 1523 1524#endif /* notyet */ 1525 | 1432 if (!pn->mn_fileno) 1433 mqfs_fileno_alloc(mi, pn); 1434 entry.d_fileno = pn->mn_fileno; 1435 for (i = 0; i < MQFS_NAMELEN - 1 && pn->mn_name[i] != '\0'; ++i) 1436 entry.d_name[i] = pn->mn_name[i]; 1437 entry.d_name[i] = 0; 1438 entry.d_namlen = i; 1439 switch (pn->mn_type) { --- 116 unchanged lines hidden (view full) --- 1556 mqnode_release(pt); 1557 sx_xunlock(&mqfs->mi_lock); 1558 cache_purge(ap->a_vp); 1559 return (0); 1560} 1561 1562#endif /* notyet */ 1563 |
1564 |
|
1526/* | 1565/* |
1566 * Set a destructor task with the prison's root 1567 */ 1568static int 1569mqfs_prison_create(void *obj, void *data __unused) 1570{ 1571 struct prison *pr = obj; 1572 struct mqfs_osd *mo; 1573 void *rsv; 1574 1575 if (pr->pr_root == pr->pr_parent->pr_root) 1576 return(0); 1577 1578 mo = malloc(sizeof(struct mqfs_osd), M_PRISON, M_WAITOK); 1579 rsv = osd_reserve(mqfs_osd_jail_slot); 1580 TASK_INIT(&mo->mo_task, 0, mqfs_prison_remove_task, mo); 1581 mtx_lock(&pr->pr_mtx); 1582 mo->mo_pr_root = pr->pr_root; 1583 (void)osd_jail_set_reserved(pr, mqfs_osd_jail_slot, rsv, mo); 1584 mtx_unlock(&pr->pr_mtx); 1585 return (0); 1586} 1587 1588/* 1589 * Queue the task for after jail/OSD locks are released 1590 */ 1591static void 1592mqfs_prison_destructor(void *data) 1593{ 1594 struct mqfs_osd *mo = data; 1595 1596 if (mqfs_osd_jail_slot != 0) 1597 taskqueue_enqueue(taskqueue_thread, &mo->mo_task); 1598 else 1599 free(mo, M_PRISON); 1600} 1601 1602/* 1603 * See if this prison root is obsolete, and clean up associated queues if it is 1604 */ 1605static void 1606mqfs_prison_remove_task(void *context, int pending) 1607{ 1608 struct mqfs_osd *mo = context; 1609 struct mqfs_node *pn, *tpn; 1610 const struct prison *pr; 1611 const void *pr_root; 1612 int found; 1613 1614 pr_root = mo->mo_pr_root; 1615 found = 0; 1616 sx_slock(&allprison_lock); 1617 TAILQ_FOREACH(pr, &allprison, pr_list) { 1618 if (pr->pr_root == pr_root) 1619 found = 1; 1620 } 1621 sx_sunlock(&allprison_lock); 1622 if (!found) { 1623 /* 1624 * No jails are rooted in this directory anymore, 1625 * so no queues should be either. 1626 */ 1627 sx_xlock(&mqfs_data.mi_lock); 1628 LIST_FOREACH_SAFE(pn, &mqfs_data.mi_root->mn_children, 1629 mn_sibling, tpn) { 1630 if (pn->mn_pr_root == pr_root) 1631 (void)do_unlink(pn, curthread->td_ucred); 1632 } 1633 sx_xunlock(&mqfs_data.mi_lock); 1634 } 1635 free(mo, M_PRISON); 1636} 1637 1638 1639/* |
|
1527 * Allocate a message queue 1528 */ 1529static struct mqueue * 1530mqueue_alloc(const struct mq_attr *attr) 1531{ 1532 struct mqueue *mq; 1533 1534 if (curmq >= maxmq) --- 443 unchanged lines hidden (view full) --- 1978 if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) 1979 return (EINVAL); 1980 1981 error = falloc(td, &fp, &fd, O_CLOEXEC); 1982 if (error) 1983 return (error); 1984 1985 sx_xlock(&mqfs_data.mi_lock); | 1640 * Allocate a message queue 1641 */ 1642static struct mqueue * 1643mqueue_alloc(const struct mq_attr *attr) 1644{ 1645 struct mqueue *mq; 1646 1647 if (curmq >= maxmq) --- 443 unchanged lines hidden (view full) --- 2091 if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) 2092 return (EINVAL); 2093 2094 error = falloc(td, &fp, &fd, O_CLOEXEC); 2095 if (error) 2096 return (error); 2097 2098 sx_xlock(&mqfs_data.mi_lock); |
1986 pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1); | 2099 pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1, td->td_ucred); |
1987 if (pn == NULL) { 1988 if (!(flags & O_CREAT)) { 1989 error = ENOENT; 1990 } else { 1991 mq = mqueue_alloc(attr); 1992 if (mq == NULL) { 1993 error = ENFILE; 1994 } else { --- 78 unchanged lines hidden (view full) --- 2073 if (error) 2074 return (error); 2075 2076 len = strlen(path); 2077 if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) 2078 return (EINVAL); 2079 2080 sx_xlock(&mqfs_data.mi_lock); | 2100 if (pn == NULL) { 2101 if (!(flags & O_CREAT)) { 2102 error = ENOENT; 2103 } else { 2104 mq = mqueue_alloc(attr); 2105 if (mq == NULL) { 2106 error = ENFILE; 2107 } else { --- 78 unchanged lines hidden (view full) --- 2186 if (error) 2187 return (error); 2188 2189 len = strlen(path); 2190 if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) 2191 return (EINVAL); 2192 2193 sx_xlock(&mqfs_data.mi_lock); |
2081 pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1); | 2194 pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1, td->td_ucred); |
2082 if (pn != NULL) 2083 error = do_unlink(pn, td->td_ucred); 2084 else 2085 error = ENOENT; 2086 sx_xunlock(&mqfs_data.mi_lock); 2087 return (error); 2088} 2089 --- 775 unchanged lines hidden --- | 2195 if (pn != NULL) 2196 error = do_unlink(pn, td->td_ucred); 2197 else 2198 error = ENOENT; 2199 sx_xunlock(&mqfs_data.mi_lock); 2200 return (error); 2201} 2202 --- 775 unchanged lines hidden --- |