X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Futil.c;h=b6e490d457a3562ad1e97037bdd9fbe7a9687bd9;hb=1124fe6f01b1d59d016c238026f20380f38d98dc;hp=a6cdfd5b5ade9bf23a6a5082cf15392ded1d0150;hpb=c1072ea0dade39a4188de5e511adfffd4ba8e42c;p=elogind.git diff --git a/src/util.c b/src/util.c index a6cdfd5b5..b6e490d45 100644 --- a/src/util.c +++ b/src/util.c @@ -3077,6 +3077,8 @@ int parse_bytes(const char *t, off_t *bytes) { { "M", 1024ULL*1024ULL }, { "G", 1024ULL*1024ULL*1024ULL }, { "T", 1024ULL*1024ULL*1024ULL*1024ULL }, + { "P", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, + { "E", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, { "", 1 }, }; @@ -4402,31 +4404,37 @@ int vtnr_from_tty(const char *tty) { return i; } -const char *default_term_for_tty(const char *tty) { +bool tty_is_vc_resolve(const char *tty) { char *active = NULL; - const char *term; + bool b; assert(tty); if (startswith(tty, "/dev/")) tty += 5; - /* Resolve where /dev/console is pointing when determining - * TERM */ + /* Resolve where /dev/console is pointing to */ if (streq(tty, "console")) if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) { /* If multiple log outputs are configured the * last one is what /dev/console points to */ - if ((tty = strrchr(active, ' '))) + tty = strrchr(active, ' '); + if (tty) tty++; else tty = active; } - term = tty_is_vc(tty) ? "TERM=linux" : "TERM=vt100"; + b = tty_is_vc(tty); free(active); - return term; + return b; +} + +const char *default_term_for_tty(const char *tty) { + assert(tty); + + return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt100"; } bool dirent_is_file(const struct dirent *de) { @@ -6076,6 +6084,8 @@ char *format_bytes(char *buf, size_t l, off_t t) { const char *suffix; off_t factor; } table[] = { + { "E", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, + { "P", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, { "T", 1024ULL*1024ULL*1024ULL*1024ULL }, { "G", 1024ULL*1024ULL*1024ULL }, { "M", 1024ULL*1024ULL },