Fix some issues with the OSX port
[fio.git] / options.c
index 211bca743048e5a16893634930a85b4eaa7f0e83..1543eb95c160aa1afd2fae34c402dd3cab0092de 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1714,6 +1714,44 @@ static struct fio_option options[] = {
                .help   = "Continue on non-fatal errors during I/O",
                .def    = "0",
        },
+       {
+               .name   = "profile",
+               .type   = FIO_OPT_STR,
+               .off1   = td_var_offset(profile),
+               .posval = {
+                         { .ival = "tiobench",
+                           .oval = PROFILE_TIOBENCH,
+                           .help = "Perform tiobench like test",
+                         },
+               },
+               .help   = "Select a specific builtin performance test",
+       },
+       {
+               .name   = "cgroup",
+               .type   = FIO_OPT_STR_STORE,
+               .off1   = td_var_offset(cgroup),
+               .help   = "Add job to cgroup of this name",
+       },
+       {
+               .name   = "cgroup_weight",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(cgroup_weight),
+               .help   = "Use given weight for cgroup",
+               .minval = 100,
+               .maxval = 1000,
+       },
+       {
+               .name   = "uid",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(uid),
+               .help   = "Run job with this user ID",
+       },
+       {
+               .name   = "gid",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(gid),
+               .help   = "Run job with this group ID",
+       },
        {
                .name = NULL,
        },
@@ -1771,16 +1809,15 @@ static struct fio_keyword fio_keywords[] = {
 
 void fio_keywords_init(void)
 {
-       unsigned long mb_memory;
+       unsigned long long mb_memory;
        char buf[128];
        long l;
 
        sprintf(buf, "%lu", page_size);
        fio_keywords[0].replace = strdup(buf);
 
-       l = sysconf(_SC_PHYS_PAGES);
-       mb_memory = l * (page_size / 1024UL);
-       sprintf(buf, "%lu", mb_memory);
+       mb_memory = os_phys_mem() / page_size;
+       sprintf(buf, "%llu", mb_memory);
        fio_keywords[1].replace = strdup(buf);
 
        l = sysconf(_SC_NPROCESSORS_ONLN);
@@ -1811,6 +1848,7 @@ static char *bc_calc(char *str)
                return str;
 
        tmp++;
+       memset(opt, 0, sizeof(opt));
        strncpy(opt, str, tmp - str);
 
        buf = malloc(128);
@@ -1879,14 +1917,16 @@ static char *fio_keyword_replace(char *opt)
                         * replace opt and free the old opt
                         */
                        opt = new;
-                       free(o_org);
+                       //free(o_org);
+
+                       /*
+                        * Check for potential math and invoke bc, if possible
+                        */
+                       opt = bc_calc(opt);
                }
        }
 
-       /*
-        * Check for potential math and invoke bc, if possible
-        */
-       return bc_calc(opt);
+       return opt;
 }
 
 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)