diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-30 01:24:48 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-30 01:24:48 +0200 |
commit | 524d896ac17518b824b2c94b3b0b2a23c23da08f (patch) | |
tree | 44f0e5d16641f99a5408dbf73c97bceba845f2c6 | |
parent | 765027454b70c15afdf5507e85ff23cb16e1f889 (diff) |
sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version
As perparation for future incompatible kdbus kernel API changes.
-rw-r--r-- | src/core/bus-policy.c | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 17 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/core/bus-policy.c b/src/core/bus-policy.c index 064eee1c8a..a6a8fcd4d3 100644 --- a/src/core/bus-policy.c +++ b/src/core/bus-policy.c @@ -150,8 +150,11 @@ int bus_kernel_make_starter( hello->attach_flags_send = _KDBUS_ATTACH_ANY; hello->attach_flags_recv = _KDBUS_ATTACH_ANY; - if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) + if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) { + if (errno == ENOTTY) /* Major API change */ + return -ESOCKTNOSUPPORT; return -errno; + } /* not interested in any output values */ cmd_free.offset = hello->offset; @@ -160,7 +163,7 @@ int bus_kernel_make_starter( /* The higher 32bit of the bus_flags fields are considered * 'incompatible flags'. Refuse them all for now. */ if (hello->bus_flags > 0xFFFFFFFFULL) - return -EOPNOTSUPP; + return -ESOCKTNOSUPPORT; return fd; } diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index 556b5eb704..8e3b64337c 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -962,8 +962,16 @@ int bus_kernel_take_fd(sd_bus *b) { } r = ioctl(b->input_fd, KDBUS_CMD_HELLO, hello); - if (r < 0) + if (r < 0) { + if (errno == ENOTTY) + /* If the ioctl is not supported we assume that the + * API version changed in a major incompatible way, + * let's indicate an API incompatibility in this + * case. */ + return -ESOCKTNOSUPPORT; + return -errno; + } if (!b->kdbus_buffer) { b->kdbus_buffer = mmap(NULL, KDBUS_POOL_SIZE, PROT_READ, MAP_SHARED, b->input_fd, 0); @@ -977,7 +985,7 @@ int bus_kernel_take_fd(sd_bus *b) { /* The higher 32bit of the bus_flags fields are considered * 'incompatible flags'. Refuse them all for now. */ if (hello->bus_flags > 0xFFFFFFFFULL) { - r = -EOPNOTSUPP; + r = -ESOCKTNOSUPPORT; goto fail; } @@ -1611,6 +1619,11 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) { if (ioctl(fd, KDBUS_CMD_BUS_MAKE, make) < 0) { safe_close(fd); + + /* Major API change? then the ioctls got shuffled around. */ + if (errno == ENOTTY) + return -ESOCKTNOSUPPORT; + return -errno; } |