1
0
mirror of git://git.suckless.org/ubase synced 2024-12-26 00:32:58 +00:00
ubase/util/grabmntinfo.c
sin 97cbad7eef Remove OpenBSD support
This is becoming a nightmare.  Just support Linux.
2013-08-14 14:40:47 +01:00

32 lines
628 B
C

/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
#include "../grabmntinfo.h"
#include "../util.h"
int
grabmntinfo(struct mntinfo **minfo)
{
struct mntent *me;
struct mntinfo *mi = NULL;
int siz = 0;
FILE *fp;
fp = setmntent("/proc/mounts", "r");
if (!fp)
eprintf("setmntent:");
while ((me = getmntent(fp))) {
mi = realloc(mi, (siz + 1) * sizeof(*mi));
if (!mi)
eprintf("realloc:");
mi[siz].fsname = strdup(me->mnt_fsname);
mi[siz].mntdir = strdup(me->mnt_dir);
siz++;
}
endmntent(fp);
*minfo = mi;
return siz;
}