| 1875 | } |
| 1876 | |
| 1877 | static int |
| 1878 | shm_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td) |
| 1879 | { |
| 1880 | void *rl_cookie; |
| 1881 | struct shmfd *shmfd; |
| 1882 | size_t size; |
| 1883 | int error; |
| 1884 | |
| 1885 | /* This assumes that the caller already checked for overflow. */ |
| 1886 | error = 0; |
| 1887 | shmfd = fp->f_data; |
| 1888 | size = offset + len; |
| 1889 | |
| 1890 | /* |
| 1891 | * Just grab the rangelock for the range that we may be attempting to |
| 1892 | * grow, rather than blocking read/write for regions we won't be |
| 1893 | * touching while this (potential) resize is in progress. Other |
| 1894 | * attempts to resize the shmfd will have to take a write lock from 0 to |
| 1895 | * OFF_MAX, so this being potentially beyond the current usable range of |
| 1896 | * the shmfd is not necessarily a concern. If other mechanisms are |
| 1897 | * added to grow a shmfd, this may need to be re-evaluated. |
| 1898 | */ |
| 1899 | rl_cookie = rangelock_wlock(&shmfd->shm_rl, offset, size, |
| 1900 | &shmfd->shm_mtx); |
| 1901 | if (size > shmfd->shm_size) |
| 1902 | error = shm_dotruncate_cookie(shmfd, size, rl_cookie); |
| 1903 | rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx); |
| 1904 | /* Translate to posix_fallocate(2) return value as needed. */ |
| 1905 | if (error == ENOMEM) |
| 1906 | error = ENOSPC; |
| 1907 | return (error); |
| 1908 | } |
| 1909 | |
| 1910 | static int |
| 1911 | sysctl_posix_shm_list(SYSCTL_HANDLER_ARGS) |
nothing calls this directly
no test coverage detected