summaryrefslogtreecommitdiff
path: root/mmap
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-12-07 05:00:28 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-12-07 05:00:28 +0000
commitc87cdcea7902217002ece8e5a967600ec12b38d6 (patch)
treea8f88943ab4b3e3e6751caa0d64007fb6984cbe1 /mmap
parent362f16c2e71a3db80be3bd2584e833ed77478233 (diff)
downloadlibapr-c87cdcea7902217002ece8e5a967600ec12b38d6.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: http://svn.apache.org/repos/asf/apr/apr/trunk@60908 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'mmap')
-rw-r--r--mmap/unix/mmap.c22
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) {