On 12 January 2014 03:56, Luc Verhaegen <[email protected]> wrote:
> It might be slightly useful to know this.
>
> Signed-off-by: Luc Verhaegen <[email protected]>
> ---
>  nand-part-main.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/nand-part-main.c b/nand-part-main.c
> index 274ce90..347ef17 100644
> --- a/nand-part-main.c
> +++ b/nand-part-main.c
> @@ -23,6 +23,8 @@
>  #include <string.h>
>  #include <strings.h>
>  #include <fcntl.h>
> +#include <sys/ioctl.h>
> +#include <sys/mount.h>
>  #include "nand-common.h"
>
>  void usage(const char *cmd)
> @@ -74,6 +76,8 @@ int main (int argc, char **argv)
>         const char *cmd = argv[0];
>         int fd;
>         int force = 0;          // force write even if magics and CRCs don't 
> match
> +       unsigned long long blkdev_bytes;
> +       int ret;
>
>         argc--;
>         argv++;
> @@ -103,6 +107,17 @@ int main (int argc, char **argv)
>                 usage(cmd);
>                 return -2;
>         }
> +
> +       ret = ioctl(fd, BLKGETSIZE64, &blkdev_bytes);
> +       if (ret < 0) {
> +               fprintf(stderr, "%s: Unable to get block device size: %s\n",
> +                       __func__, strerror(-ret));
> +               return ret;
> +       }
> +
> +       printf("Using NAND %s, with %lld sectors (%.1fMB).\n\n", nand,
> +              blkdev_bytes >> 9, ((double) blkdev_bytes) / (1024*1024));
> +

This is cool but maybe we can point users to sfdisk or other tool that
displays this number with the right argument.

Also does not work for files.

Thanks

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to