Improve O_SYNC logic
This commit is contained in:
parent
425c58e79d
commit
1e359d2324
@ -164,8 +164,11 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifdef O_SYNC
|
||||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC);
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC);
|
||||||
|
if(fd < 0 && errno == EINVAL){ // O_SYNC not supported (e.g. raspberian)
|
||||||
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC );
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC );
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user