Hi!
> diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
> index c8099c5..de58c1e 100644
> --- a/tools/apicmds/ltpapicmd.c
> +++ b/tools/apicmds/ltpapicmd.c
> @@ -73,6 +73,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <stdlib.h>
> +#include <stdint.h>
>  #include "test.h"
>  #include "usctest.h"
>  #include "safe_macros.h"
> @@ -324,6 +325,28 @@ err:
>       exit(1);
>  }
>  
> +int apicmd_fs_has_free(int argc, char *argv[])
> +{
> +     if (argc != 3)
> +             goto fs_has_free_err;
> +
> +     char *endptr;
> +     uint64_t required_kib = strtoull(argv[1], &endptr, 0);
> +
> +     if (*argv[1] == '\0' || *endptr != '\0') {
> +             fprintf(stderr, "%s is not a valid numeric string\n", argv[1]);
> +             goto fs_has_free_err;
> +     }
> +
> +     return tst_fs_has_free(NULL, argv[0], required_kib);
> +
> +fs_has_free_err:
> +     fprintf(stderr, "Usage: tst_fs_has_free path required_kib\n"
> +             "path: the pathname of any file within the mounted filesystem\n"
> +             "required_kib: the required free space(count in KB)\n");
> +     exit(1);
> +}
> +
>  /*
>   * Function:    main - entry point of this program
>   *
> @@ -359,6 +382,7 @@ int main(int argc, char *argv[])
>       if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) {
>               if (!strcmp(cmd_name, "tst_kvercmp") &&
>                   !strcmp(cmd_name, "tst_kvercmp2") &&
> +                 !strcmp(cmd_name, "tst_fs_has_free") &&
>                   !strcmp(cmd_name, "tst_get_unused_port")) {
>                       fprintf(stderr,
>                               "\nSet variables TCID, TST_TOTAL, and TST_COUNT 
> before each test:\n"
> @@ -409,6 +433,8 @@ int main(int argc, char *argv[])
>               printf("%li\n", tst_ncpus_max());
>       } else if (strcmp(cmd_name, "tst_get_unused_port") == 0) {
>               printf("%u\n", apicmd_get_unused_port(argc, argv));
> +     } else if (strcmp(cmd_name, "tst_fs_has_free") == 0) {
> +             printf("%d\n", apicmd_fs_has_free(argc, argv));

It think that it would be better to return the result in exit value,
just as tst_kvercmp does so we can write:

if ! tst_fs_has_free . 32; then
        tst_brkm TCONF "Not enough free space"
fi

I would go for:

0 - everything ok
1 - not enough space
2 - error

The rest is Ok.

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to