mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Documentation
This commit is contained in:
parent
7e97901075
commit
04a54144fd
10
Makefile
10
Makefile
@ -1,19 +1,19 @@
|
|||||||
|
|
||||||
#PREFIX=/usr/local
|
PREFIX=/usr
|
||||||
CFLAGS=-O2 -Wall -g
|
CFLAGS=-O2 -Wall -g
|
||||||
|
|
||||||
all: make-bcache probe-bcache
|
all: make-bcache probe-bcache
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f make-bcache bcache-test *.o
|
|
||||||
|
|
||||||
install: make-bcache probe-bcache
|
install: make-bcache probe-bcache
|
||||||
install -m0755 make-bcache ${PREFIX}/sbin/
|
install -m0755 make-bcache ${PREFIX}/sbin/
|
||||||
install -m0755 probe-bcache ${PREFIX}/sbin/
|
install -m0755 probe-bcache /sbin/
|
||||||
install -m0644 61-bcache.rules /lib/udev/rules.d/
|
install -m0644 61-bcache.rules /lib/udev/rules.d/
|
||||||
install -m0755 initramfs /usr/share/initramfs-tools/hooks/bcache
|
install -m0755 initramfs /usr/share/initramfs-tools/hooks/bcache
|
||||||
|
install -m0644 make-bcache.8 ${PREFIX}/share/man/man8
|
||||||
# install -m0755 bcache-test ${PREFIX}/sbin/
|
# install -m0755 bcache-test ${PREFIX}/sbin/
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f make-bcache bcache-test *.o
|
||||||
|
|
||||||
bcache-test: LDFLAGS += -lm -lssl -lcrypto
|
bcache-test: LDFLAGS += -lm -lssl -lcrypto
|
||||||
make-bcache: LDFLAGS += -luuid
|
make-bcache: LDFLAGS += -luuid
|
||||||
|
5
bcache.h
5
bcache.h
@ -7,8 +7,9 @@ static const char bcache_magic[] = {
|
|||||||
|
|
||||||
struct cache_sb {
|
struct cache_sb {
|
||||||
uint8_t magic[16];
|
uint8_t magic[16];
|
||||||
#define CACHE_CLEAN 1
|
#define CACHE_CLEAN 1
|
||||||
#define CACHE_SYNC 2
|
#define CACHE_SYNC 2
|
||||||
|
#define CACHE_BACKING_DEVICE 4
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
uint16_t block_size; /* sectors */
|
uint16_t block_size; /* sectors */
|
||||||
uint16_t bucket_size; /* sectors */
|
uint16_t bucket_size; /* sectors */
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -58,21 +59,32 @@ long hatoi(const char *s)
|
|||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("");
|
printf("Usage: make-bcache [options] device\n"
|
||||||
|
" -C Format a cache device\n"
|
||||||
|
" -B Format a backing device\n"
|
||||||
|
" -b bucket size\n"
|
||||||
|
" -U UUID\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int64_t nblocks, bucketsize = 32, blocksize = 8;
|
bool cache = false, backingdev = false;
|
||||||
|
int64_t nblocks, bucketsize = 0, blocksize = 8;
|
||||||
int fd, i, c;
|
int fd, i, c;
|
||||||
struct cache_sb sb;
|
struct cache_sb sb;
|
||||||
char uuid[40];
|
char uuid[40];
|
||||||
|
|
||||||
uuid_generate(sb.uuid);
|
uuid_generate(sb.uuid);
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "U:b:")) != -1)
|
while ((c = getopt(argc, argv, "CBU:b:")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'C':
|
||||||
|
cache = true;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
backingdev = true;
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
bucketsize = hatoi(optarg) / 512;
|
bucketsize = hatoi(optarg) / 512;
|
||||||
break;
|
break;
|
||||||
@ -84,6 +96,14 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bucketsize)
|
||||||
|
bucketsize = cache ? 256 : 8192;
|
||||||
|
|
||||||
|
if (cache == backingdev) {
|
||||||
|
printf("Must specify one of -C or -B\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (argc <= optind) {
|
if (argc <= optind) {
|
||||||
printf("Please supply a device\n");
|
printf("Please supply a device\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -104,7 +124,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy(sb.magic, bcache_magic, 16);
|
memcpy(sb.magic, bcache_magic, 16);
|
||||||
sb.version = 0;
|
sb.version = backingdev ? CACHE_BACKING_DEVICE : 0;
|
||||||
sb.block_size = blocksize;
|
sb.block_size = blocksize;
|
||||||
sb.bucket_size = bucketsize;
|
sb.bucket_size = bucketsize;
|
||||||
sb.nbuckets = nblocks / sb.bucket_size;
|
sb.nbuckets = nblocks / sb.bucket_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user