X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.c;h=f3161bd7f3e888b4a4b34e8ded2b1a4fde652f13;hb=108736d0d34d7b74a61a6ac7b99d4d4fec81ce09;hp=29f48b08e3b918991350caa2794682a239b7ca5e;hpb=bbd671356647d9d2c7d6c2c0401e907e169c7576;p=elogind.git diff --git a/util.c b/util.c index 29f48b08e..f3161bd7f 100644 --- a/util.c +++ b/util.c @@ -1258,6 +1258,42 @@ bool chars_intersect(const char *a, const char *b) { return false; } +char *format_timestamp(char *buf, size_t l, usec_t t) { + struct tm tm; + time_t sec; + + assert(buf); + assert(l > 0); + + if (t <= 0) + return NULL; + + sec = (time_t) t / USEC_PER_SEC; + + if (strftime(buf, l, "%a, %d %b %Y %H:%M:%S %z", localtime_r(&sec, &tm)) <= 0) + return NULL; + + return buf; +} + +bool fstype_is_network(const char *fstype) { + static const char * const table[] = { + "cifs", + "smbfs", + "ncpfs", + "nfs", + "nfs4" + }; + + unsigned i; + + for (i = 0; i < ELEMENTSOF(table); i++) + if (streq(table[i], fstype)) + return true; + + return false; +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",