summaryrefslogtreecommitdiff
path: root/sysdeps/openbsd/glibtop_private.c
blob: 87bec623f517d3260bad25e1dc359663283c8ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <config.h>
#include <glibtop.h>
#include <glibtop/error.h>

#include "glibtop_private.h"

#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <errno.h>

/* Ported from linux/glibtop_private.c */
gboolean
safe_readlink(const char *path, char *buf, int bufsiz)
{
	int ret;

	ret = readlink(path, buf, bufsiz - 1);

	if (ret == -1) {
		g_warning("Could not read link %s : %s", path, strerror(errno));
		return FALSE;
	}

	buf[ret] = '\0';
	return TRUE;
}