char *buffer, int buffer_size);
int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
int llapi_file_lookup(int dirfd, const char *name);
+void llapi_set_command_name(const char *cmd);
+void llapi_clear_command_name(void);
#define VERBOSE_COUNT 0x1
#define VERBOSE_SIZE 0x2
#include <linux/lnet/lnetctl.h>
#include "obdctl.h"
#include <linux/lustre/lustre_ver.h>
+#include <lustre/lustreapi.h>
static int lctl_list_commands(int argc, char **argv);
Parser_init("lctl > ", cmdlist);
if (argc > 1) {
+ llapi_set_command_name(argv[1]);
rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
+ llapi_clear_command_name();
} else {
rc = Parser_commands();
}
Parser_init("lfs > ", cmdlist);
- progname = argv[0]; /* Used in error messages */
- if (argc > 1)
+ progname = program_invocation_short_name; /* Used in error messages */
+ if (argc > 1) {
+ llapi_set_command_name(argv[1]);
rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
- else
+ llapi_clear_command_name();
+ } else {
rc = Parser_commands();
+ }
return rc < 0 ? -rc : rc;
}
#include "lustreapi_internal.h"
static int llapi_msg_level = LLAPI_MSG_MAX;
+const char *liblustreapi_cmd;
char *mdt_hash_name[] = { "none",
LMV_HASH_NAME_ALL_CHARS,
return llapi_msg_level;
}
+void llapi_set_command_name(const char *cmd)
+{
+ liblustreapi_cmd = cmd;
+}
+
+void llapi_clear_command_name(void)
+{
+ liblustreapi_cmd = NULL;
+}
+
static void error_callback_default(enum llapi_message_level level, int err,
const char *fmt, va_list ap)
{
+ if (liblustreapi_cmd != NULL)
+ fprintf(stderr, "%s %s: ", program_invocation_short_name,
+ liblustreapi_cmd);
+ else
+ fprintf(stderr, "%s: ", program_invocation_short_name);
vfprintf(stderr, fmt, ap);
if (level & LLAPI_MSG_NO_ERRNO)
fprintf(stderr, "\n");
static void info_callback_default(enum llapi_message_level level, int err,
const char *fmt, va_list ap)
{
+ if (liblustreapi_cmd != NULL)
+ fprintf(stderr, "%s %s: ", program_invocation_short_name,
+ liblustreapi_cmd);
+ else
+ fprintf(stderr, "%s: ", program_invocation_short_name);
vfprintf(stdout, fmt, ap);
}