0
通常のubuntuマシンでは、ホームディレクトリで実行しない限り、次のテストは成功します。この場合、バスエラーでクラッシュします。私が考えることができるのは、ホームディレクトリが暗号化されているからです。 (プライベートと.ecryptfsのリンクがあります)ecryptfsディレクトリにメモリマップファイルがありません
// Make with g++ -mcmodel=large -fPIC -g -O0 -o checkmm checkmm.c
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#define TALLIES "tallies.bin"
#define NUM_TALLIES (550588000/sizeof(int))
typedef struct { int tallies[NUM_TALLIES]; } World;
World* world;
void loadWorld() {
int fd = open(TALLIES, O_RDWR | O_CREAT);
if (fd == -1) { printf("Can't open tallies file %s\n", TALLIES); exit(0); }
fallocate(fd, 0, 0, sizeof(World));
world = (World*) mmap(0, sizeof(World), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (world ==(World*) -1) { printf("Failed to map tallies file %s\n", TALLIES); exit(1); }
}
void unloadWorld() { munmap(world, sizeof(World)); }
void resetWorld() {
int i;
for (i=0;i<NUM_TALLIES;i++) world->tallies[i]=-1;
}
int main() {
loadWorld();
resetWorld();
unloadWorld();
}
誰でも解明できますか?
ターゲット、Ricardo! –