On Fri, Dec 09, 2011 at 02:20:17PM -0500, Eric B Munson wrote:
> 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 <[email protected]>
> Cc: Andrew Lutomirski <[email protected]>
> ---
> hugeutils.c | 26 +++++++++++++++++++++++++-
> 1 files changed, 25 insertions(+), 1 deletions(-)
>
> diff --git a/hugeutils.c b/hugeutils.c
> index b28bd0a..5b16a31 100644
> --- a/hugeutils.c
> +++ b/hugeutils.c
> @@ -37,6 +37,7 @@
> #include <sys/vfs.h>
> #include <sys/statfs.h>
> #include <sys/types.h>
> +#include <sys/stat.h>
> #include <sys/mman.h>
> #include <sys/file.h>
> #include <sys/uio.h>
> @@ -607,6 +608,28 @@ void debug_show_page_sizes(void)
> hpage_sizes[i].mount);
> }
>
> +static bool hugetlbfs_test_access(const char *path)
> +{
> + struct stat stats;
> + uid_t uid;
> + gid_t gid;
> + if (stat(path, &stats))
> + return false;
> +
> + if (stats.st_mode & S_IRWXO)
> + return true;
> +
> + gid = getegid();
> + if (stats.st_gid == gid && (stats.st_mode & S_IRWXG))
> + return true;
> +
> + uid = geteuid();
> + if (stats.st_uid == uid && (stats.st_mode & S_IRWXU))
> + return true;
> +
> + return false;
> +}
Couldn't you simplify this logic by using access(2)?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel