For checked versions of dm_strncpy use inline wrapper _dm_strncpy.
lc->skip_bit_warning = region_count;
lc->disk_fd = -1;
lc->log_dev_failed = 0;
- if (!dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
+ if (!_dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
LOG_ERROR("Cannot use too long UUID %s.", uuid);
r = -EINVAL;
goto fail;
/* Recognize some older reserved LVs just from the LV name (snapshot, pvmove...) */
vgname = vg_name;
- if (!dm_strncpy(vg_name, name, sizeof(vg_name)) ||
+ if (!_dm_strncpy(vg_name, name, sizeof(vg_name)) ||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
return_0;
char path[PATH_MAX];
size_t len;
- if (!dm_strncpy(path, dir, sizeof(path) - 1)) {
+ if (!_dm_strncpy(path, dir, sizeof(path))) {
log_debug_devs("Dir path %s is too long", path);
return 0;
}
if (dirent[n]->d_name[0] == '.')
continue;
- if (!dm_strncpy(path + len, dirent[n]->d_name, sizeof(path) - len)) {
+ if (!_dm_strncpy(path + len, dirent[n]->d_name, sizeof(path) - len)) {
log_debug_devs("Path %s/%s is too long.", dir, dirent[n]->d_name);
r = 0;
continue;
continue;
if (stme.st_dev != st_lv.st_rdev)
continue;
- if (!dm_strncpy(mtab_mntpath, me->mnt_dir, sizeof(mtab_mntpath)))
+ if (!_dm_strncpy(mtab_mntpath, me->mnt_dir, sizeof(mtab_mntpath)))
continue; /* Ignore too long unsupported paths */
break;
}
vgname = split[3];
if (name && !strncmp(name, "scan:", 5))
- if (!dm_strncpy(hint.name, name + 5, sizeof(hint.name)))
+ if (!_dm_strncpy(hint.name, name + 5, sizeof(hint.name)))
continue;
if (pvid && !strncmp(pvid, "pvid:", 5))
- if (!dm_strncpy(hint.pvid, pvid + 5, sizeof(hint.pvid)))
+ if (!_dm_strncpy(hint.pvid, pvid + 5, sizeof(hint.pvid)))
continue;
if (devn && sscanf(devn, "devn:%d:%d", &major, &minor) == 2)
hint.devt = makedev(major, minor);
if (vgname && (strlen(vgname) > 3) && (vgname[4] != '-'))
- if (!dm_strncpy(hint.vgname, vgname + 3, sizeof(hint.vgname)))
+ if (!_dm_strncpy(hint.vgname, vgname + 3, sizeof(hint.vgname)))
continue;
if (!(alloc_hint = zalloc(sizeof(struct hint)))) {
/* Get lockfile directory from config file */
locking_dir = find_config_tree_str(cmd, global_locking_dir_CFG, NULL);
- if (!dm_strncpy(_lock_dir, locking_dir, sizeof(_lock_dir))) {
+ if (!_dm_strncpy(_lock_dir, locking_dir, sizeof(_lock_dir))) {
log_error("Path for locking_dir %s is invalid.", locking_dir);
return 0;
}
if (!_blocking_supported)
flags |= LCK_NONBLOCK;
- if (!dm_strncpy(resource, vol, sizeof(resource))) {
+ if (!_dm_strncpy(resource, vol, sizeof(resource))) {
log_error(INTERNAL_ERROR "Resource name %s is too long.", vol);
return 0;
}
lv_set_visible(lv);
/* Cut off suffix _pmspare */
- if (!dm_strncpy(new_name, lv->name, sizeof(new_name)) ||
+ if (!_dm_strncpy(new_name, lv->name, sizeof(new_name)) ||
!(c = strchr(new_name, '_'))) {
log_error(INTERNAL_ERROR "LV %s has no suffix for pool metadata spare.",
display_lvname(lv));
* Failing to rename is not really a problem, so we intentionally
* do not consider some things here as errors.
*/
- if (!dm_strncpy(cvol_name, lv_fast->name, sizeof(cvol_name)) ||
+ if (!_dm_strncpy(cvol_name, lv_fast->name, sizeof(cvol_name)) ||
!(suffix = strstr(cvol_name, "_cvol"))) {
log_debug("LV %s has no suffix for cachevol (skipping rename).",
display_lvname(lv_fast));
{
char *c;
- if (!dm_strncpy(new_name, name, NAME_LEN)) {
+ if (!_dm_strncpy(new_name, name, NAME_LEN)) {
log_debug(INTERNAL_ERROR "Name is too long.");
return 0;
}
goto error;
}
- if (!dm_strncpy(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path))) {
+ if (!_dm_strncpy(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path))) {
log_error("%s: Daemon socket path too long.", i.socket);
goto error;
}
fprintf(stderr, "setting O_NONBLOCK on socket fd %d failed: %s\n", fd, strerror(errno));
fprintf(stderr, "[D] creating %s\n", s.socket_path);
- if (!dm_strncpy(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path))) {
+ if (!_dm_strncpy(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path))) {
fprintf(stderr, "%s: daemon socket path too long.\n", s.socket_path);
goto error;
}
device[strlen(dev_dir)] != '/')
goto_bad;
- if (!dm_strncpy(buf, strrchr(device, '/') + 1, PATH_MAX))
+ if (!_dm_strncpy(buf, strrchr(device, '/') + 1, PATH_MAX))
goto_bad;
free(device);
} else {
if (strncmp(dev, "loop", sizeof("loop") - 1))
goto_bad;
- if (!dm_strncpy(buf, dev, PATH_MAX))
+ if (!_dm_strncpy(buf, dev, PATH_MAX))
goto_bad;
}
return NULL;
}
- if (!dm_strncpy(buf, DMS_GROUP_TAG, DMS_GROUP_TAG_LEN + 1))
+ if (!_dm_strncpy(buf, DMS_GROUP_TAG, DMS_GROUP_TAG_LEN + 1))
goto_bad;
buf += DMS_GROUP_TAG_LEN;
return 0;
}
+static inline int _dm_strncpy(char *dest, const char *src, size_t n) {
+ return dm_strncpy(dest, src, n);
+}
static char *dm_pool_strdup(void *p, const char *str)
{
/* compare the name before any suffix like _new or _<lvtype> */
- if (!dm_strncpy(name, str, sizeof(name)))
+ if (!_dm_strncpy(name, str, sizeof(name)))
return 0; /* Buffer is too short */
if ((new = strchr(name, '_')))
int i;
int first = 0, last = ARG_COUNT - 1, middle;
- if (!dm_strncpy(long_name, str, sizeof(long_name)))
+ if (!_dm_strncpy(long_name, str, sizeof(long_name)))
goto err;
if ((p = strstr(long_name, "_long")))
dm_list_init(&untrim_list);
- if (!dm_strncpy(sublv_name, lv_name, sizeof(sublv_name))) {
+ if (!_dm_strncpy(sublv_name, lv_name, sizeof(sublv_name))) {
log_error(INTERNAL_ERROR "LV name %s is too long.", lv_name);
return 0;
}
idx++;
/* Copy idx to local buffer */
- if (!dm_strncpy(idx_buf, idx, sizeof(idx_buf))) {
+ if (!_dm_strncpy(idx_buf, idx, sizeof(idx_buf))) {
log_error(INTERNAL_ERROR "Unexpected LV index %s.", idx);
return 0;
}
return 0;
}
- if (!dm_strncpy(single_args->report_prefix, report_prefix, sizeof(single_args->report_prefix))) {
+ if (!_dm_strncpy(single_args->report_prefix, report_prefix, sizeof(single_args->report_prefix))) {
log_error("_set_report_prefix_and_name: dm_strncpy failed");
return 0;
}
do {
/* TODO: Do we want to validate UUID LVM- prefix as well ? */
names = (struct dm_names *)((char *) names + next);
- if (!dm_strncpy(vgname_buf, names->name, sizeof(vgname_buf))) {
+ if (!_dm_strncpy(vgname_buf, names->name, sizeof(vgname_buf))) {
r = 0;
goto_out;
}