#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <getopt.h>
#include <glob.h>
#include <signal.h>
#include <stdarg.h>
#include "obdctl.h"
#include <libcfs/libcfs.h>
-#include <lnet/lnet.h>
+#include <lnet/nidstr.h>
#include <lustre/lustre_idl.h>
#include <lustre_cfg.h>
#include <lustre_ioctl.h>
if (rc)
fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
strerror(-rc));
- else
- printf("Lustre version: %s\n", version);
+ else
+ printf("Lustre version: %s\n", version);
- printf("lctl version: %s\n", BUILD_VERSION);
- return rc;
+ return rc;
}
-/*
- * Print an obd device line with the ost_conn_uuid inserted, if the obd
- * is an osc.
- */
static void print_obd_line(char *s)
{
char buf[MAX_STRING_SIZE];
FILE *fp = NULL;
char *ptr;
- if (sscanf(s, " %*d %*s osc %s %*s %*d ", obd_name) == 0)
+ snprintf(buf, sizeof(buf), " %%*d %%*s osc %%%zus %%*s %%*d ",
+ sizeof(obd_name) - 1);
+ if (sscanf(s, buf, obd_name) == 0)
goto try_mdc;
snprintf(buf, sizeof(buf),
"/proc/fs/lustre/osc/%s/ost_conn_uuid", obd_name);
goto got_one;
try_mdc:
- if (sscanf(s, " %*d %*s mdc %s %*s %*d ", obd_name) == 0)
+ snprintf(buf, sizeof(buf), " %%*d %%*s mdc %%%zus %%*s %%*d ",
+ sizeof(obd_name) - 1);
+ if (sscanf(s, buf, obd_name) == 0)
goto fail;
snprintf(buf, sizeof(buf),
"/proc/fs/lustre/mdc/%s/mds_conn_uuid", obd_name);
if (ostname != NULL)
lustre_cfg_bufs_set_string(&bufs, 2, ostname);
- lcfg = lustre_cfg_new(cmd, &bufs);
+ lcfg = lustre_cfg_new(cmd, &bufs);
if (lcfg == NULL)
- return rc;
+ return -ENOMEM;
memset(&data, 0, sizeof(data));
rc = data.ioc_dev = get_mgs_device();
if (rc) {
fprintf(stderr, "error: %s: invalid ioctl\n",
jt_cmdname(cmdname));
+ lustre_cfg_free(lcfg);
return rc;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_POOL, buf);
}
if (nodemap_name == NULL || param == NULL || value == NULL) {
- fprintf(stderr, "usage: nodemap_modify --name <name> "
- "--property <range> --value <value>\n");
+ fprintf(stderr, "usage: nodemap_modify --name <nodemap_name> "
+ "--property <property_name> --value <value>\n");
+ fprintf(stderr, "valid properties: admin trusted "
+ "squash_uid squash_gid\n");
return -1;
}
rc = nodemap_cmd(cmd, NULL, 0, argv[0], nodemap_name, idmap, NULL);
if (rc != 0) {
errno = -rc;
- fprintf(stderr, "cannot add %smap '%s' to nodemap '%s'"
+ fprintf(stderr, "cannot delete %smap '%s' from nodemap '%s'"
": rc = %d\n", idtype, idmap, nodemap_name, rc);
}
return 0;
}
-void llapi_ping_target(char *obd_type, char *obd_name,
- char *obd_uuid, void *args)
-{
- int rc;
- struct obd_ioctl_data data;
- char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
-
- memset(&data, 0, sizeof(data));
- data.ioc_inlbuf4 = obd_name;
- data.ioc_inllen4 = strlen(obd_name) + 1;
- data.ioc_dev = OBD_DEV_BY_DEVNAME;
- memset(buf, 0, sizeof(rawbuf));
- if (obd_ioctl_pack(&data, &buf, sizeof(rawbuf))) {
- fprintf(stderr, "error: invalid ioctl\n");
- return;
- }
- rc = l_ioctl(OBD_DEV_ID, OBD_IOC_PING_TARGET, buf);
- if (rc)
- rc = errno;
- if (rc == ENOTCONN || rc == ESHUTDOWN) {
- printf("%s: INACTIVE\n", obd_name);
- } else if (rc) {
- printf("%s: check error: %s\n",
- obd_name, strerror(errno));
- } else {
- printf("%s: active\n", obd_name);
- }
-}
-
int jt_changelog_register(int argc, char **argv)
{
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;