#include <linux/lustre/lustre_ver.h>
#include <linux/lustre/lustre_param.h>
#include <linux/lnet/nidstr.h>
+#include <cyaml.h>
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0])))
" [--stripe-count|-c <stripe_count>]\n" \
" [--stripe-index|-i <start_ost_idx>]\n" \
" [--stripe-size|-S <stripe_size>]\n" \
- " [--layout|-L <pattern>]\n" \
+ " [--layout|-L <pattern>]\n" \
" [--pool|-p <pool_name>]\n" \
- " [--ost|-o <ost_indices>]\n"
+ " [--ost|-o <ost_indices>]\n" \
+ " [--yaml|-y <yaml_template_file>]\n" \
+ " [--copy=<lustre_src>]\n"
#define SSM_HELP_COMMON \
"\tstripe_count: Number of OSTs to stripe over (0=fs default, -1 all)\n" \
"\tcomp_end: Extent end of component, start after previous end.\n"\
"\t Can be specified with K, M or G (for KB, MB, GB\n" \
"\t respectively, -1 for EOF). Must be a multiple of\n"\
- "\t stripe_size.\n"
+ "\t stripe_size.\n" \
+ "\tyaml_template_file:\n" \
+ "\t YAML layout template file, can't be used with -c,\n" \
+ "\t -i, -S, -p, -o, or -E arguments.\n" \
+ "\tlustre_src: Lustre file/dir whose layout info is used to set\n" \
+ "\t another lustre file or directory, can't used with\n" \
+ "\t -c, -i, -S, -p, -o, or -E arguments.\n"
#define MIRROR_CREATE_HELP \
"\tmirror_count: Number of mirrors to be created with the upcoming\n" \
"\t It can be a plain layout or a composite layout.\n" \
"\t If not specified, the stripe options inherited\n" \
"\t from the previous component will be used.\n" \
- "\tparent: Use default stripe options from parent directory\n" \
"\tflags: set flags to the component of the current mirror.\n" \
"\t Only \"prefer\" flag is supported so far.\n"
#define MIRROR_EXTEND_USAGE \
" <--mirror-count|-N[mirror_count]>\n" \
- " [setstripe options|--parent|-f <victim_file>]\n" \
+ " [setstripe options|-f <victim_file>]\n" \
" [--no-verify]\n"
#define SETSTRIPE_USAGE \
.pc_help = "Create a mirrored file.\n"
"usage: lfs mirror create "
"<--mirror-count|-N[mirror_count]> "
- "[setstripe options|--parent] ... <filename|directory>\n"
+ "[setstripe options] ... <filename|directory>\n"
MIRROR_CREATE_HELP },
{ .pc_name = "extend", .pc_func = lfs_mirror_extend,
.pc_help = "Extend a mirrored file.\n"
"usage: lfs mirror extend "
"<--mirror-count|-N[mirror_count]> [--no-verify] "
- "[setstripe options|--parent|-f <victim_file>] ... <filename>\n"
+ "[setstripe options|-f <victim_file>] ... <filename>\n"
MIRROR_EXTEND_HELP },
{ .pc_name = "split", .pc_func = lfs_mirror_split,
.pc_help = "Split a mirrored file.\n"
"find files matching given attributes recursively in directory tree.\n"
"usage: find <directory|filename> ...\n"
" [[!] --atime|-A [+-]N] [[!] --ctime|-C [+-]N]\n"
- " [[!] --mtime|-M [+-]N] [--maxdepth|-D N]\n"
+ " [[!] --mtime|-M [+-]N] [--maxdepth|-D N] [[!] --blocks|-b N]\n"
" [[!] --mdt-index|--mdt|-m <uuid|index,...>]\n"
" [[!] --name|-n <pattern>] [[!] --ost|-O <uuid|index,...>]\n"
" [--print|-P] [--print0|-0] [[!] --size|-s [+-]N[bkMGTPE]]\n"
}
if (has_m_file && has_m_layout) {
- fprintf(stderr, "error: %s: -f <victim_file> option should not "
- "be specified with setstripe options or "
- "--parent option\n", progname);
+ fprintf(stderr,
+ "error: %s: -f <victim_file> option should not be specified with setstripe options\n",
+ progname);
return -EINVAL;
}
goto error;
}
- rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0644,
+ rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0666,
layout);
if (rc >= 0) {
close(rc);
fprintf(stderr, "error %s: file name of '%s' too long\n",
progname, fname);
rc = -ERANGE;
- goto free_layout;
+ goto close_fd;
}
strncpy(parent, fname, sizeof(parent));
ptr = strrchr(parent, '/');
fprintf(stderr, "error %s: getcwd failed: %s\n",
progname, strerror(errno));
rc = -errno;
- goto free_layout;
+ goto close_fd;
}
} else {
if (ptr == parent)
if (rc < 0) {
fprintf(stderr, "%s: cannot get MDT index of '%s'\n",
progname, fname);
- goto free_layout;
+ goto close_fd;
}
if (victim_file == NULL) {
__u32 lsa_comp_flags;
__u32 lsa_comp_neg_flags;
unsigned long long lsa_pattern;
+ unsigned int lsa_mirror_count;
int lsa_nr_tgts;
+ bool lsa_first_comp;
__u32 *lsa_tgts;
char *lsa_pool_name;
};
static inline void setstripe_args_init(struct lfs_setstripe_args *lsa)
{
+ unsigned int mirror_count = lsa->lsa_mirror_count;
+ bool first_comp = lsa->lsa_first_comp;
+
memset(lsa, 0, sizeof(*lsa));
lsa->lsa_stripe_size = LLAPI_LAYOUT_DEFAULT;
lsa->lsa_stripe_off = LLAPI_LAYOUT_DEFAULT;
lsa->lsa_pattern = LLAPI_LAYOUT_RAID0;
lsa->lsa_pool_name = NULL;
+
+ lsa->lsa_mirror_count = mirror_count;
+ lsa->lsa_first_comp = first_comp;
}
/**
* Return: 0 on success or an error code on failure.
*/
static int comp_args_to_layout(struct llapi_layout **composite,
- struct lfs_setstripe_args *lsa)
+ struct lfs_setstripe_args *lsa,
+ bool set_extent)
{
struct llapi_layout *layout = *composite;
uint64_t prev_end = 0;
return rc;
}
- rc = llapi_layout_comp_add(layout);
+ if (lsa->lsa_first_comp)
+ prev_end = 0;
+
+ if (lsa->lsa_first_comp)
+ rc = llapi_layout_add_first_comp(layout);
+ else
+ rc = llapi_layout_comp_add(layout);
if (rc) {
fprintf(stderr, "Add component failed. %s\n",
strerror(errno));
return rc;
}
}
+ /* reset lsa_first_comp */
+ lsa->lsa_first_comp = false;
- rc = llapi_layout_comp_extent_set(layout, prev_end, lsa->lsa_comp_end);
- if (rc) {
- fprintf(stderr, "Set extent [%lu, %llu) failed. %s\n",
- prev_end, lsa->lsa_comp_end, strerror(errno));
- return rc;
+ if (set_extent) {
+ rc = llapi_layout_comp_extent_set(layout, prev_end,
+ lsa->lsa_comp_end);
+ if (rc) {
+ fprintf(stderr, "Set extent [%lu, %llu) failed. %s\n",
+ prev_end, lsa->lsa_comp_end, strerror(errno));
+ return rc;
+ }
}
/* Data-on-MDT component setting */
lsa->lsa_stripe_count != LLAPI_LAYOUT_DEFAULT &&
lsa->lsa_stripe_count != LLAPI_LAYOUT_WIDE &&
lsa->lsa_nr_tgts != lsa->lsa_stripe_count) {
- fprintf(stderr, "stripe_count(%lld) != nr_osts(%d)\n",
+ fprintf(stderr, "stripe_count(%lld) != nr_tgts(%d)\n",
lsa->lsa_stripe_count, lsa->lsa_nr_tgts);
return -EINVAL;
}
if (rc)
break;
}
- } else if (lsa->lsa_stripe_off != LLAPI_LAYOUT_DEFAULT) {
+ } else if (lsa->lsa_stripe_off != LLAPI_LAYOUT_DEFAULT &&
+ lsa->lsa_stripe_off != -1) {
rc = llapi_layout_ost_index_set(layout, 0, lsa->lsa_stripe_off);
}
if (rc) {
return 0;
}
+static int build_component(struct llapi_layout **layout,
+ struct lfs_setstripe_args *lsa, bool set_extent)
+{
+ int rc;
+
+ rc = comp_args_to_layout(layout, lsa, set_extent);
+ if (rc)
+ return rc;
+
+ if (lsa->lsa_mirror_count > 0) {
+ rc = llapi_layout_mirror_count_set(*layout,
+ lsa->lsa_mirror_count);
+ if (rc)
+ return rc;
+
+ rc = llapi_layout_flags_set(*layout, LCM_FL_RDONLY);
+ if (rc)
+ return rc;
+ lsa->lsa_mirror_count = 0;
+ }
+
+ return rc;
+}
+
+static int build_layout_from_yaml_node(struct cYAML *node,
+ struct llapi_layout **layout,
+ struct lfs_setstripe_args *lsa,
+ __u32 *osts)
+{
+ char *string;
+ int rc = 0;
+
+ while (node) {
+ string = node->cy_string;
+ /* skip leading lmm_ if present, to simplify parsing */
+ if (string != NULL && strncmp(string, "lmm_", 4) == 0)
+ string += 4;
+
+ if (node->cy_type == CYAML_TYPE_STRING) {
+ if (!strcmp(string, "lcme_extent.e_end")) {
+ if (!strcmp(node->cy_valuestring, "EOF") ||
+ !strcmp(node->cy_valuestring, "eof"))
+ lsa->lsa_comp_end = LUSTRE_EOF;
+ } else if (!strcmp(string, "pool")) {
+ lsa->lsa_pool_name = node->cy_valuestring;
+ } else if (!strcmp(string, "pattern")) {
+ if (!strcmp(node->cy_valuestring, "mdt"))
+ lsa->lsa_pattern = LLAPI_LAYOUT_MDT;
+ }
+ } else if (node->cy_type == CYAML_TYPE_NUMBER) {
+ if (!strcmp(string, "lcm_mirror_count")) {
+ lsa->lsa_mirror_count = node->cy_valueint;
+ } else if (!strcmp(string, "lcme_extent.e_start")) {
+ if (node->cy_valueint != 0 || *layout != NULL) {
+ rc = build_component(layout, lsa, true);
+ if (rc)
+ return rc;
+ }
+
+ if (node->cy_valueint == 0)
+ lsa->lsa_first_comp = true;
+
+ /* initialize lsa */
+ setstripe_args_init(lsa);
+ lsa->lsa_tgts = osts;
+ } else if (!strcmp(string, "lcme_extent.e_end")) {
+ if (node->cy_valueint == -1)
+ lsa->lsa_comp_end = LUSTRE_EOF;
+ else
+ lsa->lsa_comp_end = node->cy_valueint;
+ } else if (!strcmp(string, "stripe_count")) {
+ lsa->lsa_stripe_count = node->cy_valueint;
+ } else if (!strcmp(string, "stripe_size")) {
+ lsa->lsa_stripe_size = node->cy_valueint;
+ } else if (!strcmp(string, "stripe_offset")) {
+ lsa->lsa_stripe_off = node->cy_valueint;
+ } else if (!strcmp(string, "l_ost_idx")) {
+ osts[lsa->lsa_nr_tgts] = node->cy_valueint;
+ lsa->lsa_nr_tgts++;
+ }
+ } else if (node->cy_type == CYAML_TYPE_OBJECT) {
+ /* go deep to sub blocks */
+ rc = build_layout_from_yaml_node(node->cy_child, layout,
+ lsa, osts);
+ if (rc)
+ return rc;
+ }
+ node = node->cy_next;
+ }
+
+ return rc;
+}
+
+static int lfs_comp_create_from_yaml(char *template,
+ struct llapi_layout **layout,
+ struct lfs_setstripe_args *lsa,
+ __u32 *osts)
+{
+ struct cYAML *tree = NULL, *err_rc = NULL;
+ int rc = 0;
+
+ tree = cYAML_build_tree(template, NULL, 0, &err_rc, false);
+ if (!tree) {
+ fprintf(stderr, "%s: cannot parse YAML file %s\n",
+ progname, template);
+ cYAML_build_error(-EINVAL, -1, "yaml", "from comp yaml",
+ "can't parse", &err_rc);
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ rc = -EINVAL;
+ goto err;
+ }
+
+ /* initialize lsa for plain file */
+ setstripe_args_init(lsa);
+ lsa->lsa_tgts = osts;
+
+ rc = build_layout_from_yaml_node(tree, layout, lsa, osts);
+ if (rc) {
+ fprintf(stderr, "%s: cannot build layout from YAML file %s.\n",
+ progname, template);
+ goto err;
+ } else {
+ rc = build_component(layout, lsa, *layout != NULL);
+ }
+ /* clean clean lsa */
+ setstripe_args_init(lsa);
+
+err:
+ if (tree)
+ cYAML_free_tree(tree);
+ return rc;
+}
+
/* In 'lfs setstripe --component-add' mode, we need to fetch the extent
* end of the last component in the existing file, and adjust the
* first extent start of the components to be added accordingly. */
LFS_COMP_DEL_OPT,
LFS_COMP_SET_OPT,
LFS_COMP_ADD_OPT,
- LFS_COMP_USE_PARENT_OPT,
LFS_COMP_NO_VERIFY_OPT,
LFS_PROJID_OPT,
LFS_MIRROR_FLAGS_OPT,
LFS_MIRROR_ID_OPT,
LFS_MIRROR_STATE_OPT,
+ LFS_LAYOUT_COPY,
};
/* functions */
static int lfs_setstripe_internal(int argc, char **argv,
enum setstripe_origin opc)
{
- struct lfs_setstripe_args lsa;
+ struct lfs_setstripe_args lsa = { 0 };
struct llapi_stripe_param *param = NULL;
struct find_param migrate_mdt_param = {
.fp_max_depth = -1,
.fp_mdt_index = -1,
};
char *fname;
- int result;
+ int result = 0;
int result2 = 0;
char *end;
int c;
struct mirror_args *last_mirror = NULL;
__u16 mirror_id = 0;
char cmd[PATH_MAX];
+ bool from_yaml = false;
+ bool from_copy = false;
+ char *template = NULL;
struct option long_opts[] = {
/* find { .val = 'A', .name = "atime", .has_arg = required_argument }*/
{ .val = LFS_COMP_SET_OPT,
.name = "component-set",
.has_arg = no_argument},
- { .val = LFS_COMP_USE_PARENT_OPT,
- .name = "parent", .has_arg = no_argument},
{ .val = LFS_COMP_NO_VERIFY_OPT,
.name = "no-verify", .has_arg = no_argument},
{ .val = LFS_MIRROR_FLAGS_OPT,
.name = "flags", .has_arg = required_argument},
{ .val = LFS_MIRROR_ID_OPT,
.name = "mirror-id", .has_arg = required_argument},
+ { .val = LFS_LAYOUT_COPY,
+ .name = "copy", .has_arg = required_argument},
{ .val = 'c', .name = "stripe-count", .has_arg = required_argument},
{ .val = 'c', .name = "stripe_count", .has_arg = required_argument},
/* find { .val = 'C', .name = "ctime", .has_arg = required_argument }*/
/* find { .val = 'U', .name = "user", .has_arg = required_argument }*/
/* --verbose is only valid in migrate mode */
{ .val = 'v', .name = "verbose", .has_arg = no_argument},
-/* getstripe { .val = 'y', .name = "yaml", .has_arg = no_argument }, */
+ { .val = 'y', .name = "yaml", .has_arg = required_argument },
{ .name = NULL } };
setstripe_args_init(&lsa);
snprintf(cmd, sizeof(cmd), "%s %s", progname, argv[0]);
progname = cmd;
- while ((c = getopt_long(argc, argv, "bc:dDE:f:i:I:m:N::no:p:L:s:S:v",
+ while ((c = getopt_long(argc, argv, "bc:dDE:f:i:I:m:N::no:p:L:s:S:vy:",
long_opts, NULL)) >= 0) {
switch (c) {
case 0:
case LFS_COMP_SET_OPT:
comp_set = 1;
break;
- case LFS_COMP_USE_PARENT_OPT:
- if (!mirror_mode) {
- fprintf(stderr, "error: %s: --parent must be "
- "specified with --mirror-count|-N "
- "option\n", progname);
- goto usage_error;
- }
- setstripe_args_init(&lsa);
- break;
case LFS_COMP_NO_VERIFY_OPT:
mirror_flags |= MF_NO_VERIFY;
break;
}
break;
}
+ case LFS_LAYOUT_COPY:
+ from_copy = true;
+ template = optarg;
+ break;
case 'b':
if (!migrate_mode) {
fprintf(stderr,
break;
case 'E':
if (lsa.lsa_comp_end != 0) {
- result = comp_args_to_layout(lpp, &lsa);
+ result = comp_args_to_layout(lpp, &lsa, true);
if (result) {
fprintf(stderr,
"%s %s: invalid layout\n",
if (lsa.lsa_comp_end == 0)
lsa.lsa_comp_end = LUSTRE_EOF;
- result = comp_args_to_layout(lpp, &lsa);
+ result = comp_args_to_layout(lpp, &lsa, true);
if (result) {
lfs_mirror_free(new_mirror);
goto error;
if (optarg == NULL)
goto usage_error;
lsa.lsa_pool_name = optarg;
+
+ if (strlen(lsa.lsa_pool_name) == 0 ||
+ strncmp(lsa.lsa_pool_name, "none",
+ LOV_MAXPOOLNAME) == 0)
+ lsa.lsa_pool_name = NULL;
break;
case 'S':
result = llapi_parse_size(optarg, &lsa.lsa_stripe_size,
}
migrate_mdt_param.fp_verbose = VERBOSE_DETAIL;
break;
+ case 'y':
+ from_yaml = true;
+ template = optarg;
+ break;
default:
fprintf(stderr, "%s %s: unrecognized option '%s'\n",
progname, argv[0], argv[optind - 1]);
}
if (lsa.lsa_comp_end != 0) {
- result = comp_args_to_layout(lpp, &lsa);
+ result = comp_args_to_layout(lpp, &lsa, true);
if (result)
goto error;
}
goto error;
}
+ if (from_yaml && from_copy) {
+ fprintf(stderr,
+ "%s: can't specify --yaml and --copy together\n",
+ progname);
+ goto error;
+ }
+
+ if ((from_yaml || from_copy) &&
+ (setstripe_args_specified(&lsa) || layout != NULL)) {
+ fprintf(stderr, "error: %s: can't specify --yaml with "
+ "-c, -S, -i, -o, -p or -E options.\n",
+ argv[0]);
+ goto error;
+ }
+
if (mdt_idx_arg != NULL && optind > 3) {
fprintf(stderr,
"%s %s: option -m cannot be used with other options\n",
}
}
+ if (from_yaml) {
+ /* generate a layout from a YAML template */
+ result = lfs_comp_create_from_yaml(template, &layout,
+ &lsa, osts);
+ if (result) {
+ fprintf(stderr, "error: %s: can't create composite "
+ "layout from template file %s\n",
+ argv[0], template);
+ goto error;
+ }
+ } else if (from_copy) {
+ layout = llapi_layout_get_by_path(template, 0);
+ if (layout == NULL) {
+ fprintf(stderr,
+ "%s: can't create composite layout from file %s.\n",
+ progname, template);
+ goto error;
+ }
+ }
+
for (fname = argv[optind]; fname != NULL; fname = argv[++optind]) {
if (mdt_idx_arg != NULL) {
result = llapi_migrate_mdt(fname, &migrate_mdt_param);
NULL);
} else if (layout != NULL) {
result = lfs_component_create(fname, O_CREAT | O_WRONLY,
- 0644, layout);
+ 0666, layout);
if (result >= 0) {
close(result);
result = 0;
} else {
result = llapi_file_open_param(fname,
O_CREAT | O_WRONLY,
- 0644, param);
+ 0666, param);
if (result >= 0) {
close(result);
result = 0;
};
struct option long_opts[] = {
{ .val = 'A', .name = "atime", .has_arg = required_argument },
+ { .val = 'b', .name = "blocks", .has_arg = required_argument },
{ .val = LFS_COMP_COUNT_OPT,
.name = "comp-count", .has_arg = required_argument },
{ .val = LFS_COMP_COUNT_OPT,
/* when getopt_long_only() hits '!' it returns 1, puts "!" in optarg */
while ((c = getopt_long_only(argc, argv,
- "-0A:c:C:D:E:g:G:H:i:L:m:M:n:N:O:Ppqrs:S:t:T:u:U:v",
+ "-0A:b:c:C:D:E:g:G:H:i:L:m:M:n:N:O:Ppqrs:S:t:T:u:U:v",
long_opts, NULL)) >= 0) {
xtime = NULL;
xsign = NULL;
if (rc)
*xsign = rc;
break;
+ case 'b':
+ if (optarg[0] == '+') {
+ param.fp_blocks_sign = -1;
+ optarg++;
+ } else if (optarg[0] == '-') {
+ param.fp_blocks_sign = 1;
+ optarg++;
+ }
+
+ param.fp_blocks_units = 1024;
+ ret = llapi_parse_size(optarg, ¶m.fp_blocks,
+ ¶m.fp_blocks_units, 0);
+ if (ret) {
+ fprintf(stderr, "error: bad blocks '%s'\n",
+ optarg);
+ goto err;
+ }
+ param.fp_check_blocks = 1;
+ param.fp_exclude_blocks = !!neg_opt;
+ break;
case LFS_COMP_COUNT_OPT:
if (optarg[0] == '+') {
param.fp_comp_count_sign = -1;
{
struct option long_opts[] = {
/* find { .val = 'A', .name = "atime", .has_arg = required_argument }*/
+/* find { .val = 'b', .name = "blocks", .has_arg = required_argument }*/
{ .val = LFS_COMP_COUNT_OPT,
.name = "comp-count", .has_arg = no_argument },
{ .val = LFS_COMP_COUNT_OPT,
{
char *dname;
int result;
- struct lfs_setstripe_args lsa;
+ struct lfs_setstripe_args lsa = { 0 };
struct llapi_stripe_param *param = NULL;
__u32 mdts[LMV_MAX_STRIPE_COUNT] = { 0 };
char *end;
{ .val = 't', .name = "hash-type", .has_arg = required_argument },
#endif
{ .val = 'T', .name = "mdt-count", .has_arg = required_argument },
+/* setstripe { .val = 'y', .name = "yaml", .has_arg = no_argument }, */
{ .name = NULL } };
setstripe_args_init(&lsa);
break;
case 'o':
valid = qctl.qc_valid = QC_UUID;
- strlcpy(obd_uuid, optarg, sizeof(qctl.obd_uuid));
+ snprintf(obd_uuid, sizeof(qctl.obd_uuid), "%s", optarg);
break;
case 'i':
valid = qctl.qc_valid = QC_MDTIDX;
if (rc1 && !rc)
rc = rc1;
}
+ return rc;
/* lfs quota -u username /path/to/lustre/mount */
} else if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
/* options should be followed by u/g-name and mntpoint */
return CMD_HELP;
}
}
- mnt = argv[optind];
- rc = get_print_quota(mnt, name, &qctl, verbose, quiet,
- human_readable);
} else if (optind + 1 != argc || qctl.qc_type == ALLQUOTA) {
fprintf(stderr, "%s quota: missing quota info argument(s)\n",
progname);
return CMD_HELP;
}
+ mnt = argv[optind];
+ rc = get_print_quota(mnt, name, &qctl, verbose, quiet,
+ human_readable);
return rc;
}
#endif /* HAVE_SYS_QUOTA_H! */
case 'f':
follow++;
break;
- case '?':
- return CMD_HELP;
default:
- fprintf(stderr, "error: %s: option '%s' unrecognized\n",
- argv[0], argv[optind - 1]);
+ fprintf(stderr,
+ "%s changelog: unrecognized option '%s'\n",
+ progname, argv[optind - 1]);
return CMD_HELP;
}
}
- if (optind >= argc)
- return CMD_HELP;
+ if (optind >= argc) {
+ fprintf(stderr, "%s changelog: mdtname must be specified\n",
+ progname);
+ return CMD_HELP;
+ }
mdd = argv[optind++];
if (argc > optind)
(follow ? CHANGELOG_FLAG_FOLLOW : 0),
mdd, startrec);
if (rc < 0) {
- fprintf(stderr, "Can't start changelog: %s\n",
- strerror(errno = -rc));
+ fprintf(stderr, "%s changelog: cannot start changelog: %s\n",
+ progname, strerror(errno = -rc));
return rc;
}
CHANGELOG_EXTRA_FLAG_OMODE |
CHANGELOG_EXTRA_FLAG_XATTR);
if (rc < 0) {
- fprintf(stderr, "Can't set xflags for changelog: %s\n",
- strerror(errno = -rc));
+ fprintf(stderr,
+ "%s changelog: cannot set xflags for changelog: %s\n",
+ progname, strerror(errno = -rc));
return rc;
}
if (omd->cr_openflags & MDS_FMODE_EXEC) {
mode[2] = 'x';
} else {
- if (omd->cr_openflags & FMODE_READ)
+ if (omd->cr_openflags & MDS_FMODE_READ)
mode[0] = 'r';
if (omd->cr_openflags &
- (FMODE_WRITE |
+ (MDS_FMODE_WRITE |
MDS_OPEN_TRUNC |
MDS_OPEN_APPEND))
mode[1] = 'w';
printf("\n");
llapi_changelog_free(&rec);
- }
+ }
- llapi_changelog_fini(&changelog_priv);
+ llapi_changelog_fini(&changelog_priv);
- if (rc < 0)
- fprintf(stderr, "Changelog: %s\n", strerror(errno = -rc));
+ if (rc < 0)
+ fprintf(stderr, "%s changelog: cannot access changelog: %s\n",
+ progname, strerror(errno = -rc));
- return (rc == 1 ? 0 : rc);
+ return (rc == 1 ? 0 : rc);
}
static int lfs_changelog_clear(int argc, char **argv)