Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Testing my software with a not mmap-able filesystem

I have a piece of code that tries to mmap some file. If it can mmap the file, it does something, if it can not mmap it does something else.

The code is working in both cases, but I wanted to to do some tests in some filesystem that does not support mmap. The problem is that I did not find any filesystem that were not able to mmap.

Can someone point me out some filesystem that is not mmap-able?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You might simulate a non-mmap-capable system using library interposition. Simply take this C file

#include <errno.h>
#include <sys/mman.h>
void* mmap(void*, size_t, int, int, int, off_t) {
  errno = ENODEV;
  return NULL;
}

and compile it to a shared library. Name the path of that library in the LD_PRELOAD environment variable, and it should take precedence over the real mmap, thus simulating a system where mmap will always fail. That way, you can test your code without superuser privileges, without creating certain file systems, and without having to have the corresponding kernel modules, userland tools and the likes available.

You might theoretically encounter situations where some library outside your control relies on specific kinds of mmap to always work. A map with MAP_ANONYMOUS is a prime example, since it is not backed by a file system and therefore does not depend on FS types. If you encounter any problems in libraries failing due to violated mmap assumptions, you might have to modify the interposer to have a closer look at its arguments and forward some calls to the libc implementation while rejecting others itself. But I'd only do this if the need actually arises.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda