On Fri, 2008-10-10 at 16:58 +0100, Andy Whitcroft wrote:
> Add a very basic framework for hugeadm, the administrator pool configuration
> helper.
> 
> Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]>
> Acked-by: Mel Gorman <[EMAIL PROTECTED]>
Acked-by: Adam Litke <[EMAIL PROTECTED]>

> ---
>  Makefile  |    8 ++++-
>  hugeadm.c |   95 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 102 insertions(+), 1 deletions(-)
>  create mode 100644 hugeadm.c
> 
> diff --git a/Makefile b/Makefile
> index fd86b4f..72d2ab2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -4,7 +4,7 @@ EXEDIR = /bin
>  LIBOBJS = hugeutils.o version.o init.o morecore.o debug.o alloc.o shm.o 
> kernel-features.o
>  INSTALL_OBJ_LIBS = libhugetlbfs.so libhugetlbfs.a
>  BIN_OBJ_DIR=obj
> -INSTALL_BIN = hugectl hugeedit
> +INSTALL_BIN = hugectl hugeedit hugeadm
>  INSTALL_HEADERS = hugetlbfs.h
>  INSTALL_MAN3 = get_huge_pages.3
>  INSTALL_MAN7 = libhugetlbfs.7
> @@ -262,6 +262,12 @@ $(BIN_OBJ_DIR)/hugeedit: $(BIN_OBJ_DIR)/hugeedit.o
>       mkdir -p $(BIN_OBJ_DIR)
>       $(CC) $(CPPFLAGS) $(CFLAGS) $(LIBPATHS) -o $@ $^
> 
> +HUGEADM_OBJ=hugeadm.o hugeutils.o debug.o
> +$(BIN_OBJ_DIR)/hugeadm: $(foreach file,$(HUGEADM_OBJ),$(BIN_OBJ_DIR)/$(file))
> +     @$(VECHO) LDHOST $@
> +     mkdir -p $(BIN_OBJ_DIR)
> +     $(CC) $(CPPFLAGS) $(CFLAGS) $(LIBPATHS) -o $@ $^
> +
>  clean:
>       @$(VECHO) CLEAN
>       rm -f *~ *.o *.so *.a *.d *.i core a.out $(VERSION)
> diff --git a/hugeadm.c b/hugeadm.c
> new file mode 100644
> index 0000000..78beec7
> --- /dev/null
> +++ b/hugeadm.c
> @@ -0,0 +1,95 @@
> +/***************************************************************************
> + *   User front end for using huge pages Copyright (C) 2008, IBM           *
> + *                                                                         *
> + *   This program is free software; you can redistribute it and/or modify  *
> + *   it under the terms of the Lesser GNU General Public License as        *
> + *   published by the Free Software Foundation; either version 2.1 of the  *
> + *   License, or at your option) any later version.                        *
> + *                                                                         *
> + *   This program is distributed in the hope that it will be useful,       *
> + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
> + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
> + *   GNU Lesser General Public License for more details.                   *
> + *                                                                         *
> + *   You should have received a copy of the Lesser GNU General Public      *
> + *   License along with this program; if not, write to the                 *
> + *   Free Software Foundation, Inc.,                                       *
> + *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
> + ***************************************************************************/
> +
> +/*
> + * hugeadm is designed to make an administrators life simpler, to automate
> + * and simplify basic system configuration as it relates to hugepages.  It
> + * is designed to help with pool and mount configuration.
> + */
> +
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +#include <string.h>
> +#include <limits.h>
> +
> +#define _GNU_SOURCE /* for getopt_long */
> +#include <unistd.h>
> +#include <getopt.h>
> +
> +#define REPORT_UTIL "hugeadm"
> +#include "libhugetlbfs_internal.h"
> +
> +extern int optind;
> +extern char *optarg;
> +
> +#define OPTION(opts, text)   fprintf(stderr, " %-25s  %s\n", opts, text)
> +#define CONT(text)           fprintf(stderr, " %-25s  %s\n", "", text)
> +
> +void print_usage()
> +{
> +     fprintf(stderr, "hugectl [options] target\n");
> +     fprintf(stderr, "options:\n");
> +
> +     OPTION("--help, -h", "Prints this message");
> +}
> +
> +int opt_dry_run = 0;
> +
> +int main(int argc, char** argv)
> +{
> +     char opts[] = "+h";
> +     int ret = 0, index = 0;
> +     struct option long_opts[] = {
> +             {"help",       no_argument, NULL, 'h'},
> +
> +             {0},
> +     };
> +
> +     __lh_hugetlbfs_setup_debug();
> +
> +     while (ret != -1) {
> +             ret = getopt_long(argc, argv, opts, long_opts, &index);
> +             switch (ret) {
> +             case -1:
> +                     break;
> +
> +             case '?':
> +                     print_usage();
> +                     exit(EXIT_FAILURE);
> +
> +             case 'h':
> +                     print_usage();
> +                     exit(EXIT_SUCCESS);
> +
> +             default:
> +                     WARNING("unparsed option %08x\n", ret);
> +                     ret = -1;
> +                     break;
> +             }
> +     }
> +     index = optind;
> +
> +     if ((argc - index) != 0) {
> +             print_usage();
> +             exit(EXIT_FAILURE);
> +     }
> +
> +     exit(EXIT_SUCCESS);
> +}
-- 
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to