Btrfs-progs: make some subdirs
Subsystems (2)
cover Btrfs-progs: make some subdirs
These are some patches I've been sitting on for a while that I think clean up the btrfs-progs tree a bit; there are still quite a few files left in the top-level dir, but moving tests & cmd files into cmd/ seems to clean things up a bit. Curious to see what people think.
This is just file-moves and makefile-mangling, no code changes.
(a common/ or similar later on to hold kernel copies would probably be the next move if this all looks reasonable)
Thanks,
-Eric
[PATCH 1/3] Btrfs-progs: Add Makefile infrastructure for subdirs [PATCH 2/3] Btrfs-progs: move test tools to tests/ subdir [PATCH 3/3] Btrfs-progs: move btrfs cmd files to cmd/ subdir
PATCH 1/3 Btrfs-progs: Add Makefile infrastructure for subdirs
Preparatory patch to move cmd & test files into their own subdirs.
--- Makefile | 38 +++++++++++++++++++++++++++++++------- man/Makefile | 1 - 2 files changed, 31 insertions(+), 8 deletions(-)
Makefile +31 -7
@@ -1,3 +1,6 @@ +# Export all variables to sub-makes by default +export + CC = gcc LN = ln AR = ar
@@ -53,6 +56,18 @@ btrfs_convert_libs = -lext2fs -lcom_err btrfs_image_libs = -lpthread btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype +SUBDIRS = man +BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) +INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) +CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) + +.PHONY: $(SUBDIRS) +.PHONY: $(BUILDDIRS) +.PHONY: $(INSTALLDIRS) +.PHONY: $(TESTDIRS) +.PHONY: $(CLEANDIRS) +.PHONY: all install clean + # Create all the static targets static_objects = $(patsubst %.o, %.static.o, $(objects)) static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
@@ -85,7 +100,11 @@ endif @echo " [CC] $@" $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@ -all: version.h $(progs) manpages +all: version.h $(progs) $(BUILDDIRS) +$(SUBDIRS): $(BUILDDIRS) +$(BUILDDIRS): + @echo "Making all in $(patsubst build-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@) # # NOTE: For static compiles, you need to have all the required libs
@@ -178,19 +197,19 @@ send-test: $(objects) $(libs) send-test.o manpages: $(Q)$(MAKE) $(MAKEOPTS) -C man -install-man: - cd man; $(MAKE) install - -clean : +clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ btrfs-zero-log btrfstune dir-test ioctl-test quick-test send-test btrfsck \ btrfs.static mkfs.btrfs.static btrfs-calc-size \ version.h \ $(libs) $(lib_links) - $(Q)$(MAKE) $(MAKEOPTS) -C man $@ -install: $(libs) $(progs) install-man +$(CLEANDIRS): + @echo "Cleaning $(patsubst clean-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean + +install: $(libs) $(progs) $(INSTALLDIRS) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs) $(DESTDIR)$(bindir) # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
@@ -201,4 +220,9 @@ install: $(libs) $(progs) install-man $(INSTALL) -m755 -d $(DESTDIR)$(incdir) $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir) +$(INSTALLDIRS): + @echo "Making install in $(patsubst install-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install + + -include .*.d
man/Makefile +0 -1
@@ -21,7 +21,6 @@ all: $(MANPAGES) $(Q)$(GZIPCMD) -n -c $< > $@ clean : - @echo "Cleaning manpages" $(Q)rm -f $(MANPAGES) install: $(MANPAGES)
Signature · 1 line
1.7.1
Re: [PATCH 1/3] Btrfs-progs: Add Makefile infrastructure for subdirs
Quoted 2 lines · Eric Sandeen
Preparatory patch to move cmd & test files into their own subdirs.
I'm adding this to integration as it's just an infrastructure change, but there are some bits missing before we can move more .c files into their own subdirs. More under 'move files to tests/' patch.
david
PATCH 2/3 Btrfs-progs: move test tools to tests/ subdir
In reply to Eric SandeenMove test tools to tests/
--- Makefile | 23 +-------- tests/Makefile | 49 ++++++++++++++++++++ .../btrfs-corrupt-block.c | 0 dir-test.c => tests/dir-test.c | 0 ioctl-test.c => tests/ioctl-test.c | 0 quick-test.c => tests/quick-test.c | 0 random-test.c => tests/random-test.c | 0 send-test.c => tests/send-test.c | 0 8 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 tests/Makefile rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%) rename dir-test.c => tests/dir-test.c (100%) rename ioctl-test.c => tests/ioctl-test.c (100%) rename quick-test.c => tests/quick-test.c (100%) rename random-test.c => tests/random-test.c (100%) rename send-test.c => tests/send-test.c (100%)
Makefile +3 -20
@@ -56,7 +56,7 @@ btrfs_convert_libs = -lext2fs -lcom_err btrfs_image_libs = -lpthread btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype -SUBDIRS = man +SUBDIRS = man tests BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
@@ -102,7 +102,7 @@ endif all: version.h $(progs) $(BUILDDIRS) $(SUBDIRS): $(BUILDDIRS) -$(BUILDDIRS): +$(BUILDDIRS): $(libs) @echo "Making all in $(patsubst build-%,%,$@)" $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
@@ -178,30 +178,13 @@ btrfstune: $(objects) $(libs) btrfstune.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) -dir-test: $(objects) $(libs) dir-test.o - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) - -quick-test: $(objects) $(libs) quick-test.o - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS) - -ioctl-test: $(objects) $(libs) ioctl-test.o - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) - -send-test: $(objects) $(libs) send-test.o - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread - manpages: $(Q)$(MAKE) $(MAKEOPTS) -C man clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune dir-test ioctl-test quick-test send-test btrfsck \ - btrfs.static mkfs.btrfs.static btrfs-calc-size \ + btrfs-zero-log btrfstune btrfsck btrfs.static mkfs.btrfs.static btrfs-calc-size \ version.h \ $(libs) $(lib_links)
tests/Makefile new file +49 -0
49 lines not on this page · raw message
tests/btrfs-corrupt-block.c renamed from btrfs-corrupt-block.c +0 -0
tests/dir-test.c renamed from dir-test.c +0 -0
tests/ioctl-test.c renamed from ioctl-test.c +0 -0
tests/quick-test.c renamed from quick-test.c +0 -0
tests/random-test.c renamed from random-test.c +0 -0
tests/send-test.c renamed from send-test.c +0 -0
Signature · 1 line
1.7.1
Re: [PATCH 2/3] Btrfs-progs: move test tools to tests/ subdir
Quoted 3 lines · Eric Sandeen
Move test tools to tests/
rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%)
IMO this is not a test by itself, so it should stay in the toplevel dir.
tests/Makefile
Quoted 3 lines
tests/Makefile new file +0
-0@@ -0,0 +1,49 @@
eg.
TOPLEVEL = ..
tests/Makefile line 1
Quoted 1 line
tests/Makefile new file +1
-0+CFLAGS += -I..
CFLAGS += -I$(TOPLEVEL)
tests/Makefile line 3
Quoted 2 lines
tests/Makefile new file +2
-0+ +objects := $(addprefix ../, $(objects))
etc. s/../$(TOPLEVEL)
tests/Makefile line 14
Quoted 11 lines
tests/Makefile new file +11
-0+ +lib_LIBS = -lblkid -luuid +LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static)) + +# These last 2 don't actually build anymore +progs = btrfs-corrupt-block ioctl-test quick-test send-test # random-test dir-test + +libs_static = libbtrfs.a +libs = $(addprefix ../, $(libs_static)) +headers = $(libbtrfs_headers) +
the default rule belongs here, ie
all: $(progs)
Otherwise 'make' in the tests/ subdir will try to execute the first .c file it needs to build.
tests/Makefile line 18
Quoted 4 lines
tests/Makefile new file +4
-0+.c.o: + $(Q)$(check) $< + @echo " [CC] $@" + $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
Until now we've had only man/ and it does not compile anything, now tests/ duplicate the .c.o: rule. The rules are not exported to subdirs, we need either to duplicate it in every subdir/Makefile or have something like Makefile.rules or builddefs, and each Makefile has to keep track back to the toplevel dir. We want to be able to 'make tests' but also just 'make' in the tests/ directory -- which does not work right now.
tests/Makefile line 49
Quoted 8 lines
tests/Makefile new file +7
-0+ +all: $(progs) + +clean : + $(Q)rm -f *.o .*.d $(progs) + +-include .*.d
This should probably look like the update in the toplevel makefile:
ifneq ($(MAKECMDGOALS),clean)
-include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d))) endif
and for the clean: rule a minor update: the .d files do not start with '.'. (Both introduced in "btrfs-progs: Fix automatic prerequisite generation")
Let's start with moving just the tests, see how the makefiles work and then proceed with cmds/ and the shared kernel files.
david
Re: [PATCH 2/3] Btrfs-progs: move test tools to tests/ subdir
Quoted 6 lines · David Sterba
Quoted 3 lines · Eric Sandeen
Move test tools to tests/
rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%)IMO this is not a test by itself, so it should stay in the toplevel dir.
Hum, well, it has a main() - ok, not a test, but a tool used for testing? Ok, fine. Maybe misc/ someday ;)
Quoted 7 lines
tests/Makefile
Quoted 4 lines
tests/Makefile new file +0
-0@@ -0,0 +1,49 @@eg.
TOPLEVEL = ..
Quoted 7 lines
tests/Makefile line 1
Quoted 1 line
tests/Makefile new file +1
-0+CFLAGS += -I..CFLAGS += -I$(TOPLEVEL)
tests/Makefile line 3
Quoted 2 lines
tests/Makefile new file +2
-0+ +objects := $(addprefix ../, $(objects))etc. s/../$(TOPLEVEL)
Ok, that's probably good.
Quoted 18 lines
tests/Makefile line 14
Quoted 11 lines
tests/Makefile new file +11
-0+ +lib_LIBS = -lblkid -luuid +LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static)) + +# These last 2 don't actually build anymore +progs = btrfs-corrupt-block ioctl-test quick-test send-test # random-test dir-test + +libs_static = libbtrfs.a +libs = $(addprefix ../, $(libs_static)) +headers = $(libbtrfs_headers) +the default rule belongs here, ie
all: $(progs)Otherwise 'make' in the tests/ subdir will try to execute the first .c file it needs to build.
Quoted 12 lines
tests/Makefile line 18
Quoted 4 lines
tests/Makefile new file +4
-0+.c.o: + $(Q)$(check) $< + @echo " [CC] $@" + $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<Until now we've had only man/ and it does not compile anything, now tests/ duplicate the .c.o: rule. The rules are not exported to subdirs, we need either to duplicate it in every subdir/Makefile or have something like Makefile.rules or builddefs, and each
Makefilehas to keep track back to the toplevel dir. We want to be able to 'make tests' but also just 'make' in the tests/ directory -- which does not work right now.
*nod* ok. It's been a while since I did make hacking, sorry.
Quoted 15 lines
tests/Makefile line 49
Quoted 8 lines
tests/Makefile new file +7
-0+ +all: $(progs) + +clean : + $(Q)rm -f *.o .*.d $(progs) + +-include .*.dThis should probably look like the update in the toplevel makefile:
ifneq ($(MAKECMDGOALS),clean)
-include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d))) endif
Quoted 5 lines
and for the clean: rule a minor update: the .d files do not start with '.'. (Both introduced in "btrfs-progs: Fix automatic prerequisite generation")
Let's start with moving just the tests, see how the makefiles work and then proceed with cmds/ and the shared kernel files.
Sounds like a plan.
thanks for the review,
-Eric
Quoted 3 lines
david
PATCH 3/3 Btrfs-progs: move btrfs cmd files to cmd/ subdir
In reply to Eric SandeenMove btrfs cmd files to cmd/ subdir
--- Makefile | 38 ++++++----------- cmd/Makefile | 61 ++++++++++++++++++++++++++++ btrfs.c => cmd/btrfs.c | 0 cmds-balance.c => cmd/cmds-balance.c | 0 cmds-check.c => cmd/cmds-check.c | 0 cmds-device.c => cmd/cmds-device.c | 0 cmds-filesystem.c => cmd/cmds-filesystem.c | 0 cmds-inspect.c => cmd/cmds-inspect.c | 0 cmds-qgroup.c => cmd/cmds-qgroup.c | 0 cmds-quota.c => cmd/cmds-quota.c | 0 cmds-receive.c => cmd/cmds-receive.c | 0 cmds-replace.c => cmd/cmds-replace.c | 0 cmds-restore.c => cmd/cmds-restore.c | 0 cmds-scrub.c => cmd/cmds-scrub.c | 0 cmds-send.c => cmd/cmds-send.c | 0 cmds-subvolume.c => cmd/cmds-subvolume.c | 0 help.c => cmd/help.c | 0 17 files changed, 74 insertions(+), 25 deletions(-) create mode 100644 cmd/Makefile rename btrfs.c => cmd/btrfs.c (100%) rename cmds-balance.c => cmd/cmds-balance.c (100%) rename cmds-check.c => cmd/cmds-check.c (100%) rename cmds-device.c => cmd/cmds-device.c (100%) rename cmds-filesystem.c => cmd/cmds-filesystem.c (100%) rename cmds-inspect.c => cmd/cmds-inspect.c (100%) rename cmds-qgroup.c => cmd/cmds-qgroup.c (100%) rename cmds-quota.c => cmd/cmds-quota.c (100%) rename cmds-receive.c => cmd/cmds-receive.c (100%) rename cmds-replace.c => cmd/cmds-replace.c (100%) rename cmds-restore.c => cmd/cmds-restore.c (100%) rename cmds-scrub.c => cmd/cmds-scrub.c (100%) rename cmds-send.c => cmd/cmds-send.c (100%) rename cmds-subvolume.c => cmd/cmds-subvolume.c (100%) rename help.c => cmd/help.c (100%)
Makefile +13 -25
@@ -10,10 +10,6 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ extent-cache.o extent_io.o volumes.o utils.o repair.o \ qgroup.o raid6.o free-space-cache.o -cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ - cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ - cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ - cmds-restore.o libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
@@ -46,8 +42,8 @@ endif MAKEOPTS = --no-print-directory Q=$(Q) -progs = mkfs.btrfs btrfs-debug-tree btrfsck \ - btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ +progs = mkfs.btrfs btrfs-debug-tree \ + btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ btrfs-find-root btrfstune btrfs-show-super # external libs required by various binaries; for btrfs-foo,
@@ -56,13 +52,17 @@ btrfs_convert_libs = -lext2fs -lcom_err btrfs_image_libs = -lpthread btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype -SUBDIRS = man tests +SUBDIRS = cmd man tests +STATIC_SUBDIRS = cmd BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) +STATIC_BUILDDIRS = $(patsubst %,buildstatic-%,$(STATIC_SUBDIRS)) INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) .PHONY: $(SUBDIRS) +.PHONY: $(STATIC_SUBDIRS) .PHONY: $(BUILDDIRS) +.PHONY: $(STATIC_BUILDDIRS) .PHONY: $(INSTALLDIRS) .PHONY: $(TESTDIRS) .PHONY: $(CLEANDIRS)
@@ -70,7 +70,6 @@ CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) # Create all the static targets static_objects = $(patsubst %.o, %.static.o, $(objects)) -static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects)) static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects)) # Define static compilation flags
@@ -110,7 +109,11 @@ $(BUILDDIRS): $(libs) # NOTE: For static compiles, you need to have all the required libs # static equivalent available # -static: version.h btrfs.static mkfs.btrfs.static btrfs-find-root.static +static: version.h mkfs.btrfs.static btrfs-find-root.static $(STATIC_BUILDDIRS) +$(STATIC_SUBDIRS): $(STATIC_BUILDDIRS) +$(STATIC_BUILDDIRS): $(static_objects) $(static_libbtrfs_objects) + @echo "Making static in $(patsubst buildstatic-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst buildstatic-%,%,$@) static version.h: @echo " [SH] $@"
@@ -150,21 +153,6 @@ btrfs-%: version.h $(objects) $(libs) btrfs-%.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o $@ $(objects) [email protected] $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs)) -btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs) - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \ - $(objects) $(LDFLAGS) $(LIBS) -lpthread - -btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects) - @echo " [LD] $@" - $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o help.static.o $(static_cmds_objects) \ - $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) - -# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck' -btrfsck: btrfs - @echo " [LN] $@" - $(Q)$(LN) -f btrfs btrfsck - mkfs.btrfs: $(objects) $(libs) mkfs.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
@@ -184,7 +172,7 @@ manpages: clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune btrfsck btrfs.static mkfs.btrfs.static btrfs-calc-size \ + btrfs-zero-log btrfstune mkfs.btrfs.static btrfs-calc-size \ version.h \ $(libs) $(lib_links)
cmd/Makefile new file +61 -0
61 lines not on this page · raw message
cmd/btrfs.c renamed from btrfs.c +0 -0
cmd/cmds-balance.c renamed from cmds-balance.c +0 -0
cmd/cmds-check.c renamed from cmds-check.c +0 -0
cmd/cmds-device.c renamed from cmds-device.c +0 -0
cmd/cmds-filesystem.c renamed from cmds-filesystem.c +0 -0
cmd/cmds-inspect.c renamed from cmds-inspect.c +0 -0
cmd/cmds-qgroup.c renamed from cmds-qgroup.c +0 -0
cmd/cmds-quota.c renamed from cmds-quota.c +0 -0
cmd/cmds-receive.c renamed from cmds-receive.c +0 -0
cmd/cmds-replace.c renamed from cmds-replace.c +0 -0
cmd/cmds-restore.c renamed from cmds-restore.c +0 -0
cmd/cmds-scrub.c renamed from cmds-scrub.c +0 -0
cmd/cmds-send.c renamed from cmds-send.c +0 -0
cmd/cmds-subvolume.c renamed from cmds-subvolume.c +0 -0
cmd/help.c renamed from help.c +0 -0
Signature · 1 line
1.7.1
Re: [PATCH 3/3] Btrfs-progs: move btrfs cmd files to cmd/ subdir
Quoted 3 lines · Eric Sandeen
Move btrfs cmd files to cmd/ subdir
Signed-off-by Eric Sandeen <[email protected]>
crud just realized this doesn't DTRT w/ btrfsck links, will have to send a V2 for this one I guess.
-Eric
Quoted 261 lines
--- Makefile | 38 ++++++----------- cmd/Makefile | 61 ++++++++++++++++++++++++++++ btrfs.c => cmd/btrfs.c | 0 cmds-balance.c => cmd/cmds-balance.c | 0 cmds-check.c => cmd/cmds-check.c | 0 cmds-device.c => cmd/cmds-device.c | 0 cmds-filesystem.c => cmd/cmds-filesystem.c | 0 cmds-inspect.c => cmd/cmds-inspect.c | 0 cmds-qgroup.c => cmd/cmds-qgroup.c | 0 cmds-quota.c => cmd/cmds-quota.c | 0 cmds-receive.c => cmd/cmds-receive.c | 0 cmds-replace.c => cmd/cmds-replace.c | 0 cmds-restore.c => cmd/cmds-restore.c | 0 cmds-scrub.c => cmd/cmds-scrub.c | 0 cmds-send.c => cmd/cmds-send.c | 0 cmds-subvolume.c => cmd/cmds-subvolume.c | 0 help.c => cmd/help.c | 0 17 files changed, 74 insertions(+), 25 deletions(-) create mode 100644 cmd/Makefile rename btrfs.c => cmd/btrfs.c (100%) rename cmds-balance.c => cmd/cmds-balance.c (100%) rename cmds-check.c => cmd/cmds-check.c (100%) rename cmds-device.c => cmd/cmds-device.c (100%) rename cmds-filesystem.c => cmd/cmds-filesystem.c (100%) rename cmds-inspect.c => cmd/cmds-inspect.c (100%) rename cmds-qgroup.c => cmd/cmds-qgroup.c (100%) rename cmds-quota.c => cmd/cmds-quota.c (100%) rename cmds-receive.c => cmd/cmds-receive.c (100%) rename cmds-replace.c => cmd/cmds-replace.c (100%) rename cmds-restore.c => cmd/cmds-restore.c (100%) rename cmds-scrub.c => cmd/cmds-scrub.c (100%) rename cmds-send.c => cmd/cmds-send.c (100%) rename cmds-subvolume.c => cmd/cmds-subvolume.c (100%) rename help.c => cmd/help.c (100%)Makefile +13
-25@@ -10,10 +10,6 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ extent-cache.o extent_io.o volumes.o utils.o repair.o \ qgroup.o raid6.o free-space-cache.o -cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ - cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ - cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ - cmds-restore.o libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \@@ -46,8 +42,8 @@ endif MAKEOPTS = --no-print-directory Q=$(Q) -progs = mkfs.btrfs btrfs-debug-tree btrfsck \ - btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ +progs = mkfs.btrfs btrfs-debug-tree \ + btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ btrfs-find-root btrfstune btrfs-show-super # external libs required by various binaries; for btrfs-foo,@@ -56,13 +52,17 @@ btrfs_convert_libs = -lext2fs -lcom_err btrfs_image_libs = -lpthread btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype -SUBDIRS = man tests +SUBDIRS = cmd man tests +STATIC_SUBDIRS = cmd BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) +STATIC_BUILDDIRS = $(patsubst %,buildstatic-%,$(STATIC_SUBDIRS)) INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) .PHONY: $(SUBDIRS) +.PHONY: $(STATIC_SUBDIRS) .PHONY: $(BUILDDIRS) +.PHONY: $(STATIC_BUILDDIRS) .PHONY: $(INSTALLDIRS) .PHONY: $(TESTDIRS) .PHONY: $(CLEANDIRS)@@ -70,7 +70,6 @@ CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) # Create all the static targets static_objects = $(patsubst %.o, %.static.o, $(objects)) -static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects)) static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects)) # Define static compilation flags@@ -110,7 +109,11 @@ $(BUILDDIRS): $(libs) # NOTE: For static compiles, you need to have all the required libs # static equivalent available # -static: version.h btrfs.static mkfs.btrfs.static btrfs-find-root.static +static: version.h mkfs.btrfs.static btrfs-find-root.static $(STATIC_BUILDDIRS) +$(STATIC_SUBDIRS): $(STATIC_BUILDDIRS) +$(STATIC_BUILDDIRS): $(static_objects) $(static_libbtrfs_objects) + @echo "Making static in $(patsubst buildstatic-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst buildstatic-%,%,$@) static version.h: @echo " [SH] $@"@@ -150,21 +153,6 @@ btrfs-%: version.h $(objects) $(libs) btrfs-%.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o $@ $(objects) [email protected] $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs)) -btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs) - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \ - $(objects) $(LDFLAGS) $(LIBS) -lpthread - -btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects) - @echo " [LD] $@" - $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o help.static.o $(static_cmds_objects) \ - $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) - -# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck' -btrfsck: btrfs - @echo " [LN] $@" - $(Q)$(LN) -f btrfs btrfsck - mkfs.btrfs: $(objects) $(libs) mkfs.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)@@ -184,7 +172,7 @@ manpages: clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune btrfsck btrfs.static mkfs.btrfs.static btrfs-calc-size \ + btrfs-zero-log btrfstune mkfs.btrfs.static btrfs-calc-size \ version.h \ $(libs) $(lib_links)cmd/Makefile new file +61
-0@@ -0,0 +1,61 @@ +CFLAGS += -I.. + +cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ + cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ + cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ + cmds-restore.o +objects := $(addprefix ../, $(objects)) +static_objects = $(patsubst %.o, %.static.o, $(objects)) + +progs = btrfs + +lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L. +LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static)) + +libs_static = libbtrfs.a +libs = $(addprefix ../, $(libs_static)) + +.c.o: + $(Q)$(check) $< + @echo " [CC] $@" + $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $< + +%.static.o: %.c + @echo " [CC] $@" + $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@ + +all: $(progs) + +# +# NOTE: For static compiles, you need to have all the required libs +# static equivalent available +# +static: btrfs.static + +btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs) + @echo " [LD] $@" + $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \ + $(objects) $(LDFLAGS) $(LIBS) -lpthread + +btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects) + @echo " [LD] $@" + $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o help.static.o $(static_cmds_objects) \ + $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) + +# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck' +btrfsck: btrfs + @echo " [LN] $@" + $(Q)$(LN) -f btrfs btrfsck + +clean: + $(Q)rm -f *.o .*.d $(progs) + +install: $(libs) $(progs) $(INSTALLDIRS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(progs) $(DESTDIR)$(bindir) + +$(INSTALLDIRS): + $(Q)$(MAKE) $(MAKEOPTS) -C $(@:install-%=%) install + + +-include .*.dcmd/btrfs.c renamed from btrfs.c +0
-0cmd/cmds-balance.c renamed from cmds-balance.c +0
-0cmd/cmds-check.c renamed from cmds-check.c +0
-0cmd/cmds-device.c renamed from cmds-device.c +0
-0cmd/cmds-filesystem.c renamed from cmds-filesystem.c +0
-0cmd/cmds-inspect.c renamed from cmds-inspect.c +0
-0cmd/cmds-qgroup.c renamed from cmds-qgroup.c +0
-0cmd/cmds-quota.c renamed from cmds-quota.c +0
-0cmd/cmds-receive.c renamed from cmds-receive.c +0
-0cmd/cmds-replace.c renamed from cmds-replace.c +0
-0cmd/cmds-restore.c renamed from cmds-restore.c +0
-0cmd/cmds-scrub.c renamed from cmds-scrub.c +0
-0cmd/cmds-send.c renamed from cmds-send.c +0
-0cmd/cmds-subvolume.c renamed from cmds-subvolume.c +0
-0cmd/help.c renamed from help.c +0
-0
PATCH v2 3/3 Btrfs-progs: move btrfs cmd files to cmd/ subdir
In reply to Eric SandeenMove btrfs cmd files to cmd/ subdir
---
V2: move btrfsck symlink handling to cmd/Makefile too
Makefile | 38 ++++++----------- cmd/Makefile | 61 ++++++++++++++++++++++++++++ btrfs.c => cmd/btrfs.c | 0 cmds-balance.c => cmd/cmds-balance.c | 0 cmds-check.c => cmd/cmds-check.c | 0 cmds-device.c => cmd/cmds-device.c | 0 cmds-filesystem.c => cmd/cmds-filesystem.c | 0 cmds-inspect.c => cmd/cmds-inspect.c | 0 cmds-qgroup.c => cmd/cmds-qgroup.c | 0 cmds-quota.c => cmd/cmds-quota.c | 0 cmds-receive.c => cmd/cmds-receive.c | 0 cmds-replace.c => cmd/cmds-replace.c | 0 cmds-restore.c => cmd/cmds-restore.c | 0 cmds-scrub.c => cmd/cmds-scrub.c | 0 cmds-send.c => cmd/cmds-send.c | 0 cmds-subvolume.c => cmd/cmds-subvolume.c | 0 help.c => cmd/help.c | 0 17 files changed, 74 insertions(+), 25 deletions(-) create mode 100644 cmd/Makefile rename btrfs.c => cmd/btrfs.c (100%) rename cmds-balance.c => cmd/cmds-balance.c (100%) rename cmds-check.c => cmd/cmds-check.c (100%) rename cmds-device.c => cmd/cmds-device.c (100%) rename cmds-filesystem.c => cmd/cmds-filesystem.c (100%) rename cmds-inspect.c => cmd/cmds-inspect.c (100%) rename cmds-qgroup.c => cmd/cmds-qgroup.c (100%) rename cmds-quota.c => cmd/cmds-quota.c (100%) rename cmds-receive.c => cmd/cmds-receive.c (100%) rename cmds-replace.c => cmd/cmds-replace.c (100%) rename cmds-restore.c => cmd/cmds-restore.c (100%) rename cmds-scrub.c => cmd/cmds-scrub.c (100%) rename cmds-send.c => cmd/cmds-send.c (100%) rename cmds-subvolume.c => cmd/cmds-subvolume.c (100%) rename help.c => cmd/help.c (100%)
Makefile +13 -27
@@ -10,10 +10,6 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ extent-cache.o extent_io.o volumes.o utils.o repair.o \ qgroup.o raid6.o free-space-cache.o -cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ - cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ - cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ - cmds-restore.o libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
@@ -46,8 +42,8 @@ endif MAKEOPTS = --no-print-directory Q=$(Q) -progs = mkfs.btrfs btrfs-debug-tree btrfsck \ - btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ +progs = mkfs.btrfs btrfs-debug-tree \ + btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ btrfs-find-root btrfstune btrfs-show-super # external libs required by various binaries; for btrfs-foo,
@@ -56,13 +52,17 @@ btrfs_convert_libs = -lext2fs -lcom_err btrfs_image_libs = -lpthread btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype -SUBDIRS = man tests +SUBDIRS = cmd man tests +STATIC_SUBDIRS = cmd BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) +STATIC_BUILDDIRS = $(patsubst %,buildstatic-%,$(STATIC_SUBDIRS)) INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) .PHONY: $(SUBDIRS) +.PHONY: $(STATIC_SUBDIRS) .PHONY: $(BUILDDIRS) +.PHONY: $(STATIC_BUILDDIRS) .PHONY: $(INSTALLDIRS) .PHONY: $(TESTDIRS) .PHONY: $(CLEANDIRS)
@@ -70,7 +70,6 @@ CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) # Create all the static targets static_objects = $(patsubst %.o, %.static.o, $(objects)) -static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects)) static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects)) # Define static compilation flags
@@ -110,7 +109,11 @@ $(BUILDDIRS): $(libs) # NOTE: For static compiles, you need to have all the required libs # static equivalent available # -static: version.h btrfs.static mkfs.btrfs.static btrfs-find-root.static +static: version.h mkfs.btrfs.static btrfs-find-root.static $(STATIC_BUILDDIRS) +$(STATIC_SUBDIRS): $(STATIC_BUILDDIRS) +$(STATIC_BUILDDIRS): $(static_objects) $(static_libbtrfs_objects) + @echo "Making static in $(patsubst buildstatic-%,%,$@)" + $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst buildstatic-%,%,$@) static version.h: @echo " [SH] $@"
@@ -150,21 +153,6 @@ btrfs-%: version.h $(objects) $(libs) btrfs-%.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o $@ $(objects) [email protected] $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs)) -btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs) - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \ - $(objects) $(LDFLAGS) $(LIBS) -lpthread - -btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects) - @echo " [LD] $@" - $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o help.static.o $(static_cmds_objects) \ - $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) - -# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck' -btrfsck: btrfs - @echo " [LN] $@" - $(Q)$(LN) -f btrfs btrfsck - mkfs.btrfs: $(objects) $(libs) mkfs.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
@@ -184,7 +172,7 @@ manpages: clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune btrfsck btrfs.static mkfs.btrfs.static btrfs-calc-size \ + btrfs-zero-log btrfstune mkfs.btrfs.static btrfs-calc-size \ version.h \ $(libs) $(lib_links)
@@ -195,8 +183,6 @@ $(CLEANDIRS): install: $(libs) $(progs) $(INSTALLDIRS) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs) $(DESTDIR)$(bindir) - # btrfsck is a link to btrfs in the src tree, make it so for installed file as well - $(LN) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck $(INSTALL) -m755 -d $(DESTDIR)$(libdir) $(INSTALL) $(libs) $(DESTDIR)$(libdir) cp -a $(lib_links) $(DESTDIR)$(libdir)
cmd/Makefile new file +63 -0
63 lines not on this page · raw message
cmd/btrfs.c renamed from btrfs.c +0 -0
cmd/cmds-balance.c renamed from cmds-balance.c +0 -0
cmd/cmds-check.c renamed from cmds-check.c +0 -0
cmd/cmds-device.c renamed from cmds-device.c +0 -0
cmd/cmds-filesystem.c renamed from cmds-filesystem.c +0 -0
cmd/cmds-inspect.c renamed from cmds-inspect.c +0 -0
cmd/cmds-qgroup.c renamed from cmds-qgroup.c +0 -0
cmd/cmds-quota.c renamed from cmds-quota.c +0 -0
cmd/cmds-receive.c renamed from cmds-receive.c +0 -0
cmd/cmds-replace.c renamed from cmds-replace.c +0 -0
cmd/cmds-restore.c renamed from cmds-restore.c +0 -0
cmd/cmds-scrub.c renamed from cmds-scrub.c +0 -0
cmd/cmds-send.c renamed from cmds-send.c +0 -0
cmd/cmds-subvolume.c renamed from cmds-subvolume.c +0 -0
cmd/help.c renamed from help.c +0 -0
---
1.7.1
Re: [PATCH 3/3 V2] Btrfs-progs: move btrfs cmd files to cmd/ subdir
Quoted 1 line · Eric Sandeen
Move btrfs cmd files to cmd/ subdir
Are you ok with naming the subdirectory 'cmds'?
david
Re: [PATCH 3/3 V2] Btrfs-progs: move btrfs cmd files to cmd/ subdir
Quoted 7 lines · David Sterba
Quoted 1 line · Eric Sandeen
Move btrfs cmd files to cmd/ subdir
Are you ok with naming the subdirectory 'cmds'?
david
yep! That's the _last_ bike shed I want to paint. ;)
I had picked "cmd" because they are for the btrfs command (singular), but *shrug* - it really doesn't matter to me.
-Eric
Quoted 4 lines · Eric Sandeen
These are some patches I've been sitting on for a while that I think clean up the btrfs-progs tree a bit; there are still quite a few files left in the top-level dir, but moving tests & cmd files into cmd/ seems to clean things up a bit. Curious to see what people think.
Seems reasonable to me.
Quoted 1 line
This is just file-moves and makefile-mangling, no code changes.
I guess .gitignore should also be updated.
Quoted 2 lines
(a common/ or similar later on to hold kernel copies would probably be the next move if this all looks reasonable)
kernel_import_no_touching/ ? :)
- z
Quoting Zach Brown (2013-06-11 19:24:46)
Quoted 8 lines · Eric Sandeen
Quoted 4 lines
These are some patches I've been sitting on for a while that I think clean up the btrfs-progs tree a bit; there are still quite a few files left in the top-level dir, but moving tests & cmd files into cmd/ seems to clean things up a bit. Curious to see what people think.
Seems reasonable to me.
Quoted 8 lines
Quoted 1 line
This is just file-moves and makefile-mangling, no code changes.
I guess .gitignore should also be updated.
Quoted 2 lines
(a common/ or similar later on to hold kernel copies would probably be the next move if this all looks reasonable)
kernel_import_no_touching/ ? :)
dangerdonteverchange?
I'd actually just go for kernel_import. It would be nice if git had a way to make the files readonly.
-chris
[PATCH 4/3] Btrfs-progs: fix up .gitignore
In reply to Eric SandeenFix .gitignore for new file locations.
---
(could update other patches rather than add 4th if it's better)
.gitignore +9 -8
@@ -4,17 +4,10 @@ version.h version man/*.gz -btrfs -btrfs.static btrfs-debug-tree btrfs-map-logical btrfs-fragments -btrfsck calc-size -ioctl-test -dir-test -send-test -quick-test find-root mkfs.btrfs mkfs.btrfs.static
@@ -26,10 +19,18 @@ btrfs-find-root.static btrfs-image btrfs-show-super btrfs-zero-log -btrfs-corrupt-block btrfs-select-super btrfstune libbtrfs.a libbtrfs.so libbtrfs.so.0 libbtrfs.so.0.1 +cmd/btrfs +cmd/btrfs.static +cmd/btrfsck +tests/btrfs-corrupt-block +tests/dir-test +tests/ioctl-test +tests/quick-test +tests/random-test +tests/send-test