On 07/23/14 21:06, Daniel P. Berrange wrote:
On Wed, Jul 23, 2014 at 05:37:17PM +0200, Michal Privoznik wrote:
> +int
> +virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
> + size_t *ret_nfs)
> +{
> + int ret = -1;
> + FILE *f = NULL;
> + struct mntent mb;
> + char mntbuf[1024];
> + virHugeTLBFSPtr fs = NULL;
> + size_t nfs = 0;
> + unsigned long long default_hugepagesz;
> +
> + if (virFileGetDefaultHugepageSize(&default_hugepagesz) < 0)
> + goto cleanup;
> +
> + if (!(f = setmntent(PROC_MOUNTS, "r"))) {
> + virReportSystemError(errno,
> + _("Unable to open %s"),
> + PROC_MOUNTS);
> + goto cleanup;
> + }
> +
> + while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) {
> + virHugeTLBFSPtr tmp;
> +
> + if (STRNEQ(mb.mnt_type, "hugetlbfs"))
> + continue;
> +
> + if (VIR_REALLOC_N(fs, nfs + 1) < 0)
> + goto cleanup;
> +
> + tmp = &fs[nfs];
> + nfs++;
Stilll think we should be using VIR_EXPAND_N here to ensure
new space is fully zerod.
Or perhaps use VIR_APPEND_ELEMENT?
> +
> + if (VIR_STRDUP(tmp->mnt_dir, mb.mnt_dir) < 0)
> + goto cleanup;