From 7916b2eb3bb9ac164449e454440a64429e4feae1 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 5 Dec 2014 19:20:03 -0800 Subject: [PATCH] bcacheadm fixes Change-Id: I3f6024d54aee263ef843705a0e9a02869e2a53e9 --- Makefile | 19 ++++++++++++++----- bcache.c | 1 - bcacheadm.c | 16 +++++++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 5b95af19..cda51875 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,16 @@ PREFIX=/usr UDEVLIBDIR=/lib/udev DRACUTLIBDIR=/lib/dracut INSTALL=install -CFLAGS+=-O2 -Wall -Werror -g +CFLAGS+=-O2 -Wall -Werror -g -I. -all: make-bcache probe-bcache bcache-super-show bcachectl +all: bcacheadm make-bcache probe-bcache bcachectl -install: make-bcache probe-bcache bcache-super-show - $(INSTALL) -m0755 make-bcache bcache-super-show bcachectl $(DESTDIR)${PREFIX}/sbin/ +install: bcacheadm make-bcache probe-bcache + $(INSTALL) -m0755 bcacheadm bcachectl $(DESTDIR)${PREFIX}/sbin/ + $(INSTALL) -m0755 make-bcache bcachectl $(DESTDIR)${PREFIX}/sbin/ $(INSTALL) -m0755 probe-bcache bcache-register $(DESTDIR)$(UDEVLIBDIR)/ $(INSTALL) -m0644 69-bcache.rules $(DESTDIR)$(UDEVLIBDIR)/rules.d/ - -$(INSTALL) -T -m0755 initramfs/hook $(DESTDIR)/usr/share/initramfs-tools/hooks/bcache + #-$(INSTALL) -T -m0755 initramfs/hook $(DESTDIR)/usr/share/initramfs-tools/hooks/bcache if [ -d $(DESTDIR)$(DRACUTLIBDIR)/modules.d ]; \ then $(INSTALL) -D -m0755 dracut/module-setup.sh $(DESTDIR)$(DRACUTLIBDIR)/modules.d/90bcache/module-setup.sh; \ fi @@ -22,12 +23,20 @@ clean: $(RM) -f make-bcache probe-bcache bcache-super-show bcache-test bcachectl *.o bcache-test: LDLIBS += `pkg-config --libs openssl` + +bcacheadm: LDLIBS += `pkg-config --libs uuid blkid libnih` +bcacheadm: CFLAGS += `pkg-config --cflags uuid blkid libnih` +bcacheadm: bcache.o + make-bcache: LDLIBS += `pkg-config --libs uuid blkid` make-bcache: CFLAGS += `pkg-config --cflags uuid blkid` make-bcache: bcache.o + probe-bcache: LDLIBS += `pkg-config --libs uuid blkid` probe-bcache: CFLAGS += `pkg-config --cflags uuid blkid` + bcache-super-show: LDLIBS += `pkg-config --libs uuid` bcache-super-show: CFLAGS += -std=gnu99 bcache-super-show: bcache.o + bcachectl: bcachectl.o diff --git a/bcache.c b/bcache.c index 2c1f2322..7484f3d0 100644 --- a/bcache.c +++ b/bcache.c @@ -1042,7 +1042,6 @@ char *list_cachesets(char *cset_dir, bool list_devs) while ((ent = readdir(dir)) != NULL) { struct stat statbuf; char entry[MAX_PATH]; - struct dirent *cache_ent; if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) continue; diff --git a/bcacheadm.c b/bcacheadm.c index 913fcefd..11769d84 100644 --- a/bcacheadm.c +++ b/bcacheadm.c @@ -125,6 +125,8 @@ static int set_cache(NihOption *option, const char *arg) devs++; nr_cache_devices++; + + return 0; } static int set_bdev(NihOption *option, const char *arg) @@ -398,12 +400,14 @@ int bcache_query_devs(NihCommand *command, char *const *args) { int i; - for (i = 0; args[i] != NULL; i++){ + for (i = 0; args[i] != NULL; i++) { char dev_uuid[40]; query_dev(args[i], force_csum, true, uuid_only, dev_uuid); if(uuid_only) printf("%s\n", dev_uuid); } + + return 0; } int bcache_status(NihCommand *command, char *const *args) @@ -418,19 +422,23 @@ int bcache_status(NihCommand *command, char *const *args) sb->nr_this_dev; long long unsigned cache_tier = CACHE_TIER(m); - if (!cache_tier) + if (!cache_tier) { if (!sb_tier0 || sb->seq > sb_tier0->seq) { sb_tier0 = sb; dev0 = args[i]; } - else if (cache_tier == 1) + } else if (cache_tier == 1) { if (!sb_tier1 || sb->seq > sb_tier1->seq) { sb_tier1 = sb; dev1 = args[i]; } + } } + if (sb_tier0) sb_state(sb_tier0, dev0); if (sb_tier1) sb_state(sb_tier1, dev1); + + return 0; } static char *stats_subdir(char* stats_dir) @@ -562,4 +570,6 @@ int main(int argc, char *argv[]) exit (1); nih_signal_reset(); + + return 0; }