1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00

sd-varlink: expose api to get input/output fd separately

This commit is contained in:
Lennart Poettering 2024-11-07 11:49:33 +01:00
parent 32c3e1379d
commit 2afcc034c7
3 changed files with 29 additions and 1 deletions

View File

@ -1062,8 +1062,10 @@ global:
LIBSYSTEMD_258 {
global:
sd_device_enumerator_add_all_parents;
sd_json_variant_type_from_string;
sd_json_variant_type_to_string;
sd_varlink_get_input_fd;
sd_varlink_get_output_fd;
sd_varlink_reset_fds;
sd_device_enumerator_add_all_parents;
} LIBSYSTEMD_257;

View File

@ -1673,6 +1673,30 @@ _public_ int sd_varlink_get_fd(sd_varlink *v) {
return v->input_fd;
}
_public_ int sd_varlink_get_input_fd(sd_varlink *v) {
assert_return(v, -EINVAL);
if (v->state == VARLINK_DISCONNECTED)
return varlink_log_errno(v, SYNTHETIC_ERRNO(ENOTCONN), "Not connected.");
if (v->input_fd < 0)
return varlink_log_errno(v, SYNTHETIC_ERRNO(EBADF), "No valid input fd.");
return v->input_fd;
}
_public_ int sd_varlink_get_output_fd(sd_varlink *v) {
assert_return(v, -EINVAL);
if (v->state == VARLINK_DISCONNECTED)
return varlink_log_errno(v, SYNTHETIC_ERRNO(ENOTCONN), "Not connected.");
if (v->output_fd < 0)
return varlink_log_errno(v, SYNTHETIC_ERRNO(EBADF), "No valid output fd.");
return v->output_fd;
}
_public_ int sd_varlink_get_events(sd_varlink *v) {
int ret = 0;

View File

@ -96,6 +96,8 @@ sd_varlink* sd_varlink_ref(sd_varlink *link);
sd_varlink* sd_varlink_unref(sd_varlink *v);
int sd_varlink_get_fd(sd_varlink *v);
int sd_varlink_get_input_fd(sd_varlink *v);
int sd_varlink_get_output_fd(sd_varlink *v);
int sd_varlink_get_events(sd_varlink *v);
int sd_varlink_get_timeout(sd_varlink *v, uint64_t *ret);