Ich versuche mmap()
einen Dateideskriptor zu Speicher, aber ich bekomme Fehler.mmap zurücksenden 'Keine solche Datei oder Verzeichnis'
LOG_BUFFER_SIZE als 500.
printf("fcntl fd check: %d\n", fcntl(ss->fd_log, F_GETFD));
ss->log_mmap = mmap(NULL, LOG_BUFFER_SIZE, PROT_WRITE | PROT_WRITE, MAP_PRIVATE, ss->fd_log, 0);
if (ss->data_mmap == NULL){
printf("mmap() error: %s (errno=%d)\n", strerror(errno), errno);
exit(EXIT_FAILURE);
}
Der Deskriptor ist Datei definiert gültig, wie ich überprüft habe:
fcntl fd check: 1
mmap() error for fd #6: No such file or directory (errno=2)
Dies ist der strace:
access("../ss_data/SunLoadRight", F_OK) = -1 ENOENT (No such file or directory)
open("../ss_data/log/SunLoadRight.log", O_RDWR|O_CREAT|O_APPEND|O_CLOEXEC, 0662) = 6
fcntl(6, F_GETFD) = 0x1 (flags FD_CLOEXEC)
write(1, "fcntl fd check: 1\n", 18fcntl fd check: 1
) = 18
mmap(NULL, 500, PROT_WRITE, MAP_PRIVATE, 6, 0) = 0x7f624c426000
write(1, "mmap() error for fd #6: No such "..., 60mmap() error for fd #6: No such file or directory (errno=2)
) = 60
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
rt_sigaction(SIGPROF, {SIG_DFL, [], SA_RESTORER, 0x7f624be704b0}, NULL, 8) = 0
open("gmon.out", O_WRONLY|O_CREAT|O_TRUNC|O_NOFOLLOW, 0666) = 7
write(7, "gmon\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) = 20
writev(7, [{"\0", 1}, {"\320\[email protected]\0\0\0\0\0\354\[email protected]\0\0\0\0\0H7\0\0d\0\0\0seconds\0"..., 40}, {"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 28304}], 3) = 28345
writev(7, [{"\1", 1}, {"\320*@\0\0\0\0\0$\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\300,@\0\0\0\0\0A\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\320,@\0\0\0\0\0\222\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\340,@\0\0\0\0\0n\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\360,@\0\0\0\0\0\341\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"[email protected]\0\0\0\0\0\367\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\[email protected]\0\0\0\0\0>\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"0/@\0\0\0\0\0\22\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"[email protected]\0\0\0\0\0\37\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\[email protected]\0\0\0\0\0\232\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\320\[email protected]\0\0\0\0\0\246\[email protected]\0\0\0\0\0P\0\0\0", 20}, {"\1", 1}, {"0\[email protected]\0\0\0\0\0-\[email protected]\0\0\0\0\0P\0\0\0", 20}, {"\1", 1}, {"\220\[email protected]\0\0\0\0\0\22\[email protected]\0\0\0\0\0P\0\0\0", 20}, {"\1", 1}, {"\300\[email protected]\0\0\0\0\0-\[email protected]\0\0\0\0\0P\0\0\0", 20}, {"\1", 1}, {"\200\[email protected]\0\0\0\0\0\"\[email protected]\0\0\0\0\0\1\0\0\0", 20}, {"\1", 1}, {"\240\[email protected]\0\0\0\0\0\"\[email protected]\0\0\0\0\0\1\0\0\0", 20}, ...], 62) = 651
close(7) = 0
exit_group(1) = ?
+++ exited with 1 +++
Dies ist alles ziemlich neue Sachen für mich, also mache ich wahrscheinlich irgendwo einen Grundfehler. Etwas mit den Flaggen, denke ich?
Zuweisen von 'ss-> log_mmap' dann ist' ss-> data_mapap' verdächtig. Auch 'PROT_WRITE | PROT_WRITE'? Sehen Sie auch, was die man-Seite für den Rückgabewert von mmap im Falle eines Fehlers sagt. – Mat
Die zweite Ausgabezeile stimmt nicht mit der zweiten 'printf' überein. Woher kommt das '' fd # 6 ''? – mch