When hugeadm creates mount points currently the pagesize is used in bytes. This is not very human readable as page sizes grow. This patch changes the mount point creation to use points labeled in a more readable fashion. For instance 2MB instead of 2097152.
Signed-off-by: Eric B Munson <emun...@mgebm.net> --- Changes from V1: Simplified the way the path is assembled to avoid circular paths hugeadm.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hugeadm.c b/hugeadm.c index 509968a..26056e9 100644 --- a/hugeadm.c +++ b/hugeadm.c @@ -44,6 +44,10 @@ #include <unistd.h> #include <getopt.h> +#define KB (1024) +#define MB (1024*KB) +#define GB (1024*MB) + #define REPORT_UTIL "hugeadm" #define REPORT(level, prefix, format, ...) \ do { \ @@ -553,6 +557,15 @@ int mount_dir(char *path, char *options, mode_t mode, uid_t uid, gid_t gid) return 0; } +void scale_size(char *buf, unsigned long pagesize) +{ + if(pagesize >= GB) + snprintf(buf, OPT_MAX, "%luGB", pagesize / GB); + else if(pagesize >= MB) + snprintf(buf, OPT_MAX, "%luMB", pagesize / MB); + else + snprintf(buf, OPT_MAX, "%luKB", pagesize / KB); +} void create_mounts(char *user, char *group, char *base, mode_t mode) { @@ -560,6 +573,7 @@ void create_mounts(char *user, char *group, char *base, mode_t mode) char path[PATH_MAX]; char options[OPT_MAX]; char limits[OPT_MAX]; + char scaled[OPT_MAX]; int cnt, pos; struct passwd *pwd; struct group *grp; @@ -598,15 +612,17 @@ void create_mounts(char *user, char *group, char *base, mode_t mode) } for (pos=0; cnt--; pos++) { + scaled[0] = 0; + scale_size(scaled, pools[pos].pagesize); if (user) - snprintf(path, PATH_MAX, "%s/%s/pagesize-%ld", - base, user, pools[pos].pagesize); + snprintf(path, PATH_MAX, "%s/%s/pagesize-%s", + base, user, scaled); else if (group) - snprintf(path, PATH_MAX, "%s/%s/pagesize-%ld", - base, group, pools[pos].pagesize); + snprintf(path, PATH_MAX, "%s/%s/pagesize-%s", + base, group, scaled); else - snprintf(path, PATH_MAX, "%s/pagesize-%ld", - base, pools[pos].pagesize); + snprintf(path, PATH_MAX, "%s/pagesize-%s", + base, scaled); snprintf(options, OPT_MAX, "pagesize=%ld", pools[pos].pagesize); -- 1.7.1 ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel