return (char *)(uuid->uuid);
}
+#define LUSTRE_MAXFSNAME 8
+
/* Extract fsname from uuid (or target name) of a target
e.g. (myfs-OST0007_UUID -> myfs)
see also deuuidify. */
return -EINVAL;
/* or too long */
- if (len > MTI_NAME_MAXLEN)
+ if (len > LUSTRE_MAXFSNAME)
return -ENAMETOOLONG;
strncpy(fsname, arg, len);
{
const char *dash;
- dash = svname + strnlen(svname, 8); /* max fsname length is 8 */
+ dash = svname + strnlen(svname, LUSTRE_MAXFSNAME);
for (; dash > svname && *dash != '-' && *dash != ':'; dash--)
;
if (dash == svname)
return rc < 0 ? rc : nr;
}
-static int verify_pool_name(char *prog_name, char *pool_name)
-{
- char *ptr;
-
- if (pool_name == NULL)
- return 0;
-
- ptr = strchr(pool_name, '.');
- if (ptr != NULL && ptr == pool_name) {
- fprintf(stderr, "error: %s: fsname is empty in pool name '%s'\n",
- prog_name, pool_name);
- return -EINVAL;
- }
-
- return 0;
-}
-
struct lfs_setstripe_args {
unsigned long long lsa_comp_end;
unsigned long long lsa_stripe_size;
lsa.lsa_stripe_off = osts[0];
break;
case 'p':
- result = verify_pool_name(argv[0], optarg);
- if (result)
+ if (optarg == NULL)
goto error;
lsa.lsa_pool_name = optarg;
break;
#include <ctype.h>
#include <linux/lnet/nidstr.h>
#include <linux/lnet/lnetctl.h>
-#include <linux/lustre/lustre_param.h>
+#include <linux/lustre/lustre_user.h>
#include <linux/lustre/lustre_ver.h>
#include "mount_utils.h"
ldd->ldd_flags &= ~LDD_F_NEED_INDEX;
break;
}
- case 'L':
+ case 'L': {
+ const char *tmp;
+ size_t len;
+
+ len = strlen(optarg);
+ if (len < 1 || len > LUSTRE_MAXFSNAME) {
+ fprintf(stderr, "%s: filesystem name must be "
+ "1-%d chars\n", progname, LUSTRE_MAXFSNAME);
+ return 1;
+ }
+
+ for (tmp = optarg; *tmp != '\0'; ++tmp) {
+ if (isalnum(*tmp) || *tmp == '_' || *tmp == '-')
+ continue;
+ else
+ break;
+ }
+ if (*tmp != '\0') {
+ fprintf(stderr, "%s: char '%c' not allowed in "
+ "filesystem name\n", progname, *tmp);
+ return 1;
+ }
strscpy(new_fsname, optarg, sizeof(new_fsname));
break;
+ }
case 'm': {
char *nids = convert_hostnames(optarg);
out:
if (rc)
rc = -errno;
+ switch (rc) {
+ case -ENAMETOOLONG:
+ fprintf(stderr, "error: %s: either the pool or file "
+ "system name is too long (max pool name len "
+ "is %d and file system name is %d)\n",
+ jt_cmdname(cmdname), LOV_MAXPOOLNAME,
+ LUSTRE_MAXFSNAME);
+ break;
+ case -EINVAL:
+ fprintf(stderr, "error: %s can contain only "
+ "alphanumeric characters, underscores, and "
+ "dashes besides the required '.'\n",
+ jt_cmdname(cmdname));
+ default:
+ break;
+ }
free(lcfg);
- return rc;
+ return rc;
}
/**