AC_MSG_NOTICE([LibCFS core checks
==============================================================================])
-# lnet/utils/portals.c
-AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
-
-# lnet/utils/debug.c
-AC_CHECK_HEADERS([linux/version.h])
-
-AC_CHECK_TYPE([spinlock_t],
- [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
- [],
- [#include <linux/spinlock.h>])
-
-# lnet/utils/wirecheck.c
-AC_CHECK_FUNCS([strnlen])
-
-# lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
-AC_CHECK_FUNCS([strlcpy])
-
-# libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
-AC_CHECK_FUNCS([strlcat])
-
-# libcfs/include/libcfs/linux/linux-prim.h, ...
-AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
-
-# libcfs/include/libcfs/linux/linux-prim.h
-AC_CHECK_HEADERS([linux/random.h], [], [],
- [#ifdef HAVE_LINUX_TYPES_H
- #include <linux/types.h>
- #endif
- ])
-
-# libcfs/include/libcfs/linux/libcfs.h
-# libcfs/include/libcfs/byteorder.h
# libcfs/libcfs/util/nidstrings.c
AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
AC_CHECK_FUNCS([gethostbyname])
#include <linux/types.h>
#include <libcfs/util/list.h>
-#ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcpy(char *tgt, const char *src, size_t tgt_len);
-#endif
-
-#ifndef HAVE_STRLCAT /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcat(char *tgt, const char *src, size_t tgt_len);
-#endif
-
/**
* Structure to represent NULL-less strings.
*/
int
cfs_get_param_paths(glob_t *paths, const char *pattern, ...)
{
- char path[PATH_MAX] = "{/sys/{fs,kernel/debug}/{lnet,lustre}/,"
- "/proc/{fs,sys}/{lnet,lustre}/}";
+ char topdir[PATH_MAX] = "{/sys/{fs,kernel/debug}/{lnet,lustre},"
+ "/proc/{fs,sys}/{lnet,lustre}}";
static bool test_mounted = false;
- size_t len = strlen(path);
+ char path[PATH_MAX];
char buf[PATH_MAX];
struct statfs statfsbuf;
va_list args;
errno = EINVAL;
return -1;
}
- len += rc;
- if (strlcat(path, buf, sizeof(path)) != len) {
+ if (snprintf(path, sizeof(path), "%s/%s", topdir, buf) >=
+ sizeof(path)) {
errno = E2BIG;
return -1;
}
#include <unistd.h>
#include <libcfs/util/string.h>
-/*
- * According manual of strlcpy() and strlcat() the functions should return
- * the total length of the string they tried to create. For strlcpy() that
- * means the length of src. For strlcat() that means the initial length of
- * dst plus the length of src. So, the function strnlen() cannot be used
- * otherwise the return value will be wrong.
- */
-#ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcpy(char *dst, const char *src, size_t size)
-{
- size_t ret = strlen(src);
-
- if (size) {
- size_t len = (ret >= size) ? size - 1 : ret;
- memcpy(dst, src, len);
- dst[len] = '\0';
- }
- return ret;
-}
-#endif
-
-#ifndef HAVE_STRLCAT /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcat(char *dst, const char *src, size_t size)
-{
- size_t dsize = strlen(dst);
- size_t len = strlen(src);
- size_t ret = dsize + len;
-
- dst += dsize;
- size -= dsize;
- if (len >= size)
- len = size-1;
- memcpy(dst, src, len);
- dst[len] = '\0';
- return ret;
-}
-#endif
-
/**
* Extracts tokens from strings.
*
rc = llapi_file_get_stripe(argv[1], lum_dir);
if (rc == -ENODATA) {
- char root[PATH_MAX];
+ char root[PATH_MAX], path[PATH_MAX + 2];
rc = llapi_search_mounts(argv[1], 0, root, NULL);
if (rc) {
goto cleanup;
}
- strlcat(root, "/.", PATH_MAX);
- rc = llapi_file_get_stripe(root, lum_dir);
+ snprintf(path, sizeof(path), "%s/.", root);
+ rc = llapi_file_get_stripe(path, lum_dir);
if (rc == -ENODATA) {
free(lum_dir);
lum_dir = NULL;
} else if (rc) {
llapi_error(LLAPI_MSG_ERROR, rc, "error: cant't get "
- "root's LOVEA for %s\n", root);
+ "root's LOVEA for %s\n", path);
goto cleanup;
}
} else if (rc) {
#include "krb5_util.h"
#include "lsupport.h"
-char pipefs_dir[PATH_MAX] = GSSD_PIPEFS_DIR;
+char *pipefs_dir = GSSD_PIPEFS_DIR;
char pipefs_nfsdir[PATH_MAX] = GSSD_PIPEFS_DIR;
-char keytabfile[PATH_MAX] = GSSD_DEFAULT_KEYTAB_FILE;
-char ccachedir[PATH_MAX] = GSSD_DEFAULT_CRED_DIR;
+char *keytabfile = GSSD_DEFAULT_KEYTAB_FILE;
+char *ccachedir = GSSD_DEFAULT_CRED_DIR;
int use_memcache = 0;
int lgssd_mutex_downcall = -1;
verbosity++;
break;
case 'p':
- strlcpy(pipefs_dir, optarg, sizeof(pipefs_dir));
- if (pipefs_dir[sizeof(pipefs_dir)-1] != '\0')
- errx(1, "pipefs path name too long");
+ pipefs_dir = strdup(optarg);
+ if (!pipe_dir)
+ errx(1, "pipefs path name not aquired");
break;
case 'k':
- strlcpy(keytabfile, optarg, sizeof(keytabfile));
- if (keytabfile[sizeof(keytabfile)-1] != '\0')
- errx(1, "keytab path name too long");
+ keytabfile = strdup(optarg);
+ if (!keytab_file)
+ errx(1, "keytab path name not aquired");
break;
case 'd':
- strlcpy(ccachedir, optarg, sizeof(ccachedir));
- if (ccachedir[sizeof(ccachedir)-1] != '\0')
- errx(1, "ccachedir path name too long");
+ ccachedir = strdup(optarg);
+ if (!ccachedir)
+ errx(1, "ccachedir path name not aquired");
break;
default:
usage(argv[0]);
-extern char pipefs_dir[PATH_MAX];
-extern char keytabfile[PATH_MAX];
-extern char ccachedir[PATH_MAX];
-extern char gethostname_ex[PATH_MAX];
-extern int use_memcache;
+extern char *pipefs_dir;
+extern char *keytabfile;
+extern char *ccachedir;
+extern char gethostname_ex[PATH_MAX];
+extern int use_memcache;
TAILQ_HEAD(clnt_list_head, clnt_info) clnt_list;
data[6], data[7], data[8], data[9], data[10]);
uparam->kup_secid = strtol(data[0], NULL, 0);
- strlcpy(uparam->kup_mech, data[1], sizeof(uparam->kup_mech));
+ snprintf(uparam->kup_mech, sizeof(uparam->kup_mech), "%s", data[1]);
uparam->kup_uid = strtol(data[2], NULL, 0);
uparam->kup_gid = strtol(data[3], NULL, 0);
if (strchr(data[4], 'r'))
uparam->kup_svc_type = data[5][0];
uparam->kup_svc = strtol(data[6], NULL, 0);
uparam->kup_nid = strtoll(data[7], NULL, 0);
- strlcpy(uparam->kup_tgt, data[8], sizeof(uparam->kup_tgt));
+ snprintf(uparam->kup_tgt, sizeof(uparam->kup_tgt), "%s", data[8]);
uparam->kup_selfnid = strtoll(data[9], NULL, 0);
uparam->kup_pid = strtol(data[10], NULL, 0);
#include <syslog.h>
#include <libcfs/util/param.h>
-#include <libcfs/util/string.h>
#include <linux/lnet/nidstr.h>
#include <linux/lustre/lustre_user.h>
#include <linux/lustre/lustre_idl.h>
unsigned int ngroups = 0;
int ngroups_tmp;
struct passwd *pw;
- char *pw_name;
- int namelen;
int i;
pw = getpwuid(data->idd_uid);
}
data->idd_gid = pw->pw_gid;
- namelen = sysconf(_SC_LOGIN_NAME_MAX);
- if (namelen < _POSIX_LOGIN_NAME_MAX)
- namelen = _POSIX_LOGIN_NAME_MAX;
-
- pw_name = malloc(namelen);
- if (!pw_name) {
- errlog("malloc error\n");
- data->idd_err = errno;
- return -1;
- }
- strlcpy(pw_name, pw->pw_name, namelen);
groups = data->idd_groups;
/* Allocate array of size maxgroups instead of handling two
* consecutive and potentially racy getgrouplist() calls. */
groups_tmp = malloc(maxgroups * sizeof(gid_t));
if (groups_tmp == NULL) {
- free(pw_name);
data->idd_err = errno ? errno : ENOMEM;
errlog("malloc error=%u\n",data->idd_err);
return -1;
ngroups_tmp = maxgroups;
if (getgrouplist(pw->pw_name, pw->pw_gid, groups_tmp, &ngroups_tmp) <
0) {
- free(pw_name);
free(groups_tmp);
data->idd_err = errno ? errno : EIDRM;
errlog("getgrouplist() error for uid %u: error=%u\n",
qsort(groups, ngroups, sizeof(*groups), compare_u32);
data->idd_ngroups = ngroups;
- free(pw_name);
free(groups_tmp);
return 0;
}
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;
{
struct hsm_copyaction_private *hcp = NULL;
char src[PATH_MAX];
- char dst[PATH_MAX] = "";
+ char dst[PATH_MAX + 4] = "";
+ char root[PATH_MAX] = "";
int rc;
int rcf = 0;
bool rename_needed = false;
* destination = lustre FID
*/
ct_path_lustre(src, sizeof(src), opt.o_mnt, &hai->hai_dfid);
- ct_path_archive(dst, sizeof(dst), opt.o_hsm_root, &hai->hai_fid);
+ ct_path_archive(root, sizeof(root), opt.o_hsm_root, &hai->hai_fid);
if (hai->hai_extent.length == -1) {
/* whole file, write it to tmp location and atomically
* replace old archived file */
- strlcat(dst, "_tmp", sizeof(dst));
+ snprintf(dst, sizeof(dst), "%s_tmp", root);
/* we cannot rely on the same test because ct_copy_data()
* updates hai_extent.length */
rename_needed = true;
+ } else {
+ snprintf(dst, sizeof(dst), "%s", root);
}
CT_TRACE("archiving '%s' to '%s'", src, dst);
static int ct_remove(const struct hsm_action_item *hai, const long hal_flags)
{
struct hsm_copyaction_private *hcp = NULL;
- char dst[PATH_MAX];
+ char dst[PATH_MAX], attr[PATH_MAX + 4];
int rc;
rc = ct_begin(&hcp, hai);
goto fini;
}
- strlcat(dst, ".lov", sizeof(dst));
- rc = unlink(dst);
+ snprintf(attr, sizeof(attr), "%s.lov", dst);
+ rc = unlink(attr);
if (rc < 0) {
rc = -errno;
- CT_ERROR(rc, "cannot unlink '%s'", dst);
+ CT_ERROR(rc, "cannot unlink '%s'", attr);
err_minor++;
goto fini;
}
ct_path_archive(dst, sizeof(dst), opt.o_hsm_root, new_fid);
if (!opt.o_dry_run) {
+ char src_attr[PATH_MAX + 4];
+ char dst_attr[PATH_MAX + 4];
+
ct_mkdir_p(dst);
if (rename(src, dst)) {
rc = -errno;
return -errno;
}
/* rename lov file */
- strlcat(src, ".lov", sizeof(src));
- strlcat(dst, ".lov", sizeof(dst));
- if (rename(src, dst))
- CT_ERROR(errno, "cannot rename '%s' to '%s'", src, dst);
+ snprintf(src_attr, sizeof(src_attr), "%s.lov", src);
+ snprintf(dst_attr, sizeof(dst_attr), "%s.lov", dst);
+ if (rename(src_attr, dst_attr))
+ CT_ERROR(errno, "cannot rename '%s' to '%s'",
+ src_attr, dst_attr);
}
return 0;
__u64 seq = 0;
__u16 subseq;
- strlcpy(path, opt.o_hsm_root, sizeof(path));
+ snprintf(path, sizeof(path), "%s", opt.o_hsm_root);
/* FID sequence is stored in top-level directory names:
* hsm_root/16bits (high weight)/16 bits/16 bits/16 bits (low weight).
*/
{
int rc;
- strlcpy(cmd_name, basename(argv[0]), sizeof(cmd_name));
+ snprintf(cmd_name, sizeof(cmd_name), "%s", basename(argv[0]));
rc = ct_parseopts(argc, argv);
if (rc < 0) {
CT_WARN("try '%s --help' for more information", cmd_name);
if (source == NULL)
return NULL;
- ptr = calloc(size + 1, sizeof(char));
- if (ptr == NULL)
- return NULL;
+ if (need_convert) {
+ ptr = calloc(size + 1, sizeof(char));
+ if (ptr == NULL)
+ return NULL;
- if (need_convert) {
opt = packdigit((unsigned char*)source);
if (opt == NULL) {
free(ptr);
free(opt);
}
} else {
- strlcpy(ptr, source, size + 1);
+ ptr = strdup(source);
}
return ptr;
path = realpath(pathname, NULL);
if (path == NULL) {
- char buf[PATH_MAX], *ptr;
+ char tmp[PATH_MAX - 1];
+ char buf[PATH_MAX];
+ char *ptr;
+ tmp[0] = '\0';
buf[0] = '\0';
if (pathname[0] != '/') {
/* Need an absolute path, but realpath() only works for
* pathnames that actually exist. We go through the
* extra hurdle of dirname(getcwd() + pathname) in
* case the relative pathname contains ".." in it. */
- if (getcwd(buf, sizeof(buf) - 2) == NULL) {
+ char realpath[PATH_MAX - 1];
+
+ if (getcwd(realpath, sizeof(realpath) - 2) == NULL) {
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
"cannot get current working directory");
return rc;
}
- rc = strlcat(buf, "/", sizeof(buf));
- if (rc >= sizeof(buf)) {
+
+ rc = snprintf(tmp, sizeof(tmp), "%s/", realpath);
+ if (rc >= sizeof(tmp)) {
rc = -E2BIG;
llapi_error(LLAPI_MSG_ERROR, rc,
"invalid parent path '%s'",
- buf);
+ tmp);
return rc;
}
}
- rc = strlcat(buf, pathname, sizeof(buf));
+
+ rc = snprintf(buf, sizeof(buf), "%s%s", tmp, pathname);
if (rc >= sizeof(buf)) {
rc = -E2BIG;
llapi_error(LLAPI_MSG_ERROR, rc,
/* name is FSNAME.POOLNAME */
if (strlen(poolname) >= sizeof(fsname))
return -EOVERFLOW;
- strlcpy(fsname, poolname, sizeof(fsname));
+
+ snprintf(fsname, sizeof(fsname), "%s", poolname);
pool = strchr(fsname, '.');
if (pool == NULL)
return -EINVAL;
* a large filesystem. */
fname = (fname == NULL ? path : fname + 1);
/* retrieve needed file info */
- strlcpy((char *)lmd, fname, lumlen);
+ snprintf((char *)lmd, lumlen, "%s", fname);
ret = ioctl(dirfd(parent), IOC_MDC_GETFILEINFO, (void *)lmd);
}
if (!buf)
return -ENOMEM;
- strlcpy(buf, path, PATH_MAX + 1);
+ snprintf(buf, PATH_MAX + 1, "%s", path);
ret = common_param_init(param, buf);
if (ret)
goto out;
if (rc)
return rc;
} else {
- strlcpy(fsname_buf, fsname, sizeof(fsname_buf));
+ snprintf(fsname_buf, sizeof(fsname_buf), "%s", fsname);
}
if (strncmp(fsname_buf, cache.fsname, sizeof(fsname_buf) - 1) != 0) {
cache.stripecount = tmp[0];
cache.stripesize = tmp[1];
cache.stripeoffset = tmp[2];
- strlcpy(cache.fsname, fsname_buf, sizeof(cache.fsname));
+ snprintf(cache.fsname, sizeof(cache.fsname), "%s", fsname_buf);
}
if (scount)
lov_v1v3_pool_name(struct lov_user_md *v1, char *pool_name)
{
if (v1->lmm_magic == LOV_USER_MAGIC_V3)
- strlcpy(pool_name, ((struct lov_user_md_v3 *)v1)->lmm_pool_name,
- LOV_MAXPOOLNAME);
+ snprintf(pool_name, LOV_MAXPOOLNAME, "%s",
+ ((struct lov_user_md_v3 *)v1)->lmm_pool_name);
else
pool_name[0] = '\0';
}
struct lov_user_ost_data_v1 *objects;
struct lov_user_md_v3 *lmmv3 = (void *)¶m->fp_lmd->lmd_lmm;
- strlcpy(pool_name, lmmv3->lmm_pool_name, sizeof(pool_name));
+ snprintf(pool_name, sizeof(pool_name), "%s",
+ lmmv3->lmm_pool_name);
objects = lmmv3->lmm_objects;
lov_dump_user_lmm_v1v3(¶m->fp_lmd->lmd_lmm, pool_name,
objects, path, param->fp_obd_index,
struct lmv_user_md *lum;
lum = (struct lmv_user_md *)param->fp_lmv_md;
- strlcpy(pool_name, lum->lum_pool_name, sizeof(pool_name));
+ snprintf(pool_name, sizeof(pool_name), "%s",
+ lum->lum_pool_name);
lmv_dump_user_lmm(lum, pool_name, path, param->fp_obd_index,
param->fp_max_depth, param->fp_verbose,
flags);
char *fname = strrchr(path, '/');
fname = (fname == NULL ? path : fname + 1);
- strlcpy((char *)¶m->fp_lmd->lmd_lmm, fname,
- param->fp_lum_size);
+ snprintf((char *)¶m->fp_lmd->lmd_lmm, param->fp_lum_size,
+ "%s", fname);
ret = ioctl(dirfd(parent), IOC_MDC_GETFILESTRIPE,
(void *)¶m->fp_lmd->lmd_lmm);
mdt_hash_name;
Parser_*;
register_ioc_*;
- strlcat;
- strlcpy;
local:
*;
};
if (new_item->lji_key == NULL)
return -ENOMEM;
- strlcpy(new_item->lji_key, key, len);
+ snprintf(new_item->lji_key, len, "%s", key);
new_item->lji_type = type;
new_item->lji_next = NULL;
new_item->lji_string = calloc(len, sizeof(char));
if (new_item->lji_string == NULL)
return -ENOMEM;
- strlcpy(new_item->lji_string, (char *)val, len);
+ snprintf(new_item->lji_string, len, "%s", (char *)val);
break;
default:
llapi_err_noerrno(LLAPI_MSG_ERROR, "Unknown JSON type: %d",
#include <sys/stat.h>
#include <sys/syscall.h>
#include <lustre/lustreapi.h>
-#include <libcfs/util/string.h> /* only needed for compat strlcpy() */
#include <linux/lustre/lustre_ver.h> /* only until LUSTRE_VERSION_CODE is gone */
#include "lustreapi_internal.h"
return -1;
}
- if (strlcpy(version, ptr, version_size) >= version_size) {
+ if (snprintf(version, version_size, "%s", ptr) >= version_size) {
errno = EOVERFLOW;
return -1;
}
} else {
link = info->linktmp;
}
- strlcpy(info->link, link, sizeof(info->link));
-
+ rc = snprintf(info->link, sizeof(info->link), "%s", link);
+ if (rc >= sizeof(info->link))
+ rc = -E2BIG;
return rc;
}
p = calloc(1, sizeof(*p));
if (p == NULL)
return -ENOMEM;
- len = strlcpy(p->pc_log.pcl_pfid, pfid, sizeof(p->pc_log.pcl_pfid));
+ len = snprintf(p->pc_log.pcl_pfid, sizeof(p->pc_log.pcl_pfid),
+ "%s", pfid);
if (len >= sizeof(p->pc_log.pcl_pfid))
goto out_err;
- len = strlcpy(p->pc_log.pcl_tfid, tfid, sizeof(p->pc_log.pcl_tfid));
+ len = snprintf(p->pc_log.pcl_tfid, sizeof(p->pc_log.pcl_tfid),
+ "%s", tfid);
if (len >= sizeof(p->pc_log.pcl_tfid))
goto out_err;
- len = strlcpy(p->pc_log.pcl_name, name, sizeof(p->pc_log.pcl_name));
+ len = snprintf(p->pc_log.pcl_name, sizeof(p->pc_log.pcl_name),
+ "%s", name);
if (len >= sizeof(p->pc_log.pcl_name))
goto out_err;
info->path);
if (strcmp(srcpath, info->dest) != 0) {
- strlcpy(info->src, srcpath, sizeof(info->src));
+ snprintf(info->src, sizeof(info->src), "%s",
+ srcpath);
lr_debug(DINFO, "link source is %s\n",
info->src);
}
namelen = strnlen(changelog_rec_name(rec), rec->cr_namelen);
if (copylen > namelen + 1)
copylen = namelen + 1;
- strlcpy(info->name, changelog_rec_name(rec), copylen);
+ snprintf(info->name, copylen, "%s", changelog_rec_name(rec));
/* Don't use rnm if CLF_RENAME isn't set */
rnm = changelog_rec_rename(rec);
namelen = changelog_rec_snamelen(rec);
if (copylen > namelen + 1)
copylen = namelen + 1;
- strlcpy(info->sname, changelog_rec_sname(rec), copylen);
+ snprintf(info->sname, copylen, "%s", changelog_rec_sname(rec));
if (verbose > 1)
printf("Rec %lld: %d %s %s\n", info->recno, info->type,
status->ls_last_recno = s->ls_last_recno;
if (status->ls_registration[0] == '\0')
- strlcpy(status->ls_registration, s->ls_registration,
- sizeof(status->ls_registration));
+ snprintf(status->ls_registration,
+ sizeof(status->ls_registration), "%s",
+ s->ls_registration);
if (status->ls_mdt_device[0] == '\0')
- strlcpy(status->ls_mdt_device, s->ls_mdt_device,
- sizeof(status->ls_mdt_device));
+ snprintf(status->ls_mdt_device,
+ sizeof(status->ls_mdt_device), "%s",
+ s->ls_mdt_device);
if (status->ls_source_fs[0] == '\0')
- strlcpy(status->ls_source_fs, s->ls_source_fs,
- sizeof(status->ls_source_fs));
+ snprintf(status->ls_source_fs,
+ sizeof(status->ls_source_fs), "%s",
+ s->ls_source_fs);
if (status->ls_source[0] == '\0')
- strlcpy(status->ls_source, s->ls_source,
- sizeof(status->ls_source));
+ snprintf(status->ls_source,
+ sizeof(status->ls_source), "%s",
+ s->ls_source);
out:
if (fd != -1)
/* llapi_changelog_clear modifies the mdt
* device name so make a copy of it until this
* is fixed.
- */
- strlcpy(mdt_device, status->ls_mdt_device,
- sizeof(mdt_device));
+ */
+ snprintf(mdt_device, sizeof(mdt_device), "%s",
+ status->ls_mdt_device);
rc = llapi_changelog_clear(mdt_device,
status->ls_registration,
rec);
memcpy(info->spfid, info->pfid, sizeof(info->spfid));
memcpy(info->tfid, ext->tfid, sizeof(info->tfid));
memcpy(info->pfid, ext->pfid, sizeof(info->pfid));
- strlcpy(info->sname, info->name, sizeof(info->sname));
- strlcpy(info->name, ext->name, sizeof(info->name));
+ snprintf(info->sname, sizeof(info->sname), "%s",
+ info->name);
+ snprintf(info->name, sizeof(info->name), "%s",
+ ext->name);
info->is_extended = 1;
}
break;
case 's':
/* Assume absolute paths */
- strlcpy(status->ls_source, optarg,
- sizeof(status->ls_source));
+ snprintf(status->ls_source, sizeof(status->ls_source),
+ "%s", optarg);
break;
case 't':
status->ls_num_targets++;
if (status == NULL)
return -ENOMEM;
}
- strlcpy(status->ls_targets[status->ls_num_targets - 1],
- optarg, sizeof(status->ls_targets[0]));
+ snprintf(status->ls_targets[status->ls_num_targets - 1],
+ sizeof(status->ls_targets[0]), "%s", optarg);
break;
case 'm':
- strlcpy(status->ls_mdt_device, optarg,
- sizeof(status->ls_mdt_device));
+ snprintf(status->ls_mdt_device,
+ sizeof(status->ls_mdt_device),
+ "%s", optarg);
break;
case 'u':
- strlcpy(status->ls_registration, optarg,
- sizeof(status->ls_registration));
+ snprintf(status->ls_registration,
+ sizeof(status->ls_registration),
+ "%s", optarg);
break;
case 'l':
statuslog = optarg;
return 0;
}
+static size_t merge_strings(char *dst, const char *src, size_t size)
+{
+ size_t dsize = strlen(dst);
+ size_t len = strlen(src);
+ size_t ret = dsize + len;
+
+ dst += dsize;
+ size -= dsize;
+ if (len >= size)
+ len = size - 1;
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+ return ret;
+}
+
static int append_option(char *options, size_t options_len,
const char *param, const char *value)
{
int rc;
+
if (options[0] != '\0') {
- rc = strlcat(options, ",", options_len);
+ rc = merge_strings(options, ",", options_len);
if (rc >= options_len)
goto out_err;
}
- rc = strlcat(options, param, options_len);
+
+ rc = merge_strings(options, param, options_len);
if (rc >= options_len)
goto out_err;
+
if (value != NULL) {
- rc = strlcat(options, value, options_len);
+ rc = merge_strings(options, value, options_len);
if (rc >= options_len)
goto out_err;
}
char *ptr;
int rc;
- strlcpy(fsname, arg, PATH_MAX + 1);
+ snprintf(fsname, PATH_MAX + 1, "%s", arg);
ptr = strchr(fsname, '.');
if (ptr == NULL) {
fprintf(stderr, ". is missing in %s\n", fsname);
#include <time.h>
#include <linux/types.h>
-#include <libcfs/util/string.h>
#include <libcfs/util/ioctl.h>
#include <linux/lnet/libcfs_debug.h>
#include <linux/lnet/lnet-dlc.h>
#include <linux/lnet/lnetctl.h>
#include <linux/lnet/nidstr.h>
#include <linux/lnet/socklnd.h>
+#include <lustre/lustreapi.h>
unsigned int libcfs_debug;
unsigned int libcfs_printk = D_CANTMASK;
net_ip = htonl (ipaddr);
he = gethostbyaddr (&net_ip, sizeof (net_ip), AF_INET);
if (he != NULL) {
- strlcpy(str, he->h_name, strsize);
+ snprintf(str, strsize, "%s", he->h_name);
return (str);
}
}