From 1e359d232451f19d668359ff5da79e3db021e99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20=27Morty=27=20Str=C3=BCbe?= Date: Fri, 8 May 2015 09:14:40 +0200 Subject: [PATCH] Improve O_SYNC logic --- tools/sky/serialdump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/sky/serialdump.c b/tools/sky/serialdump.c index 447999026..d0e7fac3c 100644 --- a/tools/sky/serialdump.c +++ b/tools/sky/serialdump.c @@ -164,8 +164,11 @@ main(int argc, char **argv) } 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); + if(fd < 0 && errno == EINVAL){ // O_SYNC not supported (e.g. raspberian) + fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT); + } #else fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC ); #endif