|
Lines 78-83
Link Here
|
| 78 |
#include "src/common/gres.h" |
78 |
#include "src/common/gres.h" |
| 79 |
#include "src/common/list.h" |
79 |
#include "src/common/list.h" |
| 80 |
#include "src/common/proc_args.h" |
80 |
#include "src/common/proc_args.h" |
|
|
81 |
#include "src/common/slurm_protocol_api.h" |
| 81 |
#include "src/common/xmalloc.h" |
82 |
#include "src/common/xmalloc.h" |
| 82 |
#include "src/common/xstring.h" |
83 |
#include "src/common/xstring.h" |
| 83 |
|
84 |
|
|
Lines 601-611
char * base_name(char* command)
Link Here
|
| 601 |
return name; |
602 |
return name; |
| 602 |
} |
603 |
} |
| 603 |
|
604 |
|
| 604 |
/* |
605 |
static long _str_to_mbtyes(const char *arg, int use_gbytes) |
| 605 |
* str_to_mbytes(): verify that arg is numeric with optional "K", "M", "G" |
|
|
| 606 |
* or "T" at end and return the number in mega-bytes |
| 607 |
*/ |
| 608 |
long str_to_mbytes(const char *arg) |
| 609 |
{ |
606 |
{ |
| 610 |
long result; |
607 |
long result; |
| 611 |
char *endptr; |
608 |
char *endptr; |
|
Lines 614-620
long str_to_mbytes(const char *arg)
Link Here
|
| 614 |
result = strtol(arg, &endptr, 10); |
611 |
result = strtol(arg, &endptr, 10); |
| 615 |
if ((errno != 0) && ((result == LONG_MIN) || (result == LONG_MAX))) |
612 |
if ((errno != 0) && ((result == LONG_MIN) || (result == LONG_MAX))) |
| 616 |
result = -1; |
613 |
result = -1; |
| 617 |
else if (endptr[0] == '\0') |
614 |
else if ((endptr[0] == '\0') && (use_gbytes == 1)) /* GB default */ |
|
|
615 |
result *= 1024; |
| 616 |
else if (endptr[0] == '\0') /* MB default */ |
| 618 |
; |
617 |
; |
| 619 |
else if ((endptr[0] == 'k') || (endptr[0] == 'K')) |
618 |
else if ((endptr[0] == 'k') || (endptr[0] == 'K')) |
| 620 |
result = (result + 1023) / 1024; /* round up */ |
619 |
result = (result + 1023) / 1024; /* round up */ |
|
Lines 630-635
long str_to_mbytes(const char *arg)
Link Here
|
| 630 |
return result; |
629 |
return result; |
| 631 |
} |
630 |
} |
| 632 |
|
631 |
|
|
|
632 |
/* |
| 633 |
* str_to_mbytes(): verify that arg is numeric with optional "K", "M", "G" |
| 634 |
* or "T" at end and return the number in mega-bytes. Default units are MB. |
| 635 |
*/ |
| 636 |
long str_to_mbytes(const char *arg) |
| 637 |
{ |
| 638 |
return _str_to_mbtyes(arg, 0); |
| 639 |
} |
| 640 |
|
| 641 |
/* |
| 642 |
* str_to_mbytes2(): verify that arg is numeric with optional "K", "M", "G" |
| 643 |
* or "T" at end and return the number in mega-bytes. Default units are GB |
| 644 |
* if "SchedulerParameters=default_gbytes" is configured, otherwise MB. |
| 645 |
*/ |
| 646 |
long str_to_mbytes2(const char *arg) |
| 647 |
{ |
| 648 |
static int use_gbytes = -1; |
| 649 |
|
| 650 |
if (use_gbytes == -1) { |
| 651 |
char *sched_params = slurm_get_sched_params(); |
| 652 |
if (sched_params && strstr(sched_params, "default_gbytes")) |
| 653 |
use_gbytes = 1; |
| 654 |
else |
| 655 |
use_gbytes = 0; |
| 656 |
xfree(sched_params); |
| 657 |
} |
| 658 |
|
| 659 |
return _str_to_mbtyes(arg, use_gbytes); |
| 660 |
} |
| 661 |
|
| 633 |
/* Convert a string into a node count */ |
662 |
/* Convert a string into a node count */ |
| 634 |
static int |
663 |
static int |
| 635 |
_str_to_nodes(const char *num_str, char **leftover) |
664 |
_str_to_nodes(const char *num_str, char **leftover) |