#include "crc32c.h"
#include "commands.h"
#include "version.h"
+#include "utils.h"
static const char * const btrfs_cmd_group_usage[] = {
"btrfs [--help] [--version] <group> [<group>...] <command> [<args>]",
static const char btrfs_cmd_group_info[] =
"Use --help as an argument for information on a specific group or command.";
-static char argv0_buf[ARGV0_BUF_SIZE] = "btrfs";
-
static inline const char *skip_prefix(const char *str, const char *prefix)
{
size_t len = strlen(prefix);
}
}
-static void fixup_argv0(char **argv, const char *token)
-{
- int len = strlen(argv0_buf);
-
- snprintf(argv0_buf + len, sizeof(argv0_buf) - len, " %s", token);
- argv[0] = argv0_buf;
-}
-
int handle_command_group(const struct cmd_group *grp, int argc,
char **argv)
return cmd->fn(argc, argv);
}
-int check_argc_exact(int nargs, int expected)
-{
- if (nargs < expected)
- fprintf(stderr, "%s: too few arguments\n", argv0_buf);
- if (nargs > expected)
- fprintf(stderr, "%s: too many arguments\n", argv0_buf);
-
- return nargs != expected;
-}
-
-int check_argc_min(int nargs, int expected)
-{
- if (nargs < expected) {
- fprintf(stderr, "%s: too few arguments\n", argv0_buf);
- return 1;
- }
-
- return 0;
-}
-
-int check_argc_max(int nargs, int expected)
-{
- if (nargs > expected) {
- fprintf(stderr, "%s: too many arguments\n", argv0_buf);
- return 1;
- }
-
- return 0;
-}
-
static const struct cmd_group btrfs_cmd_group;
static const char * const cmd_help_usage[] = {
#include "commands.h"
#include "props.h"
#include "ctree.h"
+#include "utils.h"
static const char * const property_cmd_group_usage[] = {
"btrfs property get/set/list [-t <type>] <object> [<name>] [value]",
* Boston, MA 021110-1307, USA.
*/
-#define ARGV0_BUF_SIZE 64
-
struct cmd_struct {
const char *token;
int (*fn)(int, char **);
/* btrfs.c */
int prefixcmp(const char *str, const char *prefix);
-int check_argc_exact(int nargs, int expected);
-int check_argc_min(int nargs, int expected);
-int check_argc_max(int nargs, int expected);
-
int handle_command_group(const struct cmd_group *grp, int argc,
char **argv);
#include <string.h>
#include "commands.h"
+#include "utils.h"
static char argv0_buf[ARGV0_BUF_SIZE];
#define BLKDISCARD _IO(0x12,119)
#endif
+static char argv0_buf[ARGV0_BUF_SIZE] = "btrfs";
+
+void fixup_argv0(char **argv, const char *token)
+{
+ int len = strlen(argv0_buf);
+
+ snprintf(argv0_buf + len, sizeof(argv0_buf) - len, " %s", token);
+ argv[0] = argv0_buf;
+}
+
+void set_argv0(char **argv)
+{
+ sprintf(argv0_buf, "%s", argv[0]);
+}
+
+int check_argc_exact(int nargs, int expected)
+{
+ if (nargs < expected)
+ fprintf(stderr, "%s: too few arguments\n", argv0_buf);
+ if (nargs > expected)
+ fprintf(stderr, "%s: too many arguments\n", argv0_buf);
+
+ return nargs != expected;
+}
+
+int check_argc_min(int nargs, int expected)
+{
+ if (nargs < expected) {
+ fprintf(stderr, "%s: too few arguments\n", argv0_buf);
+ return 1;
+ }
+
+ return 0;
+}
+
+int check_argc_max(int nargs, int expected)
+{
+ if (nargs > expected) {
+ fprintf(stderr, "%s: too many arguments\n", argv0_buf);
+ return 1;
+ }
+
+ return 0;
+}
+
+
/*
* Discard the given range in one go
*/
#define BTRFS_UUID_UNPARSED_SIZE 37
+#define ARGV0_BUF_SIZE 64
+
+int check_argc_exact(int nargs, int expected);
+int check_argc_min(int nargs, int expected);
+int check_argc_max(int nargs, int expected);
+
+void fixup_argv0(char **argv, const char *token);
+void set_argv0(char **argv);
+
int make_btrfs(int fd, const char *device, const char *label,
char *fs_uuid, u64 blocks[6], u64 num_bytes, u32 nodesize,
u32 leafsize, u32 sectorsize, u32 stripesize, u64 features);