Commit b698c7eb authored by Kamil Iskra's avatar Kamil Iskra
Browse files

[feature] support offsets for file mappings

Replace the unused "max" argument for file-based mappings with an offset
argument (until now the offset was hardcoded to 0).
parent 12e946e0
......@@ -224,7 +224,7 @@ void *aml_area_linux_mmap_generic(struct aml_area_linux_mmap_data *data,
void *ptr, size_t size);
int aml_area_linux_mmap_anonymous_init(struct aml_area_linux_mmap_data *data);
int aml_area_linux_mmap_fd_init(struct aml_area_linux_mmap_data *data, int fd,
size_t max);
off_t offset);
int aml_area_linux_mmap_tmpfile_init(struct aml_area_linux_mmap_data *data,
char *template, size_t max);
int aml_area_linux_mmap_anonymous_destroy(struct aml_area_linux_mmap_data *data);
......
......@@ -176,8 +176,8 @@ int aml_area_linux_vinit(struct aml_area *a, int manager_type,
else if(mmap_type == AML_AREA_LINUX_MMAP_TYPE_FD)
{
int fd = va_arg(ap, int);
size_t max = va_arg(ap, size_t);
aml_area_linux_mmap_fd_init(&area->data.mmap, fd, max);
off_t offset = va_arg(ap, off_t);
aml_area_linux_mmap_fd_init(&area->data.mmap, fd, offset);
}
else if(mmap_type == AML_AREA_LINUX_MMAP_TYPE_TMPFILE)
{
......
......@@ -36,14 +36,14 @@ int aml_area_linux_mmap_anonymous_destroy(struct aml_area_linux_mmap_data *data)
}
int aml_area_linux_mmap_fd_init(struct aml_area_linux_mmap_data *data, int fd,
size_t max)
off_t offset)
{
/* TODO: should we check for the right open flags ? */
assert(data != NULL);
data->prot = PROT_READ|PROT_WRITE;
data->flags = MAP_PRIVATE;
data->fildes = fd;
data->off = 0;
data->off = offset;
return 0;
}
......
......@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
assert(tmpfile != -1);
/* use ftruncate to make sure we have enough space in the file. */
ftruncate(tmpfile, ALLOC_SIZE);
aml_area_linux_mmap_fd_init(&config[1], tmpfile, ALLOC_SIZE);
aml_area_linux_mmap_fd_init(&config[1], tmpfile, 0);
aml_area_linux_mmap_tmpfile_init(&config[2], tmpname2, ALLOC_SIZE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment