]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
mdctl-0.6
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index ea30b3109096a3501ad41aa8e5ef9d8556ab49ea..17a7e87d6272b968445f588aa52dd5ad0655a2bd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
 /*
  * mdctl - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001 Neil Brown <neilb@cse.unsw.edu.au>
+ * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -424,3 +424,16 @@ int calc_sb_csum(mdp_super_t *super)
        super->sb_csum = oldcsum;
        return csum;
 }
+
+char *human_size(long kbytes)
+{
+       static char buf[30];
+
+       if (kbytes < 2000)
+               buf[0]=0;
+       else if (kbytes < 2*1024*1024)
+               sprintf(buf, " (%d MiB)", kbytes>>10);
+       else
+               sprintf(buf, " (%d GiB)", kbytes>>20);
+       return buf;
+}