summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-24 15:56:55 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-24 15:56:55 +0200
commite5f8b9380b9cb893dbb3449c7b1635e256752591 (patch)
treea939d1e2b3f382a023b1fcd16ec32a968813ca62
parentac6513c0f94e6599d520ca223d25938c79fa7e76 (diff)
systemd: update sd-daemon.[ch]
-rw-r--r--avahi-daemon/sd-daemon.c47
-rw-r--r--avahi-daemon/sd-daemon.h14
2 files changed, 9 insertions, 52 deletions
diff --git a/avahi-daemon/sd-daemon.c b/avahi-daemon/sd-daemon.c
index 316fccc..6d1eebf 100644
--- a/avahi-daemon/sd-daemon.c
+++ b/avahi-daemon/sd-daemon.c
@@ -40,6 +40,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stddef.h>
#include "sd-daemon.h"
@@ -307,17 +308,17 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t
if (length <= 0)
/* Unnamed socket */
- return l == sizeof(sa_family_t);
+ return l == offsetof(struct sockaddr_un, sun_path);
if (path[0])
/* Normal path socket */
return
- (l >= sizeof(sa_family_t) + length + 1) &&
+ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
memcmp(path, sockaddr.un.sun_path, length+1) == 0;
else
/* Abstract namespace socket */
return
- (l == sizeof(sa_family_t) + length) &&
+ (l == offsetof(struct sockaddr_un, sun_path) + length) &&
memcmp(path, sockaddr.un.sun_path, length) == 0;
}
@@ -366,7 +367,7 @@ int sd_notify(int unset_environment, const char *state) {
memset(&msghdr, 0, sizeof(msghdr));
msghdr.msg_name = &sockaddr;
- msghdr.msg_namelen = sizeof(sa_family_t) + strlen(e);
+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
msghdr.msg_namelen = sizeof(struct sockaddr_un);
@@ -433,41 +434,3 @@ int sd_booted(void) {
return a.st_dev != b.st_dev;
#endif
}
-
-static int touch(const char *path) {
-
-#if !defined(DISABLE_SYSTEMD) && defined(__linux__)
- int fd;
-
- mkdir("/dev/.systemd", 0755);
- mkdir("/dev/.systemd/readahead", 0755);
-
- if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666)) < 0)
- return -errno;
-
- for (;;) {
- if (close(fd) >= 0)
- break;
-
- if (errno != -EINTR)
- return -errno;
- }
-
-#endif
- return 0;
-}
-
-int sd_readahead(const char *action) {
-
- if (!action)
- return -EINVAL;
-
- if (strcmp(action, "cancel") == 0)
- return touch("/dev/.systemd/readahead/cancel");
- else if (strcmp(action, "done") == 0)
- return touch("/dev/.systemd/readahead/done");
- else if (strcmp(action, "noreplay") == 0)
- return touch("/dev/.systemd/readahead/noreplay");
-
- return -EINVAL;
-}
diff --git a/avahi-daemon/sd-daemon.h b/avahi-daemon/sd-daemon.h
index 2fbfe95..fdf3cc0 100644
--- a/avahi-daemon/sd-daemon.h
+++ b/avahi-daemon/sd-daemon.h
@@ -67,17 +67,21 @@ extern "C" {
See sd-daemon(7) for more information.
*/
+#ifndef _sd_printf_attr_
#if __GNUC__ >= 4
#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
#else
#define _sd_printf_attr_(a,b)
#endif
+#endif
+#ifndef _sd_hidden_
#if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS)
#define _sd_hidden_ __attribute__ ((visibility("hidden")))
#else
#define _sd_hidden_
#endif
+#endif
/*
Log levels for usage on stderr:
@@ -254,16 +258,6 @@ int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(
*/
int sd_booted(void) _sd_hidden_;
-/*
- Controls ongoing disk read-ahead operations during boot-up. The argument
- must be a string, and either "cancel", "done" or "noreplay".
-
- cancel = terminate read-ahead data collection, drop collected information
- done = terminate read-ahead data collection, keep collected information
- noreplay = terminate read-ahead replay
-*/
-int sd_readahead(const char *action);
-
#ifdef __cplusplus
}
#endif