Skip to contentSkip to conversation

initscripts: do not save timestamp for readonly system

PATCH In review Ming Liu 2 participants 3 messages Nov 23, 2015

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH 1/1 initscripts: do not save timestamp for readonly system

From: Ming Liu <[email protected]>

To avoid reporting errors for /etc/timestamp is not writeable in a readonly system.

---
 meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh +2 -2
index b038fc5..6e5be79 100644
@@ -9,5 +9,5 @@
 # Description:       
 ### END INIT INFO
 
-# Update the timestamp
-date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp
+# Update the timestamp for writeable system
+[ -w /etc/timestamp ] && date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Ming Liu

+[ -w /etc/timestamp ] && date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp

This would fail if /etc/timestamp doesn't already exist. I'm tempted to say you should just 2>/dev/null so it tries and the error is hidden in case /etc/timestamp is deleted on a writable file system.

Ross

author
#2 lore raw
Quoted 7 lines · Ross

On 23 November 2015 at 09:42, Ming Liu <[email protected] <mailto:[email protected]>> wrote:

    +[ -w /etc/timestamp ] && date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp

This would fail if /etc/timestamp doesn't already exist. I'm tempted to say you should just 2>/dev/null so it tries and the error is hidden in case /etc/timestamp is deleted on a writable file system.

Yes, that is true! I did not consider that case, then I will send a V2 soon.

//Ming Liu

Quoted 2 lines

Ross