Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37708381
en ru br
Репозитории ALT
S:2.38.0-alt2
5.1: 0.1.5-alt1
www.altlinux.org/Changes

Группа :: Система/Основа
Пакет: make-initrd

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: 0001-Use-really-raw-output.patch
Скачать


From 4e1d532e0662b4a19a2de4f328addaa066f7ce46 Mon Sep 17 00:00:00 2001
From: Alexey Gladkov <gladkov.alexey@gmail.com>
Date: Fri, 18 Aug 2023 16:03:55 +0200
Subject: Use really raw output
Leading zeros can interfere with the use of values in bash. bash tries
to convert it and fails.
+ now=000008.562075087
+ now=000008
+ deadline=182
+ $(( $deadline - $now ))
line 60: 182 - 000008: value too great for base (error token is "000008")
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
---
 data/bin/uevent-sh-functions  |  2 +-
 datasrc/timestamp/timestamp.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/data/bin/uevent-sh-functions b/data/bin/uevent-sh-functions
index 665f2e57..652656dc 100644
--- a/data/bin/uevent-sh-functions
+++ b/data/bin/uevent-sh-functions
@@ -26,7 +26,7 @@ publish_event() {
 
 release_event() {
 	local num dummy
-	num=$(/sbin/timestamp boottime raw)
+	num=$(/sbin/timestamp boottime simple)
 	publish_event "$1.${num:-0.0}${2##*/}" "$2"
 }
 
diff --git a/datasrc/timestamp/timestamp.c b/datasrc/timestamp/timestamp.c
index 8a9495c8..8b6fe385 100644
--- a/datasrc/timestamp/timestamp.c
+++ b/datasrc/timestamp/timestamp.c
@@ -10,7 +10,7 @@ main(int argc, char **argv)
 	struct timespec tp = { 0 };
 
 	if (arg == argc) {
-		fprintf(stderr, "Usage: timestamp {monotonic|boottime} [raw]\n");
+		fprintf(stderr, "Usage: timestamp {monotonic|boottime} [raw|simple]\n");
 		return 0;
 	} else if (!strcmp(argv[arg], "monotonic")) {
 		clockid = CLOCK_MONOTONIC_RAW;
@@ -24,9 +24,15 @@ main(int argc, char **argv)
 
 	clock_gettime(clockid, &tp);
 
-	if (arg < argc && !strcmp(argv[arg], "raw")) {
-		printf("%06lu.%07lu", (unsigned long) tp.tv_sec, tp.tv_nsec);
-		return 0;
+	if (arg < argc) {
+		if (!strcmp(argv[arg], "simple")) {
+			printf("%06lu.%07lu", (unsigned long) tp.tv_sec, tp.tv_nsec);
+			return 0;
+		}
+		if (!strcmp(argv[arg], "raw")) {
+			printf("%lu.%lu", (unsigned long) tp.tv_sec, tp.tv_nsec);
+			return 0;
+		}
 	}
 	printf("[%5lu.%06lu] ", (unsigned long) tp.tv_sec, tp.tv_nsec / 1000);
 	return 0;
-- 
2.33.8
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin