uipc_shm.c (d8fee543ec64428c4a06901c5b2d2a065029837a) | uipc_shm.c (90f54cbfeb973c0e2ee7b617b7759ac4335a9efe) |
---|---|
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 --- 704 unchanged lines hidden (view full) --- 713 error = falloc(td, &fp, &fd, O_CLOEXEC); 714 if (error) 715 return (error); 716 717 /* A SHM_ANON path pointer creates an anonymous object. */ 718 if (uap->path == SHM_ANON) { 719 /* A read-only anonymous object is pointless. */ 720 if ((uap->flags & O_ACCMODE) == O_RDONLY) { | 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 --- 704 unchanged lines hidden (view full) --- 713 error = falloc(td, &fp, &fd, O_CLOEXEC); 714 if (error) 715 return (error); 716 717 /* A SHM_ANON path pointer creates an anonymous object. */ 718 if (uap->path == SHM_ANON) { 719 /* A read-only anonymous object is pointless. */ 720 if ((uap->flags & O_ACCMODE) == O_RDONLY) { |
721 fdclose(fdp, fp, fd, td); | 721 fdclose(td, fp, fd); |
722 fdrop(fp, td); 723 return (EINVAL); 724 } 725 shmfd = shm_alloc(td->td_ucred, cmode); 726 } else { 727 path = malloc(MAXPATHLEN, M_SHMFD, M_WAITOK); 728 error = copyinstr(uap->path, path, MAXPATHLEN, NULL); 729#ifdef KTRACE 730 if (error == 0 && KTRPOINT(curthread, KTR_NAMEI)) 731 ktrnamei(path); 732#endif 733 /* Require paths to start with a '/' character. */ 734 if (error == 0 && path[0] != '/') 735 error = EINVAL; 736 if (error) { | 722 fdrop(fp, td); 723 return (EINVAL); 724 } 725 shmfd = shm_alloc(td->td_ucred, cmode); 726 } else { 727 path = malloc(MAXPATHLEN, M_SHMFD, M_WAITOK); 728 error = copyinstr(uap->path, path, MAXPATHLEN, NULL); 729#ifdef KTRACE 730 if (error == 0 && KTRPOINT(curthread, KTR_NAMEI)) 731 ktrnamei(path); 732#endif 733 /* Require paths to start with a '/' character. */ 734 if (error == 0 && path[0] != '/') 735 error = EINVAL; 736 if (error) { |
737 fdclose(fdp, fp, fd, td); | 737 fdclose(td, fp, fd); |
738 fdrop(fp, td); 739 free(path, M_SHMFD); 740 return (error); 741 } 742 743 fnv = fnv_32_str(path, FNV1_32_INIT); 744 sx_xlock(&shm_dict_lock); 745 shmfd = shm_lookup(path, fnv); --- 49 unchanged lines hidden (view full) --- 795 shm_dotruncate(shmfd, 0); 796 } 797 if (error == 0) 798 shm_hold(shmfd); 799 } 800 sx_xunlock(&shm_dict_lock); 801 802 if (error) { | 738 fdrop(fp, td); 739 free(path, M_SHMFD); 740 return (error); 741 } 742 743 fnv = fnv_32_str(path, FNV1_32_INIT); 744 sx_xlock(&shm_dict_lock); 745 shmfd = shm_lookup(path, fnv); --- 49 unchanged lines hidden (view full) --- 795 shm_dotruncate(shmfd, 0); 796 } 797 if (error == 0) 798 shm_hold(shmfd); 799 } 800 sx_xunlock(&shm_dict_lock); 801 802 if (error) { |
803 fdclose(fdp, fp, fd, td); | 803 fdclose(td, fp, fd); |
804 fdrop(fp, td); 805 return (error); 806 } 807 } 808 809 finit(fp, FFLAGS(uap->flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops); 810 811 td->td_retval[0] = fd; --- 238 unchanged lines hidden --- | 804 fdrop(fp, td); 805 return (error); 806 } 807 } 808 809 finit(fp, FFLAGS(uap->flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops); 810 811 td->td_retval[0] = fd; --- 238 unchanged lines hidden --- |