Re: [PATCH] doc: watchdog simple example: don't fail on fsync()

Previous thread: [PATCH 1/2] HID: N-trig Add set feature commands to driver by micki on Monday, March 22, 2010 - 5:16 am. (10 messages)

Next thread: About source IP address of IGMP Join sent on loopback interface by preetham B on Monday, March 22, 2010 - 7:38 am. (1 message)
From: Giel van Schijndel
Date: Monday, March 22, 2010 - 5:22 am

Don't terminate the watchdog daemon when fsync() fails because no
watchdog driver actually implements the fsync() syscall.
---
 Documentation/watchdog/src/watchdog-simple.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
index 4cf72f3..cd6d0dd 100644
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ b/Documentation/watchdog/src/watchdog-simple.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -18,7 +19,9 @@ int main(void)
 			break;
 		}
 		ret = fsync(fd);
-		if (ret)
+		if (ret
+		 && errno != EINVAL
+		 && errno != ENOSYS)
 			break;
 		sleep(10);
 	}
-- 
1.6.4.4

--

From: Giel van Schijndel
Date: Wednesday, March 24, 2010 - 2:04 am

Seems I forgot to sign off my own patch:

Signed-off-by: Giel van Schijndel <me@mortis.eu>

-- 
Met vriendelijke groet,
With kind regards,
Giel van Schijndel
From: Wim Van Sebroeck
Date: Monday, March 29, 2010 - 11:40 am

Wouldn't it be simpler then to just do an fsync without checking the error-result?

Kind regards,
Wim.


--

From: Giel van Schijndel
Date: Monday, March 29, 2010 - 12:12 pm

Yes, it definitly would be. Though I think it would be even simpler to
simply ditch the fsync() call. Considering that none of the watchdog
drivers implements it, nor can I think of a usecase where it would make
sense to implement (as more than a NOP).

So instead I suggest the patch following this line:
========================================================================
doc: watchdog simple example: don't fail on fsync()

Don't terminate the watchdog daemon when fsync() fails because no
watchdog driver actually implements the fsync() syscall.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
---
 Documentation/watchdog/src/watchdog-simple.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
index 4cf72f3..ba45803 100644
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ b/Documentation/watchdog/src/watchdog-simple.c
@@ -17,9 +17,6 @@ int main(void)
 			ret = -1;
 			break;
 		}
-		ret = fsync(fd);
-		if (ret)
-			break;
 		sleep(10);
 	}
 	close(fd);
-- 
1.6.4.4

-- 
Met vriendelijke groet,
With kind regards,
Giel van Schijndel
Previous thread: [PATCH 1/2] HID: N-trig Add set feature commands to driver by micki on Monday, March 22, 2010 - 5:16 am. (10 messages)

Next thread: About source IP address of IGMP Join sent on loopback interface by preetham B on Monday, March 22, 2010 - 7:38 am. (1 message)