diff options
author | Ryan Bloom <rbb@apache.org> | 2000-12-07 05:00:28 +0000 |
---|---|---|
committer | Ryan Bloom <rbb@apache.org> | 2000-12-07 05:00:28 +0000 |
commit | 3ca1bb6afb81b2406a2d0ec6ce2757ca12d2becf (patch) | |
tree | a8f88943ab4b3e3e6751caa0d64007fb6984cbe1 /mmap | |
parent | bcf79c545d6622239015b4fdd1c8e49139551dbd (diff) | |
download | apr-3ca1bb6afb81b2406a2d0ec6ce2757ca12d2becf.tar.gz |
Allow APR programmers to determine if an MMAP is read-only or if it should
be write-able.
Submitted by: Ryan Bloom and Will Rowe
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60908 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'mmap')
-rw-r--r-- | mmap/unix/mmap.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/mmap/unix/mmap.c b/mmap/unix/mmap.c index 33d1cfff2..8b8b5440d 100644 --- a/mmap/unix/mmap.c +++ b/mmap/unix/mmap.c @@ -101,9 +101,11 @@ static apr_status_t mmap_cleanup(void *themmap) return errno; } -apr_status_t apr_mmap_create(apr_mmap_t **new, apr_file_t *file, apr_off_t offset, - apr_size_t size, apr_pool_t *cont) +apr_status_t apr_mmap_create(apr_mmap_t **new, apr_file_t *file, + apr_off_t offset, apr_size_t size, + apr_int32_t flag, apr_pool_t *cont) { + apr_int32_t native_flags = 0; #ifdef BEOS void *mm; area_id aid = -1; @@ -122,8 +124,15 @@ apr_status_t apr_mmap_create(apr_mmap_t **new, apr_file_t *file, apr_off_t offse apr_seek(file, APR_SET, &offset); pages = ((size -1) / B_PAGE_SIZE) + 1; + if (flag & APR_MMAP_WRITE) { + native_flags |= B_WRITE_AREA; + } + if (flag & APR_MMAP_READ) { + native_flags |= B_READ_AREA; + } + aid = create_area(areaname, &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE, - B_FULL_LOCK, B_READ_AREA|B_WRITE_AREA); + B_FULL_LOCK, native_flags); if (aid < B_NO_ERROR) { /* we failed to get an mmap'd file... */ @@ -135,6 +144,13 @@ apr_status_t apr_mmap_create(apr_mmap_t **new, apr_file_t *file, apr_off_t offse (*new)->area = aid; #else + if (flag & APR_MMAP_WRITE) { + native_flags |= PROT_WRITE; + } + if (flag & APR_MMAP_READ) { + native_flags |= PROT_READ; + } + mm = mmap(NULL, size, PROT_READ, MAP_SHARED, file->filedes, offset); if (mm == (caddr_t)-1) { |