btrfsprogs/0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch

264 lines
8.1 KiB
Diff
Raw Normal View History

Accepting request 232435 from home:dsterba:branches:filesystems - update to upstream 3.14.1 - mkfs: - fix TRIM detection - do not zero-out end of device unconditionally - no crash with --features option - fsck: - clear log tree in repair mode - check reloc roots - btrfs - reworked space reporting (bnc#873106) - btrfs fi usage - new command - btrfs dev usage - new command - btrfs fi df - enhanced output with GlobalReserve - Removed patches: * 0001-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch - Added patches: * 0001-Btrfs-progs-fix-check-to-test-trim-support.patch * 0002-Btrfs-progs-fsck-fix-double-free-memory-crash.patch * 0003-Btrfs-progs-mkfs-Remove-zero_end-1-since-it-has-been.patch * 0004-btrfs-progs-fix-wrong-max-system-array-size-check-in.patch * 0005-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch * 0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch * 0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch * 0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch * 0009-btrfs-progs-prevent-close_root-if-the-root-to-close-.patch * 0010-btrfs-progs-fix-mkfs.btrfs-segfault-with-features-op.patch * 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch * 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch * 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch * 0014-btrfs-progs-Add-btrfs-device-disk-usage-command.patch * 0015-btrfs-progs-cleanup-dead-return-after-usage-for-fi-d.patch * 0016-btrfs-progs-Fix-memleak-in-get_raid56_used.patch * 0017-Btrfs-progs-fi-usage-free-memory-if-realloc-fails.patch * 0018-btrfs-progs-read-global-reserve-size-from-space-info.patch * 0019-btrfs-progs-add-original-df-and-rename-disk_usage-to.patch * 0020-btrfs-progs-move-device-usage-to-cmds-device-more-cl.patch * 0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch * 0022-btrfs-progs-zero-out-structures-before-calling-ioctl.patch * 0023-btrfs-progs-print-B-for-bytes.patch * 0024-btrfs-progs-Print-more-info-about-device-sizes.patch * 0025-btrfs-progs-compare-unallocated-space-against-the-co.patch * 0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch * 0027-btrfs-progs-cleanup-filesystem-device-usage-code.patch * 0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch * 0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch * 0030-btrfs-progs-clean-up-return-codes-and-paths.patch * 0031-btrfs-progs-move-global-reserve-to-overall-summary.patch OBS-URL: https://build.opensuse.org/request/show/232435 OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=156
2014-05-02 16:21:40 +02:00
From a1764abe279f04a664d2745d6d2ce49db722bce3 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Mon, 28 Apr 2014 18:13:16 +0200
Subject: [PATCH 40/42] btrfs-progs: replace df_pretty_sizes with
pretty_size_mode
Signed-off-by: David Sterba <dsterba@suse.cz>
---
cmds-device.c | 8 +++----
cmds-fi-disk_usage.c | 63 ++++++++++++++++++++++------------------------------
cmds-fi-disk_usage.h | 3 ---
3 files changed, 30 insertions(+), 44 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index bf5898f6da68..eb6b79ca5127 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -471,19 +471,19 @@ exit:
int cmd_device_usage(int argc, char **argv)
{
- int flags = DF_HUMAN_UNIT;
+ int mode = UNITS_HUMAN;
int i, more_than_one = 0;
optind = 1;
while (1) {
- char c = getopt(argc, argv, "b");
+ int c = getopt(argc, argv, "b");
if (c < 0)
break;
switch (c) {
case 'b':
- flags &= ~DF_HUMAN_UNIT;
+ mode = UNITS_RAW;
break;
default:
usage(cmd_device_usage_usage);
@@ -506,7 +506,7 @@ int cmd_device_usage(int argc, char **argv)
return 12;
}
- r = _cmd_device_usage(fd, argv[i], flags);
+ r = _cmd_device_usage(fd, argv[i], mode);
close_file_or_dir(fd, dirstream);
if (r)
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 1e412c0b0e69..d1b8bbddc4d5 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -32,17 +32,6 @@
#include "version.h"
/*
- * Pretty print the size
- */
-char *df_pretty_sizes(u64 size, int mode)
-{
- if (mode & DF_HUMAN_UNIT)
- return pretty_size_mode(size, UNITS_HUMAN);
- else
- return pretty_size_mode(size, UNITS_RAW);
-}
-
-/*
* Add the chunk info to the chunk_info list
*/
static int add_info_to_list(struct chunk_info **info_ptr,
@@ -389,7 +378,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
K = ((double)total_used + (double)total_free) / (double)total_chunks;
- if (mode & DF_HUMAN_UNIT)
+ if (mode == UNITS_HUMAN)
width = 10;
else
width = 18;
@@ -397,22 +386,22 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
printf("Overall:\n");
printf(" Device size:\t\t%*s\n", width,
- df_pretty_sizes(total_disk, mode));
+ pretty_size_mode(total_disk, mode));
printf(" Device allocated:\t\t%*s\n", width,
- df_pretty_sizes(total_chunks, mode));
+ pretty_size_mode(total_chunks, mode));
printf(" Device unallocated:\t\t%*s\n", width,
- df_pretty_sizes(total_disk-total_chunks, mode));
+ pretty_size_mode(total_disk - total_chunks, mode));
printf(" Used:\t\t\t%*s\n", width,
- df_pretty_sizes(total_used, mode));
+ pretty_size_mode(total_used, mode));
printf(" Free (Estimated):\t\t%*s\t(",
width,
- df_pretty_sizes((u64)(K*total_disk-total_used), mode));
+ pretty_size_mode((u64)(K * total_disk - total_used), mode));
printf("Max: %s, ",
- df_pretty_sizes(total_disk-total_chunks+total_free, mode));
+ pretty_size_mode(total_disk - total_chunks + total_free, mode));
printf("min: %s)\n",
- df_pretty_sizes((total_disk-total_chunks)/2+total_free, mode));
+ pretty_size_mode((total_disk-total_chunks) / 2 + total_free, mode));
printf(" Data to device ratio:\t%*.0f %%\n",
- width-2, K*100);
+ width - 2, K * 100);
exit:
@@ -612,7 +601,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
if (size)
table_printf(matrix, col, i+3,
- ">%s", df_pretty_sizes(size, mode));
+ ">%s", pretty_size_mode(size, mode));
else
table_printf(matrix, col, i+3, ">-");
@@ -624,7 +613,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
- total_allocated;
table_printf(matrix, sargs->total_spaces + 1, i + 3,
- ">%s", df_pretty_sizes(unused, mode));
+ ">%s", pretty_size_mode(unused, mode));
total_unused += unused;
}
@@ -636,15 +625,15 @@ static void _cmd_filesystem_usage_tabular(int mode,
table_printf(matrix, 0, device_info_count + 4, "<Total");
for (i = 0; i < sargs->total_spaces; i++)
table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
- df_pretty_sizes(sargs->spaces[i].total_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].total_bytes, mode));
table_printf(matrix, sargs->total_spaces + 1, device_info_count + 4,
- ">%s", df_pretty_sizes(total_unused, mode));
+ ">%s", pretty_size_mode(total_unused, mode));
table_printf(matrix, 0, device_info_count + 5, "<Used");
for (i = 0; i < sargs->total_spaces; i++)
table_printf(matrix, 1 + i, device_info_count+5, ">%s",
- df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].used_bytes, mode));
table_dump(matrix);
table_free(matrix);
@@ -670,7 +659,7 @@ static void print_unused(struct chunk_info *info_ptr,
printf(" %s\t%10s\n",
device_info_ptr[i].path,
- df_pretty_sizes(device_info_ptr[i].size - total, mode));
+ pretty_size_mode(device_info_ptr[i].size - total, mode));
}
}
@@ -704,7 +693,7 @@ static void print_chunk_device(u64 chunk_type,
if (total > 0)
printf(" %s\t%10s\n",
device_info_ptr[i].path,
- df_pretty_sizes(total, mode));
+ pretty_size_mode(total, mode));
}
}
@@ -732,10 +721,10 @@ static void _cmd_filesystem_usage_linear(int mode,
printf("%s,%s: Size:%s, ",
description,
r_mode,
- df_pretty_sizes(sargs->spaces[i].total_bytes ,
+ pretty_size_mode(sargs->spaces[i].total_bytes,
mode));
printf("Used:%s\n",
- df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
+ pretty_size_mode(sargs->spaces[i].used_bytes, mode));
print_chunk_device(flags, info_ptr, info_count,
device_info_ptr, device_info_count, mode);
printf("\n");
@@ -787,7 +776,7 @@ const char * const cmd_filesystem_usage_usage[] = {
int cmd_filesystem_usage(int argc, char **argv)
{
- int flags = DF_HUMAN_UNIT;
+ int mode = UNITS_HUMAN;
int i, more_than_one = 0;
int tabular = 0;
@@ -800,7 +789,7 @@ int cmd_filesystem_usage(int argc, char **argv)
switch (c) {
case 'b':
- flags &= ~DF_HUMAN_UNIT;
+ mode = UNITS_RAW;
break;
case 't':
tabular = 1;
@@ -837,12 +826,12 @@ int cmd_filesystem_usage(int argc, char **argv)
goto cleanup;
ret = print_filesystem_usage_overall(fd, chunkinfo, chunkcount,
- devinfo, devcount, argv[i], flags);
+ devinfo, devcount, argv[i], mode);
if (ret)
goto cleanup;
printf("\n");
ret = print_filesystem_usage_by_chunk(fd, chunkinfo, chunkcount,
- devinfo, devcount, argv[i], flags, tabular);
+ devinfo, devcount, argv[i], mode, tabular);
cleanup:
close_file_or_dir(fd, dirstream);
free(chunkinfo);
@@ -881,22 +870,22 @@ void print_device_chunks(int fd, struct device_info *devinfo,
description,
r_mode,
(int)(20 - strlen(description) - strlen(r_mode)), "",
- df_pretty_sizes(size, mode));
+ pretty_size_mode(size, mode));
allocated += size;
}
printf(" Unallocated: %*s%10s\n",
(int)(20 - strlen("Unallocated")), "",
- df_pretty_sizes(devinfo->size - allocated, mode));
+ pretty_size_mode(devinfo->size - allocated, mode));
}
void print_device_sizes(int fd, struct device_info *devinfo, int mode)
{
printf(" Device size: %*s%10s\n",
(int)(20 - strlen("Device size")), "",
- df_pretty_sizes(devinfo->device_size, mode));
+ pretty_size_mode(devinfo->device_size, mode));
printf(" FS occuppied:%*s%10s\n",
(int)(20 - strlen("FS occupied")), "",
- df_pretty_sizes(devinfo->size, mode));
+ pretty_size_mode(devinfo->size, mode));
}
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 0779defc71db..8a0c60f011e4 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -19,8 +19,6 @@
#ifndef __CMDS_FI_DISK_USAGE__
#define __CMDS_FI_DISK_USAGE__
-#define DF_HUMAN_UNIT (1<<0)
-
extern const char * const cmd_filesystem_usage_usage[];
int cmd_filesystem_usage(int argc, char **argv);
@@ -48,7 +46,6 @@ struct chunk_info {
int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
int *chunkcount, struct device_info **devinfo, int *devcount);
-char *df_pretty_sizes(u64 size, int mode);
void print_device_chunks(int fd, struct device_info *devinfo,
struct chunk_info *chunks_info_ptr,
int chunks_info_count, int mode);
--
1.9.0