diff --git a/.drone.yml b/.drone.yml index 25a42834..1134397f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,16 +5,12 @@ name: debian-unstable steps: - name: debian-build - image: dankamongmen/unstable_builder:2020-02-05a + image: dankamongmen/unstable_builder:2020-05-27a commands: - - apt-get update - - apt-get -y install git-buildpackage - export LANG=en_US.UTF-8 - - mk-build-deps --install -t'apt-get -y' - autoreconf -fis - ./configure - make - - make test --- kind: pipeline type: docker @@ -22,13 +18,10 @@ name: ubuntu-focal steps: - name: ubuntu-build - image: dankamongmen/focal:2020-02-05a + image: dankamongmen/focal:2020-05-27a commands: - - apt-get update - - apt-get -y install git-buildpackage - export LANG=en_US.UTF-8 - mk-build-deps --install -t'apt-get -y' - autoreconf -fis - ./configure - make - - make test diff --git a/Makefile.am b/Makefile.am index b8c2d550..4ac73817 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,9 +26,6 @@ AM_CPPFLAGS=-D_GNU_SOURCE bin_PROGRAMS=growlight-readline bin_PROGRAMS+=growlight -bin_PROGRAMS+=growlight-test - -TESTS=growlight-test common_SOURCES=src/growlight.c src/growlight.h src/mbr.c src/mbr.h \ src/libblkid.c src/libblkid.h src/apm.c src/apm.h src/ssd.h src/ssd.c \ @@ -51,12 +48,8 @@ growlight_SOURCES=$(common_SOURCES) growlight_SOURCES+=src/notcurses.c src/notcurses.h src/notui-aggregate.h src/notui-aggregate.c growlight_LDADD=@notcurses_LIBS@ -growlight_test_SOURCES=$(common_SOURCES) -growlight_test_SOURCES+=test/growlight.c -growlight_test_LDADD=$(CUNIT_LIBS) - -#XSLTARGS=--nonet /usr/share/xml/docbook/stylesheet/docbook-xsl -XSLTARGS=http://docbook.sourceforge.net/release/xsl/current +XSLTARGS=--nonet /usr/share/xml/docbook/stylesheet/docbook-xsl +#XSLTARGS=http://docbook.sourceforge.net/release/xsl/current $(dist_man_MANS): %.8: $(doc_DIR)/man/man8/%.xml $(doc_DIR)/@PACKAGE_NAME@.ent $(XSLTPROC) --path $(doc_DIR) -o $@ $(XSLTARGS)/manpages/docbook.xsl $< diff --git a/README.md b/README.md index a4f991a5..34672092 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,10 @@ https://nick-black.com/dankwiki/index.php/Growlight Dependencies: - - notcurses 1.1.6+ + - notcurses 1.4.2+ - libudev 175+ - - libblkid 2.20.1+ + - libblkid 2.20.1 + - libpci 3.1.9+ - libpciaccess 0.13.1+ - libdevmapper 1.02.74+ @@ -34,7 +35,6 @@ Build-only dependencies: - docbook-xsl (tested with 4.5) - autotools (tested with 1.11) - pkg-config (tested with 0.29) - - cunit (tested with 2.1) - autoconf-archive (tested with 2018+) Building from a git checkout: diff --git a/configure.ac b/configure.ac index 5fccd66b..3f85218b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.61]) -AC_INIT([growlight], [1.2.0], [dankamongmen@gmail.com], [growlight], [https://nick-black.com/dankwiki/index.php/Growlight]) +AC_INIT([growlight], [1.2.5], [dankamongmen@gmail.com], [growlight], [https://nick-black.com/dankwiki/index.php/Growlight]) AC_CONFIG_AUX_DIR([.]) AM_INIT_AUTOMAKE([-Wall foreign dist-xz no-dist-gzip std-options subdir-objects nostdinc]) AC_CONFIG_HEADER([src/config.h]) @@ -62,9 +62,6 @@ AX_LIB_READLINE AC_CHECK_LIB([readline], [main], [have_readline=yes], [AC_MSG_ERROR([Cannot find libreadline.])]) -# CUnit (unit testing) -PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes]) - # Remaining dependencies are needed by all binaries. AC_CHECK_LIB(pciaccess, pci_system_init, [have_pciaccess=yes], [AC_MSG_ERROR([Cannot find libpciaccess.])]) @@ -75,7 +72,7 @@ AC_CHECK_LIB(pci, pci_get_dev, [have_libpci=yes], LIBS+=" -lpci" if test "x$notcurses" = "xtrue" ; then - PKG_CHECK_MODULES([notcurses], [notcurses >= 1.1.6]) + PKG_CHECK_MODULES([notcurses], [notcurses >= 1.4.3]) notcurses_CFLAGS+=" $notcurses_CFLAGS" notcurses_LIBS+=" $notcurses_LIBS" fi diff --git a/debian/changelog b/debian/changelog index 06a698f0..17e2bb0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,53 +1,5 @@ -growlight (1.2.1-1) UNRELEASED; urgency=medium +growlight (1.2.5-1) unstable; urgency=medium - * Debian policy 4.5.0 - * Update copyrights + * New upstream version - -- Nick Black Wed, 22 Jan 2020 22:40:15 -0500 - -growlight (1.2.0-1) unstable; urgency=medium - - * Swap out GUI for notcurses, add dep on notcurses - - -- Nick Black Thu, 12 Dec 2019 11:51:45 -0500 - -growlight (1.1.3.3-1) unstable; urgency=medium - - * Reenable ZFS support; build-dep on libzfslinux-dev - * Require outcurses 0.0.7+ - - -- Nick Black Sun, 17 Nov 2019 06:38:28 -0500 - -growlight (1.1.3-1) unstable; urgency=medium - - * New upstream release, fixes assert()s in ncurses UI - * Compile with -D_FORTIFY_SOURCE=2 - - -- Nick Black Sun, 27 Oct 2019 05:37:40 -0400 - -growlight (1.1.1.1-1) unstable; urgency=medium - - * New upstream release - * Debian policy 4.4.1.1, no changes necessary - * Use liboutcurses-dev for enmetric() - - -- Nick Black Sat, 26 Oct 2019 14:12:15 -0400 - -growlight (1.1.1-1) unstable; urgency=medium - - * New upstream release - * Debhelper 12 - - -- Nick Black Thu, 19 Sep 2019 09:07:34 -0400 - -growlight (1.1.0.1-2) unstable; urgency=medium - - * Debian standards -> 4.4.0.1 - - -- nick black Sun, 25 Aug 2019 18:47:15 -0400 - -growlight (1.1.0.1-1) unstable; urgency=medium - - * Initial debianization - - -- nick black Fri, 09 Aug 2019 01:03:03 -0400 + -- Nick Black Wed, 27 May 2020 19:52:13 -0400 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 48082f72..00000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -12 diff --git a/debian/control b/debian/control index 455d712f..7646129d 100644 --- a/debian/control +++ b/debian/control @@ -1,32 +1,32 @@ Source: growlight -Section: utils Priority: optional Maintainer: Nick Black -Build-Depends: - autoconf-archive, - debhelper (>= 12), - docbook-xsl, - libatasmart-dev, - libblkid-dev, - libcryptsetup-dev, - libcunit1-ncurses-dev, - libdevmapper-dev, - libnotcurses-dev (>= 1.1.6), - libpci-dev, - libpciaccess-dev, - libreadline-dev, - libssl-dev, - libudev-dev, - libzfslinux-dev (>= 0.8.0), - pkg-config, - xsltproc, -Standards-Version: 4.5.0 +Build-Depends: autoconf-archive, + debhelper (>= 13), + docbook-xsl, + libatasmart-dev, + libblkid-dev, + libcryptsetup-dev, + libdevmapper-dev, + libnotcurses-dev (>= 1.4.3), + libpci-dev, + libpciaccess-dev, + libreadline-dev, + libssl-dev, + libudev-dev, + libzfslinux-dev (>= 0.8.0), + pkg-config, + xsltproc +Section: utils +Standards-Version: 4.5.0.2 +Rules-Requires-Root: no Homepage: https://nick-black.com/dankwiki/index.php/Growlight Vcs-Browser: https://github.com/dankamongmen/growlight Vcs-Git: https://github.com/dankamongmen/growlight.git Package: growlight Architecture: any +Multi-Arch: foreign Depends: ${misc:Depends}, ${shlibs:Depends} Description: Disk manipulation and system preparation tool Growlight can manipulate both real and virtual (mdadm, device-mapper, and ZFS) diff --git a/debian/rules b/debian/rules index e1c367c1..915e1237 100755 --- a/debian/rules +++ b/debian/rules @@ -1,25 +1,10 @@ #!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed %: dh $@ - -# dh_make generated override targets -# This is example for Cmake (See https://bugs.debian.org/641051 ) -#override_dh_auto_configure: -# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) - +override_dh_auto_configure: + dh_auto_configure -- --disable-zfs diff --git a/debian/watch b/debian/watch index c72796a5..759e5160 100644 --- a/debian/watch +++ b/debian/watch @@ -1,11 +1,4 @@ -# Example watch control file for uscan -# Rename this file to "watch" and then you can run the "uscan" command -# to check for upstream updates and more. -# See uscan(1) for format - -# Compulsory line, this is a version 4 file version=4 - opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%growlight-$1.tar.gz%" \ https://github.com/dankamongmen/growlight/tags \ (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate diff --git a/src/growlight.c b/src/growlight.c index ddf2fa17..5c3989d3 100644 --- a/src/growlight.c +++ b/src/growlight.c @@ -2108,10 +2108,17 @@ int rescan_controller(controller *c){ diag("Can't rescan unknown/virtual controllers\n"); return -1; } - if(snprintf(buf, sizeof(buf), "%s/device/rescan", c->sysfs) >= (int)sizeof(buf)){ - diag("Name too long: %s\n", c->sysfs); - return -1; - } + if(c->transport == TRANSPORT_NVME){ + if(snprintf(buf, sizeof(buf), "%s/device/rescan_controller", c->sysfs) >= (int)sizeof(buf)){ + diag("Name too long: %s\n", c->sysfs); + return -1; + } + }else{ + if(snprintf(buf, sizeof(buf), "%s/device/rescan", c->sysfs) >= (int)sizeof(buf)){ + diag("Name too long: %s\n", c->sysfs); + return -1; + } + } if(write_sysfs(buf, "1\n")){ return -1; } @@ -2159,12 +2166,19 @@ rescan_blockdev_internal(const device *d, int killedpart){ char buf[PATH_MAX]; int fd; - if(snprintf(buf, sizeof(buf), SYSROOT"/%s/device/rescan", d->name) >= (int)sizeof(buf)){ - diag("Name too long: %s\n", d->name); - return -1; - } + if(d->c->transport == TRANSPORT_NVME){ + if(snprintf(buf, sizeof(buf), "%s/rescan", d->c->sysfs) >= (int)sizeof(buf)){ + diag("Name too long: %s\n", d->c->sysfs); + return -1; + } + }else{ + if(snprintf(buf, sizeof(buf), SYSROOT"/%s/device/rescan", d->name) >= (int)sizeof(buf)){ + diag("Name too long: %s\n", d->name); + return -1; + } + } if(write_sysfs(buf, "1\n")){ - diag("Failed writing to %s/rescan (%s?)\n", d->name, strerror(errno)); + diag("Failed writing to %s (%s?)\n", buf, strerror(errno)); return -1; } diag("Wrote '1' to %s\n", buf); diff --git a/src/growlight.h b/src/growlight.h index f10a0552..9d2677ef 100644 --- a/src/growlight.h +++ b/src/growlight.h @@ -15,7 +15,7 @@ extern "C" { #include #include #include -#include +#include #include "gpt.h" #include "stats.h" diff --git a/src/notcurses.c b/src/notcurses.c index 89907f05..883cecef 100644 --- a/src/notcurses.c +++ b/src/notcurses.c @@ -177,7 +177,7 @@ struct form_state { // int idx; // selection index int scrolloff; // scroll offset - struct selector_item *ops;// selector_item array for *this instance* + struct ncselector_item *ops;// selector_item array for *this instance* int opcount; // total number of ops int selectno; // number of selections, total int selections; // number of active selections @@ -407,6 +407,15 @@ screen_update(void){ if(PR){ ncreel_redraw(PR); } + if(active){ + ncplane_move_top(active->p); + } + if(actform){ + if(actform->extext){ + ncplane_move_top(actform->extext->p); + } + ncplane_move_top(actform->p); + } if(splash){ ncplane_move_top(splash->p); } @@ -446,8 +455,8 @@ typedef struct blockobj { zobj* zone; } blockobj; -// An adapter, which might be invisible (in which case the tablet is NULL). If a -// tablet exists for this adapter, its userptr is the adapterstate. +// An adapter, which might be invisible (in which case the nctablet is NULL). If a +// nctablet exists for this adapter, its userptr is the adapterstate. typedef struct adapterstate { controller* c; unsigned devs; @@ -708,7 +717,7 @@ cmvwhline(struct ncplane* nc, int y, int x, const char* ch, int n){ return 0; } -static int +static int __attribute__ ((format (printf, 4, 5))) cmvwprintw(struct ncplane* n, int y, int x, const char* fmt, ...){ if(ncplane_cursor_move_yx(n, y, x)){ return -1; @@ -720,7 +729,7 @@ cmvwprintw(struct ncplane* n, int y, int x, const char* fmt, ...){ return ret; } -static int +static int __attribute__ ((format (printf, 2, 3))) cwprintw(struct ncplane* n, const char* fmt, ...){ va_list va; va_start(va, fmt); @@ -731,10 +740,7 @@ cwprintw(struct ncplane* n, const char* fmt, ...){ static int cwbkgd(struct ncplane* nc){ - uint64_t channels = 0; - channels_set_fg_rgb(&channels, 0, 0, 0); - ncplane_set_base(nc, channels, 0, " "); - return 0; + return ncplane_set_base(nc, " ", 0, 0); } static void @@ -1141,11 +1147,12 @@ case LAYOUT_NONE: }else if(selected){ cwattron(n, NCSTYLE_REVERSE); } - cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s " PREFIXFMT " %4uB %-6.6s%-16.16s %4.4s %-*.*s", + qprefix(bo->d->size, 1, buf, 0); + cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s %*s %4uB %-6.6s%-16.16s %4.4s %-*.*s", bo->d->name, bo->d->model ? bo->d->model : "n/a", bo->d->revision ? bo->d->revision : "n/a", - qprefix(bo->d->size, 1, buf, 0), + PREFIXFMT(buf), bo->d->physsec, bo->d->blkdev.pttable ? bo->d->blkdev.pttable : "none", bo->d->blkdev.wwn ? bo->d->blkdev.wwn : "n/a", @@ -1175,11 +1182,12 @@ case LAYOUT_MDADM: }else if(selected){ cwattron(n, NCSTYLE_REVERSE); } - cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s " PREFIXFMT " %4uB %-6.6s%-16.16s %4.4s %-*.*s", + qprefix(bo->d->size, 1, buf, 0); + cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s %*s %4uB %-6.6s%-16.16s %4.4s %-*.*s", bo->d->name, bo->d->model ? bo->d->model : "n/a", bo->d->revision ? bo->d->revision : "n/a", - qprefix(bo->d->size, 1, buf, 0), + PREFIXFMT(buf), bo->d->physsec, bo->d->mddev.pttable ? bo->d->mddev.pttable : "none", bo->d->mddev.mdname ? bo->d->mddev.mdname : "n/a", @@ -1202,11 +1210,12 @@ case LAYOUT_DM: }else if(selected){ cwattron(n, NCSTYLE_REVERSE); } - cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s " PREFIXFMT " %4uB %-6.6s%-16.16s %4.4s %-*.*s", + qprefix(bo->d->size, 1, buf, 0); + cmvwprintw(n, line, 1, "%11.11s %-16.16s %4.4s %*s %4uB %-6.6s%-16.16s %4.4s %-*.*s", bo->d->name, bo->d->model ? bo->d->model : "n/a", bo->d->revision ? bo->d->revision : "n/a", - qprefix(bo->d->size, 1, buf, 0), + PREFIXFMT(buf), bo->d->physsec, bo->d->dmdev.pttable ? bo->d->dmdev.pttable : "none", bo->d->dmdev.dmname ? bo->d->dmdev.dmname : "n/a", @@ -1230,11 +1239,12 @@ case LAYOUT_ZPOOL: }else if(selected){ cwattron(n, NCSTYLE_REVERSE); } - cmvwprintw(n, line, 1, "%11.11s %-16.16s %4ju " PREFIXFMT " %4uB %-6.6s%-16.16s %4.4s %-*.*s", + qprefix(bo->d->size, 1, buf, 0); + cmvwprintw(n, line, 1, "%11.11s %-16.16s %4ju %*s %4uB %-6.6s%-16.16s %4.4s %-*.*s", bo->d->name, bo->d->model ? bo->d->model : "n/a", (uintmax_t)bo->d->zpool.zpoolver, - qprefix(bo->d->size, 1, buf, 0), + PREFIXFMT(buf), bo->d->physsec, "spa", "n/a", // FIXME @@ -1701,7 +1711,7 @@ free_form(struct form_state *fs){ static void multiselector_items(struct form_state *fs){ - const struct selector_item *opstrs = fs->ops; + const struct ncselector_item *opstrs = fs->ops; struct ncplane* fsw = fs->p; int z, cols, selidx, maxz; @@ -1755,7 +1765,7 @@ multiselector_items(struct form_state *fs){ static void check_options(struct form_state *fs){ - const struct selector_item *opstrs = fs->ops; + const struct ncselector_item *opstrs = fs->ops; int z, cols, selidx, maxz; assert(fs->formtype == FORM_CHECKBOXEN); @@ -1861,7 +1871,7 @@ raise_form_explication(struct ncplane* n, const char* text, int linesz){ } void raise_multiform(const char *str, void (*fxn)(const char *, char **, int, int), - struct selector_item *opstrs, int ops, int defidx, + struct ncselector_item *opstrs, int ops, int defidx, int selectno, char **selarray, int selections, const char *text, int scrollidx){ size_t longop, longdesc; @@ -1940,7 +1950,7 @@ void raise_multiform(const char *str, void (*fxn)(const char *, char **, int, in // A collection of checkboxes static void raise_checkform(const char* str, void (*fxn)(const char*, char**, int, int), - struct selector_item* opstrs, int ops, int defidx, + struct ncselector_item* opstrs, int ops, int defidx, char** selarray, int selections, const char* text, int scrollidx){ size_t longop, longdesc; @@ -2022,7 +2032,7 @@ raise_checkform(const char* str, void (*fxn)(const char*, char**, int, int), // - select type form, for single choice from among a set // ------------------------------------------------------------------------- void raise_form(const char* str, void (*fxn)(const char*), - struct selector_item* opstrs, int ops, int defidx, + struct ncselector_item* opstrs, int ops, int defidx, const char* text){ if(opstrs == NULL || !ops){ locked_diag("Passed empty %u-option string table", ops); @@ -2032,7 +2042,7 @@ void raise_form(const char* str, void (*fxn)(const char*), locked_diag("An input dialog is already active"); return; } - selector_options sopts; + ncselector_options sopts; memset(&sopts, 0, sizeof(sopts)); sopts.items = opstrs; sopts.itemcount = ops; @@ -2122,7 +2132,7 @@ void raise_str_form(const char* str, void (*fxn)(const char*), screen_update(); } -static const struct selector_item common_fsops[] = { +static const struct ncselector_item common_fsops[] = { { .option = "ro", .desc = "Read-only", @@ -2165,10 +2175,10 @@ static const struct selector_item common_fsops[] = { }, }; -static struct selector_item * +static struct ncselector_item * ops_table(int *count, const char *match, int *defidx, char ***selarray, int *selections, - const struct selector_item *flags, unsigned fcount){ - struct selector_item *fo = NULL; + const struct ncselector_item *flags, unsigned fcount){ + struct ncselector_item *fo = NULL; int z = 0; *count = 0; @@ -2236,7 +2246,7 @@ static char forming_targ[PATH_MAX + 1]; static void mountop_callback(const char *op, char **selarray, int selections, int scrollidx){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; int opcount, defidx; blockobj *b; @@ -2288,7 +2298,7 @@ mountop_callback(const char *op, char **selarray, int selections, int scrollidx) // ------------------------------------------------------------------------- static void targpoint_callback(const char *path){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; int scrollidx = 0; blockobj *b; @@ -2336,10 +2346,10 @@ targpoint_callback(const char *path){ // ------------------------------------------------------------------------- // - filesystem type form, for new filesystem creation // ------------------------------------------------------------------------- -static struct selector_item * +static struct ncselector_item * fs_table(int *count, const char *match, int *defidx){ - struct selector_item* fo = NULL; - struct selector_item* tmp; + struct ncselector_item* fo = NULL; + struct ncselector_item* tmp; pttable_type* types; int z; @@ -2454,7 +2464,7 @@ fs_do(const char *name){ static void fs_named_callback(const char *name){ if(name == NULL){ - struct selector_item *ops_fs; + struct ncselector_item *ops_fs; int opcount, defidx; if((ops_fs = fs_table(&opcount, pending_fstype, &defidx)) == NULL){ @@ -2494,9 +2504,9 @@ fs_callback(const char *fs){ // A NULL return is only an error if *count is set to -1. If *count is set to // 0, it simply means this partition table type doesn't have type tags. -static struct selector_item * +static struct ncselector_item * ptype_table(const device *d, int *count, int match, int *defidx){ - struct selector_item *fo = NULL, *tmp; + struct ncselector_item *fo = NULL, *tmp; const char *pttable; const ptype *pt; @@ -2782,7 +2792,7 @@ psectors_callback(const char *psects){ return; } if(psects == NULL){ // go back to partition type - struct selector_item *ops_ptype; + struct ncselector_item *ops_ptype; int opcount, defidx; if((ops_ptype = ptype_table(b->d, &opcount, pending_ptype, &defidx)) == NULL){ @@ -2849,7 +2859,7 @@ ptype_callback(const char *pty){ static void new_partition(void){ - struct selector_item *ops_ptype; + struct ncselector_item *ops_ptype; blockobj *b; int opcount; int defidx; @@ -2874,7 +2884,7 @@ new_partition(void){ // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- -// - partition tabletype form, for new partition table creation +// - partition nctabletype form, for new partition table creation // ------------------------------------------------------------------------- static inline int partition_table_makeablep(const blockobj *b){ @@ -2927,7 +2937,7 @@ pttype_callback(const char *pttype){ // ------------------------------------------------------------------------- static int confirm_operation(const char *op,void (*confirmcb)(const char *)){ - struct selector_item *ops_confirm; + struct ncselector_item *ops_confirm; if((ops_confirm = malloc(sizeof(*ops_confirm) * 2)) == NULL){ return -1; @@ -2984,9 +2994,9 @@ detail_fs(struct ncplane* hw, const device* d, int row){ char buf[BPREFIXSTRLEN + 1]; ncplane_styles_off(hw, NCSTYLE_BOLD); - cmvwprintw(hw, row, START_COL, BPREFIXFMT "%c ", - d->mntsize ? bprefix(d->mntsize, 1, buf, 1) : "", - d->mntsize ? 'B' : ' '); + const char *size = d->mntsize ? bprefix(d->mntsize, 1, buf, 1) : ""; + cmvwprintw(hw, row, START_COL, "%*s%c ", + BPREFIXFMT(size), d->mntsize ? 'B' : ' '); ncplane_styles_on(hw, NCSTYLE_BOLD); cwprintw(hw, "%s%s", d->label ? "" : "unlabeled ", d->mnttype); if(d->label){ @@ -3155,9 +3165,9 @@ update_details(struct ncplane* hw){ if(blockobj_unpartitionedp(b)){ char ubuf[BPREFIXSTRLEN + 1]; + bprefix(d->size, 1, ubuf, 1); ncplane_styles_off(hw, NCSTYLE_BOLD); - cmvwprintw(hw, 6, START_COL, BPREFIXFMT "B ", - bprefix(d->size, 1, ubuf, 1)); + cmvwprintw(hw, 6, START_COL, "%*sB ", BPREFIXFMT(ubuf)); ncplane_styles_on(hw, NCSTYLE_BOLD); cwprintw(hw, "%s", "unpartitioned media"); detail_fs(hw, b->d, 7); @@ -3171,9 +3181,9 @@ update_details(struct ncplane* hw){ assert(b->zone->p->layout == LAYOUT_PARTITION); bprefix(b->zone->p->partdev.alignment, 1, align, 1); // FIXME limit length! + bprefix(d->logsec * (b->zone->lsector - b->zone->fsector + 1),1, zbuf, 1); ncplane_styles_off(hw, NCSTYLE_BOLD); - cmvwprintw(hw, 6, START_COL, BPREFIXFMT "B ", - bprefix(d->logsec * (b->zone->lsector - b->zone->fsector + 1), 1, zbuf, 1)); + cmvwprintw(hw, 6, START_COL, "%*sB ", BPREFIXFMT(zbuf)); ncplane_styles_on(hw, NCSTYLE_BOLD); cwprintw(hw, "P%lc%lc ", subscript((b->zone->p->partdev.pnumber % 100 / 10)), subscript((b->zone->p->partdev.pnumber % 10))); @@ -3204,8 +3214,8 @@ update_details(struct ncplane* hw){ // but not until we implement zones in core (bug 252) // or we'll need recreate alignment() etc here ncplane_styles_off(hw, NCSTYLE_BOLD); - cmvwprintw(hw, 6, START_COL, BPREFIXFMT "B ", - bprefix(d->logsec * (b->zone->lsector - b->zone->fsector + 1), 1, zbuf, 1)); + bprefix(d->logsec * (b->zone->lsector - b->zone->fsector + 1), 1, zbuf, 1); + cmvwprintw(hw, 6, START_COL, "%*sB ", BPREFIXFMT(zbuf)); ncplane_styles_on(hw, NCSTYLE_BOLD); ncplane_styles_off(hw, NCSTYLE_BOLD); cwprintw(hw, "%ju", b->zone->fsector); @@ -3557,13 +3567,14 @@ detail_mounts(struct ncplane* w, int* row, int maxy, const device* d){ continue; } cmvwhline(w, *row, START_COL, " ", cols - 2); - cmvwprintw(w, *row, START_COL, "%-*.*s %-5.5s %-36.36s " PREFIXFMT " %-*.*s", + qprefix(d->mntsize, 1, buf, 0); + cmvwprintw(w, *row, START_COL, "%-*.*s %-5.5s %-36.36s %*s %-*.*s", FSLABELSIZ, FSLABELSIZ, d->label ? d->label : "n/a", d->mnttype, d->uuid ? d->uuid : "n/a", - qprefix(d->mntsize, 1, buf, 0), - cols - (FSLABELSIZ + 47 + PREFIXSTRLEN), - cols - (FSLABELSIZ + 47 + PREFIXSTRLEN), + PREFIXFMT(buf), + cols - (FSLABELSIZ + 47 + PREFIXCOLUMNS), + cols - (FSLABELSIZ + 47 + PREFIXCOLUMNS), d->name); if(++*row == maxy){ return; @@ -3594,13 +3605,14 @@ detail_targets(struct ncplane* w, int* row, int both, const device* d){ continue; } cmvwhline(w, *row, START_COL, " ", cols - 2); - cmvwprintw(w, *row, START_COL, "%-*.*s %-5.5s %-36.36s " PREFIXFMT " %-*.*s", + qprefix(d->mntsize, 1, buf, 0); + cmvwprintw(w, *row, START_COL, "%-*.*s %-5.5s %-36.36s %*s %-*.*s", FSLABELSIZ, FSLABELSIZ, d->label ? d->label : "n/a", d->mnttype, d->uuid ? d->uuid : "n/a", - qprefix(d->mntsize, 1, buf, 0), - cols - (FSLABELSIZ + 47 + PREFIXSTRLEN), - cols - (FSLABELSIZ + 47 + PREFIXSTRLEN), + PREFIXFMT(buf), + cols - (FSLABELSIZ + 47 + PREFIXCOLUMNS), + cols - (FSLABELSIZ + 47 + PREFIXCOLUMNS), d->name); ++*row; if(!both){ @@ -3671,9 +3683,9 @@ map_details(struct ncplane *hw){ } cwattrset(hw, NCSTYLE_BOLD|SUBDISPLAY_COLOR); cmvwhline(hw, y, 1, " ", cols - 2); - cmvwprintw(hw, y, 1, "%-*.*s %-5.5s %-36.36s " PREFIXFMT " %s", + cmvwprintw(hw, y, 1, "%-*.*s %-5.5s %-36.36s %*s %s", FSLABELSIZ, FSLABELSIZ, "Label", - "Type", "UUID", "Bytes", "Device"); + "Type", "UUID", PREFIXFMT("Bytes"), "Device"); if(++y >= rows){ return 0; } @@ -3980,9 +3992,9 @@ remove_ptable(void){ confirm_operation("remove the partition table", remove_ptable_confirm); } -static struct selector_item * +static struct ncselector_item * pttype_table(int *count){ - struct selector_item *fo = NULL, *tmp; + struct ncselector_item *fo = NULL, *tmp; pttable_type *types; int z; @@ -4022,7 +4034,7 @@ pttype_table(int *count){ static void make_ptable(void){ - struct selector_item *ops_ptype; + struct ncselector_item *ops_ptype; int opcount; blockobj *b; @@ -4043,7 +4055,7 @@ make_ptable(void){ static void new_filesystem(void){ blockobj *b = get_selected_blockobj(); - struct selector_item *ops_fs; + struct ncselector_item *ops_fs; int opcount, defidx; if(b == NULL){ @@ -4140,14 +4152,14 @@ kill_filesystem(void){ } } -static const struct selector_item dos_flags[] = { +static const struct ncselector_item dos_flags[] = { { .option = "0x80", .desc = "Bootable", }, }; -static const struct selector_item gpt_flags[] = { +static const struct ncselector_item gpt_flags[] = { { // protects OEM partitions from being overwritten by windows .option = "0x0000000000000001", // 2^0, 1 .desc = "System partition", @@ -4172,10 +4184,10 @@ static const struct selector_item gpt_flags[] = { }, }; -static struct selector_item * +static struct ncselector_item * flag_table(int *count, const char *match, int *defidx, char ***selarray, int *selections, - const struct selector_item *flags, unsigned fcount){ - struct selector_item *fo = NULL; + const struct ncselector_item *flags, unsigned fcount){ + struct ncselector_item *fo = NULL; int z = 0; *count = 0; @@ -4267,7 +4279,7 @@ do_partflag(char **selarray, int selections){ static void partflag_callback(const char *fn, char **selarray, int selections, int scrollp){ - struct selector_item *flags_agg; + struct ncselector_item *flags_agg; int opcount, defidx; if(fn == NULL){ @@ -4290,7 +4302,7 @@ partflag_callback(const char *fn, char **selarray, int selections, int scrollp){ static void dos_partflag_callback(const char *fn, char **selarray, int selections, int scrollp){ - struct selector_item *flags_agg; + struct ncselector_item *flags_agg; int opcount, defidx; if(fn == NULL){ @@ -4313,7 +4325,7 @@ dos_partflag_callback(const char *fn, char **selarray, int selections, int scrol static int flag_to_selections(uint64_t flags, char ***selarray, int *selections, - const struct selector_item *ops, unsigned opcount){ + const struct ncselector_item *ops, unsigned opcount){ assert(selarray && selections); assert(!*selarray && !*selections); while(opcount--){ @@ -4339,7 +4351,7 @@ flag_to_selections(uint64_t flags, char ***selarray, int *selections, static void set_partition_attrs(void){ - struct selector_item *flags_agg; + struct ncselector_item *flags_agg; char **selarray = NULL; int selections = 0; int opcount, defidx; @@ -4932,7 +4944,7 @@ handle_actform_input(const ncinput *ni){ if(ch == NCKEY_ENTER || (ni->ctrl && (ch == 'J' || ch == 'M'))){ int op, selections, scrolloff; char **selarray; - char *optstr; + const char *optstr; lock_notcurses(); if(fs->ns){ @@ -4957,14 +4969,13 @@ handle_actform_input(const ncinput *ni){ }else{ cb(optstr); } - free(optstr); unlock_notcurses(); return 0; } switch(ch){ case 12: // CTRL+L FIXME lock_notcurses(); - notcurses_refresh(NC); + notcurses_refresh(NC, NULL, NULL); unlock_notcurses(); break; case KEY_ESC:{ @@ -4984,7 +4995,7 @@ handle_actform_input(const ncinput *ni){ }case NCKEY_UP: case 'k':{ lock_notcurses(); if(fs->ns){ - ncselector_previtem(fs->ns, NULL); + ncselector_previtem(fs->ns); }else{ if(fs->idx == fs->scrolloff){ if(--fs->scrolloff < 0){ @@ -5005,7 +5016,7 @@ handle_actform_input(const ncinput *ni){ }case NCKEY_DOWN: case 'j':{ lock_notcurses(); if(fs->ns){ - ncselector_nextitem(fs->ns, NULL); + ncselector_nextitem(fs->ns); }else{ int maxz; ncplane_dim_yx(fs->p, &maxz, NULL); @@ -5229,7 +5240,7 @@ handle_ncurses_input(struct ncplane* w){ while((ch = notcurses_getc_blocking(NC, &ni)) != (char32_t)-1){ if(ch == 12){ // CTRL+L FIXME lock_notcurses(); - notcurses_refresh(NC); + notcurses_refresh(NC, NULL, NULL); unlock_notcurses(); continue; } diff --git a/src/notcurses.h b/src/notcurses.h index b7e873fe..c7dd71dd 100644 --- a/src/notcurses.h +++ b/src/notcurses.h @@ -6,14 +6,14 @@ extern "C" { #endif #include "config.h" -#include +#include struct panel_state; void locked_diag(const char *, ...); // Scrolling single select form -void raise_form(const char *, void (*)(const char *), struct selector_item *, +void raise_form(const char *, void (*)(const char *), struct ncselector_item *, int, int, const char *); // Single-entry string entry form with command-line editing @@ -21,7 +21,7 @@ void raise_str_form(const char *, void (*)(const char *), const char *, const ch // Multiselect form with side panel void raise_multiform(const char *, void (*)(const char *, char **, int, int), - struct selector_item *, int, int, int, char **, int, + struct ncselector_item *, int, int, int, char **, int, const char *, int); struct panel_state *show_splash(const wchar_t *); diff --git a/src/notui-aggregate.c b/src/notui-aggregate.c index dcd5330f..41a07eaa 100644 --- a/src/notui-aggregate.c +++ b/src/notui-aggregate.c @@ -40,7 +40,7 @@ struct form_state { form_enum formtype; // type of form union { struct { - struct selector_item *ops; // selector_item array for *this instance* + struct ncselector_item *ops; // selector_item array for *this instance* int scrolloff; // scroll offset int opcount; // total number of ops }; @@ -59,10 +59,10 @@ destroy_agg_forms(void){ pending_aggname = NULL; } -static struct selector_item * +static struct ncselector_item * agg_table(int *count, const char *match, int *defidx){ const aggregate_type *types; - struct selector_item *fo; + struct ncselector_item *fo; int z; *defidx = -1; @@ -118,7 +118,7 @@ prefix_desc_with_size(const device *d, char *desc){ if((uni = malloc(sz)) == NULL){ return NULL; } - if((unsigned)snprintf(uni, sz, "("BPREFIXFMT"B) %s", s, desc) >= sz){ + if((unsigned)snprintf(uni, sz, "(%*sB) %s", BPREFIXFMT(s), desc) >= sz){ free(uni); return NULL; } @@ -126,10 +126,10 @@ prefix_desc_with_size(const device *d, char *desc){ return uni; } -static struct selector_item * +static struct ncselector_item * grow_component_table(const device *d, int *count, const char *match, int *defidx, - char ***selarray, int *selections, struct selector_item *fo){ - struct selector_item *tmp; + char ***selarray, int *selections, struct ncselector_item *fo){ + struct ncselector_item *tmp; char *key, *desc; int z; @@ -195,10 +195,10 @@ grow_component_table(const device *d, int *count, const char *match, int *defidx return fo; } -static struct selector_item * +static struct ncselector_item * component_table(const aggregate_type *at, int *count, const char *match, int *defidx, char ***selarray, int *selections){ - struct selector_item *fo = NULL, *tmp; + struct ncselector_item *fo = NULL, *tmp; const controller *c; *count = 0; @@ -274,7 +274,7 @@ do_agg(const aggregate_type *at, char * const *selarray, int selections){ static void aggcomp_callback(const char *fn, char **selarray, int selections, int scrollp){ - struct selector_item *comps_agg; + struct ncselector_item *comps_agg; const aggregate_type *at; int opcount, defidx; @@ -296,7 +296,7 @@ aggcomp_callback(const char *fn, char **selarray, int selections, int scrollp){ } } if((comps_agg = component_table(at, &opcount, fn, &defidx, &selarray, &selections)) == NULL){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; if( (ops_agg = agg_table(&opcount, pending_aggtype, &defidx)) ){ raise_form("select an aggregate type", agg_callback, ops_agg, @@ -319,14 +319,14 @@ aggcomp_callback(const char *fn, char **selarray, int selections, int scrollp){ static void aggname_callback(const char *fn){ - struct selector_item *comps_agg; + struct ncselector_item *comps_agg; const aggregate_type *at; int selections = 0; int opcount, defidx; char **selarray; if(fn == NULL){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; if( (ops_agg = agg_table(&opcount, pending_aggtype, &defidx)) ){ raise_form("select an aggregate type", agg_callback, ops_agg, @@ -344,7 +344,7 @@ aggname_callback(const char *fn){ } selarray = NULL; if((comps_agg = component_table(at, &opcount, NULL, &defidx, &selarray, &selections)) == NULL){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; if( (ops_agg = agg_table(&opcount, pending_aggtype, &defidx)) ){ raise_form("select an aggregate type", agg_callback, ops_agg, @@ -381,7 +381,7 @@ agg_callback(const char *fn){ } int raise_aggregate_form(void){ - struct selector_item *ops_agg; + struct ncselector_item *ops_agg; int opcount, defidx; if((ops_agg = agg_table(&opcount, pending_aggtype, &defidx)) == NULL){ diff --git a/src/readline.c b/src/readline.c index 7fb90222..a4d31bfd 100644 --- a/src/readline.c +++ b/src/readline.c @@ -242,16 +242,15 @@ static int print_dev_mplex(const device *,int,int); static int print_mounts(const device *d){ char buf[PREFIXSTRLEN + 1]; - int r = 0,rr; + int r = 0, rr; unsigned z; for(z = 0 ; z < d->mnt.count ; ++z){ - r += rr = printf("%-*.*s %-5.5s %-36.36s %-6.6s " PREFIXFMT "\n %s %s\n", + const char *size = d->mntsize ? qprefix(d->mntsize, 1, buf, 0) : ""; + r += rr = printf("%-*.*s %-5.5s %-36.36s %-6.6s %*s\n %s %s\n", FSLABELSIZ,FSLABELSIZ,d->label ? d->label : "n/a", - d->mnttype, - d->uuid ? d->uuid : "n/a", d->name, - d->mntsize ? qprefix(d->mntsize,1,buf,0) : "", - d->mnt.list[z],d->mntops.list[z]); + d->mnttype, d->uuid ? d->uuid : "n/a", d->name, + PREFIXFMT(size), d->mnt.list[z], d->mntops.list[z]); if(rr < 0){ return -1; } @@ -262,15 +261,14 @@ print_mounts(const device *d){ static int print_swap(const device *p){ char buf[PREFIXSTRLEN + 1]; - int r = 0,rr; + int r = 0, rr; assert(p->mnttype); - r += rr = printf("%-*.*s %-5.5s %-36.36s %-6.6s " PREFIXFMT, + qprefix(p->mntsize, 1, buf, 0), + r += rr = printf("%-*.*s %-5.5s %-36.36s %-6.6s %*s", FSLABELSIZ,FSLABELSIZ,p->label ? p->label : "n/a", - p->mnttype, - p->uuid ? p->uuid : "n/a", - qprefix(p->mntsize,1,buf,0), - p->name); + p->mnttype, p->uuid ? p->uuid : "n/a", + p->name, PREFIXFMT(buf)); if(rr < 0){ return -1; } @@ -334,10 +332,11 @@ print_partition(const device *p, int descend){ int r = 0, rr; use_ncdirect_color(COLOR_BLUE, 1); - r += rr = printf("%-10.10s %-36.36s " PREFIXFMT " %-3.3s %ls\n", + qprefix(p->size, 1, buf, 0); + r += rr = printf("%-10.10s %-36.36s %*s %-3.3s %ls\n", p->name, p->partdev.uuid ? p->partdev.uuid : "n/a", - qprefix(p->size, 1, buf, 0), + PREFIXFMT(buf), partrole_str(p->partdev.ptype, p->partdev.flags), p->partdev.pname ? p->partdev.pname : L"n/a"); if(rr < 0){ @@ -401,11 +400,12 @@ print_drive(const device *d,int descend){ }else{ use_ncdirect_color(COLOR_MAGENTA,1); // virtual } - r += rr = printf("%-10.10s %-16.16s %4.4s " PREFIXFMT " %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-10.10s %-16.16s %4.4s %*s %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", d->name, d->model ? d->model : "n/a", d->revision ? d->revision : "n/a", - qprefix(d->size,1,buf,0), + PREFIXFMT(buf), d->physsec, d->blkdev.unloaded ? L'U' : d->blkdev.removable ? L'R' : @@ -426,12 +426,13 @@ print_drive(const device *d,int descend){ ); break; }case LAYOUT_MDADM:{ - use_ncdirect_color(COLOR_YELLOW,1); - r += rr = printf("%-10.10s %-16.16s %4.4s " PREFIXFMT " %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", + use_ncdirect_color(COLOR_YELLOW, 1); + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-10.10s %-16.16s %4.4s %*s %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", d->name, d->model ? d->model : "n/a", d->revision ? d->revision : "n/a", - qprefix(d->size,1,buf,0), + PREFIXFMT(buf), d->physsec, L'V', L'M', L'.', d->roflag ? L'r' : L'.', L'.', d->mddev.pttable ? d->mddev.pttable : "none", @@ -440,12 +441,13 @@ print_drive(const device *d,int descend){ ); break; }case LAYOUT_DM:{ - use_ncdirect_color(COLOR_YELLOW,1); - r += rr = printf("%-10.10s %-16.16s %4.4s " PREFIXFMT " %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", + use_ncdirect_color(COLOR_YELLOW, 1); + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-10.10s %-16.16s %4.4s %*s %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", d->name, d->model ? d->model : "n/a", d->revision ? d->revision : "n/a", - qprefix(d->size,1,buf,0), + PREFIXFMT(buf), d->physsec, L'V', L'D', L'.', d->roflag ? L'r' : L'.', L'.', "n/a", @@ -454,12 +456,13 @@ print_drive(const device *d,int descend){ ); break; }case LAYOUT_ZPOOL:{ - use_ncdirect_color(COLOR_RED,1); - r += rr = printf("%-10.10s %-16.16s %4ju " PREFIXFMT " %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", + use_ncdirect_color(COLOR_RED, 1); + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-10.10s %-16.16s %4ju %*s %4uB %lc%lc%lc%lc%lc %-6.6s%-16.16s %-4.4s\n", d->name, d->model ? d->model : "n/a", (uintmax_t)d->zpool.zpoolver, - qprefix(d->size,1,buf,0), + PREFIXFMT(buf), d->physsec, L'V', L'Z', L'.', d->roflag ? L'r' : L'.', L'.', "spa", @@ -518,11 +521,11 @@ print_zpool(const device *d,int descend){ if(d->layout != LAYOUT_ZPOOL){ return 0; } - r += rr = printf("%-10.10s %-36.36s " PREFIXFMT " %4uB ZFS%2ju %5lu %-6.6s\n", + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-10.10s %-36.36s %*s %4uB ZFS%2ju %5lu %-6.6s\n", d->name, d->uuid ? d->uuid : "n/a", - qprefix(d->size,1,buf,0), - d->physsec, d->zpool.zpoolver, + PREFIXFMT(buf), d->physsec, d->zpool.zpoolver, d->zpool.disks,d->zpool.level ? d->zpool.level : "n/a" ); if(rr < 0){ @@ -544,12 +547,12 @@ print_dm(const device *d,int prefix,int descend){ return 0; } use_ncdirect_color(COLOR_YELLOW,1); - r += rr = printf("%-*.*s%-10.10s %-36.36s " PREFIXFMT " %4uB %-6.6s%5lu %-6.6s\n", + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-*.*s%-10.10s %-36.36s %*s %4uB %-6.6s%5lu %-6.6s\n", prefix,prefix,"", d->name, d->uuid ? d->uuid : "n/a", - qprefix(d->size,1,buf,0), - d->physsec, "n/a", + PREFIXFMT(buf), d->physsec, "n/a", d->dmdev.disks,d->dmdev.level ? d->dmdev.level : "n/a" ); if(rr < 0){ @@ -594,14 +597,15 @@ print_mdadm(const device *d,int prefix,int descend){ if(d->layout != LAYOUT_MDADM){ return 0; } - use_ncdirect_color(COLOR_YELLOW,1); - r += rr = printf("%-*.*s%-10.10s %-36.36s " PREFIXFMT " %4uB %-6.6s%5lu %-6.6s\n", + use_ncdirect_color(COLOR_YELLOW, 1); + qprefix(d->size, 1, buf, 0); + r += rr = printf("%-*.*s%-10.10s %-36.36s %*s %4uB %-6.6s%5lu %-6.6s\n", prefix,prefix,"", d->name, d->uuid ? d->uuid : "n/a", - qprefix(d->size,1,buf,0), + PREFIXFMT(buf), d->physsec, "n/a", - d->mddev.disks,d->mddev.level ? d->mddev.level : "n/a"); + d->mddev.disks, d->mddev.level ? d->mddev.level : "n/a"); if(rr < 0){ return -1; } @@ -806,8 +810,8 @@ zpool(wchar_t * const *args,const char *arghelp){ } return 0; } - printf("%-10.10s %-36.36s " PREFIXFMT " %5.5s %-6.6s%-6.6s%-6.6s\n", - "Device","UUID","Bytes","AShft","Fmt","Disks","Level"); + printf("%-10.10s %-36.36s %*s %5.5s %-6.6s%-6.6s%-6.6s\n", + "Device", "UUID", PREFIXFMT("Bytes"), "AShft", "Fmt", "Disks", "Level"); if(walk_devices(print_zpool,descend)){ return -1; } @@ -842,7 +846,7 @@ dm(wchar_t * const *args,const char *arghelp){ return 0; } /* - printf("%-10.10s %-36.36s " PREFIXFMT " %5.5s %-6.6s%-6.6s%-6.6s\n", + printf("%-10.10s %-36.36s %*s %5.5s %-6.6s%-6.6s%-6.6s\n", "Device","UUID","Bytes","PSect","Table","Disks","Level"); if(walk_devices(print_zpool,descend)){ return -1; @@ -869,8 +873,8 @@ mdadm(wchar_t * const *args,const char *arghelp){ usage(args,arghelp); return -1; } - printf("%-10.10s %-36.36s " PREFIXFMT " %5.5s %-6.6s%-6.6s%-6.6s\n", - "Device","UUID","Bytes","PSect","Table","Disks","Level"); + printf("%-10.10s %-36.36s %*s %5.5s %-6.6s%-6.6s%-6.6s\n", + "Device","UUID", PREFIXFMT("Bytes"), "PSect","Table","Disks","Level"); for(c = get_controllers() ; c ; c = c->next){ device *d; @@ -932,8 +936,8 @@ static inline int blockdev_dump(int descend){ const controller *c; - printf("%-10.10s %-16.16s %4.4s " PREFIXFMT " %5.5s Flags %-6.6s%-16.16s %-4.4s\n", - "Device","Model","Rev","Bytes","PSect","Table","WWN","PHY"); + printf("%-10.10s %-16.16s %4.4s %*s %5.5s Flags %-6.6s%-16.16s %-4.4s\n", + "Device","Model","Rev", PREFIXFMT("Bytes"),"PSect","Table","WWN","PHY"); for(c = get_controllers() ; c ; c = c->next){ const device *d; @@ -1115,7 +1119,7 @@ print_partition_types(void){ const ptype *pt; for(pt = ptypes ; pt->name ; ++pt){ - if(printf("%04x %-37.37s",pt->code,pt->name) < 0){ + if(printf("%04x %-37.37s", pt->code, pt->name) < 0){ return -1; } // FIXME if all zeros, don't print gpt guid @@ -1320,8 +1324,8 @@ partition(wchar_t * const *args,const char *arghelp){ usage(args,arghelp); return -1; } - printf("%-10.10s %-36.36s " PREFIXFMT " %-4.4s %s\n", - "Partition","UUID","Bytes","Role","Name"); + printf("%-10.10s %-36.36s %*s %-4.4s %s\n", + "Partition","UUID", PREFIXFMT("Bytes"), "Role", "Name"); for(c = get_controllers() ; c ; c = c->next){ const device *d; @@ -1343,9 +1347,9 @@ mounts(wchar_t * const *args,const char *arghelp){ const controller *c; ZERO_ARG_CHECK(args,arghelp); - printf("%-*.*s %-5.5s %-36.36s %s " PREFIXFMT "\n", + printf("%-*.*s %-5.5s %-36.36s %s %*s\n", FSLABELSIZ,FSLABELSIZ,"Label", - "Type","UUID","Device","Bytes"); + "Type","UUID","Device", PREFIXFMT("Bytes")); for(c = get_controllers() ; c ; c = c->next){ const device *d; @@ -1428,11 +1432,11 @@ print_swaps(const device *d,int descend){ if(d->swapprio == SWAP_INVALID){ return 0; } - r += rr = printf("%-*.*s %-5d %-36.36s %s " PREFIXFMT "\n", + qprefix(d->mntsize,1,buf,0); + r += rr = printf("%-*.*s %-5d %-36.36s %s %*s\n", FSLABELSIZ,FSLABELSIZ,d->label ? d->label : "n/a", d->swapprio,d->uuid ? d->uuid : "n/a", - d->name, - qprefix(d->mntsize,1,buf,0)); + d->name, PREFIXFMT(buf)); if(rr < 0){ return -1; } @@ -1441,9 +1445,9 @@ print_swaps(const device *d,int descend){ static inline int fs_dump(int descend){ - printf("%-*.*s %-5.5s %-36.36s %s " PREFIXFMT "\n", - FSLABELSIZ,FSLABELSIZ,"Label", - "Type","UUID","Device","Bytes"); + printf("%-*.*s %-5.5s %-36.36s %s %*s\n", + FSLABELSIZ, FSLABELSIZ, "Label", + "Type", "UUID", "Device", PREFIXFMT("Bytes")); if(walk_devices(print_fs,descend)){ return -1; } @@ -1544,11 +1548,11 @@ static int swap(wchar_t * const *args,const char *arghelp){ device *d; if(!args[1]){ - if(printf("%-*.*s %-5.5s %-36.36s %s " PREFIXFMT "\n",FSLABELSIZ,FSLABELSIZ, - "Label","Prio","UUID","Device","Bytes") < 0){ + if(printf("%-*.*s %-5.5s %-36.36s %s %*s\n", FSLABELSIZ, FSLABELSIZ, + "Label", "Prio", "UUID", "Device", PREFIXFMT("Bytes")) < 0){ return -1; } - if(walk_devices(print_swaps,0)){ + if(walk_devices(print_swaps, 0)){ return -1; } return 0; @@ -1557,16 +1561,16 @@ swap(wchar_t * const *args,const char *arghelp){ if((d = lookup_wdevice(args[2])) == NULL){ return -1; } - if(wcscmp(args[1],L"on") == 0){ + if(wcscmp(args[1], L"on") == 0){ if(swapondev(d)){ return -1; } - }else if(wcscmp(args[1],L"off") == 0){ + }else if(wcscmp(args[1], L"off") == 0){ if(swapoffdev(d)){ return -1; } }else{ - usage(args,arghelp); + usage(args, arghelp); return -1; } return 0; @@ -2192,7 +2196,7 @@ int main(int argc,char * const *argv){ if(isatty(STDOUT_FILENO)){ int errret; - if((ncdirect = notcurses_directmode(NULL, stdout)) == NULL){ + if((ncdirect = ncdirect_init(NULL, stdout)) == NULL){ fprintf(stderr, "Couldn't set up terminfo db (errret %d)\n", errret); } } diff --git a/test/growlight.c b/test/growlight.c deleted file mode 100644 index 01eba32f..00000000 --- a/test/growlight.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -static int -init_suite(void) { - return 0; -} - -static int -clean_suite(void) { - return 0; -} - -int main() { - unsigned failures; - CU_pSuite suite; - if(CUE_SUCCESS != CU_initialize_registry()){ - fprintf(stderr, "Couldn't initialize CUnit (%d)\n", CU_get_error()); - exit(EXIT_FAILURE); - } - if((suite = CU_add_suite(__FILE__, init_suite, clean_suite)) == NULL){ - fprintf(stderr, "Couldn't add CUnit suite %s (%d)\n", - __FILE__, CU_get_error()); - exit(EXIT_FAILURE); - } - CU_basic_set_mode(CU_BRM_VERBOSE); - if(CU_basic_run_tests()){ - fprintf(stderr, "Error %d running CUnit tests\n", CU_get_error()); - exit(EXIT_FAILURE); - } - failures = CU_get_number_of_failures(); - if(failures){ - fprintf(stderr, "Returning %d after %u test failure\n", - EXIT_FAILURE, failures); - exit(EXIT_FAILURE); - } - CU_cleanup_registry(); - return CU_get_error(); -}