From e78f1de499b423616bea7f77c71aaa40a4b158d9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 20 Jun 2023 20:51:05 -0500 Subject: [PATCH] Feature: Add F_again and F_again_not status codes. The fcntl() function uses two forms of privilege failures. The EPERM is already translated to F_prohibited. Therefore, add F_again (and F_again_not) so that EAGAIN can be used for that. --- level_0/f_status/c/status.h | 2 ++ level_0/f_status_string/c/status_string.c | 12 ++++++++++++ level_0/f_status_string/c/status_string.h | 6 ++++++ level_0/f_status_string/tests/unit/c/test-status_string-to.c | 6 +++++- level_1/fl_status_string/c/status_string.c | 12 ++++++++++++ .../fl_status_string/tests/unit/c/test-status_string-from.c | 6 +++++- 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 6b69422..7fa7b55 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -211,6 +211,8 @@ extern "C" { F_absolute_not, F_address, F_address_not, + F_again, + F_again_not, F_ascii, F_ascii_not, F_atomic, diff --git a/level_0/f_status_string/c/status_string.c b/level_0/f_status_string/c/status_string.c index 07d197b..370f1fa 100644 --- a/level_0/f_status_string/c/status_string.c +++ b/level_0/f_status_string/c/status_string.c @@ -85,6 +85,8 @@ extern "C" { const f_string_static_t f_status_absolute_not_s = macro_f_string_static_t_initialize_1(F_status_absolute_not_s, 0, F_status_absolute_not_s_length); const f_string_static_t f_status_address_s = macro_f_string_static_t_initialize_1(F_status_address_s, 0, F_status_address_s_length); const f_string_static_t f_status_address_not_s = macro_f_string_static_t_initialize_1(F_status_address_not_s, 0, F_status_address_not_s_length); + const f_string_static_t f_status_again_s = macro_f_string_static_t_initialize_1(F_status_again_s, 0, F_status_again_s_length); + const f_string_static_t f_status_again_not_s = macro_f_string_static_t_initialize_1(F_status_again_not_s, 0, F_status_again_not_s_length); const f_string_static_t f_status_ascii_s = macro_f_string_static_t_initialize_1(F_status_ascii_s, 0, F_status_ascii_s_length); const f_string_static_t f_status_ascii_not_s = macro_f_string_static_t_initialize_1(F_status_ascii_not_s, 0, F_status_ascii_not_s_length); const f_string_static_t f_status_atomic_s = macro_f_string_static_t_initialize_1(F_status_atomic_s, 0, F_status_atomic_s_length); @@ -1050,6 +1052,16 @@ extern "C" { break; + case F_again: + *name = f_status_again_s; + + break; + + case F_again_not: + *name = f_status_again_not_s; + + break; + case F_ascii: *name = f_status_ascii_s; diff --git a/level_0/f_status_string/c/status_string.h b/level_0/f_status_string/c/status_string.h index e6053c5..47a71de 100644 --- a/level_0/f_status_string/c/status_string.h +++ b/level_0/f_status_string/c/status_string.h @@ -238,6 +238,8 @@ extern "C" { #define F_status_absolute_not_s "F_absolute_not" #define F_status_address_s "F_address" #define F_status_address_not_s "F_address_not" + #define F_status_again_s "F_again" + #define F_status_again_not_s "F_again_not" #define F_status_ascii_s "F_ascii" #define F_status_ascii_not_s "F_ascii_not" #define F_status_atomic_s "F_atomic" @@ -548,6 +550,8 @@ extern "C" { #define F_status_absolute_not_s_length 14 #define F_status_address_s_length 9 #define F_status_address_not_s_length 13 + #define F_status_again_s_length 7 + #define F_status_again_not_s_length 11 #define F_status_ascii_s_length 7 #define F_status_ascii_not_s_length 11 #define F_status_atomic_s_length 8 @@ -858,6 +862,8 @@ extern "C" { extern const f_string_static_t f_status_absolute_not_s; extern const f_string_static_t f_status_address_s; extern const f_string_static_t f_status_address_not_s; + extern const f_string_static_t f_status_again_s; + extern const f_string_static_t f_status_again_not_s; extern const f_string_static_t f_status_ascii_s; extern const f_string_static_t f_status_ascii_not_s; extern const f_string_static_t f_status_atomic_s; diff --git a/level_0/f_status_string/tests/unit/c/test-status_string-to.c b/level_0/f_status_string/tests/unit/c/test-status_string-to.c index 0b2eec0..4b89db7 100644 --- a/level_0/f_status_string/tests/unit/c/test-status_string-to.c +++ b/level_0/f_status_string/tests/unit/c/test-status_string-to.c @@ -103,6 +103,8 @@ void test__f_status_string_to__works(void **state) { F_absolute_not, F_address, F_address_not, + F_again, + F_again_not, F_ascii, F_ascii_not, F_atomic, @@ -717,6 +719,8 @@ void test__f_status_string_to__works(void **state) { f_status_absolute_not_s, f_status_address_s, f_status_address_not_s, + f_status_again_s, + f_status_again_not_s, f_status_ascii_s, f_status_ascii_not_s, f_status_atomic_s, @@ -1257,7 +1261,7 @@ void test__f_status_string_to__works(void **state) { f_status_status_code_last_s, }; - for (uint16_t i = 0; i < 611; ++i) { + for (uint16_t i = 0; i < 613; ++i) { f_string_static_t result = f_string_static_t_initialize; diff --git a/level_1/fl_status_string/c/status_string.c b/level_1/fl_status_string/c/status_string.c index 1ea4544..95900c9 100644 --- a/level_1/fl_status_string/c/status_string.c +++ b/level_1/fl_status_string/c/status_string.c @@ -461,6 +461,18 @@ extern "C" { return F_none; } + if (f_compare_dynamic(name, f_status_again_s) == F_equal_to) { + *code = F_again; + + return F_none; + } + + if (f_compare_dynamic(name, f_status_again_not_s) == F_equal_to) { + *code = F_again_not; + + return F_none; + } + if (f_compare_dynamic(name, f_status_ascii_s) == F_equal_to) { *code = F_ascii; diff --git a/level_1/fl_status_string/tests/unit/c/test-status_string-from.c b/level_1/fl_status_string/tests/unit/c/test-status_string-from.c index 588ff7f..f201747 100644 --- a/level_1/fl_status_string/tests/unit/c/test-status_string-from.c +++ b/level_1/fl_status_string/tests/unit/c/test-status_string-from.c @@ -119,6 +119,8 @@ void test__fl_status_string_from__works(void **state) { F_absolute_not, F_address, F_address_not, + F_again, + F_again_not, F_ascii, F_ascii_not, F_atomic, @@ -733,6 +735,8 @@ void test__fl_status_string_from__works(void **state) { f_status_absolute_not_s, f_status_address_s, f_status_address_not_s, + f_status_again_s, + f_status_again_not_s, f_status_ascii_s, f_status_ascii_not_s, f_status_atomic_s, @@ -1273,7 +1277,7 @@ void test__fl_status_string_from__works(void **state) { f_status_status_code_last_s, }; - for (uint16_t i = 0; i < 611; ++i) { + for (uint16_t i = 0; i < 613; ++i) { f_status_t result = F_none; -- 1.8.3.1