uipc_shm.c (454bc887f250ce0bceaabd0ec624d077269d3220) | uipc_shm.c (1eaa36523cb921e90d61b20531ed525aba0cfe7e) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2006, 2011, 2016-2017 Robert N. M. Watson 5 * Copyright 2020 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * Portions of this software were developed by BAE Systems, the University of --- 1891 unchanged lines hidden (view full) --- 1900 vm_pindex_t pistart, pi, piend; 1901 vm_ooffset_t off, len; 1902 int startofs, endofs, end; 1903 int error; 1904 1905 off = *offset; 1906 len = *length; 1907 KASSERT(off + len <= (vm_ooffset_t)OFF_MAX, ("off + len overflows")); | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2006, 2011, 2016-2017 Robert N. M. Watson 5 * Copyright 2020 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * Portions of this software were developed by BAE Systems, the University of --- 1891 unchanged lines hidden (view full) --- 1900 vm_pindex_t pistart, pi, piend; 1901 vm_ooffset_t off, len; 1902 int startofs, endofs, end; 1903 int error; 1904 1905 off = *offset; 1906 len = *length; 1907 KASSERT(off + len <= (vm_ooffset_t)OFF_MAX, ("off + len overflows")); |
1908 if (off + len > shmfd->shm_size) 1909 len = shmfd->shm_size - off; |
|
1908 object = shmfd->shm_object; 1909 startofs = off & PAGE_MASK; 1910 endofs = (off + len) & PAGE_MASK; 1911 pistart = OFF_TO_IDX(off); 1912 piend = OFF_TO_IDX(off + len); 1913 pi = OFF_TO_IDX(off + PAGE_MASK); 1914 error = 0; 1915 | 1910 object = shmfd->shm_object; 1911 startofs = off & PAGE_MASK; 1912 endofs = (off + len) & PAGE_MASK; 1913 pistart = OFF_TO_IDX(off); 1914 piend = OFF_TO_IDX(off + len); 1915 pi = OFF_TO_IDX(off + PAGE_MASK); 1916 error = 0; 1917 |
1918 /* Handle the case when offset is beyond shm size */ 1919 if ((off_t)len < 0) { 1920 *offset = shmfd->shm_size; 1921 *length = 0; 1922 return (0); 1923 } 1924 |
|
1916 VM_OBJECT_WLOCK(object); 1917 1918 if (startofs != 0) { 1919 end = pistart != piend ? PAGE_SIZE : endofs; 1920 error = shm_partial_page_invalidate(object, pistart, startofs, 1921 end); 1922 if (error) 1923 goto out; --- 45 unchanged lines hidden (view full) --- 1969 &shmfd->shm_mtx); 1970 switch (cmd) { 1971 case SPACECTL_DEALLOC: 1972 if ((shmfd->shm_seals & F_SEAL_WRITE) != 0) { 1973 error = EPERM; 1974 break; 1975 } 1976 error = shm_deallocate(shmfd, &off, &len, flags); | 1925 VM_OBJECT_WLOCK(object); 1926 1927 if (startofs != 0) { 1928 end = pistart != piend ? PAGE_SIZE : endofs; 1929 error = shm_partial_page_invalidate(object, pistart, startofs, 1930 end); 1931 if (error) 1932 goto out; --- 45 unchanged lines hidden (view full) --- 1978 &shmfd->shm_mtx); 1979 switch (cmd) { 1980 case SPACECTL_DEALLOC: 1981 if ((shmfd->shm_seals & F_SEAL_WRITE) != 0) { 1982 error = EPERM; 1983 break; 1984 } 1985 error = shm_deallocate(shmfd, &off, &len, flags); |
1977 if (error != 0) 1978 break; | |
1979 *offset = off; 1980 *length = len; 1981 break; 1982 default: 1983 __assert_unreachable(); 1984 } 1985 rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx); 1986 return (error); --- 106 unchanged lines hidden --- | 1986 *offset = off; 1987 *length = len; 1988 break; 1989 default: 1990 __assert_unreachable(); 1991 } 1992 rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx); 1993 return (error); --- 106 unchanged lines hidden --- |