aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2011-12-11 07:55:58 -0500
committerEric B Munson <emunson@mgebm.net>2011-12-15 14:50:24 -0500
commitad212ac4e76fdf953e3856a76448351a34ef6542 (patch)
tree57cd77ab602835c2f88e49e36ed718ffedc51e97
parentd189f80a2900e9339c8e61cba6710829ecf73158 (diff)
downloadlibhugetlbfs-ad212ac4e76fdf953e3856a76448351a34ef6542.tar.gz
Check permissions when selecting mount
Currently the library will select the first hugetlbfs mount it finds for a given page size for usage. This can lead to frustrating failures when root owns the first mount and a user has a later mount in the list. This patch makes find_mounts check if a given mount is usable by the current user. Mounts that are not usable will be skipped. Signed-off-by: Eric B Munson <emunson@mgebm.net> Cc: Andrew Lutomirski <luto@mit.edu> Cc: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--hugeutils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hugeutils.c b/hugeutils.c
index a7ccda0..f8e2b33 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -661,7 +661,8 @@ static void find_mounts(void)
*/
err = sscanf(line, "%*s %" stringify(PATH_MAX) "s hugetlbfs "
"%*s %d", path, &dummy);
- if ((err == 2) && (hugetlbfs_test_path(path) == 1))
+ if ((err == 2) && (hugetlbfs_test_path(path) == 1) &&
+ !(access(path, R_OK | W_OK | X_OK)))
add_hugetlbfs_mount(path, 0);
}
close(fd);