X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=908593564ebd27459a736014240df5a9d1e6ed9a;hp=f1bcb8a1017a596de38c620f8dc305a462e5d11d;hb=952d817a41dfe207d159f8278f4d7f1f7654c572;hpb=5f23d5b149513d98bb90df8cb912b6f567bed89f diff --git a/src/shared/util.h b/src/shared/util.h index f1bcb8a10..908593564 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -39,6 +39,7 @@ #include "macro.h" typedef uint64_t usec_t; +typedef uint64_t nsec_t; typedef struct dual_timestamp { usec_t realtime; @@ -53,11 +54,17 @@ typedef struct dual_timestamp { #define NSEC_PER_USEC 1000ULL #define USEC_PER_MINUTE (60ULL*USEC_PER_SEC) +#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC) #define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE) +#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE) #define USEC_PER_DAY (24ULL*USEC_PER_HOUR) +#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR) #define USEC_PER_WEEK (7ULL*USEC_PER_DAY) +#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY) #define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC) +#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC) #define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC) +#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC) /* What is interpreted as whitespace? */ #define WHITESPACE " \t\n\r" @@ -103,7 +110,7 @@ bool streq_ptr(const char *a, const char *b); #define newa(t, n) ((t*) alloca(sizeof(t)*(n))) -#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n)) +#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n))) #define malloc0(n) (calloc((n), 1)) @@ -139,6 +146,7 @@ void close_many(const int fds[], unsigned n_fd); int parse_boolean(const char *v); int parse_usec(const char *t, usec_t *usec); +int parse_nsec(const char *t, nsec_t *nsec); int parse_bytes(const char *t, off_t *bytes); int parse_pid(const char *s, pid_t* ret_pid); int parse_uid(const char *s, uid_t* ret_uid); @@ -337,6 +345,7 @@ void rename_process(const char name[8]); void sigset_add_many(sigset_t *ss, ...); char* gethostname_malloc(void); +bool hostname_is_set(void); char* getlogname_malloc(void); int getttyname_malloc(int fd, char **r); @@ -348,6 +357,7 @@ int get_ctty(pid_t, dev_t *_devnr, char **r); int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid); +int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev); int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky); int pipe_eof(int fd); @@ -508,4 +518,10 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value); int can_sleep(const char *type); +bool is_valid_documentation_url(const char *url); + +bool in_initrd(void); + +void warn_melody(void); + #endif