mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-09 00:00:04 +03:00
Added 'version' command to print when the bcachefs tool was built
This commit is contained in:
parent
62e4df2a38
commit
a5d94ce0a8
13
Makefile
13
Makefile
@ -13,9 +13,12 @@ CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \
|
|||||||
-DNO_BCACHEFS_CHARDEV \
|
-DNO_BCACHEFS_CHARDEV \
|
||||||
-DNO_BCACHEFS_FS \
|
-DNO_BCACHEFS_FS \
|
||||||
-DNO_BCACHEFS_SYSFS \
|
-DNO_BCACHEFS_SYSFS \
|
||||||
|
-DVERSION_STRING='"$(VERSION)"' \
|
||||||
$(EXTRA_CFLAGS)
|
$(EXTRA_CFLAGS)
|
||||||
LDFLAGS+=$(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')
|
CC_VERSION=$(shell $(CC) -v 2>&1|grep -E '(gcc|clang) version')
|
||||||
|
|
||||||
ifneq (,$(findstring gcc,$(CC_VERSION)))
|
ifneq (,$(findstring gcc,$(CC_VERSION)))
|
||||||
@ -56,6 +59,16 @@ DEPS=$(SRCS:.c=.d)
|
|||||||
OBJS=$(SRCS:.c=.o)
|
OBJS=$(SRCS:.c=.o)
|
||||||
bcachefs: $(OBJS)
|
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
|
.PHONY: install
|
||||||
install: bcachefs
|
install: bcachefs
|
||||||
mkdir -p $(DESTDIR)$(ROOT_SBINDIR)
|
mkdir -p $(DESTDIR)$(ROOT_SBINDIR)
|
||||||
|
14
bcachefs.8
14
bcachefs.8
@ -1,5 +1,5 @@
|
|||||||
.Dd February 9, 2018
|
.Dd May 26, 2018
|
||||||
.Dt BCACHEFS 8
|
.Dt BCACHEFS 8 SMM
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm bcachefs
|
.Nm bcachefs
|
||||||
@ -87,6 +87,11 @@ Dump filesystem metadata to a qcow2 image
|
|||||||
.It Ic list
|
.It Ic list
|
||||||
List filesystem metadata in textual form
|
List filesystem metadata in textual form
|
||||||
.El
|
.El
|
||||||
|
.Ss Miscellaneous commands
|
||||||
|
.Bl -tag -width 18n -compact
|
||||||
|
.It Ic version
|
||||||
|
Display the version of the invoked bcachefs tool
|
||||||
|
.El
|
||||||
.Sh Superblock commands
|
.Sh Superblock commands
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Nm Ic format Oo Ar options Oc Ar devices\ ...
|
.It Nm Ic format Oo Ar options Oc Ar devices\ ...
|
||||||
@ -310,5 +315,10 @@ Verbose mode
|
|||||||
List mode
|
List mode
|
||||||
.El
|
.El
|
||||||
.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
|
.Sh EXIT STATUS
|
||||||
.Ex -std
|
.Ex -std
|
||||||
|
@ -70,7 +70,10 @@ static void usage(void)
|
|||||||
"Debug:\n"
|
"Debug:\n"
|
||||||
"These commands work on offline, unmounted filesystems\n"
|
"These commands work on offline, unmounted filesystems\n"
|
||||||
" dump Dump filesystem metadata to a qcow2 image\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;
|
static char *full_cmd;
|
||||||
@ -144,6 +147,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
char *cmd = pop_cmd(&argc, argv);
|
char *cmd = pop_cmd(&argc, argv);
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "version"))
|
||||||
|
return cmd_version(argc, argv);
|
||||||
if (!strcmp(cmd, "format"))
|
if (!strcmp(cmd, "format"))
|
||||||
return cmd_format(argc, argv);
|
return cmd_format(argc, argv);
|
||||||
if (!strcmp(cmd, "show-super"))
|
if (!strcmp(cmd, "show-super"))
|
||||||
|
9
cmd_version.c
Normal file
9
cmd_version.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "cmds.h"
|
||||||
|
|
||||||
|
int cmd_version(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
printf("bcachefs tool version %s\n", VERSION_STRING);
|
||||||
|
return 0;
|
||||||
|
}
|
2
cmds.h
2
cmds.h
@ -43,4 +43,6 @@ int cmd_list(int argc, char *argv[]);
|
|||||||
int cmd_migrate(int argc, char *argv[]);
|
int cmd_migrate(int argc, char *argv[]);
|
||||||
int cmd_migrate_superblock(int argc, char *argv[]);
|
int cmd_migrate_superblock(int argc, char *argv[]);
|
||||||
|
|
||||||
|
int cmd_version(int argc, char *argv[]);
|
||||||
|
|
||||||
#endif /* _CMDS_H */
|
#endif /* _CMDS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user