diff options
Diffstat (limited to 'mnt.c')
-rw-r--r-- | mnt.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -288,7 +288,7 @@ void mog_mnt_release(const struct mount_entry *me) #define MOG_DEV_T_INVAL ((dev_t)-1) struct mnt_update { - const char *prefix; + char prefix[(sizeof("/dev/") - 1) + MOG_IOSTAT_DEVLEN]; size_t prefixlen; dev_t st_rdev; char util[MOG_IOUTIL_LEN]; @@ -340,12 +340,14 @@ static bool update_util_each(void *ent, void *upd) */ void mog_mnt_update_util(struct mog_iostat *iostat) { + static const size_t pfx_len = sizeof("/dev/") - 1; struct mnt_update update; + size_t cpy_len = strlen(iostat->dev); + char *dst = mempcpy(update.prefix, "/dev/", pfx_len); struct stat st; - const char *devsuffix = iostat->dev; - update.prefix = xasprintf("/dev/%s", devsuffix); - update.prefixlen = strlen(update.prefix); + mempcpy(dst, iostat->dev, cpy_len + 1); + update.prefixlen = cpy_len + pfx_len; /* * st_rdev matching is necessary for cryptmount(8) on Linux, where @@ -368,6 +370,4 @@ void mog_mnt_update_util(struct mog_iostat *iostat) CHECK(int, 0, pthread_mutex_lock(&by_dev_lock) ); (void)hash_do_for_each(by_dev, update_util_each, &update); CHECK(int, 0, pthread_mutex_unlock(&by_dev_lock) ); - - mog_free(update.prefix); } |