-DNO_BCACHEFS_CHARDEV \
-DNO_BCACHEFS_FS \
-DNO_BCACHEFS_SYSFS \
+ -DVERSION_STRING='"$(VERSION)"' \
$(EXTRA_CFLAGS)
LDFLAGS+=$(CFLAGS)
+VERSION?=$(shell git describe --long --dirty 2>/dev/null || echo 0.1-nogit)
+
CC_VERSION=$(shell $(CC) -v 2>&1|grep -E '(gcc|clang) version')
ifneq (,$(findstring gcc,$(CC_VERSION)))
OBJS=$(SRCS:.c=.o)
bcachefs: $(OBJS)
+# If the version string differs from the last build, update the last version
+ifneq ($(VERSION),$(shell cat .version 2>/dev/null))
+.PHONY: .version
+endif
+.version:
+ echo '$(VERSION)' > $@
+
+# Rebuild the 'version' command any time the version string changes
+cmd_version.o : .version
+
.PHONY: install
install: bcachefs
mkdir -p $(DESTDIR)$(ROOT_SBINDIR)
-.Dd February 9, 2018
-.Dt BCACHEFS 8
+.Dd May 26, 2018
+.Dt BCACHEFS 8 SMM
.Os
.Sh NAME
.Nm bcachefs
.It Ic list
List filesystem metadata in textual form
.El
+.Ss Miscellaneous commands
+.Bl -tag -width 18n -compact
+.It Ic version
+Display the version of the invoked bcachefs tool
+.El
.Sh Superblock commands
.Bl -tag -width Ds
.It Nm Ic format Oo Ar options Oc Ar devices\ ...
List mode
.El
.El
+.Sh Miscellaneous commands
+.Bl -tag -width Ds
+.It Nm Ic version
+Display the version of the invoked bcachefs tool
+.El
.Sh EXIT STATUS
.Ex -std
"Debug:\n"
"These commands work on offline, unmounted filesystems\n"
" dump Dump filesystem metadata to a qcow2 image\n"
- " list List filesystem metadata in textual form\n");
+ " list List filesystem metadata in textual form\n"
+ "\n"
+ "Miscellaneous:\n"
+ " version Display the version of the invoked bcachefs tool\n");
}
static char *full_cmd;
char *cmd = pop_cmd(&argc, argv);
+ if (!strcmp(cmd, "version"))
+ return cmd_version(argc, argv);
if (!strcmp(cmd, "format"))
return cmd_format(argc, argv);
if (!strcmp(cmd, "show-super"))
--- /dev/null
+#include <stdio.h>
+
+#include "cmds.h"
+
+int cmd_version(int argc, char *argv[])
+{
+ printf("bcachefs tool version %s\n", VERSION_STRING);
+ return 0;
+}
int cmd_migrate(int argc, char *argv[]);
int cmd_migrate_superblock(int argc, char *argv[]);
+int cmd_version(int argc, char *argv[]);
+
#endif /* _CMDS_H */