\bMIN\(||min_t
mdo2fid||mdd_object_fid
mktemp||mkstemp
-nla_strlcpy|nla_strscpy
+nla_strlcpy||nla_strscpy
OBD_FAILED||CFS_FAILED
OBD_FAIL_CHECK||CFS_FAIL_CHECK
OBD_FAIL_CHECK_ORSET||CFS_FAIL_CHECK_ORSET
sprintf||snprintf
strcat||strncat
strcpy||strncpy
+strlcpy||strscpy
struct timeval||struct timespec64
tempnam||mkstemp
time_t||timeout_t
LB2_LINUX_TEST_SRC([strscpy_exists], [
#include <linux/string.h>
],[
- strscpy((char *)NULL, (const char *)NULL, 0);
+ char buf[129];
+
+ strscpy(buf, "something", sizeof(buf));
],[-Werror])
])
AC_DEFUN([LIBCFS_STRSCPY_EXISTS], [
#endif
#ifndef HAVE_STRSCPY
-#define strscpy(s1, s2, sz) strlcpy((s1), (s2), (sz))
+static inline ssize_t strscpy(char *s1, const char *s2, size_t sz)
+{
+ ssize_t len = strlcpy(s1, s2, sz);
+
+ return (len >= sz) ? -E2BIG : len;
+}
#endif
#ifndef HAVE_BITMAP_TO_ARR32
if (hs == NULL)
RETURN(NULL);
- strlcpy(hs->hs_name, name, len);
+ strscpy(hs->hs_name, name, len);
hs->hs_flags = flags;
kref_init(&hs->hs_refcount);
debug_buf += sizeof(header);
}
- strlcpy(debug_buf, file, PAGE_SIZE - tage->used);
+ snprintf(debug_buf, PAGE_SIZE - tage->used, "%s", file);
tage->used += strlen(file) + 1;
debug_buf += strlen(file) + 1;
if (fn) {
- strlcpy(debug_buf, fn, PAGE_SIZE - tage->used);
+ snprintf(debug_buf, PAGE_SIZE - tage->used, "%s", fn);
tage->used += strlen(fn) + 1;
debug_buf += strlen(fn) + 1;
}
memset(ps, 0, sizeof(struct kib_poolset));
ps->ps_cpt = cpt;
- ps->ps_net = net;
- ps->ps_pool_create = po_create;
- ps->ps_pool_destroy = po_destroy;
- ps->ps_node_init = nd_init;
- ps->ps_node_fini = nd_fini;
- ps->ps_pool_size = size;
- if (strlcpy(ps->ps_name, name, sizeof(ps->ps_name))
- >= sizeof(ps->ps_name))
- return -E2BIG;
+ ps->ps_net = net;
+ ps->ps_pool_create = po_create;
+ ps->ps_pool_destroy = po_destroy;
+ ps->ps_node_init = nd_init;
+ ps->ps_node_fini = nd_fini;
+ ps->ps_pool_size = size;
+ rc = strscpy(ps->ps_name, name, sizeof(ps->ps_name));
+ if (rc < 0)
+ return rc;
spin_lock_init(&ps->ps_lock);
INIT_LIST_HEAD(&ps->ps_pool_list);
INIT_LIST_HEAD(&ps->ps_failed_pool_list);
}
ibdev->ibd_ifip = ntohl(ifaces[i].li_ipaddr);
- strlcpy(ibdev->ibd_ifname, ifaces[i].li_name,
+ strscpy(ibdev->ibd_ifname, ifaces[i].li_name,
sizeof(ibdev->ibd_ifname));
ibdev->ibd_can_failover = ifaces[i].li_iff_master;
ni->ni_nid.nid_size = 0;
ni->ni_nid.nid_addr[0] = sa->sin_addr.s_addr;
}
- strlcpy(ksi->ksni_name, ifaces[if_idx].li_name, sizeof(ksi->ksni_name));
+ strscpy(ksi->ksni_name, ifaces[if_idx].li_name, sizeof(ksi->ksni_name));
/* call it before add it to ksocknal_data.ksnd_nets */
rc = ksocknal_net_start_threads(net, ni->ni_cpts, ni->ni_ncpts);
ifaces[nip].li_index = dev->ifindex;
ifaces[nip].li_ipaddr = ifa->ifa_local;
ifaces[nip].li_netmask = ntohl(ifa->ifa_mask);
- strlcpy(ifaces[nip].li_name, ifa->ifa_label,
+ strscpy(ifaces[nip].li_name, ifa->ifa_label,
sizeof(ifaces[nip].li_name));
nip++;
}
ifaces[nip].li_index = dev->ifindex;
memcpy(ifaces[nip].li_ipv6addr,
&ifa6->addr, sizeof(struct in6_addr));
- strlcpy(ifaces[nip].li_name, dev->name,
+ strscpy(ifaces[nip].li_name, dev->name,
sizeof(ifaces[nip].li_name));
nip++;
/* As different IPv6 addresses don't have unique
struct srpc_rmsn_reqst *rsrq;
int rc;
- switch (transop) {
- case LST_TRANS_SESNEW:
+ switch (transop) {
+ case LST_TRANS_SESNEW:
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_MAKE_SESSION,
feats, 0, 0, crpc);
- if (rc != 0)
- return rc;
+ if (rc != 0)
+ return rc;
- msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
+ msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
msrq->mksn_sid.ses_stamp = console_session.ses_id.ses_stamp;
msrq->mksn_sid.ses_nid =
lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
msrq->mksn_force = console_session.ses_force;
- strlcpy(msrq->mksn_name, console_session.ses_name,
+ strscpy(msrq->mksn_name, console_session.ses_name,
sizeof(msrq->mksn_name));
- break;
+ break;
- case LST_TRANS_SESEND:
+ case LST_TRANS_SESEND:
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_REMOVE_SESSION,
feats, 0, 0, crpc);
- if (rc != 0)
- return rc;
+ if (rc != 0)
+ return rc;
rsrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.rmsn_reqst;
rsrq->rmsn_sid.ses_stamp = console_session.ses_id.ses_stamp;
lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
break;
- default:
- LBUG();
- }
+ default:
+ LBUG();
+ }
- return 0;
+ return 0;
}
int
if (strlen(name) > sizeof(console_session.ses_name)-1)
return -E2BIG;
- strlcpy(console_session.ses_name, name,
+ strscpy(console_session.ses_name, name,
sizeof(console_session.ses_name));
- rc = lstcon_batch_add(LST_DEFAULT_BATCH);
- if (rc != 0)
- return rc;
+ rc = lstcon_batch_add(LST_DEFAULT_BATCH);
+ if (rc != 0)
+ return rc;
- rc = lstcon_rpc_pinger_start();
- if (rc != 0) {
+ rc = lstcon_rpc_pinger_start();
+ if (rc != 0) {
struct lstcon_batch *bat = NULL;
- lstcon_batch_find(LST_DEFAULT_BATCH, &bat);
- lstcon_batch_destroy(bat);
+ lstcon_batch_find(LST_DEFAULT_BATCH, &bat);
+ lstcon_batch_destroy(bat);
- return rc;
- }
+ return rc;
+ }
console_session.ses_state = LST_SESSION_ACTIVE;
struct lstcon_ndlink *ndl;
int rc = 0;
- sfw_unpack_message(req);
+ sfw_unpack_message(req);
mutex_lock(&console_session.ses_mutex);
jrep->join_sid.ses_nid = lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
if (LNET_NID_IS_ANY(&console_session.ses_id.ses_nid)) {
- jrep->join_status = ESRCH;
- goto out;
- }
+ jrep->join_status = ESRCH;
+ goto out;
+ }
if (lstcon_session_feats_check(req->msg_ses_feats) != 0) {
jrep->join_status = EPROTO;
goto out;
}
- if (jreq->join_sid.ses_nid != LNET_NID_ANY &&
- !lstcon_session_match(jreq->join_sid)) {
- jrep->join_status = EBUSY;
- goto out;
- }
+ if (jreq->join_sid.ses_nid != LNET_NID_ANY &&
+ !lstcon_session_match(jreq->join_sid)) {
+ jrep->join_status = EBUSY;
+ goto out;
+ }
- if (lstcon_group_find(jreq->join_group, &grp) != 0) {
- rc = lstcon_group_alloc(jreq->join_group, &grp);
- if (rc != 0) {
- CERROR("Out of memory\n");
- goto out;
- }
+ if (lstcon_group_find(jreq->join_group, &grp) != 0) {
+ rc = lstcon_group_alloc(jreq->join_group, &grp);
+ if (rc != 0) {
+ CERROR("Out of memory\n");
+ goto out;
+ }
list_add_tail(&grp->grp_link,
&console_session.ses_grp_list);
lstcon_group_addref(grp);
}
- if (grp->grp_ref > 2) {
- /* Group in using */
- jrep->join_status = EBUSY;
- goto out;
- }
+ if (grp->grp_ref > 2) {
+ /* Group in using */
+ jrep->join_status = EBUSY;
+ goto out;
+ }
- rc = lstcon_group_ndlink_find(grp, rpc->srpc_peer, &ndl, 0);
- if (rc == 0) {
- jrep->join_status = EEXIST;
- goto out;
- }
+ rc = lstcon_group_ndlink_find(grp, rpc->srpc_peer, &ndl, 0);
+ if (rc == 0) {
+ jrep->join_status = EEXIST;
+ goto out;
+ }
- rc = lstcon_group_ndlink_find(grp, rpc->srpc_peer, &ndl, 1);
- if (rc != 0) {
- CERROR("Out of memory\n");
- goto out;
- }
+ rc = lstcon_group_ndlink_find(grp, rpc->srpc_peer, &ndl, 1);
+ if (rc != 0) {
+ CERROR("Out of memory\n");
+ goto out;
+ }
- ndl->ndl_node->nd_state = LST_NODE_ACTIVE;
- ndl->ndl_node->nd_timeout = console_session.ses_timeout;
+ ndl->ndl_node->nd_state = LST_NODE_ACTIVE;
+ ndl->ndl_node->nd_timeout = console_session.ses_timeout;
- if (grp->grp_userland == 0)
- grp->grp_userland = 1;
+ if (grp->grp_userland == 0)
+ grp->grp_userland = 1;
- strlcpy(jrep->join_session, console_session.ses_name,
+ strscpy(jrep->join_session, console_session.ses_name,
sizeof(jrep->join_session));
- jrep->join_timeout = console_session.ses_timeout;
- jrep->join_status = 0;
+ jrep->join_timeout = console_session.ses_timeout;
+ jrep->join_status = 0;
out:
rep->msg_ses_feats = console_session.ses_features;
- if (grp != NULL)
+ if (grp != NULL)
lstcon_group_decref(grp);
mutex_unlock(&console_session.ses_mutex);
- return rc;
+ return rc;
}
static struct srpc_service lstcon_acceptor_service;
refcount_set(&sn->sn_refcount, 1); /* +1 for caller */
atomic_set(&sn->sn_brw_errors, 0);
atomic_set(&sn->sn_ping_errors, 0);
- strlcpy(&sn->sn_name[0], name, sizeof(sn->sn_name));
+ strscpy(&sn->sn_name[0], name, sizeof(sn->sn_name));
sn->sn_timer_active = 0;
sn->sn_id.ses_stamp = sid.ses_stamp;
if (!request->mksn_force) {
reply->mksn_status = EBUSY;
- cplen = strlcpy(&reply->mksn_name[0], &sn->sn_name[0],
+ cplen = strscpy(&reply->mksn_name[0], &sn->sn_name[0],
sizeof(reply->mksn_name));
- if (cplen >= sizeof(reply->mksn_name))
- return -E2BIG;
+ if (cplen < 0)
+ return cplen;
return 0;
}
}
struct srpc_debug_reply *reply)
{
struct sfw_session *sn = sfw_data.fw_session;
+ int cplen;
if (sn == NULL) {
reply->dbg_status = ESRCH;
reply->dbg_status = 0;
reply->dbg_sid = get_old_sid(sn);
reply->dbg_timeout = sn->sn_timeout;
- if (strlcpy(reply->dbg_name, &sn->sn_name[0],
- sizeof(reply->dbg_name)) >= sizeof(reply->dbg_name))
- return -E2BIG;
+ cplen = strscpy(reply->dbg_name, &sn->sn_name[0],
+ sizeof(reply->dbg_name));
+ if (cplen < 0)
+ return cplen;
return 0;
}
dcb = &ccb->suc_cb;
dcb->dcb_func = seq_update_cb;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "seq_update_cb", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "seq_update_cb", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc)
cache->fci_cache_count = 0;
rwlock_init(&cache->fci_lock);
- strlcpy(cache->fci_name, name, sizeof(cache->fci_name));
+ strscpy(cache->fci_name, name, sizeof(cache->fci_name));
cache->fci_cache_size = cache_size;
cache->fci_threshold = cache_threshold;
if (IS_ERR(path))
GOTO(out_unlock, rc = PTR_ERR(path));
- if (strlcpy(state->pccs_path, path, buf_len) >= buf_len)
+ if (strscpy(state->pccs_path, path, buf_len) < 0)
GOTO(out_unlock, rc = -ENAMETOOLONG);
out_unlock:
lsm->lsm_md_layout_version = le32_to_cpu(lmm1->lmv_layout_version);
lsm->lsm_md_migrate_offset = le32_to_cpu(lmm1->lmv_migrate_offset);
lsm->lsm_md_migrate_hash = le32_to_cpu(lmm1->lmv_migrate_hash);
- cplen = strlcpy(lsm->lsm_md_pool_name, lmm1->lmv_pool_name,
+ cplen = strscpy(lsm->lsm_md_pool_name, lmm1->lmv_pool_name,
sizeof(lsm->lsm_md_pool_name));
- if (cplen >= sizeof(lsm->lsm_md_pool_name))
- RETURN(-E2BIG);
+ if (cplen < 0)
+ RETURN(cplen);
CDEBUG(D_INFO, "unpack lsm count %d/%d, master %d hash_type %#x/%#x layout_version %d\n",
lsm->lsm_md_stripe_count,
OBD_ALLOC(*pool, len);
if (*pool == NULL)
return -ENOMEM;
- strlcpy(*pool, new_pool, len);
+ strscpy(*pool, new_pool, len);
}
return 0;
}
if (entries[i].llc_magic == LOV_MAGIC_FOREIGN)
continue;
if (entries[i].llc_pool != NULL) {
- strlcpy(pool, entries[i].llc_pool, len);
+ strscpy(pool, entries[i].llc_pool, len);
break;
}
}
objs = &lmm->lmm_objects[0];
} else {
struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *)lmm;
- size_t cplen = strlcpy(v3->lmm_pool_name,
+ size_t cplen = strscpy(v3->lmm_pool_name,
lod_comp->llc_pool,
sizeof(v3->lmm_pool_name));
- if (cplen >= sizeof(v3->lmm_pool_name))
- RETURN(-E2BIG);
+ if (cplen < 0)
+ RETURN(cplen);
objs = &v3->lmm_objects[0];
}
lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
} else {
lum3->lmm_magic = cpu_to_le32(LOV_USER_MAGIC_V3);
entry->lcme_size = cpu_to_le32(sizeof(*lum3));
- strlcpy(lum3->lmm_pool_name, pool,
+ strscpy(lum3->lmm_pool_name, pool,
sizeof(lum3->lmm_pool_name));
shift += sizeof(*lum3) - sizeof(*lum);
}
v3->lmm_stripe_offset = cpu_to_le32(v1->lmm_stripe_offset);
v3->lmm_stripe_size = cpu_to_le32(v1->lmm_stripe_size);
- strlcpy(v3->lmm_pool_name, pool, sizeof(v3->lmm_pool_name));
+ strscpy(v3->lmm_pool_name, pool, sizeof(v3->lmm_pool_name));
info->lti_buf.lb_buf = v3;
info->lti_buf.lb_len = sizeof(*v3);
if (new_pool == NULL)
RETURN(-ENOMEM);
- strlcpy(new_pool->pool_name, poolname, sizeof(new_pool->pool_name));
+ strscpy(new_pool->pool_name, poolname, sizeof(new_pool->pool_name));
new_pool->pool_spill_target[0] = '\0';
atomic_set(&new_pool->pool_spill_hit, 0);
new_pool->pool_lobd = obd;
if (pool_name) {
size_t pool_name_len;
- pool_name_len = strlcpy(lsme->lsme_pool_name, pool_name,
+ pool_name_len = strscpy(lsme->lsme_pool_name, pool_name,
sizeof(lsme->lsme_pool_name));
- if (pool_name_len >= sizeof(lsme->lsme_pool_name))
- GOTO(out_lsme, rc = -E2BIG);
+ if (pool_name_len < 0)
+ GOTO(out_lsme, rc = pool_name_len);
}
/* with Data-on-MDT set maxbytes to stripe size */
if (lsm->lsm_magic == LOV_MAGIC_V3) {
BUILD_BUG_ON(sizeof(lsm->lsm_entries[0]->lsme_pool_name) !=
sizeof(lmmv3->lmm_pool_name));
- strlcpy(lmmv3->lmm_pool_name,
+ strscpy(lmmv3->lmm_pool_name,
lsm->lsm_entries[0]->lsme_pool_name,
sizeof(lmmv3->lmm_pool_name));
lmm_objects = lmmv3->lmm_objects;
if (lsme->lsme_magic == LOV_MAGIC_V3) {
struct lov_mds_md_v3 *lmmv3 = (struct lov_mds_md_v3 *)lmm;
- strlcpy(lmmv3->lmm_pool_name, lsme->lsme_pool_name,
+ strscpy(lmmv3->lmm_pool_name, lsme->lsme_pool_name,
sizeof(lmmv3->lmm_pool_name));
lmm_objects = lmmv3->lmm_objects;
} else {
if (new_pool == NULL)
RETURN(-ENOMEM);
- strlcpy(new_pool->pool_name, poolname, sizeof(new_pool->pool_name));
+ strscpy(new_pool->pool_name, poolname, sizeof(new_pool->pool_name));
new_pool->pool_lobd = obd;
/* ref count init to 1 because when created a pool is always used
* up to deletion
buf[name_len] = '\0';
return;
}
- cpy_len = strlcpy(buf, name, buf_size);
+ cpy_len = strscpy(buf, name, buf_size);
LASSERT(lu_name_is_valid_2(buf, cpy_len));
if (cpy_len != name_len)
RCL_CLIENT);
LASSERT(buf_size == p->ssp_sepol_size);
- strlcpy(buf, p->ssp_sepol, p->ssp_sepol_size);
+ strscpy(buf, p->ssp_sepol, p->ssp_sepol_size);
}
void mdc_readdir_pack(struct req_capsule *pill, __u64 pgoff, size_t size,
rc = mdd_changelog_name_check(env, ctxt, mdd, name);
if (rc)
GOTO(out_users, rc);
- strlcpy(rec->cur_name, name, sizeof(rec->cur_name));
+ strscpy(rec->cur_name, name, sizeof(rec->cur_name));
}
mdd_chlg_username(rec, user_name, sizeof(user_name));
rnm->cr_spfid = *spfid;
changelog_rec_name(rec)[rec->cr_namelen] = '\0';
- strlcpy(changelog_rec_sname(rec), sname->ln_name, extsize);
+ strscpy(changelog_rec_sname(rec), sname->ln_name, extsize);
rec->cr_namelen += extsize;
}
if (jobid == NULL || jobid[0] == '\0')
return;
- strlcpy(jid->cr_jobid, jobid, sizeof(jid->cr_jobid));
+ strscpy(jid->cr_jobid, jobid, sizeof(jid->cr_jobid));
}
void mdd_changelog_rec_ext_extra_flags(struct changelog_rec *rec, __u64 eflags)
{
struct changelog_ext_xattr *xattr = changelog_rec_xattr(rec);
- strlcpy(xattr->cr_xattr, xattr_name, sizeof(xattr->cr_xattr));
+ strscpy(xattr->cr_xattr, xattr_name, sizeof(xattr->cr_xattr));
}
/**
if (!count || count > LOV_MAXPOOLNAME + 1 || buffer[0] == '\n')
return -EINVAL;
- strlcpy(mdd->mdd_append_pool, buffer, LOV_MAXPOOLNAME + 1);
+ strscpy(mdd->mdd_append_pool, buffer, LOV_MAXPOOLNAME + 1);
if (mdd->mdd_append_pool[count - 1] == '\n')
mdd->mdd_append_pool[count - 1] = '\0';
RETURN(-ENOMEM);
hal->hal_version = HAL_VERSION;
- strlcpy(hal->hal_fsname, hsd->hsd_fsname, MTI_NAME_MAXLEN + 1);
+ strscpy(hal->hal_fsname, hsd->hsd_fsname, MTI_NAME_MAXLEN + 1);
hal->hal_archive_id = larr->arr_archive_id;
hal->hal_flags = larr->arr_flags;
hal->hal_count = 0;
/* set jobid if specified. */
if (jobid)
- strlcpy(uc->uc_jobid, jobid, sizeof(uc->uc_jobid));
+ strscpy(uc->uc_jobid, jobid, sizeof(uc->uc_jobid));
else
uc->uc_jobid[0] = '\0';
}
body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
LASSERT(body != NULL);
LASSERT(sizeof(body->mcb_name) > strlen(cld->cld_logname));
- if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
- >= sizeof(body->mcb_name))
- GOTO(out, rc = -E2BIG);
+ rc = strscpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name));
+ if (rc < 0)
+ GOTO(out, rc);
body->mcb_offset = cfg->cfg_last_idx + 1;
body->mcb_type = cld->cld_type;
body->mcb_bits = PAGE_SHIFT;
body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
LASSERT(body);
LASSERT(sizeof(body->mcb_name) > strlen(cld->cld_logname));
- if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
- >= sizeof(body->mcb_name))
- GOTO(out, rc = -E2BIG);
+ rc = strscpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name));
+ if (rc < 0)
+ GOTO(out, rc);
body->mcb_offset = config_read_offset;
body->mcb_type = cld->cld_type;
body->mcb_bits = PAGE_SHIFT;
/* Also make sure poolname is not to long. */
if (strlen(ptr) > LOV_MAXPOOLNAME)
return -ENAMETOOLONG;
- strlcpy(poolname, ptr, LOV_MAXPOOLNAME + 1);
+ strscpy(poolname, ptr, LOV_MAXPOOLNAME + 1);
/* Test if fsname is empty */
len = strlen(arg) - strlen(ptr) - 1;
OBD_ALLOC_PTR(mml);
if (!mml)
GOTO(out_close, rc = -ENOMEM);
- if (strlcpy(mml->mml_marker.cm_comment, comment,
- sizeof(mml->mml_marker.cm_comment)) >=
- sizeof(mml->mml_marker.cm_comment))
- GOTO(out_free, rc = -E2BIG);
- if (strlcpy(mml->mml_marker.cm_tgtname, devname,
- sizeof(mml->mml_marker.cm_tgtname)) >=
- sizeof(mml->mml_marker.cm_tgtname))
- GOTO(out_free, rc = -E2BIG);
+ rc = strscpy(mml->mml_marker.cm_comment, comment,
+ sizeof(mml->mml_marker.cm_comment));
+ if (rc < 0)
+ GOTO(out_free, rc);
+ rc = strscpy(mml->mml_marker.cm_tgtname, devname,
+ sizeof(mml->mml_marker.cm_tgtname));
+ if (rc < 0)
+ GOTO(out_free, rc);
/* Modify mostly means cancel */
mml->mml_marker.cm_flags = flags;
mml->mml_marker.cm_canceltime = flags ? ktime_get_real_seconds() : 0;
GOTO(out_close, rc = -ENOMEM);
/* devname is only needed information to replace UUID records */
if (devname)
- strlcpy(mrd->target.mti_svname, devname,
+ strscpy(mrd->target.mti_svname, devname,
sizeof(mrd->target.mti_svname));
/* data is parsed in llog callback */
if (data)
- strlcpy(mrd->target.mti_params, data,
+ strscpy(mrd->target.mti_params, data,
sizeof(mrd->target.mti_params));
/* Copy records to this temporary llog */
mrd->temp_llh = orig_llh;
mgi->mgi_marker.cm_step = fsdb->fsdb_gen;
mgi->mgi_marker.cm_flags = flags;
mgi->mgi_marker.cm_vers = LUSTRE_VERSION_CODE;
- cplen = strlcpy(mgi->mgi_marker.cm_tgtname, tgtname,
+ cplen = strscpy(mgi->mgi_marker.cm_tgtname, tgtname,
sizeof(mgi->mgi_marker.cm_tgtname));
- if (cplen >= sizeof(mgi->mgi_marker.cm_tgtname))
- return -E2BIG;
- cplen = strlcpy(mgi->mgi_marker.cm_comment, comment,
+ if (cplen < 0)
+ return cplen;
+ cplen = strscpy(mgi->mgi_marker.cm_comment, comment,
sizeof(mgi->mgi_marker.cm_comment));
- if (cplen >= sizeof(mgi->mgi_marker.cm_comment))
- return -E2BIG;
+ if (cplen < 0)
+ return cplen;
mgi->mgi_marker.cm_createtime = ktime_get_real_seconds();
mgi->mgi_marker.cm_canceltime = 0;
lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL);
(marker->cm_flags & CM_START) &&
!(marker->cm_flags & CM_SKIP)) {
got_an_osc_or_mdc = 1;
- cplen = strlcpy(tmti->mti_svname, marker->cm_tgtname,
+ cplen = strscpy(tmti->mti_svname, marker->cm_tgtname,
sizeof(tmti->mti_svname));
- if (cplen >= sizeof(tmti->mti_svname))
- RETURN(-E2BIG);
+ if (cplen < 0)
+ RETURN(cplen);
rc = record_start_log(env, mgs, &mdt_llh,
mti->mti_svname);
if (rc)
int rc, del;
/* Erase any old settings of this same parameter */
- strlcpy(comment, ptr, sizeof(comment));
+ strscpy(comment, ptr, sizeof(comment));
/* But don't try to match the value. */
tmp = strchr(comment, '=');
if (tmp != NULL)
}
param = strstr(ptr, PARAM_FAILNODE);
- if (strlcpy(mti->mti_params, param, sizeof(mti->mti_params)) >=
- sizeof(mti->mti_params)) {
- rc = -E2BIG;
+ rc = strscpy(mti->mti_params, param, sizeof(mti->mti_params));
+ if (rc < 0)
goto end;
- }
CDEBUG(D_MGS, "Adding failnode with param %s\n",
mti->mti_params);
"%.*s", (int)len, param);
param += len + 1;
} else {
- if (strlcpy(mti->mti_svname, devname, sizeof(mti->mti_svname)) >=
- sizeof(mti->mti_svname))
- RETURN(-E2BIG);
+ rc = strscpy(mti->mti_svname, devname, sizeof(mti->mti_svname));
+ if (rc < 0)
+ RETURN(rc);
}
if (!strlen(mti->mti_svname)) {
/* For this case we have an invalid obd device name */
case -ENXIO:
CDEBUG(D_MGS, "%s don't contain an index\n", mti->mti_svname);
- strlcpy(mti->mti_fsname, mti->mti_svname, MTI_NAME_MAXLEN);
+ strscpy(mti->mti_fsname, mti->mti_svname, MTI_NAME_MAXLEN);
dev_type = 0;
break;
/* Not an obd device, assume devname is the fsname.
*/
case -EINVAL:
CDEBUG(D_MGS, "%s is seen as a file system name\n", mti->mti_svname);
- strlcpy(mti->mti_fsname, mti->mti_svname, MTI_NAME_MAXLEN);
+ strscpy(mti->mti_fsname, mti->mti_svname, MTI_NAME_MAXLEN);
dev_type = 0;
break;
default:
}
break;
}
-
- if (strlcpy(mti->mti_params, param, sizeof(mti->mti_params)) >=
- sizeof(mti->mti_params))
- GOTO(out, rc = -E2BIG);
+ rc = strscpy(mti->mti_params, param, sizeof(mti->mti_params));
+ if (rc < 0)
+ GOTO(out, rc);
CDEBUG(D_MGS, "set_conf_param fs='%s' device='%s' param='%s'\n",
mti->mti_fsname, mti->mti_svname, mti->mti_params);
size_t len;
int rc;
- if (strlcpy(mti->mti_params, param, sizeof(mti->mti_params)) >=
- sizeof(mti->mti_params))
- GOTO(out, rc = -E2BIG);
+ rc = strscpy(mti->mti_params, param, sizeof(mti->mti_params));
+ if (rc < 0)
+ GOTO(out, rc);
len = strcspn(param, ".=");
if (len && param[len] != '=') {
dfh->dfh_dt = dt;
dfh->dfh_fid = fid;
- strlcpy(info->dti_buf, path, sizeof(info->dti_buf));
+ strscpy(info->dti_buf, path, sizeof(info->dti_buf));
result = dt->dd_ops->dt_root_get(env, dt, fid);
if (result == 0) {
rcu_read_lock();
jid = jobid_current();
if (jid) {
- strlcpy(jobid, jid, joblen);
+ strscpy(jobid, jid, joblen);
joblen = strlen(jobid);
} else {
rc = -ENOENT;
spin_lock(&pidmap->jp_lock);
if (!rc) {
pidmap->jp_joblen = env_len;
- strlcpy(pidmap->jp_jobid, env_jobid,
+ strscpy(pidmap->jp_jobid, env_jobid,
sizeof(pidmap->jp_jobid));
rc = 0;
} else if (rc == -ENOENT) {
* If a cached missing entry was found, return -ENOENT.
*/
if (pidmap->jp_joblen) {
- strlcpy(jobid, pidmap->jp_jobid, joblen);
+ strscpy(jobid, pidmap->jp_jobid, joblen);
joblen = pidmap->jp_joblen;
rc = 0;
} else if (!rc) {
if (jobid_hash == NULL)
return;
- strlcpy(jobid, find_jobid, sizeof(jobid));
+ strscpy(jobid, find_jobid, sizeof(jobid));
/* trim \n off the end of the incoming jobid */
end = strchr(jobid, '\n');
if (end && *end == '\n')
if (!new_param)
GOTO(out_nocfg, new_cfg = ERR_PTR(-ENOMEM));
- strlcpy(new_param, new_name, new_len);
+ strscpy(new_param, new_name, new_len);
if (value)
strcat(new_param, value);
if (endptr != NULL)
*endptr = dash;
- if (strlcpy(svname, dash + 1, svsize) >= svsize)
- return -E2BIG;
+ rc = strscpy(svname, dash + 1, svsize);
+ if (rc < 0)
+ return rc;
return 0;
}
RETURN(ERR_PTR(-ENOMEM));
for (i = 0; i < cache->uc_hashsize; i++)
INIT_LIST_HEAD(&cache->uc_hashtable[i]);
- strlcpy(cache->uc_name, name, sizeof(cache->uc_name));
+ strscpy(cache->uc_name, name, sizeof(cache->uc_name));
/* upcall pathname proc tunable */
- strlcpy(cache->uc_upcall, upcall, sizeof(cache->uc_upcall));
+ strscpy(cache->uc_upcall, upcall, sizeof(cache->uc_upcall));
cache->uc_entry_expire = entry_expire;
cache->uc_acquire_expire = acquire_expire;
cache->uc_acquire_replay = replayable;
if (!oal)
return ERR_PTR(-ENOMEM);
- strlcpy(oal->oal_name, ofd_name, sizeof(oal->oal_name));
+ strscpy(oal->oal_name, ofd_name, sizeof(oal->oal_name));
oal->oal_log_size = size;
oal->oal_entry_size = entry_size;
INIT_LIST_HEAD(&oal->oal_circ_buf_list);
dcb = &ossc->ossc_cb;
dcb->dcb_func = ofd_cb_soft_sync;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "ofd_cb_soft_sync", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "ofd_cb_soft_sync", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc) {
dcb = &opc->opc_cb;
dcb->dcb_func = ofd_cb_precreate;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "ofd_cb_precreate", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "ofd_cb_precreate", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc) {
const char *name, struct lu_device *next)
{
struct osd_device *osd = osd_dev(d);
+ int cplen = strscpy(osd->od_svname, name, sizeof(osd->od_svname));
- if (strlcpy(osd->od_svname, name, sizeof(osd->od_svname)) >=
- sizeof(osd->od_svname))
- return -E2BIG;
+ if (cplen < 0)
+ return cplen;
return osd_procfs_init(osd, name);
}
/* default fallocate to unwritten extents: LU-14326/LU-14333 */
o->od_fallocate_zero_blocks = 0;
- cplen = strlcpy(o->od_svname, lustre_cfg_string(cfg, 4),
+ cplen = strscpy(o->od_svname, lustre_cfg_string(cfg, 4),
sizeof(o->od_svname));
- if (cplen >= sizeof(o->od_svname)) {
- rc = -E2BIG;
- GOTO(out, rc);
- }
+ if (cplen < 0)
+ GOTO(out, rc = cplen);
o->od_index_backup_stop = 0;
o->od_index = -1; /* -1 means index is invalid */
if (len_root > (p - path) || len_root + len_path + 16 > PATH_MAX)
goto out;
- strlcpy(path, root, len_root);
+ strscpy(path, root, len_root);
if (p > path + len_root) {
s = path + len_root;
while ((*s++ = *p++) != '\0');
if (mntdev == NULL || svname == NULL)
RETURN(-EINVAL);
- rc = strlcpy(o->od_mntdev, mntdev, sizeof(o->od_mntdev));
- if (rc >= sizeof(o->od_mntdev))
- RETURN(-E2BIG);
+ rc = strscpy(o->od_mntdev, mntdev, sizeof(o->od_mntdev));
+ if (rc < 0)
+ RETURN(rc);
- rc = strlcpy(o->od_svname, svname, sizeof(o->od_svname));
- if (rc >= sizeof(o->od_svname))
- RETURN(-E2BIG);
+ rc = strscpy(o->od_svname, svname, sizeof(o->od_svname));
+ if (rc < 0)
+ RETURN(rc);
opts = lustre_cfg_string(cfg, 3);
if (len_root > (p - path) || len_root + len_path + 16 > PATH_MAX)
goto out;
- strlcpy(path, root, len_root);
+ strscpy(path, root, len_root);
if (p > path + len_root) {
s = path + len_root;
while ((*s++ = *p++) != '\0');
if (rc)
return rc;
- rc = strlcpy(oi->oi_name, name, sizeof(oi->oi_name));
- if (rc >= sizeof(oi->oi_name))
- return -E2BIG;
+ rc = strscpy(oi->oi_name, name, sizeof(oi->oi_name));
+ if (rc < 0)
+ return rc;
oi->oi_zapid = zde->zde_dnode;
/* inode accounting is maintained by DMU since 0.7.0 */
strncpy(info->oti_buf, DMU_OBJACCT_PREFIX,
DMU_OBJACCT_PREFIX_LEN);
- strlcpy(info->oti_buf + DMU_OBJACCT_PREFIX_LEN, za->za_name,
+ strscpy(info->oti_buf + DMU_OBJACCT_PREFIX_LEN, za->za_name,
sizeof(info->oti_buf) - DMU_OBJACCT_PREFIX_LEN);
rc = osd_zap_lookup(osd, it->oiq_obj->oo_dn->dn_object,
it->oiq_obj->oo_dn, info->oti_buf, sizeof(uint64_t),
nodemap->nm_fileset[0] = '\0';
else if (fileset[0] != '/')
rc = -EINVAL;
- else if (strlcpy(nodemap->nm_fileset, fileset,
- sizeof(nodemap->nm_fileset)) >=
- sizeof(nodemap->nm_fileset))
+ else if (strscpy(nodemap->nm_fileset, fileset,
+ sizeof(nodemap->nm_fileset)) < 0)
rc = -ENAMETOOLONG;
return rc;
/* truncation cannot happen, as string length was checked in
* nodemap_validate_sepol()
*/
- strlcpy(nodemap->nm_sepol, sepol, sizeof(nodemap->nm_sepol));
+ strscpy(nodemap->nm_sepol, sepol, sizeof(nodemap->nm_sepol));
out_putref:
mutex_unlock(&active_config_lock);
mutex_lock(&active_config_lock);
old_nm = nodemap_lookup(rec->ncr.ncr_name);
if (!IS_ERR(old_nm) && old_nm->nm_fileset[0] != '\0')
- strlcpy(nodemap->nm_fileset, old_nm->nm_fileset,
+ strscpy(nodemap->nm_fileset, old_nm->nm_fileset,
sizeof(nodemap->nm_fileset));
mutex_unlock(&active_config_lock);
if (!IS_ERR(old_nm))
}
if (arg)
- strlcpy(policy->pol_arg, arg, sizeof(policy->pol_arg));
+ strscpy(policy->pol_arg, arg, sizeof(policy->pol_arg));
/* take the started reference */
refcount_set(&policy->pol_start_ref, 1);
if (desc == NULL)
GOTO(fail, rc = -ENOMEM);
- if (strlcpy(desc->pd_name, conf->nc_name, sizeof(desc->pd_name)) >=
+ if (strscpy(desc->pd_name, conf->nc_name, sizeof(desc->pd_name)) >=
sizeof(desc->pd_name)) {
OBD_FREE_PTR(desc);
GOTO(fail, rc = -E2BIG);
if (rule == NULL)
return -ENOMEM;
- strlcpy(rule->tr_name, start->tc_name, sizeof(rule->tr_name));
+ strscpy(rule->tr_name, start->tc_name, sizeof(rule->tr_name));
rule->tr_rpc_rate = start->u.tc_start.ts_rpc_rate;
rule->tr_flags = start->u.tc_start.ts_rule_flags;
rule->tr_nsecs_per_rpc = NSEC_PER_SEC / rule->tr_rpc_rate;
if (cli) {
INIT_LIST_HEAD(&cli->tc_lru);
- strlcpy(cli->tc_key, keystr, sizeof(cli->tc_key));
- strlcpy(cli->tc_jobid, jobid, sizeof(cli->tc_jobid));
+ strscpy(cli->tc_key, keystr, sizeof(cli->tc_key));
+ strscpy(cli->tc_jobid, jobid, sizeof(cli->tc_jobid));
cli->tc_nid = req->rq_peer.nid;
cli->tc_opcode = opc;
cli->tc_id = id;
if (rule->tr_ids_str == NULL)
return -ENOMEM;
- strlcpy(rule->tr_ids_str, start->u.tc_start.ts_ids_str,
+ strscpy(rule->tr_ids_str, start->u.tc_start.ts_ids_str,
ids_len);
if (!list_empty(&start->u.tc_start.ts_ids)) {
return 0;
}
- strlcpy(buf, str, sizeof(buf));
+ strscpy(buf, str, sizeof(buf));
bulk = strchr(buf, '-');
if (bulk)
OBD_ALLOC_PTR(conf_tgt);
if (conf_tgt) {
- strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
+ strscpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
sptlrpc_rule_set_init(&conf_tgt->sct_rset);
list_add(&conf_tgt->sct_list, &conf->sc_tgts);
}
OBD_ALLOC_PTR(conf);
if (conf == NULL)
return NULL;
-
- if (strlcpy(conf->sc_fsname, fsname, sizeof(conf->sc_fsname)) >=
- sizeof(conf->sc_fsname)) {
+ if (strscpy(conf->sc_fsname, fsname, sizeof(conf->sc_fsname)) < 0) {
OBD_FREE_PTR(conf);
return NULL;
}
* is a actual filesystem.
*/
if (server_name2fsname(target, fsname, NULL))
- strlcpy(fsname, target, sizeof(fsname));
+ strscpy(fsname, target, sizeof(fsname));
rc = sptlrpc_parse_rule(param, &rule);
if (rc)
kref_init(&new->ssp_ref);
new->ssp_sepol_size = pol_len + 1;
new->ssp_mtime = mtime;
- strlcpy(new->ssp_sepol, pol, new->ssp_sepol_size);
+ strscpy(new->ssp_sepol, pol, new->ssp_sepol_size);
spin_lock(&imp_sec->ps_lock);
old = rcu_dereference_protected(imp_sec->ps_sepol, 1);
RETURN(-EINVAL);
/* record who i am, it might be useful ... */
- rc = strlcpy(qmt->qmt_svname, svname, sizeof(qmt->qmt_svname));
- if (rc >= sizeof(qmt->qmt_svname))
- RETURN(-E2BIG);
+ rc = strscpy(qmt->qmt_svname, svname, sizeof(qmt->qmt_svname));
+ if (rc < 0)
+ RETURN(rc);
/* look-up the obd_device associated with the qmt */
obd = class_name2obd(qmt->qmt_svname);
qsd->qsd_exclusive = excl;
/* copy service name */
- if (strlcpy(qsd->qsd_svname, svname, sizeof(qsd->qsd_svname))
- >= sizeof(qsd->qsd_svname))
- GOTO(out, rc = -E2BIG);
+ rc = strscpy(qsd->qsd_svname, svname, sizeof(qsd->qsd_svname));
+ if (rc < 0)
+ GOTO(out, rc);
/* grab reference on osd device */
lu_device_get(&dev->dd_lu_dev);
dcb = &tgc->tgc_cb;
dcb->dcb_func = tgt_grant_commit_cb;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "tgt_grant_commit_cb", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "tgt_grant_commit_cb", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc) {
dcb = &ccb->lncc_cb;
dcb->dcb_func = tgt_cb_new_client;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "tgt_cb_new_client", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "tgt_cb_new_client", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc) {
dcb = &ccb->llcc_cb;
dcb->dcb_func = tgt_cb_last_committed;
INIT_LIST_HEAD(&dcb->dcb_linkage);
- strlcpy(dcb->dcb_name, "tgt_cb_last_committed", sizeof(dcb->dcb_name));
+ strscpy(dcb->dcb_name, "tgt_cb_last_committed", sizeof(dcb->dcb_name));
rc = dt_trans_cb_add(th, dcb);
if (rc) {
if (!mti)
GOTO(free_list, mti = ERR_PTR(-ENOMEM));
- if (strlcpy(mti->mti_svname, lsi->lsi_svname, sizeof(mti->mti_svname))
- >= sizeof(mti->mti_svname))
- GOTO(free_mti, rc = -E2BIG);
+ rc = strscpy(mti->mti_svname, lsi->lsi_svname, sizeof(mti->mti_svname));
+ if (rc < 0)
+ GOTO(free_mti, rc);
mti->mti_nid_count = nid_count;
for (i = 0; i < mti->mti_nid_count; i++) {
/* use NID strings instead */
if (large_nid)
mti->mti_flags |= LDD_F_LARGE_NID;
- cplen = strlcpy(mti->mti_params, lsi->lsi_lmd->lmd_params,
+ cplen = strscpy(mti->mti_params, lsi->lsi_lmd->lmd_params,
sizeof(mti->mti_params));
if (cplen >= sizeof(mti->mti_params))
rc = -E2BIG;
strlen(fstype) >= sizeof(lsi->lsi_fstype))
RETURN(-ENAMETOOLONG);
- strlcpy(lsi->lsi_svname, lsi->lsi_lmd->lmd_profile,
+ strscpy(lsi->lsi_svname, lsi->lsi_lmd->lmd_profile,
sizeof(lsi->lsi_svname));
- strlcpy(lsi->lsi_osd_type, osd_type, sizeof(lsi->lsi_osd_type));
+ strscpy(lsi->lsi_osd_type, osd_type, sizeof(lsi->lsi_osd_type));
/* XXX: a temp. solution for components using ldiskfs
* to be removed in one of the subsequent patches
*/
- strlcpy(lsi->lsi_fstype, fstype, sizeof(lsi->lsi_fstype));
+ strscpy(lsi->lsi_fstype, fstype, sizeof(lsi->lsi_fstype));
/* Determine server type */
rc = server_name2index(lsi->lsi_svname, &index, NULL);