uipc_shm.c (a03fbc7ecf45d3b9f58042930ae785dd7be452f2) uipc_shm.c (b68cf25fe65a9e79ed0bd1b34129fcd245d087d0)
1/*-
2 * Copyright (c) 2006, 2011 Robert N. M. Watson
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

--- 520 unchanged lines hidden (view full) ---

529 return (EINVAL);
530
531 if ((uap->flags & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC)) != 0)
532 return (EINVAL);
533
534 fdp = td->td_proc->p_fd;
535 cmode = (uap->mode & ~fdp->fd_cmask) & ACCESSPERMS;
536
1/*-
2 * Copyright (c) 2006, 2011 Robert N. M. Watson
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

--- 520 unchanged lines hidden (view full) ---

529 return (EINVAL);
530
531 if ((uap->flags & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC)) != 0)
532 return (EINVAL);
533
534 fdp = td->td_proc->p_fd;
535 cmode = (uap->mode & ~fdp->fd_cmask) & ACCESSPERMS;
536
537 error = falloc(td, &fp, &fd, 0);
537 error = falloc(td, &fp, &fd, O_CLOEXEC);
538 if (error)
539 return (error);
540
541 /* A SHM_ANON path pointer creates an anonymous object. */
542 if (uap->path == SHM_ANON) {
543 /* A read-only anonymous object is pointless. */
544 if ((uap->flags & O_ACCMODE) == O_RDONLY) {
545 fdclose(fdp, fp, fd, td);

--- 78 unchanged lines hidden (view full) ---

624 fdclose(fdp, fp, fd, td);
625 fdrop(fp, td);
626 return (error);
627 }
628 }
629
630 finit(fp, FFLAGS(uap->flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops);
631
538 if (error)
539 return (error);
540
541 /* A SHM_ANON path pointer creates an anonymous object. */
542 if (uap->path == SHM_ANON) {
543 /* A read-only anonymous object is pointless. */
544 if ((uap->flags & O_ACCMODE) == O_RDONLY) {
545 fdclose(fdp, fp, fd, td);

--- 78 unchanged lines hidden (view full) ---

624 fdclose(fdp, fp, fd, td);
625 fdrop(fp, td);
626 return (error);
627 }
628 }
629
630 finit(fp, FFLAGS(uap->flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops);
631
632 FILEDESC_XLOCK(fdp);
633 if (fdp->fd_ofiles[fd].fde_file == fp)
634 fdp->fd_ofiles[fd].fde_flags |= UF_EXCLOSE;
635 FILEDESC_XUNLOCK(fdp);
636 td->td_retval[0] = fd;
637 fdrop(fp, td);
638
639 return (0);
640}
641
642int
643sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap)

--- 218 unchanged lines hidden ---
632 td->td_retval[0] = fd;
633 fdrop(fp, td);
634
635 return (0);
636}
637
638int
639sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap)

--- 218 unchanged lines hidden ---