diff options
author | Sven Eden <yamakuzure@gmx.net> | 2016-12-16 12:09:41 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 10:18:01 +0100 |
commit | 1cfc78c91965df340cdde100ad6cb3ed50b28927 (patch) | |
tree | adc3d49b97131cd3e70edff05b14e9b67926e404 /src/libelogind/sd-daemon/sd-daemon.c | |
parent | 86e97d599f8b1ca379dce64fadac9b8f6b002ac5 (diff) |
Prep v221: Update and clean up build system to sync with upstream
This commit replays the moving around of source files that have been
done between systemd-219 and systemd-221.
Further the Makefile.am is synchronized with the upstream version and
then "re-cleaned".
A lot of functions, that are not used anywhere in elogind have been
coated into #if 0/#endif directives to further shorten the list of
dependencies.
All unneeded files have been removed.
Diffstat (limited to 'src/libelogind/sd-daemon/sd-daemon.c')
-rw-r--r-- | src/libelogind/sd-daemon/sd-daemon.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libelogind/sd-daemon/sd-daemon.c b/src/libelogind/sd-daemon/sd-daemon.c index 7bbb3517b..82ac72c72 100644 --- a/src/libelogind/sd-daemon/sd-daemon.c +++ b/src/libelogind/sd-daemon/sd-daemon.c @@ -307,6 +307,37 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path return 1; } +_public_ int sd_is_mq(int fd, const char *path) { + struct mq_attr attr; + + assert_return(fd >= 0, -EINVAL); + + if (mq_getattr(fd, &attr) < 0) + return -errno; + + if (path) { + char fpath[PATH_MAX]; + struct stat a, b; + + assert_return(path_is_absolute(path), -EINVAL); + + if (fstat(fd, &a) < 0) + return -errno; + + strncpy(stpcpy(fpath, "/dev/mqueue"), path, sizeof(fpath) - 12); + fpath[sizeof(fpath)-1] = 0; + + if (stat(fpath, &b) < 0) + return -errno; + + if (a.st_dev != b.st_dev || + a.st_ino != b.st_ino) + return 0; + } + + return 1; +} + _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state, const int *fds, unsigned n_fds) { union sockaddr_union sockaddr = { .sa.sa_family = AF_UNIX, |