]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/varlink: return StorageReadOnly error
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 13 Mar 2024 01:29:53 +0000 (10:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 13 Mar 2024 12:49:12 +0000 (21:49 +0900)
Addresses https://github.com/systemd/systemd/pull/30021#discussion_r1521595855.

src/network/networkd-manager-varlink.c
src/shared/varlink-io.systemd.Network.c

index f3b265fed50eb8afee8d4a11e81977a8880668eb..c86505b039d53590929fd53466044955d9b38f81 100644 (file)
@@ -188,8 +188,10 @@ static int vl_method_set_persistent_storage(Varlink *vlink, JsonVariant *paramet
                 r = path_is_read_only_fs("/var/lib/systemd/network/");
                 if (r < 0)
                         return log_warning_errno(r, "Failed to check if /var/lib/systemd/network/ is writable: %m");
-                if (r > 0)
-                        return log_warning_errno(SYNTHETIC_ERRNO(EROFS), "The directory /var/lib/systemd/network/ is read-only.");
+                if (r > 0) {
+                        log_warning("The directory /var/lib/systemd/network/ is read-only.");
+                        return varlink_error(vlink, "io.systemd.Network.StorageReadOnly", NULL);
+                }
         }
 
         r = varlink_verify_polkit_async(
index c3be38b99a03be9223d1e44d598b592e77795172..394cc33ace3ae0f53e154f56e071be5af3298704 100644 (file)
@@ -44,6 +44,8 @@ static VARLINK_DEFINE_METHOD(
                 SetPersistentStorage,
                 VARLINK_DEFINE_INPUT(Ready, VARLINK_BOOL, 0));
 
+static VARLINK_DEFINE_ERROR(StorageReadOnly);
+
 VARLINK_DEFINE_INTERFACE(
                 io_systemd_Network,
                 "io.systemd.Network",
@@ -52,4 +54,5 @@ VARLINK_DEFINE_INTERFACE(
                 &vl_method_GetLLDPNeighbors,
                 &vl_method_SetPersistentStorage,
                 &vl_type_LLDPNeighbor,
-                &vl_type_LLDPNeighborsByInterface);
+                &vl_type_LLDPNeighborsByInterface,
+                &vl_error_StorageReadOnly);