Ingo has it right, if the file already exists you append to it...
Mallocing for 1 single int is not very efficient, but that should work.
I guess you copied and pasted your code, the same names on variables prevent it from compiling.
Working example even if the file exists:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
int fd = open("test.dat", O_RDWR | O_CREAT, 0777);
int size = 100;
int offset = 0;
write(fd, &size, sizeof(int));
write(fd, &offset, sizeof(int));
lseek(fd, 0, SEEK_SET); /* start reading from the beginning */
int *result_size = malloc(sizeof(int));
int *result_offset = malloc(sizeof(int));
read(fd, result_size, sizeof(int));
read(fd, result_offset, sizeof(int));
printf("size is %d, offset is %d \n", *result_size, *result_offset);
free(result_size);
free(result_offset);
}