From c652136e3e717b54caf112bb4df71cee4022a532 Mon Sep 17 00:00:00 2001 From: octo Date: Sun, 9 Apr 2006 12:48:14 +0000 Subject: [PATCH] Corrected `getfsstat' part of `utils_mount.c': The buffer size needs to be passed in bytes, not elements. --- src/utils_mount.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils_mount.c b/src/utils_mount.c index 176040aa..30a155f4 100644 --- a/src/utils_mount.c +++ b/src/utils_mount.c @@ -429,15 +429,21 @@ static cu_mount_t *cu_mount_getfsstat (void) /* Get the number of mounted file systems */ if ((bufsize = getfsstat (NULL, 0, MNT_NOWAIT)) < 1) + { + DBG ("getfsstat failed: %s", strerror (errno)); return (NULL); + } - if ((buf = (struct statfs *) malloc (bufsize * sizeof (struct statfs))) == NULL) + if ((buf = (struct statfs *) malloc (bufsize * sizeof (struct statfs))) + == NULL) return (NULL); memset (buf, '\0', bufsize * sizeof (struct statfs)); - /* FIXME: If `bufsize' in bytes or structures? */ - if ((num = getfsstat (buf, bufsize, MNT_NOWAIT)) < 1) + /* The bufsize needs to be passed in bytes. Really. This is not in the + * manpage.. -octo */ + if ((num = getfsstat (buf, bufsize * sizeof (struct statfs), MNT_NOWAIT)) < 1) { + DBG ("getfsstat failed: %s", strerror (errno)); free (buf); return (NULL); } -- 2.30.2