aboutsummaryrefslogtreecommitdiff
path: root/tests/testutils.c
diff options
context:
space:
mode:
authoraglitke <aglitke@aglitke.localdomain>2006-06-08 16:03:44 -0500
committeraglitke <aglitke@aglitke.localdomain>2006-06-08 16:03:44 -0500
commitde8ad5a30dd48cd5d5afd0bedd843fc3857180a7 (patch)
tree90e73de347a17223faedba592cd05c229b3e3fa3 /tests/testutils.c
parent1ee6c76f8623e1cadcbce9e0bdbf63e9c509b00a (diff)
downloadlibhugetlbfs-de8ad5a30dd48cd5d5afd0bedd843fc3857180a7.tar.gz
sharing: Large import of segment sharing code.
Diffstat (limited to 'tests/testutils.c')
-rw-r--r--tests/testutils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/testutils.c b/tests/testutils.c
index 1af1726..67cdb39 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -27,9 +27,11 @@
#include <errno.h>
#include <unistd.h>
#include <signal.h>
+#include <sys/types.h>
#include <sys/vfs.h>
#include <sys/ipc.h>
#include <sys/shm.h>
+#include <sys/stat.h>
#include "hugetests.h"
@@ -151,6 +153,33 @@ int test_addr_huge(void *p)
return (sb.f_type == HUGETLBFS_MAGIC);
}
+ino_t get_addr_inode(void *p)
+{
+ char name[256];
+ int ret;
+ struct stat sb;
+
+ ret = read_maps((unsigned long)p, name);
+ if (ret < 0)
+ return ret;
+ if (ret == 0) {
+ ERROR("Couldn't find address %p in /proc/self/maps\n", p);
+ return -1;
+ }
+
+ /* looks like a filename? */
+ if (name[0] != '/')
+ return 0;
+
+ /* Truncate the filename portion */
+
+ ret = stat(name, &sb);
+ if (ret < 0)
+ return -1;
+
+ return sb.st_ino;
+}
+
int remove_shmid(int shmid)
{
if (shmid >= 0) {