X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=b246996fcc69bc0ba6844cda91742499039bcf4a;hb=2c21044f05e32ec483b6ab13e175278779e9ebe3;hp=062ab6dd055e00764962997bb2edd8d576d5a78d;hpb=9bdc770ccd3e23419a0d908782a661dd81a36bc8;p=elogind.git
diff --git a/src/shared/util.h b/src/shared/util.h
index 062ab6dd0..b246996fc 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -9,16 +9,16 @@
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see .
***/
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
#include "macro.h"
@@ -58,6 +59,17 @@ typedef struct dual_timestamp {
#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC)
#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC)
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"
#define NEWLINE "\n\r"
@@ -99,6 +111,10 @@ bool streq_ptr(const char *a, const char *b);
#define new0(t, n) ((t*) calloc((n), sizeof(t)))
+#define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
+
+#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n))
+
#define malloc0(n) (calloc((n), 1))
static inline const char* yes_no(bool b) {
@@ -347,6 +363,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
int path_is_mount_point(const char *path, bool allow_symlink);
+int path_is_read_only_fs(const char *path);
bool is_device_path(const char *path);
@@ -411,6 +428,7 @@ char *fstab_node_to_udev_node(const char *p);
bool tty_is_vc(const char *tty);
bool tty_is_vc_resolve(const char *tty);
+bool tty_is_console(const char *tty);
int vtnr_from_tty(const char *tty);
const char *default_term_for_tty(const char *tty);
@@ -442,8 +460,6 @@ int symlink_or_copy_atomic(const char *from, const char *to);
int fchmod_umask(int fd, mode_t mode);
-int conf_files_list(char ***strv, const char *suffix, const char *dir, ...);
-
int hwclock_is_localtime(void);
int hwclock_apply_localtime_delta(int *min);
int hwclock_reset_localtime_delta(void);
@@ -531,4 +547,8 @@ int fd_inc_rcvbuf(int fd, size_t n);
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);
+int setrlimit_closest(int resource, const struct rlimit *rlim);
+
+int getenv_for_pid(pid_t pid, const char *field, char **_value);
+
#endif