* GPL HEADER END
*/
/*
- * Copyright (c) 2016, Intel Corporation.
+ * Copyright (c) 2017, Intel Corporation.
*
* lustre/utils/lsnapshot.c
*
#include <ctype.h>
#include <libcfs/util/list.h>
-#include <lustre_ioctl.h>
-#include <lustre/lustre_barrier_user.h>
+#include <libcfs/util/ioctl.h>
+#include <linux/lustre/lustre_ioctl.h>
+#include <linux/lustre/lustre_barrier_user.h>
#include "obdctl.h"
return rc;
srandom(tv.tv_usec);
- snprintf(new_fsname, 8, "%08x", (__u32)random());
- new_fsname[8] = '\0';
+ snprintf(new_fsname, sizeof(new_fsname), "%08x", (__u32)random());
rc = snapshot_get_mgsnode(si, buf, sizeof(buf));
if (rc)
if (!rc && !rc1) {
struct barrier_ctl bc;
- __argv[0] = "barrier_stat";
- rc = __jt_barrier_stat(2, __argv, &bc);
+ rc = __jt_barrier_stat(__argv[1], &bc);
if (rc) {
SNAPSHOT_ADD_LOG(si, "Can't get barrier status "
"on %s: rc = %d\n",
int jt_snapshot_create(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_create[] = {
- { "barrier", optional_argument, 0, 'b' },
- { "comment", required_argument, 0, 'c' },
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "rsh", required_argument, 0, 'r' },
- { "timeout", required_argument, 0, 't' },
- };
+ struct option long_opts[] = {
+ { .val = 'b', .name = "barrier", .has_arg = optional_argument },
+ { .val = 'c', .name = "comment", .has_arg = required_argument },
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .val = 't', .name = "timeout", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_create, "b::c:F:hn:r:t:",
+ si = snapshot_init(argc, argv, long_opts, "b::c:F:hn:r:t:",
snapshot_create_usage, LOCK_EX, &rc);
if (!si)
return rc;
int jt_snapshot_destroy(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_destroy[] = {
- { "force", no_argument, 0, 'f' },
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "rsh", required_argument, 0, 'r' },
- };
+ struct option long_opts[] = {
+ { .val = 'f', .name = "force", .has_arg = no_argument },
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_destroy, "fF:hn:r:",
+ si = snapshot_init(argc, argv, long_opts, "fF:hn:r:",
snapshot_destroy_usage, LOCK_EX, &rc);
if (!si)
return rc;
int jt_snapshot_modify(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_modify[] = {
- { "comment", required_argument, 0, 'c' },
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "new", required_argument, 0, 'N' },
- { "rsh", required_argument, 0, 'r' },
- };
+ struct option long_opts[] = {
+ { .val = 'c', .name = "comment", .has_arg = required_argument },
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'N', .name = "new", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_modify, "c:F:hn:N:r:",
+ si = snapshot_init(argc, argv, long_opts, "c:F:hn:N:r:",
snapshot_modify_usage, LOCK_EX, &rc);
if (!si)
return rc;
int jt_snapshot_list(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_list[] = {
- { "detail", no_argument, 0, 'd' },
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "rsh", required_argument, 0, 'r' },
- };
+ struct option long_opts[] = {
+ { .val = 'd', .name = "detail", .has_arg = no_argument },
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_list, "dF:hn:r:",
+ si = snapshot_init(argc, argv, long_opts, "dF:hn:r:",
snapshot_list_usage, LOCK_SH, &rc);
if (!si)
return rc;
int jt_snapshot_mount(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_mount[] = {
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "rsh", required_argument, 0, 'r' },
- };
+ struct option long_opts[] = {
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_mount, "F:hn:r:",
+ si = snapshot_init(argc, argv, long_opts, "F:hn:r:",
snapshot_mount_usage, LOCK_EX, &rc);
if (!si)
return rc;
int jt_snapshot_umount(int argc, char **argv)
{
struct snapshot_instance *si;
- struct option lopts_umount[] = {
- { "fsname", required_argument, 0, 'F' },
- { "help", no_argument, 0, 'h' },
- { "name", required_argument, 0, 'n' },
- { "rsh", required_argument, 0, 'r' },
- };
+ struct option long_opts[] = {
+ { .val = 'F', .name = "fsname", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "rsh", .has_arg = required_argument },
+ { .name = NULL } };
int rc = 0;
- si = snapshot_init(argc, argv, lopts_umount, "F:hn:r:",
+ si = snapshot_init(argc, argv, long_opts, "F:hn:r:",
snapshot_umount_usage, LOCK_EX, &rc);
if (!si)
return rc;